From patchwork Tue Jan 15 13:34:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 953 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 3B00DA955631 for ; Tue, 15 Jan 2019 13:35:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00=-1, DKIMWL_WL_HIGH=-1.046,DKIM_SIGNED=0.1,DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_LOW=-0.7 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.9.1] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Tue, 15 Jan 2019 13:35:40 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id B1682FFEB9751; Tue, 15 Jan 2019 13:35:38 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Tue, 15 Jan 2019 13:35:38 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 96CA22CDE7; Tue, 15 Jan 2019 13:35:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1547559338; bh=D4ilBUO3zq08/vlgtFojxiC7BTPMnlE0Cb9DxfJ1ZwU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc; b=otgfibUSBQsiQX/FVUxHPLNxMmKnZqP3gi/iSK4cLC9lyyNtvRaQEWt9A18Mhdlh3 Ep8aKV84ddjrwdJxe2uGvg4goEJiprG86XFpMlaz56lsw3lvLqQYLTQ3xatz/CLuK7 7XJ9Vicls8ui0kK3r8p3iBZnr5xJacgvAFm5VM1xiXNLuwkTOgdaUtg6QNdbS2LdSF hOMNYQzCoqRrfurO4PcIN1C8F1qz4EUUNdSe+u9910VVWnEmOodz3SIjAWQW5sfmzY It9uEpWXxx3AghU+uNLpzkyyBuyD1rFPsim9q1uHJN8+KXS3u+tvX8ZlQNHNQx+mQc eBKF3+NvbJ8EdicniOpQWrR0l4IF9gybc5GDjlNJxPbmd7DUPADdz/kWoUWf7ciA3o awnFoQLkwBMaUjdlKuX39pmKI9NCRkSnsO7ysa/hp24c/XSvLFZr6C25etBG5x14Aw j4ptti7vQY9bqC293h3zfZjLOk1fuICSzb6tXMsQzQZaTDc+/sSn4Id2gYFL814Aav TYST0QWb4pCzQNMFLuifGw0MzfiSSCwugp2JeCm+g4uph1eViHIp6KBFo3bXZ5h7oV KEOfMp4r9fUl0NmvNQpQGXeoQR/ALK0HHWmMf2X3PeeSB2m6xr0Cnh/7GjJIDwI8rG m3JfV8NAHZ/2Sml0isdcSTQY= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id CEB0C2CDE7 for ; Tue, 15 Jan 2019 13:35:36 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Tue, 15 Jan 2019 13:35:36 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 8127FFFEB974C for ; Tue, 15 Jan 2019 13:35:35 +0000 (UTC) Received: from mx1.de-vri.es (mx1.de-vri.es [IPv6:2a01:7c8:aab4:33e::4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS for ; Tue, 15 Jan 2019 13:35:35 +0000 (UTC) Received: from voyager (localhost [127.0.0.1]) by voyager (OpenSMTPD) with ESMTP id 945e1418; Tue, 15 Jan 2019 13:35:34 +0000 (UTC) Received: from gourmetset.internal.delftrobotics.com (217.67.224.105 [217.67.224.105]) by voyager (OpenSMTPD) with ESMTPSA id 82264210 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Tue, 15 Jan 2019 13:35:34 +0000 (UTC) To: arch-projects@archlinux.org Date: Tue, 15 Jan 2019 14:34:53 +0100 Message-Id: <20190115133450.9676-2-maarten@de-vri.es> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115133450.9676-1-maarten@de-vri.es> References: <20190115133450.9676-1-maarten@de-vri.es> MIME-Version: 1.0 Subject: [arch-projects] [devtools] [PATCH 2/2] makechrootpkg: Allow setting pacman cache for arch-nspawn. X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Maarten de Vries via arch-projects Reply-To: Arch Linux projects development discussion Cc: Maarten de Vries Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" Signed-off-by: Maarten de Vries --- makechrootpkg.in | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index d81be84..ad65de4 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -38,6 +38,7 @@ usage() { echo 'Flags:' echo '-h This help' echo '-c Clean the chroot before building' + echo '-C Use a folder on the host as pacman cache' echo '-d Bind directory into build chroot as read-write' echo '-D Bind directory into build chroot as read-only' echo '-u Update the working copy of the chroot before building' @@ -147,7 +148,7 @@ install_packages() { pkgnames=("${install_pkgs[@]##*/}") cp -- "${install_pkgs[@]}" "$copydir/root/" - arch-nspawn "$copydir" "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ + nspawn "$copydir" \ pacman -U --noconfirm -- "${pkgnames[@]/#//root/}" ret=$? rm -- "${pkgnames[@]/#/$copydir/root/}" @@ -301,6 +302,22 @@ move_products() { fi done } + +# Usage: nspawn $copydir $nspawn-args ... +# Globals: +# - pacman_cache +# - bindmounts_ro +# - bindmounts_rw +nspawn() { + local copydir=$1 + shift + + if [[ -n $pacman_cache ]]; then + arch-nspawn -c "$pacman_cache" "$copydir" "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" "$@" + else + arch-nspawn "$copydir" "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" "$@" + fi +} # }}} main() { @@ -317,6 +334,7 @@ main() { declare -a install_pkgs declare -i ret=0 + pacman_cache= bindmounts_ro=() bindmounts_rw=() @@ -325,9 +343,10 @@ main() { [[ -z "$copy" || $copy = root ]] && copy=copy src_owner=${SUDO_USER:-$USER} - while getopts 'hcur:I:l:nTD:d:U:' arg; do + while getopts 'hcur:I:l:nTC:D:d:U:' arg; do case "$arg" in c) clean_first=true ;; + C) pacman_cache="$OPTARG" ;; D) bindmounts_ro+=("--bind-ro=$OPTARG") ;; d) bindmounts_rw+=("--bind=$OPTARG") ;; u) update_first=true ;; @@ -395,8 +414,7 @@ main() { sync_chroot "$chrootdir/root" "$copydir" "$copy" fi - $update_first && arch-nspawn "$copydir" \ - "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ + $update_first && nspawn "$copydir" \ pacman -Syu --noconfirm if [[ -n ${install_pkgs[*]:-} ]]; then @@ -415,10 +433,9 @@ main() { prepare_chroot "$copydir" "$USER_HOME" "$keepbuilddir" "$run_namcap" - if arch-nspawn "$copydir" \ + if nspawn "$copydir" \ --bind="$PWD:/startdir" \ --bind="$SRCDEST:/srcdest" \ - "${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \ /chrootbuild "${makepkg_args[@]}" then move_products "$copydir" "$src_owner"