added 'novlandev' interface flag
[util-vserver.git] / util-vserver / scripts / vserver-build.functions.rpm
index 6eec6c3..f9204db 100644 (file)
@@ -29,23 +29,23 @@ function rpm.importGPGPubKeys
     for i; do
        local file=
        for file in "$i"/*; do
-           test -f "$file" || continue
+           isRegularFile "$file" || continue
 
            pkgs=( "${pkgs[@]}" "$file" )
        done
     done
 
-    test "$pkgs" || return 0
+    test -n "$pkgs" || return 0
     "$_VRPM" "$dst" -- --import "${pkgs[@]}"
 }
 
 function rpm.initVariables
 {
-    test "$WORKAROUND_106057" && \
+    test -n "$WORKAROUND_106057" && \
        RPMDB_PATH=/.rpmdb || \
        RPMDB_PATH=/dev
 
-    findDir RPMLIBDIR "$CONFDIR/.distributions/$DISTRIBUTION/rpmlib" "$DISTRIBDIR/$DISTRIBUTION/rpmlib" /
+    findDir RPMLIBDIR "$__CONFDIR/.distributions/$DISTRIBUTION/rpmlib" "$__DISTRIBDIR/$DISTRIBUTION/rpmlib" /
 }
 
 function rpm.initFilesystem
@@ -60,11 +60,82 @@ function rpm.initFilesystem
 
     mkdir -p "$PKGCFGDIR"/rpm/{etc,state}
     populateDirectory "$PKGCFGDIR/rpm/etc" \
-       "$DISTRIBDIR/defaults/rpm" \
-       "$DISTRIBDIR/$DISTRIBUTION/rpm" \
-       "$CONFDIR/.distributions/$DISTRIBUTION/rpm"
+       "$__DISTRIBDIR/defaults/rpm" \
+       "$__DISTRIBDIR/$DISTRIBUTION/rpm" \
+       "$__CONFDIR/.distributions/$DISTRIBUTION/rpm"
 
-    echo "%_dbpath $RPMDB_PATH" >>"$pkgcfg/etc/macros"
+    echo "%_dbpath $RPMDB_PATH" >>"$PKGCFGDIR/rpm/etc/macros"
 
-    test "$RPMLIBDIR"  = / || ln -s "$RPMLIB"  "$confdir/apps/pkgmgmt/rpmlib"
+    test "$RPMLIBDIR"  = / || ln -s "$RPMLIB"  "$SETUP_CONFDIR/apps/pkgmgmt/rpmlib"
+}
+
+function rpm.initDB
+{
+    RPM_FLAVOR=d "$_VRPM" "$1" -- --initdb
+}
+
+
+
+## Usage: rpmlist.install <vserver> <basedir> <tmpfile> <listfile> <rpm-options>*
+function rpmlist.install()
+{
+    local      cfgdir=$1
+    local      basedir=$2
+    local       manifest=$3
+    local      listfile=$4
+    shift 4
+
+    while read; do
+       case x"$REPLY" in
+           (x|\#*)     continue;;
+       esac
+       
+       echo "$basedir/$REPLY"
+    done >"$manifest" <"$listfile"
+
+    test "$OPTION_DEBUG" -eq 0 || cat "$manifest"
+    test ! -s "$manifest"      || $_VRPM "$cfgdir" -- -U "$@" "$manifest"
+}
+
+
+## Usage: rpmlist.initByDistribution <result-var> <distribution>
+function rpmlist.initByDistribution()
+{
+    local      _rlid_listdir
+    declare -a _rlid_res=() 
+    
+
+    findDir _rlid_listdir "$__CONFDIR/.distributions/$2/rpmlist.d" \
+                         "$__DISTRIBDIR/$2/rpmlist.d" \
+                         ''
+                   
+    test -d "$_rlid_listdir" || return 0
+
+    local      _rlid_lst
+    for _rlid_lst in "$_rlid_listdir"/*.lst; do
+       isRegularFile "$_rlid_lst" || continue
+
+       local           _rlid_opts=${_rlid_lst%%lst}cmd
+       declare -a      _rlid_tmp=()
+
+       test ! -e "$_rlid_opts" || getFileArray _rlid_tmp "$_rlid_opts"
+       _rlid_res=( "${_rlid_res[@]}" "${_rlid_tmp[@]}" "$_rlid_lst" )
+    done
+
+    eval "$1"='( "${_rlid_res[@]}" )'
+}
+
+
+## Usage: rpm.sanityCheck
+function rpm.sanityCheck
+{
+    test -x "$BUILD_INITPRE" || colorize warn warning $"\
+WARNING: you are going to use an rpm-based installation method without
+  having an 'initpre' script. Such a script is highly recommend to
+  workaround bugs in rpm which can cause messages like
+
+  | error: unpacking of archive failed on file /usr/bin/X11;42dd8791:
+
+  Please read http://linux-vserver.org/HowToRegisterNewDistributions
+  for information how to add support for your own distribution."
 }