diff --git a/.github/workflows/generic.yaml b/.github/workflows/generic.yaml index 0f7f9d2..0898288 100644 --- a/.github/workflows/generic.yaml +++ b/.github/workflows/generic.yaml @@ -32,6 +32,10 @@ on: description: Continue building from previous debs artifact? required: true default: false + INSTALL_TO_CHROOT: + type: boolean + description: Incrementally install built packages within the chroot? + required: false BUILD_TIMEOUT: type: number description: Cancel build after this time, before github will do (minutes) @@ -148,6 +152,7 @@ jobs: DEB_BUILD_OPTIONS: ${{ inputs.DEB_BUILD_OPTIONS || vars.DEB_BUILD_OPTIONS || 'nocheck' }} CONTINUE_ON_ERROR: ${{ inputs.CONTINUE_ON_ERROR || vars.CONTINUE_ON_ERROR || false }} SKIP_EXISTING: ${{ inputs.SKIP_EXISTING || vars.SKIP_EXISTING || false }} + INSTALL_TO_CHROOT: ${{ inputs.INSTALL_TO_CHROOT || vars.INSTALL_TO_CHROOT || false }} - name: Store ccache uses: actions/cache/save@v3 diff --git a/.github/workflows/interactive.yaml b/.github/workflows/interactive.yaml index d35d32f..41616f1 100644 --- a/.github/workflows/interactive.yaml +++ b/.github/workflows/interactive.yaml @@ -30,6 +30,10 @@ on: type: boolean description: Skip existing packages? required: false + INSTALL_TO_CHROOT: + type: boolean + description: Incrementally fill chroot? + required: false DEPLOY_MODE: type: choice description: How to deploy? @@ -59,6 +63,7 @@ jobs: # proceed from existing debs artifact if run_attempt > 1 DOWNLOAD_DEBS: ${{ github.run_attempt != '1' }} SKIP_EXISTING: ${{ inputs.SKIP_EXISTING || vars.SKIP_EXISTING || false}} + INSTALL_TO_CHROOT: ${{ inputs.INSTALL_TO_CHROOT || vars.INSTALL_TO_CHROOT || false }} deploy: needs: build diff --git a/src/build.sh b/src/build.sh index 601a77b..2458c62 100644 --- a/src/build.sh +++ b/src/build.sh @@ -89,6 +89,14 @@ function build_pkg { fi ici_cmd ccache -sv + + if [ "$INSTALL_TO_CHROOT" == "true" ]; then + ici_color_output "${ANSI_BOLD}" "Install package within chroot" + # shellcheck disable=SC2012 + cat <<- EOF | ici_pipe_into_schroot sbuild-rw + apt install --no-install-recommends -q -y \$(ls -1 -t /build/repo/"$(deb_pkg_name "$pkg_name")"*.deb | head -1) +EOF + fi } function build_source { diff --git a/src/env.sh b/src/env.sh index ae0ecc1..b89131d 100644 --- a/src/env.sh +++ b/src/env.sh @@ -22,6 +22,7 @@ export EXTRA_SBUILD_OPTS=${EXTRA_SBUILD_OPTS:-} export DEB_BUILD_OPTIONS=${DEB_BUILD_OPTIONS:-nocheck} # don't build/run tests export SKIP_EXISTING=${SKIP_EXISTING:-false} +export INSTALL_TO_CHROOT=${INSTALL_TO_CHROOT:-false} ## deploy paths: 'eval echo ...' expands environment variables export DEBS_PATH diff --git a/src/prepare.sh b/src/prepare.sh index 811c3c3..c0eaf17 100644 --- a/src/prepare.sh +++ b/src/prepare.sh @@ -66,15 +66,6 @@ function create_chroot { "deb $DISTRIBUTION_REPO $DEB_DISTRO main universe" \ "deb [signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu jammy main" - ici_log - ici_color_output "${ANSI_BOLD}" "Add extra debian package sources" - while IFS= read -r line; do - echo "$line" - cat <<- EOF | ici_pipe_into_chroot "$chroot_folder" - echo "$line" >> "$REPOS_LIST_FILE" -EOF - done <<< "$EXTRA_DEB_SOURCES" - ici_log ici_color_output "${ANSI_BOLD}" "Write schroot config" cat <<- EOF | ici_asroot tee /etc/schroot/chroot.d/sbuild @@ -83,9 +74,12 @@ groups=root,sbuild root-groups=root,sbuild profile=sbuild type=directory -directory=/var/cache/sbuild-chroot +directory=$chroot_folder union-type=overlay EOF + # sbuild-rw: writable sbuild + sed -e 's#\(union-type\)=overlay#\1=none#' -e 's#\[sbuild\]#[sbuild-rw]#'\ + /etc/schroot/chroot.d/sbuild | ici_asroot tee /etc/schroot/chroot.d/sbuild-rw ici_log ici_color_output "${ANSI_BOLD}" "Add mount points to sbuild's fstab" @@ -93,6 +87,19 @@ EOF $CCACHE_DIR /build/ccache none rw,bind 0 0 $DEBS_PATH /build/repo none rw,bind 0 0 EOF + + ici_log + ici_color_output "${ANSI_BOLD}" "Add extra debian package sources" + while IFS= read -r line; do + echo "$line" + cat <<- EOF | ici_pipe_into_schroot sbuild-rw + echo "$line" >> "$REPOS_LIST_FILE" +EOF + done <<< "$EXTRA_DEB_SOURCES" + + ici_log + ici_color_output "${ANSI_BOLD}" "apt-get update in chroot" + echo "apt-get update" | ici_pipe_into_schroot sbuild-rw } function configure_sbuildrc { diff --git a/src/util.sh b/src/util.sh index d903eae..08e9c6e 100644 --- a/src/util.sh +++ b/src/util.sh @@ -99,10 +99,9 @@ function _sub_shell() ( eval "$*" || ici_exit ) -# usage echo "$*" | ici_pipe_into_chroot -function ici_pipe_into_chroot { - local folder=$1 - cat -- | ici_asroot chroot "$folder" /bin/bash -- || ici_exit +# usage echo "$*" | ici_pipe_into_schroot +function ici_pipe_into_schroot { + cat -- | ici_asroot schroot -c "$1" --directory / /bin/bash -- || ici_exit } function _label_hook() {