vserver-build.functions.rpm (3736B)
1 # $Id$ --*- sh -*-- 2 3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> 4 # 5 # This program is free software; you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation; version 2 of the License. 8 # 9 # This program is distributed in the hope that it will be useful, 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License 15 # along with this program; if not, write to the Free Software 16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 18 RPMDB_PATH= 19 RPMLIBDIR= 20 21 function rpm.importGPGPubKeys 22 { 23 local dst=$1 24 local pkgs 25 declare -a pkgs 26 local i 27 28 shift 29 for i; do 30 local file= 31 for file in "$i"/*; do 32 isRegularFile "$file" || continue 33 test -s "$file" || continue 34 35 pkgs=( "${pkgs[@]}" "$file" ) 36 done 37 done 38 39 test -n "$pkgs" || return 0 40 "$_VRPM" "$dst" -- --import "${pkgs[@]}" 41 } 42 43 function rpm.initVariables 44 { 45 test -n "$WORKAROUND_106057" && \ 46 RPMDB_PATH=/.rpmdb || \ 47 RPMDB_PATH=/dev 48 49 findDir RPMLIBDIR "$__CONFDIR/.distributions/$DISTRIBUTION/rpmlib" "$__DISTRIBDIR/$DISTRIBUTION/rpmlib" / 50 } 51 52 function rpm.initFilesystem 53 { 54 test -z "$WORKAROUND_106057" || mkdir -p "$RPMDB_PATH" 55 mkdir -p "$VDIR$RPMDB_PATH" 56 mkdir -p "$VDIR/var/lock/rpm" 57 58 test -z "$WORKAROUND_APT_DBPATH" || { 59 mkdir -p "$VDIR/var/lib" 60 ln -s "$RPMDB_PATH" "$VDIR/var/lib/rpm" 61 } 62 63 mkdir -p "$PKGCFGDIR"/rpm/{etc,state} 64 populateDirectory "$PKGCFGDIR/rpm/etc" \ 65 "$__DISTRIBDIR/defaults/rpm" \ 66 "$__DISTRIBDIR/$DISTRIBUTION/rpm" \ 67 "$__CONFDIR/.distributions/$DISTRIBUTION/rpm" 68 69 echo "%_dbpath $RPMDB_PATH" >>"$PKGCFGDIR/rpm/etc/macros" 70 71 test "$RPMLIBDIR" = / || ln -s "$RPMLIB" "$SETUP_CONFDIR/apps/pkgmgmt/rpmlib" 72 } 73 74 function rpm.initDB 75 { 76 RPM_FLAVOR=d "$_VRPM" "$1" -- --initdb 77 } 78 79 80 81 ## Usage: rpmlist.install <vserver> <basedir> <tmpfile> <listfile> <rpm-options>* 82 function rpmlist.install() 83 { 84 local cfgdir=$1 85 local basedir=$2 86 local manifest=$3 87 local listfile=$4 88 shift 4 89 90 while read; do 91 case x"$REPLY" in 92 (x|\#*) continue;; 93 esac 94 95 echo "$basedir/$REPLY" 96 done >"$manifest" <"$listfile" 97 98 test "$OPTION_DEBUG" -eq 0 || cat "$manifest" 99 test ! -s "$manifest" || $_VRPM "$cfgdir" -- -U "$@" "$manifest" 100 } 101 102 103 ## Usage: rpmlist.initByDistribution <result-var> <distribution> 104 function rpmlist.initByDistribution() 105 { 106 local _rlid_listdir 107 declare -a _rlid_res=() 108 109 110 findDir _rlid_listdir "$__CONFDIR/.distributions/$2/rpmlist.d" \ 111 "$__DISTRIBDIR/$2/rpmlist.d" \ 112 '' 113 114 test -d "$_rlid_listdir" || return 0 115 116 local _rlid_lst 117 for _rlid_lst in "$_rlid_listdir"/*.lst; do 118 isRegularFile "$_rlid_lst" || continue 119 120 local _rlid_opts=${_rlid_lst%%lst}cmd 121 declare -a _rlid_tmp=() 122 123 test ! -e "$_rlid_opts" || getFileArray _rlid_tmp "$_rlid_opts" 124 _rlid_res=( "${_rlid_res[@]}" "${_rlid_tmp[@]}" "$_rlid_lst" ) 125 done 126 127 eval "$1"='( "${_rlid_res[@]}" )' 128 } 129 130 131 ## Usage: rpm.sanityCheck 132 function rpm.sanityCheck 133 { 134 test -x "$BUILD_INITPRE" || colorize warn warning $"\ 135 WARNING: you are going to use an rpm-based installation method without 136 having an 'initpre' script. Such a script is highly recommend to 137 workaround bugs in rpm which can cause messages like 138 139 | error: unpacking of archive failed on file /usr/bin/X11;42dd8791: 140 141 Please read http://linux-vserver.org/HowToRegisterNewDistributions 142 for information how to add support for your own distribution." 143 }