minor optimizations
[util-vserver.git] / util-vserver / scripts / vserver-build.functions.rpm
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             test -f "$file" || continue
33
34             pkgs=( "${pkgs[@]}" "$file" )
35         done
36     done
37
38     test "$pkgs" || return 0
39     "$_VRPM" "$dst" -- --import "${pkgs[@]}"
40 }
41
42 function rpm.initVariables
43 {
44     test "$WORKAROUND_106057" && \
45         RPMDB_PATH=/.rpmdb || \
46         RPMDB_PATH=/dev
47
48     findDir RPMLIBDIR "$CONFDIR/.distributions/$DISTRIBUTION/rpmlib" "$DISTRIBDIR/$DISTRIBUTION/rpmlib" /
49 }
50
51 function rpm.initFilesystem
52 {
53     test -z "$WORKAROUND_106057" || mkdir -p "$RPMDB_PATH"
54     mkdir -p "$VDIR$RPMDB_PATH"
55
56     test -z "$WORKAROUND_APT_DBPATH" || {
57         mkdir -p "$VDIR/var/lib"
58         ln -s "$RPMDB_PATH" "$VDIR/var/lib/rpm"
59     }
60
61     mkdir -p "$PKGCFGDIR"/rpm/{etc,state}
62     populateDirectory "$PKGCFGDIR/rpm/etc" \
63         "$DISTRIBDIR/defaults/rpm" \
64         "$DISTRIBDIR/$DISTRIBUTION/rpm" \
65         "$CONFDIR/.distributions/$DISTRIBUTION/rpm"
66
67     echo "%_dbpath $RPMDB_PATH" >>"$pkgcfg/etc/macros"
68
69     test "$RPMLIBDIR"  = / || ln -s "$RPMLIB"  "$confdir/apps/pkgmgmt/rpmlib"
70 }
71
72 function rpm.initDB
73 {
74     RPM_FLAVOR=d "$_VRPM" "$1" -- --initdb
75 }