2 # Debian dpkg specific functions.
4 ################################################################
6 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2 or 3 as
10 # published by the Free Software Foundation.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program (see the file COPYING); if not, write to the
19 # Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 ################################################################
25 # A wrapper around chroot to set the environment correctly for dpkg and
26 # pre/postinst scripts.
31 # to workaround some version of fileutils that doesn't do a 'chdir /'
32 # when doing a 'chroot /' call lets subshell and change dir manually
36 DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical \
37 DEBCONF_NONINTERACTIVE_SEEN=true \
38 LC_ALL=C LANGUAGE=C LANG=C \
44 mkdir -p "$BUILD_ROOT"/var/lib/dpkg
45 mkdir -p "$BUILD_ROOT"/var/log
46 mkdir -p "$BUILD_ROOT"/etc/default
47 :>> "$BUILD_ROOT"/var/lib/dpkg/status
48 :>> "$BUILD_ROOT"/var/lib/dpkg/available
49 :>> "$BUILD_ROOT"/var/log/dpkg.log
50 :>> "$BUILD_ROOT"/etc/ld.so.conf
51 :>> "$BUILD_ROOT"/etc/default/rcS
56 # force dpkg into database to make epoch test work
57 if ! test "$BUILD_ROOT/.init_b_cache/rpms/dpkg.deb" -ef "$BUILD_ROOT/.init_b_cache/dpkg.deb" ; then
58 rm -f "$BUILD_ROOT"/.init_b_cache/dpkg.deb
59 cp "$BUILD_ROOT"/.init_b_cache/rpms/dpkg.deb "$BUILD_ROOT"/.init_b_cache/dpkg.deb || cleanup_and_exit 1
61 deb_chroot "$BUILD_ROOT" dpkg --install --force-depends .init_b_cache/dpkg.deb >/dev/null 2>&1
69 ( deb_chroot "$BUILD_ROOT" dpkg --install --force-depends .init_b_cache/$PKG.deb 2>&1 || touch "$BUILD_ROOT"/exit ) | \
70 perl -ne '$|=1;/^(Configuration file|Installing new config file|Selecting previously deselected|Selecting previously unselected|\(Reading database|Unpacking |Setting up|Creating config file|Preparing to replace dpkg|Preparing to unpack )/||/^$/||print'
71 # ugly workaround for upstart system. some packages (procps) try
72 # to start a service in their configure phase. As we don't have
73 # a running upstart, we just link the start binary to /bin/true
74 if test -e "$BUILD_ROOT/sbin/start"; then
75 if test "$BUILD_ROOT/sbin/start" -ef "$BUILD_ROOT/sbin/initctl" ; then
76 echo "linking /sbin/start to /bin/true"
77 mv "$BUILD_ROOT/sbin/start" "$BUILD_ROOT/sbin/start.disabled"
78 ln -s "/bin/true" "$BUILD_ROOT/sbin/start"
81 # another workaround, see bug bnc#733699
82 rm -f "$BUILD_ROOT/var/run/init.upgraded"
86 deb_chroot "$BUILD_ROOT" dpkg --purge --force-depends $PKG 2>&1 | {
90 subprocess\ installed\ *script\ returned\ error\ exit\ status*)
91 chroot "$BUILD_ROOT" rm -f /var/lib/dpkg/info/$PKG.{pre,post}rm
97 if test -n "$retry"; then
98 echo "re-try deleting $PKG without post/pre remove scripts"
99 deb_chroot "$BUILD_ROOT" dpkg --purge --force-depends $PKG 2>&1 || touch "$BUILD_ROOT"/exit
101 } | perl -ne '$|=1;/^(\(Reading database|Removing |Purging configuration files for )/||/^$/||print'
108 pkg_verify_installed_deb() {
113 echo "configuring all installed packages..."
114 # configure all packages after complete installation, not for each package like rpm does
115 # We need to run this twice, because of cyclic dependencies as it does not succeed on most
116 # debian based distros in the first attempt.
117 if ! deb_chroot "$BUILD_ROOT" dpkg --configure --pending 2>&1; then
118 echo "first configure attempt failed, trying again..."
119 deb_chroot "$BUILD_ROOT" dpkg --configure --pending 2>&1 || cleanup_and_exit 1
123 pkg_preinstall_deb() {
124 ar x "$BUILD_ROOT/.init_b_cache/rpms/$PKG.deb"
125 mkdir -p .init_b_cache/scripts/control
126 $TAR -C .init_b_cache/scripts/control -z -f control.tar.gz
127 if test -f "data.tar.gz" ; then
128 $TAR -z -f data.tar.gz
129 elif test -f "data.tar.xz" ; then
130 $TAR -J -f data.tar.xz
132 if test -e ".init_b_cache/scripts/$PKG.run" ; then
133 test -e .init_b_cache/scripts/control/preinst && mv .init_b_cache/scripts/control/preinst ".init_b_cache/scripts/$PKG.pre"
134 test -e .init_b_cache/scripts/control/postinst && mv .init_b_cache/scripts/control/postinst ".init_b_cache/scripts/$PKG.post"
136 rm -rf .init_b_cache/scripts/control control.tar.gz data.tar.{g,x}z
139 pkg_runscripts_deb() {
140 if ! test -e "$BUILD_ROOT"/var/lib/dpkg/status ; then
143 if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then
144 echo "running $PKG preinstall script"
145 deb_chroot "$BUILD_ROOT" ".init_b_cache/scripts/$PKG.pre" install \
147 rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre"
149 if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then
150 echo "running $PKG postinstall script"
151 deb_chroot "$BUILD_ROOT" ".init_b_cache/scripts/$PKG.post" configure '' \
153 rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post"