From patchwork Mon Jun 8 19:13:41 2020 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: 1683 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 C8729193FDDC7 for ; Mon, 8 Jun 2020 19:14:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1, MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01,SPF_HELO_NONE=0.001,T_DMARC_POLICY_NONE=0.01 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-BL-Results: [127.0.0.19] [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Mon, 8 Jun 2020 19:14:03 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 3B5991CA9C6C03; Mon, 8 Jun 2020 19:14:02 +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) (Authenticated sender: luna) by orion.archlinux.org (Postfix) with ESMTPSA id CC7E21CA9C6BFC; Mon, 8 Jun 2020 19:14:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1591643641; bh=gfVLS1fpI2XH61jHoNSPXq0fCF8pAWC7yzghUj6q9Z4=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc; b=R76H5VI+70it8XSmy2Ddwwmi9ppRzxTuJ/HWCKGzQHLP92X7oLOqUSbHBhGc4OPGS 9HGZbsToz8lA9LcfpNmfyNr4A6PsHs4yXjC8fRwcqkhl9K2IgQz+d6u2Q0WQWk3b4J U9/jPVYe9cquRq80Y9Zn7kKArBxmD78SiqpxTVMeMitzuyBS/G+icHhi7CE7upFpWC T2SAzGLgwOMMlQejfToC2Zm3DwQPKdXnoY8oo3kXtUpnJHurH03+0TmX+VCgf8TwTB w/9Eh1SEK0ooF3vfxhif0vyc/YbbCekCCVteZal5/n8MfY6P/iiIfDJhR4hyyNwtfx V4xldFp/prsl0bTKXwNKhONNBujeBJ+SiUNHV+d0JnDxSxYnGEQ6EEgCucCgJWde0k 58S+fNS9TWV9yCk2diLXpZiCqMmqQbf5QJc9+h6zLNpV+9YWR03rz+4fY2Fma6KXvA SIq1ZRB/fhsfboP62trJDOV2JdzjnvJGYs2l0OaihCGdBKiRkNrxKd6e6TFhwT6+oL 9YNRZMl4XIxF+hNLGKLP9X4YfHddjOpMtEPEyONg8TKjGkfSZ8prvETPYHimYzeGJe LKFpBrldkODa+rqrFbGJyMfxZFIRRXlYIYrCwArY2vwzxmF0I0dAUkt6cSgdSwwWQH CW+l+JgA2vYkBGbZU9/VXVxU= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id B70DC2B9E8; Mon, 8 Jun 2020 19:14:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1591643641; bh=gfVLS1fpI2XH61jHoNSPXq0fCF8pAWC7yzghUj6q9Z4=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc; b=BIl4Y4AnUSPxmpDwwM15TONZ+2FlEJMxWhnwNhLUhQphCXr5MRpOENr7jTPCHtpM4 37GwLWpuTLhhVO4JnwazlbGudJ5EpY2rpGCgqSXkysE5dhh92jgrezXtWOS22gYQ+I VF+P+CTjKMhOpAByLkd2CtMOsSTFAGktzBwSIVTNIiIsiyD1NuL4mRFA0uWW1A/AuW QQnZfv7jlQjtmdmUoeRLrI0mCeDoVR0xjyz7u30OAiDNMqyHsA3XWs7+BJs9wjauh0 7B0Rd0Rjszth700fFwaHYO2ek11mGaIvBPkUjSLP5Fh3iZM4PKrNpsN5ebk2i1heas pFLl1JGVghIivg6cXK4rkZbgyMhjWQjD0EGeR3gfyaVQfv5pLboGxS2wHZm/hDE1su F/LpAnSxb5CRRre08f/iilbAtDZHT6jSvu+OdT+a49ktGH6PO929VMv3QiIZ63vSH7 VOjG8dxurDWI6ZtVVYKY+TU4lZGa1ogJpK7IMbSROkkQ0qPTaWf7LRZW1zRnciobbI M7W7l7J4xivlMYcZgDlGURP1pVgjgHg/DuPZQaD2mLGMX1ntuu8rKM1FOgiQAeVTFl CS9mbl830zuSdB5iX8hlBBLw3QHEXAQCfkAJ0OJ5m52yxhfMVGi4dipHkZ8rggEYmC XTcgSrBvrSEaeD8fkzE3PvJM= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 536DB2B75F for ; Mon, 8 Jun 2020 19:13:59 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Mon, 8 Jun 2020 19:13:59 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 714331CA9C6BEE; Mon, 8 Jun 2020 19:13:54 +0000 (UTC) Received: from didactylos.attlocal.net (unknown [IPv6:2600:1700:57f0:ca20:763a:c795:fcf6:91ea]) (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 B30491CA9C6BEC; Mon, 8 Jun 2020 19:13:53 +0000 (UTC) To: arch-projects@archlinux.org Date: Mon, 8 Jun 2020 15:13:41 -0400 Message-Id: <20200608191341.2064852-1-eschwartz@archlinux.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [arch-projects] [devtools] [PATCH] makerepropkg: allow specifying the package in pacman -S format X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.33 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 Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" We now accept: 1) # nothing in which case we'll use the PKGBUILD to retrieve... 2) name, or repo/name in which case we'll use pacman to cache the package and retrieve... 3) a filename Signed-off-by: Eli Schwartz --- doc/makerepropkg.1.asciidoc | 11 +++++++- makerepropkg.in | 54 +++++++++++++++++++++++++++---------- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/doc/makerepropkg.1.asciidoc b/doc/makerepropkg.1.asciidoc index 0d7ddcb..e9f4c24 100644 --- a/doc/makerepropkg.1.asciidoc +++ b/doc/makerepropkg.1.asciidoc @@ -7,7 +7,7 @@ makerepropkg - Rebuild a package to see if it is reproducible Synopsis -------- -makerepropkg [OPTIONS] ... +makerepropkg [OPTIONS] [...] Description ----------- @@ -24,6 +24,15 @@ When given multiple packages, additional package files are assumed to be split packages and will be treated as additional artifacts to compare during the verification step. +A valid target(s) for pacman -S can be specified instead, and makerepropkg will +download it to the cache if needed. This is mostly useful to specify which +repository to retrieve from. If no positional arguments are specified, the +targets will be sourced from the PKGBUILD. + +In either case, the package name will be converted to a filename from the +cache, and makerepropkg will proceed as though this filename was initially +specified. + This implements a verifier for pacman/libalpm packages in accordance with the link:https://reproducible-builds.org/[Reproducible Builds] project. diff --git a/makerepropkg.in b/makerepropkg.in index c609ff6..051fe40 100755 --- a/makerepropkg.in +++ b/makerepropkg.in @@ -124,20 +124,46 @@ shift $((OPTIND - 1)) check_root -if [[ -n $1 ]]; then - pkgfile="$1" - splitpkgs=("$@") - for f in "${splitpkgs[@]}"; do - if ! bsdtar -tqf "${f}" .BUILDINFO >/dev/null 2>&1; then - error "file is not a valid pacman package: '%s'" "${f}" - exit 1 - fi - done -else - error "no package file specified. Try '${BASH_SOURCE[0]##*/} -h' for more information. " - exit 1 +[[ -f PKGBUILD ]] || { error "No PKGBUILD in current directory."; exit 1; } + +# without arguments, get list of packages from PKGBUILD +if [[ -z $1 ]]; then + mapfile -t pkgnames < <(source PKGBUILD; pacman -Sddp --print-format '%r/%n' "${pkgname[@]}") + wait $! || { + error "No package file specified and failed to retrieve package names from './PKGBUILD'." + plain "Try '${BASH_SOURCE[0]##*/} -h' for more information." >&2 + exit 1 + } + msg "Reproducing all pkgnames listed in ./PKGBUILD" + set -- "${pkgnames[@]}" fi +# check each package to see if it's a file, and if not, try to download it +# using pacman -Sw, and get the filename from there +splitpkgs=() +for p in "$@"; do + if [[ -f ${p} ]]; then + splitpkgs+=("${p}") + else + pkgfile_remote=$(pacman -Sddp "${p}" 2>/dev/null) || { error "package name '%s' not in repos" "${p}"; exit 1; } + pkgfile=${pkgfile_remote#file://} + if [[ ! -f ${pkgfile} ]]; then + msg "Downloading package '%s' into pacman's cache" "${pkgfile}" + sudo pacman -Swdd --noconfirm --logfile /dev/null "${p}" || exit 1 + pkgfile_remote=$(pacman -Sddp "${p}" 2>/dev/null) + pkgfile="${pkgfile_remote#file://}" + fi + splitpkgs+=("${pkgfile}") + fi +done + +for f in "${splitpkgs[@]}"; do + if ! bsdtar -tqf "${f}" .BUILDINFO >/dev/null 2>&1; then + error "file is not a valid pacman package: '%s'" "${f}" + exit 1 + fi +done + if (( ${#cache_dirs[@]} == 0 )); then mapfile -t cache_dirs < <(pacman-conf CacheDir) fi @@ -148,11 +174,11 @@ load_makepkg_config HOME=${ORIG_HOME} [[ -d ${SRCDEST} ]] || SRCDEST=${PWD} -parse_buildinfo < <(bsdtar -xOqf "${pkgfile}" .BUILDINFO) +parse_buildinfo < <(bsdtar -xOqf "${splitpkgs[0]}" .BUILDINFO) export SOURCE_DATE_EPOCH="${buildinfo[builddate]}" PACKAGER="${buildinfo[packager]}" BUILDDIR="${buildinfo[builddir]}" -PKGEXT=${pkgfile#${pkgfile%.pkg.tar*}} +PKGEXT=${splitpkgs[0]#${splitpkgs[0]%.pkg.tar*}} # nuke and restore reproducible testenv for copy in "${buildroot}"/*/; do