diff options
author | shuai.fu <shuai01.fu@samsung.com> | 2017-04-22 13:43:02 +0800 |
---|---|---|
committer | y0169.zhang <y0169.zhang@samsung.com> | 2017-07-10 11:19:29 +0800 |
commit | 24dc605f13d22c9c40999910af164d1f8c5bfd8e (patch) | |
tree | ace6b1cfe91019ef6ea452a7fa6bd9d446c4d153 /build-pkg-deb | |
parent | 07c0dbf5da85bc3931186838be1420cfd8a2de7f (diff) | |
download | build-24dc605f13d22c9c40999910af164d1f8c5bfd8e.tar.gz build-24dc605f13d22c9c40999910af164d1f8c5bfd8e.tar.bz2 build-24dc605f13d22c9c40999910af164d1f8c5bfd8e.zip |
Update to upstream 20160629upstream/20160629
Change-Id: Idc31c269aec94e852b30885dee65a827b318b7a3
Signed-off-by: shuai.fu <shuai01.fu@samsung.com>
Diffstat (limited to 'build-pkg-deb')
-rw-r--r-- | build-pkg-deb | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/build-pkg-deb b/build-pkg-deb index 83a4afe..2465204 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 @@ -39,7 +58,7 @@ 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 $BUILD_ROOT dpkg -i --force all .init_b_cache/dpkg.deb >/dev/null 2>&1 + deb_chroot $BUILD_ROOT dpkg --install --force-depends .init_b_cache/dpkg.deb >/dev/null 2>&1 } pkg_prepare_deb() { @@ -47,9 +66,7 @@ pkg_prepare_deb() { } pkg_install_deb() { - export DEBIAN_FRONTEND=noninteractive - export DEBIAN_PRIORITY=critical - ( cd $BUILD_ROOT && chroot $BUILD_ROOT dpkg --install --force all .init_b_cache/$PKG.deb 2>&1 || touch $BUILD_ROOT/exit ) | \ + ( deb_chroot $BUILD_ROOT dpkg --install --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 @@ -66,10 +83,22 @@ pkg_install_deb() { } pkg_erase_deb() { - export DEBIAN_FRONTEND=noninteractive - export DEBIAN_PRIORITY=critical - ( cd $BUILD_ROOT && chroot $BUILD_ROOT dpkg --purge --force all $PKG 2>&1 || touch $BUILD_ROOT/exit ) | \ - perl -ne '$|=1;/^(\(Reading database|Removing |Purging configuration files for )/||/^$/||print' + 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() { @@ -85,9 +114,9 @@ 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 $BUILD_ROOT 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 $BUILD_ROOT dpkg --configure --pending 2>&1 || cleanup_and_exit 1 + deb_chroot $BUILD_ROOT dpkg --configure --pending 2>&1 || cleanup_and_exit 1 fi } @@ -113,12 +142,18 @@ pkg_runscripts_deb() { fi if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then echo "running $PKG preinstall script" - (cd $BUILD_ROOT && chroot $BUILD_ROOT ".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" - (cd $BUILD_ROOT && chroot $BUILD_ROOT ".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: |