From patchwork Wed Apr 5 19:36:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luke Shumaker X-Patchwork-Id: 92 Return-Path: Delivered-To: patchwork@archlinux.org Received: from nymeria.archlinux.org by nymeria.archlinux.org (Dovecot) with LMTP id qRMvJEBH5ViYagAAtiB/HQ for ; Wed, 05 Apr 2017 21:36:32 +0200 Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 4F051406FA; Wed, 5 Apr 2017 21:36:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on nymeria.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.5 tests=BAYES_00,RCVD_IN_DNSWL_MED shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS; Wed, 5 Apr 2017 21:36:31 +0200 (CEST) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 95DD02C106; Wed, 5 Apr 2017 19:36:28 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=none Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 17E3A2C0FF for ; Wed, 5 Apr 2017 19:36:27 +0000 (UTC) Received: from mav.lukeshu.com (mav.lukeshu.com [104.207.138.63]) by luna.archlinux.org (Postfix) with ESMTPS for ; Wed, 5 Apr 2017 19:36:26 +0000 (UTC) Received: from build64-par (unknown [IPv6:2601:803:202:9275:21f:e2ff:fe4d:191b]) by mav.lukeshu.com (Postfix) with ESMTPSA id 01F9183EBB; Wed, 5 Apr 2017 15:36:25 -0400 (EDT) From: lukeshu@lukeshu.com To: arch-projects@lists.archlinux.org Date: Wed, 5 Apr 2017 15:36:00 -0400 Message-Id: <20170405193603.22277-5-lukeshu@lukeshu.com> X-Mailer: git-send-email 2.12.1 In-Reply-To: <20170405193603.22277-1-lukeshu@lukeshu.com> References: <20170405193603.22277-1-lukeshu@lukeshu.com> Subject: [arch-projects] [devtools] [PATCH 4/7] mkarchroot, arch-nspawn: Add an `-f` flag to add files to copy. X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Arch Linux projects development discussion Cc: Luke Shumaker Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" X-UID: 239 Status: X-Keywords: Content-Length: 2869 From: Luke Shumaker This allows us to copy in files like `qemu-arm-static`, which is necessary for running an ARM chroot on an x86 box. --- arch-nspawn.in | 12 +++++++++++- mkarchroot.in | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/arch-nspawn.in b/arch-nspawn.in index 7481d82..dceb3ed 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -15,6 +15,8 @@ m4_include(lib/archroot.sh) working_dir='' +files=() + usage() { echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]" echo "A wrapper around systemd-nspawn. Provides support for pacman." @@ -23,15 +25,17 @@ usage() { echo ' -C Location of a pacman config file' echo ' -M Location of a makepkg config file' echo ' -c Set pacman cache' + echo ' -f Copy file from the host to the chroot' echo ' -h This message' exit 1 } -while getopts 'hC:M:c:' arg; do +while getopts 'hC:M:c:f:' arg; do case "$arg" in C) pac_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;; c) cache_dir="$OPTARG" ;; + f) files+=("$OPTARG") ;; h|?) usage ;; *) error "invalid argument '%s'" "$arg"; usage ;; esac @@ -77,6 +81,12 @@ copy_hostconf () { [[ -n $pac_conf ]] && cp $pac_conf "$working_dir/etc/pacman.conf" [[ -n $makepkg_conf ]] && cp $makepkg_conf "$working_dir/etc/makepkg.conf" + local file + for file in "${files[@]}"; do + mkdir -p "$(dirname "$working_dir$file")" + cp -T "$file" "$working_dir$file" + done + sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i "$working_dir/etc/pacman.conf" } # }}} diff --git a/mkarchroot.in b/mkarchroot.in index 1265335..4f35c1a 100644 --- a/mkarchroot.in +++ b/mkarchroot.in @@ -15,21 +15,25 @@ m4_include(lib/archroot.sh) working_dir='' +files=() + usage() { echo "Usage: ${0##*/} [options] working-dir package-list..." echo ' options:' echo ' -C Location of a pacman config file' echo ' -M Location of a makepkg config file' echo ' -c Set pacman cache' + echo ' -f Copy file from the host to the chroot' echo ' -h This message' exit 1 } -while getopts 'hC:M:c:' arg; do +while getopts 'hC:M:c:f:' arg; do case "$arg" in C) pac_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;; c) cache_dir="$OPTARG" ;; + f) files+=("$OPTARG") ;; h|?) usage ;; *) error "invalid argument '%s'" "$arg"; usage ;; esac @@ -67,6 +71,11 @@ if is_btrfs "$working_dir"; then chmod 0755 "$working_dir" fi +for file in "${files[@]}"; do + mkdir -p "$(dirname "$working_dir$file")" + cp "$file" "$working_dir$file" +done + pacstrap -GMcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \ "${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'