From 3791cadc7684499df82eb804b78b9fbd710437e3 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:51:28 +0200 Subject: [PATCH] Add option to build chroot based on host image Useful for the WFs where the image is non-standard and uses additional ppa's so the mirror is not enough. --- misc-tools/dj_make_chroot.in | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/misc-tools/dj_make_chroot.in b/misc-tools/dj_make_chroot.in index 53b0d7c1f5..e8aa003bf9 100755 --- a/misc-tools/dj_make_chroot.in +++ b/misc-tools/dj_make_chroot.in @@ -76,6 +76,9 @@ Options: to add to the chroot (comma separated). Signing keys for the repository will be imported if they exist as .gpg, .asc or .arm. + -H Use repository lists from the host. Useful to make sure + compiler/runner versions will be the same when using a custom + image. -p HTTP(S) Proxy URL to use during package install. -m Debian or Ubuntu mirror URL to be used for package installation. -y Force overwriting the chroot dir and installing debootstrap. @@ -110,7 +113,7 @@ FORCEYES=0 FORCEDOWNLOAD=0 # Read command-line parameters: -while getopts 'a:d:D:R:i:r:l:s:p:m:yfh' OPT ; do +while getopts 'a:d:D:R:i:r:l:s:p:m:Hyfh' OPT ; do case $OPT in a) ARCH=$OPTARG ;; d) CHROOTDIR=$OPTARG ;; @@ -122,6 +125,7 @@ while getopts 'a:d:D:R:i:r:l:s:p:m:yfh' OPT ; do s) REPOLISTS=$OPTARG ;; p) DEBPROXY=$OPTARG ;; m) DEBMIRROR=$OPTARG ;; + H) HOSTLISTS=1 ;; y) FORCEYES=1 ;; f) FORCEDOWNLOAD=1 ;; h) SHOWHELP=1 ;; @@ -411,6 +415,14 @@ if [ "$DISTRO" = 'Ubuntu' ]; then in_chroot "ln -s /bin/true /sbin/initctl" fi +# Use the repositories from the host +if [ -n "$HOSTLISTS" ]; then + for files in 'sources.list' 'sources.list.d' 'keyrings' 'trusted.gpg.d'; do + cp -r "/etc/apt/${files}" "$CHROOTDIR/etc/apt/" + done + in_chroot "apt-get update && apt-get install ca-certificates" +fi + # Add additional repository lists to the chroot for upstream repos if [ -n "$REPOLISTS" ]; then in_chroot "apt-get install ca-certificates"