X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fscripts%2Fvserver-build.functions;h=b12a5d5792e9b82d63f7dad61037cbd8597318a8;hb=d45518897217889e8571d94d4459ee12c4db56a0;hp=dc699f5aa585c0888dd1be32d53d072abc5a5de5;hpb=05a57e83b574b0541c779774bdf4f43d2aacf0a0;p=util-vserver.git diff --git a/util-vserver/scripts/vserver-build.functions b/util-vserver/scripts/vserver-build.functions index dc699f5..b12a5d5 100644 --- a/util-vserver/scripts/vserver-build.functions +++ b/util-vserver/scripts/vserver-build.functions @@ -20,8 +20,6 @@ ROOTDIR= ROOTDIR_REL= -PKGCFGBASE= -PKGCFGBASE_REL= VSERVERDIRNAME= VDIR= @@ -36,12 +34,12 @@ function makeDevEntry { local dst=$1/$2 case "$3" in - c|b) mknod -m$6 "$dst" $3 $4 $5;; - d) mkdir -p -m$4 "$dst";; - f) touch "$dst" + (c|b) mknod -m$6 "$dst" $3 $4 $5;; + (d) mkdir -p -m$4 "$dst";; + (f) touch "$dst" chmod $4 "$dst" ;; - *) echo "Unknown dev-entry mode '$3'" >&2 + (*) echo "Unknown dev-entry mode '$3'" >&2 false ;; esac @@ -59,8 +57,8 @@ function populateDirectory for file in "$i"/*; do test -e "$file" || continue case "$file" in - */CVS) test ! -d "$file" || continue;; - *.rpmsave|*.rpmnew|*.rpmorig) + (*/CVS) test ! -d "$file" || continue;; + (*.rpmsave|*.rpmnew|*.rpmorig) continue;; esac @@ -81,36 +79,11 @@ function _setRootDir done test -d "$ROOTDIR" || { - echo "Root-directory '$ROOTDIR' does not exist or is invalid" + echo "Root-directory '$ROOTDIR' does not exist or is invalid" >&2 exit 1 } } -function _setPkgCfgBase -{ - test -z "$PKGCFGBASE" || return 0 - - for item in "\"$CONFDIR/.defaults/apps/pkgmgmt/base\" 1" "$ROOTDIR/.pkg" "$DEFAULT_VSERVERPKGDIR"; do - eval set -- "$item" - PKGCFGBASE=$1 - PKGCFGBASE_REL=$2 - test ! -d "$PKGCFGBASE" || break - done - - test -d "$PKGCFGBASE" || { - echo "pkgcfgbase-dir '$PKGCFGBASE' does not exists or is invalid" - exit 1 - } -} - -function _setPkgCfg -{ - _setPkgCfgBase - - test -z "$PKGCFGDIR" || return 0 - PKGCFGDIR="$PKGCFGBASE/$VSERVERDIRNAME" -} - function _setVserverDir { test -z "$VSERVERDIRNAME" || return 0 @@ -133,7 +106,7 @@ function _renameVserverCfg local suffix=.~$(date +'%s')~ local i - for i in "$VDIR" "$SETUP_CONFDIR" "$PKGCFGDIR"; do + for i in "$VDIR" "$SETUP_CONFDIR"; do test ! -e "$i" || { mv "$i" "$i$suffix" say "Renamed '$i' to '$i$suffix'" @@ -155,37 +128,36 @@ function getDistribution set -- $(cat /etc/debian_version) DISTRIBUTION=deb$1 else - echo "Can not determine distribution; please specify it manually" - echo "with the '-d' option" + echo \ +"Can not determine distribution; please specify it manually +with the '-d' option" >&2 exit 1 fi >&2 } ## Usage: initFilesystem [force] -function initFilesystem +function base.initFilesystem { test -z "$1" || _renameVserverCfg test ! -d "$VDIR" -a ! -d "$SETUP_CONFDIR" || { - echo "vserver-topdirectory and/or configuration exist already; " - echo "please try to use '--force', or remove them manually" + echo \ +"vserver-topdirectory and/or configuration exist already; +please try to use '--force', or remove them manually" >&2 exit 1 } >&2 - mkdir -p "$SETUP_CONFDIR"/apps/pkgmgmt "$VDIR"/{dev/pts,etc} "$SETUP_LOCKREVDIR" + mkdir -p -m755 "$VDIR" + chattr -t "$VDIR" + mkdir -p -m755 "$SETUP_CONFDIR"/apps "$VDIR"/{dev/pts,etc} "$SETUP_LOCKREVDIR" ln -s "$VDIR" "$SETUP_CONFDIR/vdir" - test -z "$PKGCFGDIR" || { - ln -s "$PKGCFGDIR" "$SETUP_CONFDIR/apps/pkgmgmt/base" - - test "$_EXECDIR" = / || ln -s "$_EXECDIR" "$confdir/apps/pkgmgmt/execdir" - } - local spec while read spec; do makeDevEntry "$VDIR"/dev $spec done <$_DEV_FILE + mkdir -p "$VDIR"/proc findAndCopy "$VDIR"/etc/hosts "$CONFDIR"/.defaults/files/hosts "$CONFDIR/.distributions/$DISTRIBUTION"/files/hosts \ "$DISTRIBDIR/$DISTRIBUTION"/files/hosts "$DISTRIBDIR"/defaults/files/hosts "" @@ -194,16 +166,14 @@ function initFilesystem done } -function initVariables +function base.initVariables { _setRootDir _setVserverDir - _setPkgCfg _setVdir findFile _DEV_FILE "$CONFDIR/.distributions/$DISTRIBUTION/devs" "$DISTRIBDIR/$DISTRIBUTION/devs" "$DISTRIBDIR/defaults/devs" findDir _EXECDIR "$CONFDIR/.distributions/$DISTRIBUTION/execdir" "$DISTRIBDIR/$DISTRIBUTION/execdir" / findFile BUILD_INITPRE "$CONFDIR/.distributions/$DISTRIBUTION/initpre" "$DISTRIBDIR/$DISTRIBUTION/initpre" "" findFile BUILD_INITPOST "$CONFDIR/.distributions/$DISTRIBUTION/initpost" "$DISTRIBDIR/$DISTRIBUTION/initpost" "" - findDir PKGDIR "$CONFDIR/.distributions/$DISTRIBUTION/pkgs" "$DISTRIBDIR/$DISTRIBUTION/pkgs" / }