From patchwork Wed Apr 17 02:49:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Schwartz X-Patchwork-Id: 1081 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 5B92CD5C3275 for ; Wed, 17 Apr 2019 02:50:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on apollo X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00=-1, DKIMWL_WL_HIGH=-0.024,DKIM_SIGNED=0.1,DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3, T_DMARC_POLICY_NONE=0.01 autolearn=ham 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 ; Wed, 17 Apr 2019 02:50:15 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 8FBD511FBB75FD; Wed, 17 Apr 2019 02:50:11 +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; Wed, 17 Apr 2019 02:50:11 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 7BB7020F2C; Wed, 17 Apr 2019 02:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1555469411; bh=nb3F4kVHbkJrmtN5LCvYHvBvWtYYCemsPlR4/iEkra0=; h=From:To:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe; b=A6cUiSVVx0HKScoasi8cSSB1W2r73FtAGoEWQaoTKH/5w9jtfIvnm9GSS1ufNYbKX qpOW2rUxv2MMH82rhZUnMkHlGmPokIn9f30h9+SqKeZIFPK4Td4qlxZu52vJgAy9dC Y77kamMZKIFNfTGOhSbab5pfquk3Siu8A6ALQ5GjOeq8G+3KOUTmVzXC5tk+9zbgov ASDI9v/a/0h5SoD6tik/r1+9EhuasMoUbG5tgSQjpL5SQB2Cz7XJj6j+TmT2/koc+J aGDtFiYUpus7CLAjE7i2tddVazRXHBc8hehKimszahEUX0DDH0wmrdU9Sw6YOogw4+ 9NZWkLz8f3Qtlv+j1+wgy+zVKYdSSLZGVp5JqnNIGVES7+1E7G3Zk2tTqXDch9T8GN OCXhTs3npwo8LEicMDNLmK8tMnmMHbY2wdMTQdFYD20rRbN8Qabnn+gpBidXdBGKA/ LiX8IwHazZ+jTor4fJpgy3jqY0Xk2FFu4ob3WVlIqln8/2zPIpueY0RZMcKYcI5YJt 1z4XIdWHEOkAuOLFDrIcS85cSTtu6t296ktOo03X1DeF88gw7olLT6uMuRQBfDFNlU nv4lqFpFzxGLmEBvGyLlBp038hGAWW/M9jINoDJQpvDSmMwTEDG8IXTWJX/LLFhja+ gxty7gazjHK9EP/oLFKWJhyg= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 8348D20F32 for ; Wed, 17 Apr 2019 02:50:09 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Wed, 17 Apr 2019 02:50:09 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 3EF9811FBB75F3; Wed, 17 Apr 2019 02:50:04 +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 758DF11FBB75F2; Wed, 17 Apr 2019 02:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1555469404; bh=nb3F4kVHbkJrmtN5LCvYHvBvWtYYCemsPlR4/iEkra0=; h=From:To:Subject:Date; b=eRcbLmFhLE6wPtu/VQO4fiQzmiSMQBKB5f4BQbLNZzOfte+8yWK87w0GY7/MGlnyr l5MvSdJdj+zaMd71IAawV+nRwOONO9RhxDEkrtc0yLT0ZCZ5Xjz5qehxC3nLPnfA+N P5xtEeUx9vbmdPnJPsmiGP01vFCvlKzHE8JDZTiatIKXg/FZQjzE7Sk56vWW9E+Dyy nNd/xogzD1wdQhPB9rQG1xpvJI2DuKtAKway48p/ZYRU/9xcDoIoxW533E7Txh2WOF GEMqkBm9KN6iT5MKDrq1WTueCGmrHl7UpNvs33CsINh9C0R+PtlbmK65VSdd2VU8p+ l0HpkdhXbVaCwXufBAlMTMNYy3Mvg1VNIx+r+UINe0Ctx4Pl1skJRfDOy/iLSG00up Hcvxzoh/PxCoEESmqQIFFlr71FB9tJDEphsxK0jX1DUCtNHoL2L896hmF46ZqZDb66 iRoLt/5Kt5bYLCHnSkTmVcYcBiaVTDQcpkYGidYJkD3aPktvfXFWYoSOnO1IeOt15w l8SXRyfdBhUmpSS7RA5aQ8Ql1XqZffX1d82zzjt2Up8pWrDptw5t3MeEmaRq/vLMXl ZjEgypwX649rAVxOINHTUlwNMofgO49Vp/PwPQrEUfd2PEEEmPg0/sNeIQkAW7IwGO 2rLBvstyvk8h+bKR3ZthqDW4= From: Eli Schwartz To: pacman-contrib@lists.archlinux.org Subject: [pacman-contrib] [PATCH 1/2] updpkgsums: rely on makepkg's exported schema declaration for algo types Date: Tue, 16 Apr 2019 22:49:41 -0400 Message-Id: <20190417024942.19420-1-eschwartz@archlinux.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-BeenThere: pacman-contrib@lists.archlinux.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for pacman-contrib development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-contrib-bounces@lists.archlinux.org Sender: "pacman-contrib" Rather than heuristically match (md|sha)[[:digit:]]+sums or even .*sums, read makepkg's internal description of known hash algorithms, and use it to generate a search pattern. This ensures that we will always be in sync with the makepkg installed on the user's system. Fixes support for the newly added b2sums algorithm. Signed-off-by: Eli Schwartz --- This depends on pacman from git master, because schema.sh does not exist in pacman 5.1.x src/updpkgsums.sh.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/updpkgsums.sh.in b/src/updpkgsums.sh.in index 9c545ea..618f471 100644 --- a/src/updpkgsums.sh.in +++ b/src/updpkgsums.sh.in @@ -22,6 +22,11 @@ shopt -s extglob declare -r myname='updpkgsums' declare -r myver='@PACKAGE_VERSION@' +LIBRARY=${LIBRARY:-'@datarootdir@/makepkg'} + +# Import libmakepkg +source "$LIBRARY"/util/schema.sh + usage() { printf "%s v%s\n" "${myname}" "${myver}" echo @@ -92,9 +97,10 @@ export BUILDDIR=$(mktemp -d "${TMPDIR:-/tmp}/updpkgsums.XXXXXX") newbuildfile=$(mktemp "${TMPDIR:-/tmp}/updpkgsums.XXXXXX") trap "rm -rf '$BUILDDIR' '$newbuildfile'" EXIT +sumtypes=$(IFS='|'; echo "${known_hash_algos[*]}") newsums=$(makepkg -g -p "$buildfile" "${MAKEPKG_OPTS[@]}") || die 'Failed to generate new checksums' -awk -v newsums="$newsums" ' - /^[[:blank:]]*(md|sha)[[:digit:]]+sums(_[^=]+)?=/,/\)[[:blank:]]*(#.*)?$/ { +awk -v sumtypes="$sumtypes" -v newsums="$newsums" ' + $0 ~"^[[:blank:]]*(" sumtypes ")sums(_[^=]+)?=", $0 ~ "\)[[:blank:]]*(#.*)?$" { if (!w) { print newsums w++