use the common isRegularFile() method to filter out backup-files
[util-vserver.git] / util-vserver / scripts / vserver-build.functions.rpm
index 29d8426..a479877 100644 (file)
@@ -29,7 +29,7 @@ function rpm.importGPGPubKeys
     for i; do
        local file=
        for file in "$i"/*; do
-           test -f "$file" || continue
+           isRegularFile "$file" || continue
 
            pkgs=( "${pkgs[@]}" "$file" )
        done
@@ -45,7 +45,7 @@ function rpm.initVariables
        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,16 +60,67 @@ 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[@]}" )'
+}