X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fscripts%2Fpkgmgmt;h=397eca2ef42864ca4af5cf0fca1131edc1f708bf;hb=75385100bedf6d457e88bc2bb942a6f0771b0e06;hp=3cf380f71d35c01c5a7b88cef92110e6b11e2438;hpb=92db44413f4b2522fa3e46d1be68ff4cfd5ec7b2;p=util-vserver.git diff --git a/util-vserver/scripts/pkgmgmt b/util-vserver/scripts/pkgmgmt index 3cf380f..397eca2 100755 --- a/util-vserver/scripts/pkgmgmt +++ b/util-vserver/scripts/pkgmgmt @@ -86,22 +86,41 @@ function _copySecureRev() ( cd "$dstdir" && tar xf - ) } +## Usage: _substFile +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_CAT -o "$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...