vshost-util-vserver

Build script and sources for util-vserver.
git clone https://ccx.te2000.cz/git/vshost-util-vserver
Log | Files | Refs

vserver-build.functions.pkgmgmt (2322B)


      1 # $Id$	--*- sh -*--
      2 
      3 # Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
      4 #  
      5 # This program is free software; you can redistribute it and/or modify
      6 # it under the terms of the GNU General Public License as published by
      7 # the Free Software Foundation; version 2 of the License.
      8 #  
      9 # This program is distributed in the hope that it will be useful,
     10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 # GNU General Public License for more details.
     13 #  
     14 # You should have received a copy of the GNU General Public License
     15 # along with this program; if not, write to the Free Software
     16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
     17 
     18 PKGCFGBASE=
     19 PKGCFGBASE_REL=
     20 YUM_RELEASEPKGS=( {redhat,fedora}-release )
     21 
     22 function pkgmgmt._setPkgCfgBase
     23 {
     24     test -z "$PKGCFGBASE" || return 0
     25 
     26     for item in "\"$__CONFDIR/.defaults/apps/pkgmgmt/base\" 1" ${ROOTDIR:+"$ROOTDIR/.pkg"} "$__DEFAULT_VSERVERPKGDIR"; do
     27 	eval set -- "$item"
     28 	PKGCFGBASE=$1
     29 	PKGCFGBASE_REL=$2
     30 	test ! -d "$PKGCFGBASE" || break
     31     done
     32 
     33     test -d "$PKGCFGBASE"  || {
     34 	echo "pkgcfgbase-dir '$PKGCFGBASE' does not exist or is invalid" >&2
     35 	exit 1
     36     }
     37 }
     38 
     39 function pkgmgmt._setPkgCfg
     40 {
     41     pkgmgmt._setPkgCfgBase
     42 
     43     test -z "$PKGCFGDIR" || return 0
     44     PKGCFGDIR="$PKGCFGBASE/$VSERVERDIRNAME"
     45 }
     46 
     47 function pkgmgmt._renameVserverPkgCfg
     48 {
     49     local suffix=.~$(date +'%s')~
     50     local i
     51     
     52     for i in "$PKGCFGDIR"; do
     53 	test ! -e "$i" || {
     54 	    mv "$i" "$i$suffix"
     55 	    say "Renamed '$i' to '$i$suffix'"
     56 	}
     57     done
     58 }
     59 
     60 function pkgmgmt.initFilesystem
     61 {
     62     test -z "$1" || pkgmgmt._renameVserverPkgCfg
     63     test ! -d "$PKGCFGDIR" || {
     64 	echo $\
     65 "vserver pkgmgmt-directory exists already; please try to use
     66 '--force'; or remove it manually" >&2
     67 	exit 1
     68     }
     69 
     70     mkdir -p "$PKGCFGDIR"
     71     base._addGeneratedFile "$PKGCFGDIR"
     72     
     73     mkdir -p "${SETUP_CONFDIR:?}"/apps/pkgmgmt
     74 
     75     test -z "$PKGCFGDIR" || {
     76 	ln -s "$PKGCFGDIR" "$SETUP_CONFDIR/apps/pkgmgmt/base"
     77 
     78 	test "$_EXECDIR" = / || ln -s "${_EXECDIR:?}" "$SETUP_CONFDIR/apps/pkgmgmt/execdir"
     79     }
     80 
     81 }
     82 
     83 function pkgmgmt.initVariables
     84 {
     85     pkgmgmt._setPkgCfg
     86     findDir  PKGINSTALLDIR  "$__CONFDIR/.distributions/$DISTRIBUTION/pkgs"  "$__DISTRIBDIR/$DISTRIBUTION/pkgs"     /
     87 }