6 # Copyright (c) 2002-2006 by Andrew Rose <rose.andrew@gmail.com>
7 # I used Judds pacman-optimise as a framework.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
26 dbroot="/var/lib/pacman"
27 tmproot="/var/lib/pacman.new"
28 pacmandb="/var/lib/pacman.db"
31 echo "pacman-uncage $myver"
32 echo "usage: $0 [pacman_db_root]"
34 echo "pacman-uncage returns your pacman db to the generic style."
39 echo "pacman-uncage: $*" >&2
48 if [ "$1" != "" ]; then
49 if [ "$1" = "-h" -o "$1" = "--help" ]; then
56 if [ "`id -u`" != 0 ]; then
57 die "You must be root to uncage the database"
60 # make sure pacman isn't running
61 if [ -f /tmp/pacman.lck ]; then
62 die "Pacman lockfile was found. Cannot run while pacman is running."
65 if [ ! -d $dbroot ]; then
66 die "$dbroot does not exist or is not a directory"
69 # don't let pacman run while we do this
72 # step 1: sum the old db
73 echo "==> md5sum'ing the old database..."
74 find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.old
76 echo "==> copying pacman.db contents back, note: the time needed to get a brew is now."
78 cp -a $dbroot/. $tmproot
80 echo "==> unmounting old dbroot and moving new one in"
85 echo "==> md5sum'ing the new database..."
86 find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.new
88 echo "==> checking integrity..."
89 diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1
91 # failed, move the old one back into place
95 die_r "integrity check FAILED, reverting to old database"
98 echo "==> Removing old pacman.db"
101 rm -f /tmp/pacman.lck /tmp/pacsums.old /tmp/pacsums.new
104 echo "Finished. Your pacman database has been uncaged!. Welcome home."
105 echo "You will need to remove the old mount line from your /etc/fstab"