From patchwork Tue Jun 4 16:11:19 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: 1138 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 12C97F4121DA for ; Tue, 4 Jun 2019 16:11:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED=0.1, DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,SPF_HELO_NONE=0.001,T_DKIMWL_WL_HIGH=-0.01, T_DMARC_POLICY_NONE=0.01 autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-BL-Results: [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Tue, 4 Jun 2019 16:11:41 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 143AF1314808FD; Tue, 4 Jun 2019 16:11:39 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (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, 4 Jun 2019 16:11:39 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 03AC02C567; Tue, 4 Jun 2019 16:11:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1559664699; bh=zOdFIiG8+nwo7gKkCU8la4DU23rFu20OTGq8m1gIXI8=; 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=OJHUySG+GwNOcYvxgL08aYKi0b0v+BTDFdYCbRDa+9h5pVTq83KFhVG2T9VQdBGWo yW6w4EAgxA2W2iP42SkEBZWuQIC8St9I6m0uRBKiXB0uYW4o0j6B2g6esO6a2edCxx /ncvy1Fi0QIee6UoJqpDeb4VEMooCscD07QNGpDhLTe7H5ERGj0Hv33wCwnvPQIpvl 1WZRz8lJacosCbrZ/gIppS/BNm5RbNBUVGC/gY6pZGLDoVUjMEgiPykb3mhSQQsYC8 5MRwxenFqHTSpltorGu8zhQPjxjst63UZNRsu4JsFLLeOlGCHky6e0j7oICLysdvht OBjJmBTfvp6Q7mPvFNLXf4mZrV+R97Dwa6dot/8cUN9mw0iDX3JvFPFgElI5hKSkRx V8bshhqVc/j0iy57g1GgBGj0UUJneUJYJh+IeLfEkWQODyvFCLNsBisOEtGYwThZKK nczRo8B6LPk44/VmhlT5ZlW7kzbiFw4cIDOgxyj8gNUBJS5btdwMTJabe/vyJKjqfo mKin1RnZ5RyfBn7CC5ZiPOJBEsvOcghPe9z5qXJADYVukVIRw3yZ2C7hIbzGc/qsH5 zJJoncpsbVZfeRKbmkpZKq7pkI9e3iTgSnDO6FAs7JJvYqS1qnJn0UmOomQpSZv+KV P5AxmC7aSI3nVe2YOCTMFpEM= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id A0B162C53E for ; Tue, 4 Jun 2019 16:11:34 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Tue, 4 Jun 2019 16:11:34 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 722B81314808F1; Tue, 4 Jun 2019 16:11:31 +0000 (UTC) Received: from didactylos.localdomain (unknown [216.97.144.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: eschwartz) by orion.archlinux.org (Postfix) with ESMTPSA id B78701314808F0; Tue, 4 Jun 2019 16:11:30 +0000 (UTC) To: arch-projects@archlinux.org Date: Tue, 4 Jun 2019 12:11:19 -0400 Message-Id: <20190604161120.4180-1-eschwartz@archlinux.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418011506.4350-1-eschwartz@archlinux.org> References: <20190418011506.4350-1-eschwartz@archlinux.org> MIME-Version: 1.0 Subject: [arch-projects] [devtools] [PATCH v3 1/2] Add new tool: offload-build 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: Eli Schwartz via arch-projects Reply-To: Arch Linux projects development discussion Cc: Eli Schwartz , svenstaro@gmail.com Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" This tool is useful for running makechrootpkg on a remote build server, and is by default hooked up to send a PKGBUILD and initiate a build on our shiny new build server "dragon". Signed-off-by: Eli Schwartz --- v3: Add passthrough of archbuild options as requested by anthraxx. Makefile | 1 + offload-build | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100755 offload-build diff --git a/Makefile b/Makefile index ba2d3e4..2306a17 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ IN_PROGS = \ BINPROGS = \ $(IN_PROGS) \ + offload-build \ sogrep CONFIGFILES = \ diff --git a/offload-build b/offload-build new file mode 100755 index 0000000..101a146 --- /dev/null +++ b/offload-build @@ -0,0 +1,107 @@ +#!/bin/bash +# +# offload-build - build a PKGBUILD on a remote server using makechrootpkg. +# +# Copyright (c) 2019 by Eli Schwartz +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# global defaults suitable for use by Arch staff +repo=extra +arch=x86_64 +server=dragon.archlinux.org + +die() { printf "error: $1\n" "${@:2}"; exit 1; } + +usage() { + cat <<- _EOF_ + Usage: ${BASH_SOURCE[0]##*/} [--repo REPO] [--arch ARCHITECTURE] [--server SERVER] -- [ARCHBUILD_ARGS] + + Build a PKGBUILD on a remote server using makechrootpkg. Requires a remote user + that can run archbuild without password auth. Options passed after a -- are + passed on to archbuild, and eventually to makechrootpkg. + + OPTIONS + -r, --repo Build against a specific repository (current: $repo) + -a, --arch Build against a specific architecture (current: $arch) + -s, --server Offload to a specific build server (current: $server) + -h, --help Show this help text +_EOF_ +} + +# option checking +while (( $# )); do + case $1 in + -h|--help) + usage + exit 0 + ;; + -r|--repo) + repo=$2 + shift 2 + ;; + -a|--arch) + arch=$2 + shift 2 + ;; + -s|--server) + server=$2 + shift 2 + ;; + --) + shift + break + ;; + *) + die "invalid argument: %s" "$1" + ;; + esac +done + +# multilib must be handled specially +if [[ $repo = multilib* ]]; then + arch= +fi + +archbuild_cmd=("${repo}${arch:+-$arch}-build" "$@") + +trap 'rm -rf $SRCPKGDEST' EXIT + +# Use a source-only tarball as an intermediate to transfer files. This +# guarantees the checksums are okay, and guarantees that all needed files are +# transferred, including local sources, install scripts, and changelogs. +export SRCPKGDEST=$(mktemp -d) +makepkg --source || die "unable to make source package" + +mapfile -t files < <( + # This is sort of bash golfing but it allows running a mildly complex + # command over ssh with a single connection. + cat "$SRCPKGDEST"/*.src.tar.gz | + ssh $server ' + temp="${XDG_CACHE_HOME:-$HOME/.cache}/offload-build" && + mkdir -p "$temp" && + temp=$(mktemp -d -p "$temp") && + cd "$temp" && + { + bsdtar --strip-components 1 -xvf - && + script -qefc "'"${archbuild_cmd[@]@Q}"'" /dev/null && + printf "%s\n" "" "-> build complete" && + printf "\t%s\n" "$temp"/* + } >&2 && + makepkg --packagelist +') + +(( ${#files[@]} )) && printf '%s\n' '' '-> copying files...' && scp "${files[@]/#/$server:}" .