Skip to content

Commit

Permalink
INSTALL_TO_CHROOT: Install built package into chroot
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke committed Sep 9, 2023
1 parent 65e6841 commit ea61f0e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/generic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/interactive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 17 additions & 10 deletions src/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -83,16 +74,32 @@ 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"
cat <<- EOF | ici_asroot tee -a /etc/schroot/sbuild/fstab
$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 {
Expand Down
7 changes: 3 additions & 4 deletions src/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ function _sub_shell() (
eval "$*" || ici_exit
)

# usage echo "$*" | ici_pipe_into_chroot <chroot folder>
function ici_pipe_into_chroot {
local folder=$1
cat -- | ici_asroot chroot "$folder" /bin/bash -- || ici_exit
# usage echo "$*" | ici_pipe_into_schroot <schroot name>
function ici_pipe_into_schroot {
cat -- | ici_asroot schroot -c "$1" --directory / /bin/bash -- || ici_exit
}

function _label_hook() {
Expand Down

0 comments on commit ea61f0e

Please sign in to comment.