mirror of
https://github.com/moparisthebest/pacman
synced 2024-10-31 15:45:03 -04:00
Add script to update pacman database format
The pacman-db-upgrade script was added to detect old pacman database formats and upgrade them. Currently performs the merging of depends files into desc files in the local database. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
8f3b485517
commit
d98bacd4ec
@ -7,6 +7,7 @@ bin_SCRIPTS = \
|
||||
|
||||
OURSCRIPTS = \
|
||||
makepkg \
|
||||
pacman-db-upgrade \
|
||||
pacman-optimize \
|
||||
pkgdelta \
|
||||
rankmirrors \
|
||||
@ -14,6 +15,7 @@ OURSCRIPTS = \
|
||||
|
||||
EXTRA_DIST = \
|
||||
makepkg.sh.in \
|
||||
pacman-db-upgrade.sh.in \
|
||||
pacman-optimize.sh.in \
|
||||
pkgdelta.sh.in \
|
||||
rankmirrors.sh.in \
|
||||
@ -61,6 +63,7 @@ $(OURSCRIPTS): Makefile
|
||||
@mv $@.tmp $@
|
||||
|
||||
makepkg: $(srcdir)/makepkg.sh.in
|
||||
pacman-db-upgrade: $(srcdir)/pacman-db-upgrade.sh.in
|
||||
pacman-optimize: $(srcdir)/pacman-optimize.sh.in
|
||||
pkgdelta: $(srcdir)/pkgdelta.sh.in
|
||||
rankmirrors: $(srcdir)/rankmirrors.sh.in
|
||||
|
121
scripts/pacman-db-upgrade.sh.in
Normal file
121
scripts/pacman-db-upgrade.sh.in
Normal file
@ -0,0 +1,121 @@
|
||||
#!@BASH_SHELL@ -e
|
||||
#
|
||||
# pacman-db-upgrade - upgrade the local pacman db to a newer format
|
||||
# @configure_input@
|
||||
#
|
||||
# Copyright (c) 2010 Pacman Development Team <pacman-dev@archlinux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# gettext initialization
|
||||
export TEXTDOMAIN='pacman'
|
||||
export TEXTDOMAINDIR='@localedir@'
|
||||
|
||||
myver='@PACKAGE_VERSION@'
|
||||
|
||||
eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
|
||||
dbroot="${DBPath:-@localstatedir@/lib/pacman/}"
|
||||
|
||||
msg() {
|
||||
local mesg=$1; shift
|
||||
printf "==> ${mesg}\n" "$@" >&2
|
||||
}
|
||||
|
||||
error () {
|
||||
local mesg=$1; shift
|
||||
printf "==> ERROR: ${mesg}\n" "$@" >&2
|
||||
}
|
||||
usage() {
|
||||
printf "pacman-db-upgrade (pacman) %s\n\n" "$myver"
|
||||
printf "$(gettext "Usage: %s [pacman_db_root]")\n\n" "$0"
|
||||
}
|
||||
|
||||
version() {
|
||||
printf "pacman-db-upgrade (pacman) %s\n" "$myver"
|
||||
printf "$(gettext "\
|
||||
Copyright (c) 2010 Pacman Development Team <pacman-dev@archlinux.org>.\n\
|
||||
This is free software; see the source for copying conditions.\n\
|
||||
There is NO WARRANTY, to the extent permitted by law.\n")"
|
||||
}
|
||||
|
||||
die() {
|
||||
error "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
die_r() {
|
||||
rm -f "$lockfile"
|
||||
die "$@"
|
||||
}
|
||||
|
||||
# PROGRAM START
|
||||
|
||||
# determine whether we have gettext; make it a no-op if we do not
|
||||
if ! type gettext &>/dev/null; then
|
||||
gettext() {
|
||||
echo "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
if [[ $1 = "-h" || $1 = "--help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $1 = "-V" || $1 = "--version" ]]; then
|
||||
version
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -n $1 ]]; then
|
||||
dbroot="$1"
|
||||
fi
|
||||
|
||||
if [[ ! -d $dbroot || ! -d $dbroot/local ]]; then
|
||||
die "$(gettext "%s does not exist or is not a directory.")" "$dbroot"
|
||||
fi
|
||||
|
||||
if [[ ! -w $dbroot ]]; then
|
||||
die "$(gettext "You must have correct permissions to upgrade the database.")"
|
||||
fi
|
||||
|
||||
# strip any trailing slash from our dbroot
|
||||
dbroot="${dbroot%/}"
|
||||
# form the path to our lockfile location
|
||||
lockfile="${dbroot}/db.lck"
|
||||
|
||||
# make sure pacman isn't running
|
||||
if [[ -f $lockfile ]]; then
|
||||
die "$(gettext "Pacman lock file was found. Cannot run while pacman is running.")"
|
||||
fi
|
||||
# do not let pacman run while we do this
|
||||
touch "$lockfile"
|
||||
|
||||
# pacman-3.4 to 3.5 upgrade - merge depends into desc
|
||||
if [[ $(find "$dbroot"/local -name depends) ]]; then
|
||||
msg "$(gettext "Pre-3.5 database format detected - upgrading...")"
|
||||
for i in "$dbroot"/local/*; do
|
||||
if [[ -f "$i"/depends ]]; then
|
||||
cat "$i"/depends >> "$i"/desc
|
||||
rm "$i"/depends
|
||||
fi
|
||||
done
|
||||
msg "$(gettext "Done.")"
|
||||
fi
|
||||
|
||||
# remove the lock file
|
||||
rm -f "$lockfile"
|
||||
|
||||
# vim: set ts=2 sw=2 noet:
|
Loading…
Reference in New Issue
Block a user