#!/bin/bash # $Id: pkgmgmt 2599 2007-08-26 21:30:50Z dhozac $ # Copyright (C) 2004,2005 Enrico Scholz # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. : ${UTIL_VSERVER_VARS:=/usr/lib/util-vserver/util-vserver-vars} test -e "$UTIL_VSERVER_VARS" || { echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2 exit 1 } . "$UTIL_VSERVER_VARS" . "$_LIB_FUNCTIONS" . "$_LIB_VSERVER_BUILD_FUNCTIONS" . "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT" . "$__PKGLIBDIR/vserver.functions" function showHelp() { echo \ $"Usage: $0 --externalize|--internalize [-y] [--] Report bugs to <$PACKAGE_BUGREPORT>." exit 0 } function showVersion() { echo $"\ vpkg $PACKAGE_VERSION -- shows information about packages in vservers This program is part of $PACKAGE_STRING Copyright (C) 2004,2005 Enrico Scholz This program is free software; you may redistribute it under the terms of the GNU General Public License. This program has absolutely no warranty." exit 0 } function init() { if test -z "$WORKAROUND_106057"; then rpmdb_mntpoint=/dev else rpmdb_mntpoint=/.rpmdb fi } function _createDirs() { for i; do test -n "$i" || continue mkdir -p -m755 "$i" done } function _copySecure() { local chroot=$1 local srcdir=$2 local dstdir=$3 ( cd "$srcdir" && tar chf - '.' ) | \ ( cd "$chroot" && $_EXEC_CD "$dstdir" $_TAR xf - ) } function _copySecureRev() { local chroot=$1 local srcdir=$2 local dstdir=$3 ( cd "$chroot" && $_EXEC_CD "$srcdir" $_TAR cf - '.' ) | \ ( cd "$dstdir" && tar xf - ) } ## Usage: _substFile function _substFile() { local file=$1 local expr=$2 $_CHROOT_SH testfile "$file" || return 0 local tmp=$($_MKTEMP 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 $_CHROOT_SH testfile "$file" || return 0 local tmp=$($_MKTEMP apt.conf.XXXXXX) trap "$_RM -f $tmp" EXIT $_CHROOT_SH cat "$file" | \ $_SED -e "s|^\([^$hash].*@autogenerated@\)|$hash$hash\1|" >$tmp $_CHROOT_SH cat "$file" | $_CMP -s $tmp - || \ $_CHROOT_SH truncate "$file" <$tmp $_RM -f $tmp } function _unhashAuto() { test -e "$1" || return 0 local hash=$2 local tmp=$($_MKTEMP apt.conf.XXXXXX) trap "$_RM -f $tmp" EXIT $_SED -e "s|^$hash$hash\(.*@autogenerated@\)|\1|" "$1" >$tmp $_CMP -s "$tmp" "$1" || \ $_CAT "$tmp" >"$1" $_RM -f $tmp } function _mountFilesystemsInternal() { local fstab="$1" test -e "$fstab" || return 0 shift pushd "$vdir" >/dev/null "$@" $_SECURE_MOUNT -n -a --chroot --fstab "$fstab" popd >/dev/null } function _mountFilesystems() { local cfgdir cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || { echo "Can not determine configuration directory for '$1'; ..." >&2 return 1 } test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1" _mountFilesystemsInternal "$cfgdir"/fstab || return 1 _mountFilesystemsInternal "$cfgdir"/fstab.local || return 1 _mountFilesystemsInternal "$cfgdir"/fstab.remote "${CHBIND_CMD[@]}" || return 1 } function _umountFilesystems() { local cfgdir cfgdir=$($_VSERVER_INFO "$1" CFGDIR) || { echo "Can not determine configuration directory for '$1'; ..." >&2 return 1 } local vdir=$cfgdir/vdir local is_ok=1 test -n "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$1" pushd "$vdir/" >/dev/null || return 1 _umountVserverInternal "$cfgdir"/fstab.remote "${CHBIND_CMD[@]}" || is_ok= _umountVserverInternal "$cfgdir"/fstab.local || is_ok= _umountVserverInternal "$cfgdir"/fstab || is_ok= popd >/dev/null || return 1 test -n "$is_ok" } # Usage: verifyInternalPackages