blob: c0f965399f1a535788df02810dd05de925d1d7d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
#
# RPM specific functions.
#
################################################################
#
# Copyright (c) 1995-2014 SUSE Linux Products GmbH
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or 3 as
# published by the Free Software Foundation.
#
# 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 (see the file COPYING); if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
################################################################
pkg_initdb_rpm() {
echo "initializing rpm db..."
mkdir -p $BUILD_ROOT/var/lib/rpm
# rpm v5 does not have initdb
if ! test -e $BUILD_ROOT/usr/lib/rpm/cpuinfo.yaml ; then
if test -x $BUILD_ROOT/usr/bin/rpmdb ; then
chroot $BUILD_ROOT /usr/bin/rpmdb --initdb || cleanup_and_exit 1
else
chroot $BUILD_ROOT rpm --initdb || cleanup_and_exit 1
fi
fi
# hack: add nofsync to db config to speed up install
mkdir -p $BUILD_ROOT/root
DBI_OTHER=`chroot $BUILD_ROOT rpm --eval '%{?__dbi_other}'`
echo "%__dbi_other $DBI_OTHER nofsync" > $BUILD_ROOT/.rpmmacros
echo "%__dbi_other $DBI_OTHER nofsync" > $BUILD_ROOT/root/.rpmmacros
}
pkg_prepare_rpm() {
rpm_set_checkopts
rpm_init_cumulate
}
pkg_erase_rpm() {
chroot $BUILD_ROOT rpm --nodeps -e $PKG 2>&1 | {
local retry
while read line; do
case "$line" in
r*failed:\ No\ such\ file\ or\ directory) ;;
error:\ failed\ to\ stat\ *:\ No\ such\ file\ or\ directory) ;;
error:\ *scriptlet\ failed*)
echo "$line"
retry=1
;;
*) echo "$line" ;;
esac
done
if test -n "$retry" ; then
echo "re-try deleting $PKG using --noscripts"
chroot $BUILD_ROOT rpm --nodeps --noscripts -e $PKG || true
fi
}
}
rpm_set_checkopts() {
RPMCHECKOPTS=
# on Fedora 10 rpmbuild is in a separate package so we need something else to
# detect rpm4
test -x $BUILD_ROOT/usr/bin/rpmquery && RPMCHECKOPTS="--nodigest --nosignature"
}
rpm_init_cumulate() {
cumulate=-1
CUMULATED_LIST=()
CUMULATED_PIDS=()
CUMULATED_HMD5=()
DO_CUMULATE=
typeset -ri suse_version=$(chroot $BUILD_ROOT rpm --eval '%{?suse_version}' 2>/dev/null)
if ((suse_version > 1220)) ; then
DO_CUMULATE=true
fi
}
pkg_verify_installed_rpm() {
chroot $BUILD_ROOT rpm --verify $PKG 2>&1 | tee $TMPFILE
if grep ^missing $TMPFILE > /dev/null ; then
return 1
fi
return 0
}
pkg_cumulate_rpm() {
test "$DO_CUMULATE" = true || return 1
# work around for cross-build installs, we must not overwrite the running rpm
if test "$PKG" = rpm ; then
for i in $BUILD_ROOT/.init_b_cache/preinstalls/rpm-x86-* ; do
test -e "$i" && return 1
done
fi
let cumulate++
CUMULATED_LIST[$cumulate]=".init_b_cache/$PKG.rpm"
CUMULATED_PIDS[$cumulate]="$PKGID"
CUMULATED_HMD5[$cumulate]="$PKG_HDRMD5"
return 0
}
pkg_install_rpm() {
( chroot $BUILD_ROOT rpm --ignorearch --nodeps -U --oldpackage --ignoresize $RPMCHECKOPTS \
$ADDITIONAL_PARAMS .init_b_cache/$PKG.rpm 2>&1 || \
touch $BUILD_ROOT/exit ) | \
grep -v "^warning:.*saved as.*rpmorig$"
}
pkg_finalize_rpm() {
if test -n "${CUMULATED_LIST[*]}" ; then
echo "now installing cumulated packages"
for ((num=0; num<=cumulate; num++)) ; do
echo ${CUMULATED_LIST[$num]}
PKG=${CUMULATED_LIST[$num]##*/}
test "$BUILD_ROOT/.init_b_cache/rpms/$PKG" -ef "$BUILD_ROOT/${CUMULATED_LIST[$num]}" && continue
rm -f $BUILD_ROOT/${CUMULATED_LIST[$num]}
cp $BUILD_ROOT/.init_b_cache/rpms/$PKG $BUILD_ROOT/${CUMULATED_LIST[$num]} || cleanup_and_exit 1
done > $BUILD_ROOT/.init_b_cache/manifest
chroot $BUILD_ROOT rpm --ignorearch --nodeps -Uh --oldpackage --ignoresize --verbose $RPMCHECKOPTS \
$ADDITIONAL_PARAMS .init_b_cache/manifest 2>&1 || touch $BUILD_ROOT/exit
for ((num=0; num<=cumulate; num++)) ; do
rm -f $BUILD_ROOT/${CUMULATED_LIST[$num]}
done
rm -f $BUILD_ROOT/.init_b_cache/manifest
check_exit
for ((num=0; num<=cumulate; num++)) ; do
PKG=${CUMULATED_LIST[$num]##*/}
echo "${CUMULATED_PIDS[$num]}" > $BUILD_ROOT/installed-pkg/${PKG%.rpm}
test -n "${CUMULATED_HMD5[$num]}" || continue
echo "${CUMULATED_HMD5[$num]} ${CUMULATED_PIDS[$num]}" > $BUILD_ROOT/.preinstall_image/${PKG%.rpm}
done
fi
}
pkg_preinstall_rpm() {
PAYLOADDECOMPRESS=cat
case `rpm -qp --nodigest --nosignature --qf "%{PAYLOADCOMPRESSOR}\n" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm"` in
lzma) rpm --showrc | egrep 'PayloadIsLzma|_lzma' > /dev/null || PAYLOADDECOMPRESS="lzma -d" ;;
xz) rpm --showrc | egrep 'PayloadIsXz|_xz' > /dev/null || PAYLOADDECOMPRESS="xz -d" ;;
esac
if test "$PAYLOADDECOMPRESS" = "lzma -d" ; then
if ! lzma </dev/null >/dev/null 2>&1 ; then
test -f "$BUILD_DIR/lzmadec.sh" && PAYLOADDECOMPRESS="bash $BUILD_DIR/lzmadec.sh"
fi
fi
if test "$PAYLOADDECOMPRESS" = "xz -d" ; then
if ! xz </dev/null >/dev/null 2>&1 ; then
test -f "$BUILD_DIR/xzdec.sh" && PAYLOADDECOMPRESS="bash $BUILD_DIR/xzdec.sh"
fi
fi
if test "$PAYLOADDECOMPRESS" = cat ; then
rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" | $CPIO
else
rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" | $PAYLOADDECOMPRESS | $CPIO
fi
if test -e ".init_b_cache/scripts/$PKG.run" ; then
rpm -qp --nodigest --nosignature --qf "%{PREIN}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.pre"
rpm -qp --nodigest --nosignature --qf "%{POSTIN}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.post"
echo -n '(none)' > .init_b_cache/scripts/.none
cmp -s ".init_b_cache/scripts/$PKG.pre" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$PKG.pre"
cmp -s ".init_b_cache/scripts/$PKG.post" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$PKG.post"
rm -f .init_b_cache/scripts/.none
fi
# hack for rpm erasures
if test -d "$BUILD_ROOT/installed-pkg" ; then
# call for rpm-4.x and not rpm-devel
test -z "${PKG##rpm-[0-9]*}" && chroot $BUILD_ROOT rpm --rebuilddb
# also exec for exchanged rpm ! naming is rpm-x86-<target>-<ver>
test -z "${PKG##rpm-x86-*[0-9]*}" && chroot $BUILD_ROOT rpm --rebuilddb
fi
}
pkg_runscripts_rpm() {
if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then
echo "running $PKG preinstall script"
chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.pre" 0
rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre"
fi
if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then
echo "running $PKG postinstall script"
chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.post" 1
rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post"
fi
}
|