[build][deb] Run custom scripts before build

Add ability to execute custom scripts before build stage
    Custom scripts can be executed with `run-parts` from `debian/hooks.d`
    folder

Change-Id: I0e84f6cdfca029d92178b4a66678a1c4a69808b1
This commit is contained in:
Dmitry Burmistrov 2017-05-04 17:40:15 +04:00
parent 1c066ce854
commit 567a5a13fa
1 changed files with 11 additions and 0 deletions

View File

@ -229,6 +229,12 @@ docker_build_sbuild() {
unset SET_APT_PREFS_CMD
[ -n "${PIN_CONTENT_BASE64}" ] \
&& local SET_APT_PREFS_CMD="--chroot-setup-commands=\"set-apt-prefs ${PIN_CONTENT_BASE64}\""
## Process hooks
local debian_dir=${SOURCE_PATH}/${SOURCE_TARGET}/debian
if [ -d "${debian_dir}/hooks.d" ] ; then
HOOKS_CMD="--chroot-setup-commands=\"run-parts /hooks.d/\""
fi
##
local SBUILD_OPTS="--nolog --source --force-orig-source"
if [ "$KEEP_CHROOT" = "true" ] ; then
@ -254,11 +260,16 @@ docker_build_sbuild() {
rm -rf /etc/schroot/chroot.d
ln -s /srv/images/chroot.d /etc/schroot/chroot.d
ulimit -n 10000
if [ x$HOOKS_CMD != x ] ; then
echo '/srv/source/${SOURCE_TARGET}/debian/hooks.d /hooks.d none ro,bind 0 0' \
>> /etc/schroot/sbuild/fstab
fi
( sed -i /usr/bin/sbuild -e '/debian\/rules/d'
DEB_BUILD_OPTIONS=nocheck /usr/bin/sbuild -d ${DIST} \
${SBUILD_OPTS} \
${ADD_REPO_CMD} \
${SET_APT_PREFS_CMD} \
${HOOKS_CMD} \
--chroot-setup-commands=\"apt-get update\" \
--chroot-setup-commands=\"apt-get upgrade -f -y --force-yes\" \
/srv/source/${SOURCE_TARGET} 2>&1