3 # pacman-db-upgrade - upgrade the local pacman db to a newer format
6 # Copyright (c) 2010-2011 Pacman Development Team <pacman-dev@archlinux.org>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # gettext initialization
23 export TEXTDOMAIN
='pacman-scripts'
24 export TEXTDOMAINDIR
='@localedir@'
26 myver
='@PACKAGE_VERSION@'
28 eval $
(awk '/DBPath/ {print $1$2$3}' @sysconfdir@
/pacman.conf
)
29 dbroot
="${DBPath:-@localstatedir@/lib/pacman/}"
31 m4_include
(library
/output_format.sh
)
34 printf "pacman-db-upgrade (pacman) %s\n\n" "$myver"
35 printf "$(gettext "Usage
: %s
[pacman_db_root
]")\n\n" "$0"
39 printf "pacman-db-upgrade (pacman) %s\n" "$myver"
41 Copyright
(c
) 2010-2011 Pacman Development Team
<pacman-dev@archlinux.org
>.
\n\
42 This is free software
; see the
source for copying conditions.
\n\
43 There is NO WARRANTY
, to the extent permitted by law.
\n")"
58 # determine whether we have gettext; make it a no-op if we do not
59 if ! type gettext &>/dev
/null
; then
65 if [[ $1 = "-h" ||
$1 = "--help" ]]; then
70 if [[ $1 = "-V" ||
$1 = "--version" ]]; then
79 if [[ ! -d $dbroot ]]; then
80 die
"$(gettext "%s does not exist or is not a directory.
")" "$dbroot"
83 if [[ ! -d $dbroot/local ]]; then
84 die
"$(gettext "%s is not a pacman database directory.
")" "$dbroot"
87 if [[ ! -w $dbroot ]]; then
88 die
"$(gettext "You must have correct permissions to upgrade the database.
")"
91 # strip any trailing slash from our dbroot
93 # form the path to our lockfile location
94 lockfile
="${dbroot}/db.lck"
96 # make sure pacman isn't running
97 if [[ -f $lockfile ]]; then
98 die
"$(gettext "Pacman lock
file was found. Cannot run
while pacman is running.
")"
100 # do not let pacman run while we do this
103 # pacman-3.4 to 3.5 upgrade - merge depends into desc
104 if [[ $
(find "$dbroot"/local -name depends
) ]]; then
105 msg
"$(gettext "Pre-3.5 database format detected
- upgrading...
")"
106 for i
in "$dbroot"/local
/*; do
107 if [[ -f "$i"/depends
]]; then
108 cat "$i"/depends
>> "$i"/desc
112 msg
"$(gettext "Done.
")"
115 # remove the lock file
118 # vim: set ts=2 sw=2 noet: