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