Make urpmi like the others
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Fri, 28 Oct 2011 23:57:49 +0000 (01:57 +0200)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Fri, 28 Oct 2011 23:57:49 +0000 (01:57 +0200)
scripts/util-vserver-vars.pathsubst
scripts/vserver-build.functions.urpmi [new file with mode: 0644]
scripts/vserver-build.urpmi

index bdbfbea..3e5e773 100644 (file)
@@ -53,6 +53,7 @@ _LIB_VSERVER_BUILD_FUNCTIONS="$__PKGLIBDIR/vserver-build.functions"
 _LIB_VSERVER_BUILD_FUNCTIONS_APT="$__PKGLIBDIR/vserver-build.functions.apt"
 _LIB_VSERVER_BUILD_FUNCTIONS_RPM="$__PKGLIBDIR/vserver-build.functions.rpm"
 _LIB_VSERVER_BUILD_FUNCTIONS_YUM="$__PKGLIBDIR/vserver-build.functions.yum"
+_LIB_VSERVER_BUILD_FUNCTIONS_URPMI="$__PKGLIBDIR/vserver-build.functions.urpmi"
 _LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT="$__PKGLIBDIR/vserver-build.functions.pkgmgmt"
 _LISTDEVIP="$__LEGACYDIR/listdevip"
 _LOCKFILE="$__PKGLIBDIR/lockfile"
diff --git a/scripts/vserver-build.functions.urpmi b/scripts/vserver-build.functions.urpmi
new file mode 100644 (file)
index 0000000..3c268c3
--- /dev/null
@@ -0,0 +1,58 @@
+# $Id$ --*- sh -*--
+
+# Copyright (C) 2011 Daniel Hokka Zakrisson <daniel@hozac.com>
+#  
+# 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 urpmi.initVariables
+{
+    if test -z "$MIRROR"; then
+       getFileValue MIRROR "$__CONFDIR/.distributions/$DISTRIBUTION/mirror" \
+           "$__DISTRIBDIR/$DISTRIBUTION/mirror"
+       if test -z "$MIRROR"; then
+           panic $"vserver-build.urpmi: --mirror argument required"
+       fi
+    fi
+}
+
+function urpmi.initFilesystem
+{
+    $_MKDIR -p "$PKGCFGDIR"/var/lib/urpmi "$PKGCFGDIR"/etc/urpmi
+}
+
+function urpmi.installPackages
+{
+    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='';;
+               --can-fail)  can_fail=true;;
+               *)           break;;
+           esac
+           shift
+       done
+       "$_VURPM" urpmi "$name" -- $flags $* || $can_fail
+       "$_VYUM" "$name" -- -y install $flags $* || $can_fail
+    done
+}
index 4362fb5..c372535 100644 (file)
@@ -19,11 +19,12 @@ tmp=$(getopt -o '+d:m:o:' --long debug,mirror:,mirrorlist -n "$0" -- "$@") || ex
 eval set -- "$tmp"
 
 . "$_LIB_VSERVER_BUILD_FUNCTIONS_PKGMGMT"
+. "$_LIB_VSERVER_BUILD_FUNCTIONS_RPM"
+. "$_LIB_VSERVER_BUILD_FUNCTIONS_URPMI"
 
 DISTRIBUTION=
 MIRROR=
 MIRRORLIST=
-PKGS=( basesystem-minimal )
 while true; do
     case "$1" in
        -d)             DISTRIBUTION=$2; shift;;
@@ -38,31 +39,26 @@ while true; do
     shift
 done
 
-if test -z "$MIRROR"; then
-    panic $"vserver-build.urpmi: --mirror argument required"
-fi
-
-if test "$#" -gt 0; then
-    PKGS=( "$@" )
-fi
-
 getDistribution
 
 base.init
 pkgmgmt.initVariables
-
+rpm.initVariables
+urpmi.initVariables
 
 base.initFilesystem "$OPTION_FORCE"
 pkgmgmt.initFilesystem "$OPTION_FORCE"
-
+rpm.initFilesystem
+urpmi.initFilesystem
 
 setup_writeOption "$VSERVER_NAME"
 setup_writeInitialFstab
 
 test -z "$BUILD_INITPRE"  || "$BUILD_INITPRE" "$SETUP_CONFDIR"  "$UTIL_VSERVER_VARS"
 
-urpmi.addmedia --urpmi-root "$PKGCFGDIR"/ --distrib $MIRRORLIST "$MIRROR"
-urpmi --urpmi-root "$PKGCFGDIR"/ --root "$VDIR"/ "${PKGS[@]}"
+$_VURPM urpmi.addmedia "$SETUP_CONFDIR" -- --distrib $MIRRORLIST "$MIRROR"
+urpmi.installPackages "$SETUP_CONFDIR" "$PKGINSTALLDIR"
+test -z "$1" || $_VURPM urpmi "$SETUP_CONFDIR" -- "$@"
 
 pushd "$VDIR"/ >/dev/null
 rm -rf dev