commit c0f7e1e6b657dd1bc5f3297973c8356dc1c1a48b
Author: Jan Rękorajski <bagg...@pld-linux.org>
Date:   Wed Nov 28 12:22:40 2012 +0100

    - add '-r' option to specify root directory of rpm database,
      mainly for use with util-vserver and external package management

 dbupgrade.sh | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/dbupgrade.sh b/dbupgrade.sh
index 52c073a..2d403b5 100755
--- a/dbupgrade.sh
+++ b/dbupgrade.sh
@@ -1,6 +1,18 @@
 #!/bin/sh
 
-if ! /usr/lib/rpm/bin/rpmdb_reset -r lsn /var/lib/rpm/Packages ; then
+ROOTDIR=
+if [ "$1" = "-r" ]; then
+       shift
+       ROOTDIR="$1"
+
+       if [ ! -d "$ROOTDIR" ]; then
+               echo "Specified root directory ($ROOTDIR) does not exist!"
+               echo "Bailing out!"
+               exit
+       fi
+fi
+
+if ! /usr/lib/rpm/bin/rpmdb_reset -r lsn "$ROOTDIR"/var/lib/rpm/Packages ; then
        echo
        echo "rpm database conversion failed!"
        echo
@@ -12,10 +24,10 @@ if ! /usr/lib/rpm/bin/rpmdb_reset -r lsn 
/var/lib/rpm/Packages ; then
        echo "  /usr/lib/rpm/bin/dbconvert --rebuilddb"
        echo
 else
-       /bin/rm --interactive=never -f /var/lib/rpm/__db.00* >/dev/null 
2>/dev/null || :
-       /bin/rm --interactive=never -f /var/lib/rpm/log/* >/dev/null 
2>/dev/null || :
+       /bin/rm --interactive=never -f "$ROOTDIR"/var/lib/rpm/__db.00* 
>/dev/null 2>/dev/null || :
+       /bin/rm --interactive=never -f "$ROOTDIR"/var/lib/rpm/log/* >/dev/null 
2>/dev/null || :
 
-       if ! /usr/lib/rpm/bin/dbconvert --rebuilddb; then
+       if ! /usr/lib/rpm/bin/dbconvert --rebuilddb 
${ROOTDIR:+--root="$ROOTDIR"}; then
                echo
                echo "rpm database conversion failed!"
                echo "You have to run /usr/lib/rpm/bin/dbconvert manually"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm.git/commitdiff/c0f7e1e6b657dd1bc5f3297973c8356dc1c1a48b

_______________________________________________
pld-cvs-commit mailing list
pld-cvs-commit@lists.pld-linux.org
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to