moved sanity checks which were spread in various functions into the sanityCheck(...
[util-vserver.git] / util-vserver / scripts / vserver-build.functions.yum
1 # $Id$  --*- sh -*--
2
3 # Copyright (C) 2003 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 function yum.installBasePackages
19 {
20     local name="$1"
21     local dir="$2"
22
23     test "$dir" != / || return 0
24     for filelist in "$dir"/*; do
25         test -f "$filelist" || continue
26         local idx=0
27         local can_fail=false
28         local flags=
29
30         set -- $(<$filelist)
31         while test "$#" -gt 0; do
32             case "$1" in
33                 --reinstall) flags='';;
34                 --can-fail)  can_fail=true;;
35                 *)           break;;
36             esac
37             shift
38         done
39         "$_VYUM" "$name" -- -y install $flags $* || $can_fail
40     done
41 }
42
43 function yum.initVariables
44 {
45     findDir  YUMREPOSDEFAULT \
46         "$CONFDIR/.distributions/$DISTRIBUTION/yum.repos.d" \
47         "$DISTRIBDIR/$DISTRIBUTION/yum.repos.d" \
48         ''
49 }
50
51 function yum.initFilesystem
52 {
53     mkdir -p "$PKGCFGDIR"/yum/{etc,cache}
54     
55     populateDirectory "$PKGCFGDIR/yum/etc" \
56         "$DISTRIBDIR/defaults/yum" \
57         "$DISTRIBDIR/$DISTRIBUTION/yum" \
58         "$CONFDIR/.distributions/$DISTRIBUTION/yum"
59
60     ## workaround for yum's automatism to search the configuration in the chroot
61     local prefix='/../../../../../../../../../../../../'
62     local f="$PKGCFGDIR"/yum/etc/yum.conf
63     if test -e "$f"; then
64         $_SED -e "s!@YUMETCDIR@!$prefix$PKGCFGDIR/yum/etc!g;
65                   s!@YUMCACHEDIR@!$prefix$PKGCFGDIR/yum/cache!g;
66                   s!@YUMLOGDIR@!$prefix$PKGCFGDIR/yum!g;
67                  " "$f" >"$f.tmp"
68         $_CMP -s "$f" "$f.tmp" || $_CAT "$f.tmp" >"$f"
69         $_RM -f "$f.tmp"
70     fi
71
72     test -z "$YUMREPOSDEFAULT" -o -e "$PKGCFGDIR/yum/etc/yum.repos.d" || \
73         $_LN_S "$YUMREPOSDEFAULT"   "$PKGCFGDIR/yum/etc/yum.repos.d"
74 }