util-vserver-0.30.208
[util-vserver.git] / scripts / vserver-build.functions.apt
diff --git a/scripts/vserver-build.functions.apt b/scripts/vserver-build.functions.apt
new file mode 100644 (file)
index 0000000..4973fed
--- /dev/null
@@ -0,0 +1,82 @@
+# $Id: vserver-build.functions.apt,v 1.8 2005/04/16 21:20:45 ensc Exp $        --*- sh -*--
+
+# Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+#  
+# 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.
+
+function apt.installBasePackages
+{
+    local name="$1"
+    local dir="$2"
+
+    test "$dir" != / || return 0
+    for filelist in "$dir"/*; do
+       isRegularFile "$filelist" || continue
+       local idx=0
+       local can_fail=false
+       local flags=
+
+       set -- $(<$filelist)
+       while test "$#" -gt 0; do
+           case "$1" in
+               --reinstall) flags='--reinstall';;
+               --can-fail)  can_fail=true;;
+               *)           break;;
+           esac
+           shift
+       done
+       "$_VAPT_GET" "$name" -- install -y $flags $* || $can_fail
+    done
+}
+
+function apt.initVariables
+{
+    findFile APTCONFDEFAULT \
+       "$__CONFDIR/.distributions/$DISTRIBUTION/apt.conf" \
+       "$__CONFDIR/.defaults/apps/pkgmgmt/apt.conf" \
+       "$__DISTRIBDIR/$DISTRIBUTION/apt.conf" \
+       "$__DISTRIBDIR/defaults/apt.conf" \
+       ''
+
+    findFile APTVENDORDEFAULT \
+       "$__CONFDIR/.distributions/$DISTRIBUTION/vendor.conf" \
+       "$__CONFDIR/.defaults/apps/pkgmgmt/vendor.conf" \
+       /etc/apt/vendors.list \
+       "$__DISTRIBDIR/$DISTRIBUTION/vendor.conf" \
+       "$__DISTRIBDIR/defaults/vendor.conf" \
+       ''
+}
+
+function apt.initFilesystem
+{
+    mkdir -p "$PKGCFGDIR"/apt/{etc/sources.list.d,etc/vendors.list.d,etc/apt.conf.d,archives/partial,cache,state/lists/partial}
+    
+    populateDirectory "$PKGCFGDIR/apt/etc" \
+       "$__DISTRIBDIR/defaults/apt" \
+       "$__DISTRIBDIR/$DISTRIBUTION/apt" \
+       "$__CONFDIR/.distributions/$DISTRIBUTION/apt"
+
+    local f="$PKGCFGDIR"/apt/etc/apt.conf
+    if test -e "$f"; then
+       $_SED -e "s!@APTETCDIR@!$PKGCFGDIR/apt/etc!g" "$f" >"$f.tmp"
+       $_CMP -s "$f" "$f.tmp" || $_CAT "$f.tmp" >"$f"
+       $_RM -f "$f.tmp"
+    fi
+
+    test -z "$APTCONFDEFAULT" || \
+       $_LN_S "$APTCONFDEFAULT"   "$PKGCFGDIR"/apt/etc/apt.conf.d/default.conf
+
+    test -z "$APTVENDORDEFAULT" || \
+       $_LN_S "$APTVENDORDEFAULT" "$PKGCFGDIR"/apt/etc/vendors.list.d/default.conf
+}