- cleanups
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sun, 3 Jul 2005 17:43:34 +0000 (17:43 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Sun, 3 Jul 2005 17:43:34 +0000 (17:43 +0000)
- unset %_dbpath at 'internalize' operation

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2127 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/scripts/pkgmgmt

index 7f44aae..397eca2 100755 (executable)
@@ -86,22 +86,41 @@ function _copySecureRev()
     ( cd "$dstdir" && tar xf - )
 }
 
+## Usage: _substFile <filename> <sed-expression>
+function _substFile()
+{
+    local file=$1
+    local expr=$2
+    
+    $_CHROOT_SH testfile "$file" || return 0
+
+    local tmp=$($_MKTEMP /tmp/pkgmgmt_subst.XXXXXX)
+    trap "$_RM -f $tmp" EXIT
+
+    $_CHROOT_SH cat "$file" | \
+       $_SED -e "$expr" >$tmp
+
+    $_CHROOT_SH cat "$file" | $_CMP -s $tmp - || \
+       $_CHROOT_SH truncate "$file" <$tmp
+
+    $_RM -f $tmp
+}
+
 function _hashAuto()
 {
+    local file=$1
     local hash=$2
-    local dir=$(dirname "$1")
-    local file=$(basename "$1")
 
-    $_EXEC_CD "$dir" "$(which test)" "$file" || return 0
+    $_CHROOT_SH testfile "$file" || return 0
     
     local tmp=$($_MKTEMP /tmp/apt.conf.XXXXXX)
     trap "$_RM -f $tmp" EXIT
 
-    $_EXEC_CD "$dir" $_CAT "$file" | \
+    $_CHROOT_SH cat "$file" | \
        $_SED -e "s|^\([^$hash].*@autogenerated@\)|$hash$hash\1|" >$tmp
 
-    $_CAT $tmp | $_EXEC_CD "$dir" "$(which cmp)" -s - "$file" || \
-       $_CHROOT_SH truncate "$1" <$tmp
+    $_CHROOT_SH cat "$file" | $_CMP -s $tmp - || \
+       $_CHROOT_SH truncate "$file" <$tmp
 
     $_RM -f $tmp
 }
@@ -311,6 +330,10 @@ Can not continue; use '--force' to override this check"
        _copySecure "$vdir" "$RPMETCDIR"   /etc/rpm
        _copySecure "$vdir" "$RPMSTATEDIR" /var/lib/rpm
 
+       pushd "$vdir" >/dev/null
+           ## remove %_dbpath settings
+           _substFile /etc/rpm/macros '/^%_dbpath[ \t].*/D'
+       popd >/dev/null
     else
        if test -n "$have_apt"; then
            _copySecureRev "$vdir" /etc/apt "$APTETCDIR"
@@ -319,6 +342,8 @@ Can not continue; use '--force' to override this check"
 
        _copySecureRev "$vdir" /etc/rpm     "$RPMETCDIR"
        _copySecureRev "$vdir" /var/lib/rpm "$RPMSTATEDIR"
+
+       echo -e "%_dbpath\t\t$rpmdb_mntpoint" >>$RPMETCDIR/macros
     fi
 
     ## Cleanups...