]> git.pld-linux.org Git - packages/util-vserver.git/blame - util-vserver-dbrebuild-internalize4.patch
- move TODO to separate file
[packages/util-vserver.git] / util-vserver-dbrebuild-internalize4.patch
CommitLineData
6a6b3452
ER
1--- util-vserver-0.30.215/scripts/pkgmgmt 2008-11-17 20:58:47.120292384 +0200
2+++ util-vserver-0.30.215/scripts/pkgmgmt 2008-11-17 22:47:02.486514626 +0200
3@@ -185,6 +185,43 @@
4 test -n "$is_ok"
5 }
6
7+## Usage: verifyDBTools <vdir> <type> <host_tool> <guest_tool>
8+function verifyDBTools
9+{
10+ local vdir="$1"
11+ local type="$2"
12+ local host_tool="$3"
13+ local guest_tool="$4"
14+ local res=0
15+
16+ local i host_path guest_path
17+ for i in /bin /usr/bin /usr/lib/rpm /usr/local/bin; do
18+ test ! -x "$i"/$host_tool || { host_path="$i"/$host_tool; break; }
19+ done
20+ for i in /bin /usr/bin /usr/lib/rpm /usr/local/bin; do
21+ test ! -x "$vdir$i"/$guest_tool || { guest_path="$i"/$guest_tool; break; }
22+ done
23+
24+ test -n "$host_path" || {
25+ warning "
26+* The host does not seem to have the '$host_tool' program which is required
27+ for $type package management. It is suggested to install it before
28+ continuing."
29+ res=1
30+ }
31+ test -n "$guest_path" || {
32+ warning "
69c81f2b 33+* The vserver guest does not seem to have the '$guest_tool' program which is required
6a6b3452
ER
34+ for $type package management. It is suggested to install it before
35+ continuing."
36+ res=1
37+ }
38+
39+ eval $host_tool=$host_path
40+ eval $guest_tool=$guest_path
41+ return $res
42+}
43+
44 # Usage: verifyInternalPackages <vserver> <style>
45 function verifyInternalPackages()
46 {
47@@ -392,7 +429,12 @@
48 verifyInternalPackages "$vserver" RH || test -n "$IS_FORCE" ||
49 panic "
50 Can not continue; use '--force' to override this check"
51+
52+ verifyDBTools "$vdir" 'internal' db_dump db_load || test -n "$IS_FORCE" ||
53+ panic "
54+Can not continue; use '--force' to override this check"
55
56+
57 pushd "$vdir" >/dev/null
58
59 test ! -L var/lib/rpm || {
60@@ -416,6 +458,10 @@
61 findDir RPMETCDIR "$cfgdir"/rpmetc "$cfgdir"/base/rpm/etc /etc/rpm /
62 findDir RPMSTATEDIR "$cfgdir"/rpmstate "$cfgdir"/base/rpm/state
63 else
64+ verifyDBTools "$vdir" 'external' db_load db_dump || test -n "$IS_FORCE" ||
65+ panic "
66+Can not continue; use '--force' to override this check"
67+
68 mkdir -m755 -p "$cfgdir"
69 local need_base=
70
71@@ -460,8 +506,38 @@
72 pushd "$vdir" >/dev/null
73 ## remove %_dbpath settings
74 _substFile /etc/rpm/macros '/^%_dbpath[ \t].*/D'
75+
76+ # dump and reload rpmdb to overcome db version mismatch problems
77+ if [ "$db_load" -a "$db_dump" ]; then
78+ # dump with host db_dump
79+ $db_dump var/lib/rpm/Packages > var/lib/rpm/.Packages.dump
80+
81+ # load with guest db_load.
82+ $_RM -f var/lib/rpm/__db.*
83+ mv var/lib/rpm/{Packages,.Packages.ORIG}
84+ chroot . $db_load var/lib/rpm/Packages < var/lib/rpm/.Packages.dump
85+ chroot . bin/rpm --rebuilddb 2>/dev/null
86+ rm -f var/lib/rpm/.Packages.*
87+ fi
88+
89 popd >/dev/null
90 else
91+
92+ pushd "$vdir" >/dev/null
93+ if [ "$db_load" -a "$db_dump" ]; then
94+ # dump and reload rpmdb to overcome db version mismatch problems
95+
96+ # dump with guest db_dump
97+ $_RM -f var/lib/rpm/__db.*
98+ chroot . $db_dump var/lib/rpm/Packages > var/lib/rpm/.Packages.dump
99+
100+ # load with host db_load
101+ mv var/lib/rpm/{Packages,.Packages.ORIG}
102+ $db_load var/lib/rpm/Packages < var/lib/rpm/.Packages.dump
103+ rm -f var/lib/rpm/.Packages.*
104+ fi
105+ popd >/dev/null
106+
107 if test -n "$have_poldek"; then
108 _copySecureRev "$vdir" /etc/poldek "$POLDEKETCDIR"
109 _unhashAuto "$POLDEKETCDIR"/poldek.conf '/'
This page took 0.057728 seconds and 4 git commands to generate.