summaryrefslogtreecommitdiff
path: root/build-pkg-deb
diff options
context:
space:
mode:
Diffstat (limited to 'build-pkg-deb')
-rw-r--r--build-pkg-deb85
1 files changed, 65 insertions, 20 deletions
diff --git a/build-pkg-deb b/build-pkg-deb
index c6c4702..3741b55 100644
--- a/build-pkg-deb
+++ b/build-pkg-deb
@@ -21,6 +21,25 @@
#
################################################################
+#
+# A wrapper around chroot to set the environment correctly for dpkg and
+# pre/postinst scripts.
+#
+deb_chroot ()
+{
+ #
+ # to workaround some version of fileutils that doesn't do a 'chdir /'
+ # when doing a 'chroot /' call lets subshell and change dir manually
+ #
+ (
+ cd $1 &&
+ DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical \
+ DEBCONF_NONINTERACTIVE_SEEN=true \
+ LC_ALL=C LANGUAGE=C LANG=C \
+ chroot $*
+ )
+}
+
deb_setup() {
mkdir -p $BUILD_ROOT/var/lib/dpkg
mkdir -p $BUILD_ROOT/var/log
@@ -29,7 +48,16 @@ deb_setup() {
:>> $BUILD_ROOT/var/lib/dpkg/available
:>> $BUILD_ROOT/var/log/dpkg.log
:>> $BUILD_ROOT/etc/ld.so.conf
- :>> $BUILD_ROOT/etc/default/rcS
+
+ # Install a policy so that services are not started. See
+ # https://manpages.debian.org/unstable/init-system-helpers/invoke-rc.d.8.en.html
+ # for details.
+ mkdir -p $BUILD_ROOT/usr/sbin
+ cat > $BUILD_ROOT/usr/sbin/policy-rc.d <<EOF
+#!/bin/sh
+exit 101
+EOF
+ chmod 755 $BUILD_ROOT/usr/sbin/policy-rc.d
}
pkg_initdb_deb() {
@@ -39,25 +67,16 @@ pkg_initdb_deb() {
rm -f $BUILD_ROOT/.init_b_cache/dpkg.deb
cp $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb $BUILD_ROOT/.init_b_cache/dpkg.deb || cleanup_and_exit 1
fi
- $CHROOT dpkg -i --force all .init_b_cache/dpkg.deb >/dev/null 2>&1
+ deb_chroot $BUILD_ROOT dpkg --install --force-unsafe-io --force-depends .init_b_cache/dpkg.deb >/dev/null 2>&1
}
-pkg_get_installed_deb() {
+pkg_prepare_deb() {
:
}
-pkg_set_packageid_deb() {
- PKGID=`readlink $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb`
- PKGID="${PKGID##*/}"
- PKGID="${PKGID%.deb} debian"
-}
-
pkg_install_deb() {
- export DEBIAN_FRONTEND=noninteractive
- export DEBIAN_PRIORITY=critical
- ( $CHROOT dpkg --install --force all /.init_b_cache/$PKG.deb 2>&1 || touch $BUILD_ROOT/exit ) | \
- 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)/||/^$/||print'
- check_exit
+ ( deb_chroot $BUILD_ROOT dpkg --install --force-unsafe-io --force-depends .init_b_cache/$PKG.deb 2>&1 || touch $BUILD_ROOT/exit ) | \
+ 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'
# ugly workaround for upstart system. some packages (procps) try
# to start a service in their configure phase. As we don't have
# a running upstart, we just link the start binary to /bin/true
@@ -73,7 +92,22 @@ pkg_install_deb() {
}
pkg_erase_deb() {
- cleanup_and_exit 1
+ deb_chroot $BUILD_ROOT dpkg --purge --force-depends $PKG 2>&1 | {
+ local retry
+ while read line; do
+ case "$line" in
+ subprocess\ installed\ *script\ returned\ error\ exit\ status*)
+ chroot $BUILD_ROOT rm -f /var/lib/dpkg/info/$PKG.{pre,post}rm
+ retry=1
+ ;;
+ *) echo "$line" ;;
+ esac
+ done
+ if test -n "$retry"; then
+ echo "re-try deleting $PKG without post/pre remove scripts"
+ deb_chroot $BUILD_ROOT dpkg --purge --force-depends $PKG 2>&1 || touch $BUILD_ROOT/exit
+ fi
+ } | perl -ne '$|=1;/^(\(Reading database|Removing |Purging configuration files for )/||/^$/||print'
}
pkg_cumulate_deb() {
@@ -89,16 +123,21 @@ pkg_finalize_deb() {
# configure all packages after complete installation, not for each package like rpm does
# We need to run this twice, because of cyclic dependencies as it does not succeed on most
# debian based distros in the first attempt.
- if ! $CHROOT dpkg --configure --pending 2>&1; then
+ if ! deb_chroot $BUILD_ROOT dpkg --configure --pending 2>&1; then
echo "first configure attempt failed, trying again..."
- $CHROOT dpkg --configure --pending 2>&1 || cleanup_and_exit 1
+ deb_chroot $BUILD_ROOT dpkg --configure --pending 2>&1 || cleanup_and_exit 1
fi
}
pkg_preinstall_deb() {
ar x "$BUILD_ROOT/.init_b_cache/rpms/$PKG.deb"
mkdir -p .init_b_cache/scripts/control
+ if test -f "control.tar.gz" ; then
$TAR -C .init_b_cache/scripts/control -z -f control.tar.gz
+ elif test -f "control.tar.xz" ; then
+ $TAR -C .init_b_cache/scripts/control -J -f control.tar.xz
+ fi
+ grep '^Version:' .init_b_cache/scripts/control/control || echo 'Version: unknown'
if test -f "data.tar.gz" ; then
$TAR -z -f data.tar.gz
elif test -f "data.tar.xz" ; then
@@ -108,7 +147,7 @@ pkg_preinstall_deb() {
test -e .init_b_cache/scripts/control/preinst && mv .init_b_cache/scripts/control/preinst ".init_b_cache/scripts/$PKG.pre"
test -e .init_b_cache/scripts/control/postinst && mv .init_b_cache/scripts/control/postinst ".init_b_cache/scripts/$PKG.post"
fi
- rm -rf .init_b_cache/scripts/control control.tar.gz data.tar.{g,x}z
+ rm -rf .init_b_cache/scripts/control control.tar.{g,x}z data.tar.{g,x}z
}
pkg_runscripts_deb() {
@@ -117,12 +156,18 @@ pkg_runscripts_deb() {
fi
if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then
echo "running $PKG preinstall script"
- $CHROOT "/.init_b_cache/scripts/$PKG.pre" install < /dev/null
+ deb_chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.pre" install \
+ < /dev/null
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 "/.init_b_cache/scripts/$PKG.post" configure '' < /dev/null
+ deb_chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.post" configure '' \
+ < /dev/null
rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post"
fi
}
+
+# Local Variables:
+# mode: Shell-script
+# End: