X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Fvserver-build.functions.rpm;fp=scripts%2Fvserver-build.functions.rpm;h=9aa499dcaec1496a4afc08cfe0f4758851501d91;hb=8cf13bb177d92c93eb73dc8939777150536c2d00;hp=0000000000000000000000000000000000000000;hpb=6bf3f95de36c804c97716b2d0bdf10680c559044;p=util-vserver.git diff --git a/scripts/vserver-build.functions.rpm b/scripts/vserver-build.functions.rpm new file mode 100644 index 0000000..9aa499d --- /dev/null +++ b/scripts/vserver-build.functions.rpm @@ -0,0 +1,126 @@ +# $Id: vserver-build.functions.rpm,v 1.8 2005/04/16 21:20:45 ensc Exp $ --*- sh -*-- + +# Copyright (C) 2003 Enrico Scholz +# +# 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. + +RPMDB_PATH= +RPMLIBDIR= + +function rpm.importGPGPubKeys +{ + local dst=$1 + local pkgs + declare -a pkgs + local i + + shift + for i; do + local file= + for file in "$i"/*; do + isRegularFile "$file" || continue + + pkgs=( "${pkgs[@]}" "$file" ) + done + done + + test -n "$pkgs" || return 0 + "$_VRPM" "$dst" -- --import "${pkgs[@]}" +} + +function rpm.initVariables +{ + test -n "$WORKAROUND_106057" && \ + RPMDB_PATH=/.rpmdb || \ + RPMDB_PATH=/dev + + findDir RPMLIBDIR "$__CONFDIR/.distributions/$DISTRIBUTION/rpmlib" "$__DISTRIBDIR/$DISTRIBUTION/rpmlib" / +} + +function rpm.initFilesystem +{ + test -z "$WORKAROUND_106057" || mkdir -p "$RPMDB_PATH" + mkdir -p "$VDIR$RPMDB_PATH" + + test -z "$WORKAROUND_APT_DBPATH" || { + mkdir -p "$VDIR/var/lib" + ln -s "$RPMDB_PATH" "$VDIR/var/lib/rpm" + } + + mkdir -p "$PKGCFGDIR"/rpm/{etc,state} + populateDirectory "$PKGCFGDIR/rpm/etc" \ + "$__DISTRIBDIR/defaults/rpm" \ + "$__DISTRIBDIR/$DISTRIBUTION/rpm" \ + "$__CONFDIR/.distributions/$DISTRIBUTION/rpm" + + echo "%_dbpath $RPMDB_PATH" >>"$PKGCFGDIR/rpm/etc/macros" + + test "$RPMLIBDIR" = / || ln -s "$RPMLIB" "$SETUP_CONFDIR/apps/pkgmgmt/rpmlib" +} + +function rpm.initDB +{ + RPM_FLAVOR=d "$_VRPM" "$1" -- --initdb +} + + + +## Usage: rpmlist.install * +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 +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[@]}" )' +}