[pacman-dev] [PATCH] Add script to update pacman database format

Allan McRae allan at archlinux.org
Wed Dec 8 07:20:52 EST 2010


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 at archlinux.org>
---
 scripts/Makefile.am             |    7 +++++--
 scripts/pacman-db-upgrade.sh.in |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 scripts/pacman-db-upgrade.sh.in

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 78deb0b..7448691 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -10,14 +10,16 @@ OURSCRIPTS = \
 	pacman-optimize \
 	pkgdelta \
 	rankmirrors \
-	repo-add
+	repo-add \
+	pacman-db-upgrade
 
 EXTRA_DIST = \
 	makepkg.sh.in \
 	pacman-optimize.sh.in \
 	pkgdelta.sh.in \
 	rankmirrors.sh.in \
-	repo-add.sh.in
+	repo-add.sh.in \
+	pacman-db-upgrade.sh.in
 
 # Files that should be removed, but which Automake does not know.
 MOSTLYCLEANFILES = $(bin_SCRIPTS) *.tmp
@@ -68,5 +70,6 @@ repo-add: $(srcdir)/repo-add.sh.in
 repo-remove: $(srcdir)/repo-add.sh.in
 	rm -f repo-remove
 	$(LN_S) repo-add repo-remove
+pacman-db-update: $(srcdir)/pacman-db-update.sh.in
 
 # vim:set ts=2 sw=2 noet:
diff --git a/scripts/pacman-db-upgrade.sh.in b/scripts/pacman-db-upgrade.sh.in
new file mode 100644
index 0000000..e28b1d2
--- /dev/null
+++ b/scripts/pacman-db-upgrade.sh.in
@@ -0,0 +1,34 @@
+#!@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 at 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/>.
+#
+
+eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
+DBPath="${DBPath:- at localstatedir@/lib/pacman/}/local"
+
+# pacman-3.4 to 3.5 upgrade - merge depends into desc
+if [[ $(find $DBPath -name depends) ]]; then
+	echo "==> pacman-3.4 database format dectected - upgrading"
+	for i in $DBPath/*; do
+		if [[ -f $i/depends ]]; then
+			cat $i/depends >> $i/desc
+			rm $i/depends
+		fi
+	done
+fi
-- 
1.7.3.3



More information about the pacman-dev mailing list