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'
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/}"
33 printf "==> ${mesg}\n" "$@" >&2
38 printf "==> ERROR: ${mesg}\n" "$@" >&2
41 printf "pacman-db-upgrade (pacman) %s\n\n" "$myver"
42 printf "$(gettext "Usage
: %s
[pacman_db_root
]")\n\n" "$0"
46 printf "pacman-db-upgrade (pacman) %s\n" "$myver"
48 Copyright
(c
) 2010-2011 Pacman Development Team
<pacman-dev@archlinux.org
>.
\n\
49 This is free software
; see the
source for copying conditions.
\n\
50 There is NO WARRANTY
, to the extent permitted by law.
\n")"
65 # determine whether we have gettext; make it a no-op if we do not
66 if ! type gettext &>/dev
/null
; then
72 if [[ $1 = "-h" ||
$1 = "--help" ]]; then
77 if [[ $1 = "-V" ||
$1 = "--version" ]]; then
86 if [[ ! -d $dbroot ]]; then
87 die
"$(gettext "%s does not exist or is not a directory.
")" "$dbroot"
90 if [[ ! -d $dbroot/local ]]; then
91 die
"$(gettext "%s is not a pacman database directory.
")" "$dbroot"
94 if [[ ! -w $dbroot ]]; then
95 die
"$(gettext "You must have correct permissions to upgrade the database.
")"
98 # strip any trailing slash from our dbroot
100 # form the path to our lockfile location
101 lockfile
="${dbroot}/db.lck"
103 # make sure pacman isn't running
104 if [[ -f $lockfile ]]; then
105 die
"$(gettext "Pacman lock
file was found. Cannot run
while pacman is running.
")"
107 # do not let pacman run while we do this
110 # pacman-3.4 to 3.5 upgrade - merge depends into desc
111 if [[ $
(find "$dbroot"/local -name depends
) ]]; then
112 msg
"$(gettext "Pre-3.5 database format detected
- upgrading...
")"
113 for i
in "$dbroot"/local
/*; do
114 if [[ -f "$i"/depends
]]; then
115 cat "$i"/depends
>> "$i"/desc
119 msg
"$(gettext "Done.
")"
122 # remove the lock file
125 # vim: set ts=2 sw=2 noet: