From patchwork Thu Apr 11 02:21:46 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: 1065 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 41173D2D22D2 for ; Thu, 11 Apr 2019 02:22:26 +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.001,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.0.10] [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Thu, 11 Apr 2019 02:22:26 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 1A31F11E26B3FF; Thu, 11 Apr 2019 02:22:25 +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; Thu, 11 Apr 2019 02:22:25 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 97BFA2C5EE; Thu, 11 Apr 2019 02:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1554949343; bh=+miEvK4Kp/QR+gD1d/vx507HQ90f0zMeBOkqbdEhbxs=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc; b=tUam2OfTYJNCE31CDsCA4ldzzg9lajKaLIHvuJav+wnOQuArSo4M6ZWCCF64k3BVv dpwMc4jtH7ZbgM3peDAokh9MCvUMtTjvMSAqe+oYWuVGJhAD7JlotYxz5em+Td2JVJ Lpa6D6CkA3/llI2ROGPREh3MWDbAS+YKuNmzP4Xy4sOfj7wewkmsYFresLmyNA1w4z Y9T40r0ffS9fxV63IcBAR42BwjSU/Ilpo3rQ9Hm+5yMqBclFFbEo6HuRjmGdQ/iOfS yaucpQJLr2kk6B+JnTn4OH5tnAKKRzWr5VLA/KXMN7hUxnuagDf0BuSQgtL7AVCPif Jf3kl/fJdwbKdM+AQFCNI00NYV0WwbUJkoaySl6qhXvMDXekjOwjRDyVZRplvVbsIS wmHZeBJEZVBfJGjntA29lFr6tyqEEztdhzFfRp/0yjKXDGbdSA07vP4BJUg+iaVOZw WTJMM3wMePbdQePMDP3Whmxk6DIuiB6+Wqf/1nu37OMOa83QcTzV9xzCQUCHNFUt9J g7V2IAoD7hgctQhSQ+3t6ru7li5zAgTS2/gGfk91+63Of14F8xCs62JQ4544B0GDOl k2A7AX7qFVtl+eEABYa+83V3rE7uowwmoJToBgQMmTuy+HYTYUmMaNvG8EXdYsoQFp on/2FmVdeHC99ItDuZt8z/V8= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 9053B2C5C5 for ; Thu, 11 Apr 2019 02:22:18 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Thu, 11 Apr 2019 02:22:18 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 90A5811E26B3EA; Thu, 11 Apr 2019 02:22:11 +0000 (UTC) Received: from localhost.localdomain (ool-3f8fe1f1.dyn.optonline.net [63.143.225.241]) (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 0E19311E26B3E9; Thu, 11 Apr 2019 02:22:10 +0000 (UTC) To: arch-projects@archlinux.org Date: Wed, 10 Apr 2019 22:21:46 -0400 Message-Id: <20190411022147.28703-1-eschwartz@archlinux.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [arch-projects] [namcap] [PATCH 1/2] parsepkgbuild: reduce a lot of boilerplate by being more templated 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 Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" When listing out the contents of a variable, use loops and references to the variables in order to reduce code and make it easier to extend. In the future, a new metadata type can be added simply by appending to meta_keys=() Signed-off-by: Eli Schwartz --- parsepkgbuild.sh | 127 +++++------------------------------------------ 1 file changed, 12 insertions(+), 115 deletions(-) diff --git a/parsepkgbuild.sh b/parsepkgbuild.sh index d85574d..66cea40 100644 --- a/parsepkgbuild.sh +++ b/parsepkgbuild.sh @@ -18,123 +18,20 @@ fi if [ -n "$pkgdesc" ]; then echo -e "%DESC%\n$pkgdesc\n" fi -if [ -n "$groups" ]; then - echo "%GROUPS%" - for i in ${groups[@]}; do echo $i; done - echo "" -fi - -if [ -n "$url" ]; then - echo -e "%URL%\n$url\n" -fi -if [ -n "$license" ]; then - echo "%LICENSE%" - for i in ${license[@]}; do echo $i; done - echo "" -fi -if [ -n "$arch" ]; then - echo "%ARCH%" - for i in ${arch[@]}; do echo $i; done - echo "" -fi -if [ -n "$builddate" ]; then - echo -e "%BUILDDATE%\n$builddate\n" -fi -if [ -n "$packager" ]; then - echo -e "%PACKAGER%\n$packager\n" -fi - -if [ -n "$replaces" ]; then - echo "%REPLACES%" - for i in "${replaces[@]}"; do echo $i; done - echo "" -fi -if [ -n "$force" ]; then - echo -e "%FORCE%\n" -fi -# create depends entry -if [ -n "$depends" ]; then - echo "%DEPENDS%" - for i in "${depends[@]}"; do echo $i; done - echo "" -fi -if [ -n "$makedepends" ]; then - echo "%MAKEDEPENDS%" - for i in "${makedepends[@]}"; do echo $i; done - echo "" -fi -if [ -n "$optdepends" ]; then - echo "%OPTDEPENDS%" - for i in "${optdepends[@]}"; do echo $i; done - echo "" -fi -if [ -n "$conflicts" ]; then - echo "%CONFLICTS%" - for i in "${conflicts[@]}"; do echo $i; done - echo "" -fi -if [ -n "$provides" ]; then - echo "%PROVIDES%" - for i in "${provides[@]}"; do echo $i; done - echo "" -fi -if [ -n "$backup" ]; then - echo "%BACKUP%" - for i in "${backup[@]}"; do echo $i; done - echo "" -fi -if [ -n "$options" ]; then - echo "%OPTIONS%" - for i in "${options[@]}"; do echo $i; done - echo "" -fi -if [ -n "$source" ]; then - echo "%SOURCE%" - for i in "${source[@]}"; do echo $i; done - echo "" -fi -if [ -n "$validpgpkeys" ]; then - echo "%VALIDGPGKEYS%" - for i in "${validpgpkeys[@]}"; do echo $i; done - echo "" -fi -if [ -n "$md5sums" ]; then - echo "%MD5SUMS%" - for i in "${md5sums[@]}"; do echo $i; done - echo "" -fi -if [ -n "$sha1sums" ]; then - echo "%SHA1SUMS%" - for i in "${sha1sums[@]}"; do echo $i; done - echo "" -fi -if [ -n "$sha224sums" ]; then - echo "%SHA224SUMS%" - for i in "${sha224sums[@]}"; do echo $i; done - echo "" -fi -if [ -n "$sha256sums" ]; then - echo "%SHA256SUMS%" - for i in "${sha256sums[@]}"; do echo $i; done - echo "" -fi -if [ -n "$sha384sums" ]; then - echo "%SHA384SUMS%" - for i in "${sha384sums[@]}"; do echo $i; done - echo "" -fi -if [ -n "$sha512sums" ]; then - echo "%SHA512SUMS%" - for i in "${sha512sums[@]}"; do echo $i; done - echo "" -fi - -if [ -n "$install" ]; then - echo -e "%INSTALL%\n$install\n" -fi +meta_keys=(groups url license arch builddate packager replaces force depends + makedepends optdepends conflicts provides backup options source + validpgpkeys {md5,sha{1,224,256,384,512}}sums install) +for key in "${meta_keys[@]}"; do + arr="$key[@]" + if [[ -n ${!key} ]]; then + echo "%${key^^}%" + for i in "${!arr}"; do echo "$i"; done + echo "" + fi +done -unset i +unset arr key meta_keys i echo "%SETVARS%" compgen -A variable } From patchwork Thu Apr 11 02:21:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 1066 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 47A70D2D22CE for ; Thu, 11 Apr 2019 02:22:24 +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.001,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.0.10] [127.0.9.2] Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Thu, 11 Apr 2019 02:22:24 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id A9D8611E26B3F3; Thu, 11 Apr 2019 02:22:22 +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; Thu, 11 Apr 2019 02:22:22 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 6D8EE2C5E0; Thu, 11 Apr 2019 02:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1554949342; bh=aj/KBd/8TMT595+PuXdyrfb5ij8h7at1VW6UV2SC2Y0=; 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=HHChge83T8MpLsFfb4obSlyZEtIrSDUbfjTGTVAVyeYEJf5o7X/M6EFilXby1hSYM XEFJAKGvibdw0wALymKZg5zdQoW5duiHbfvBWVkMzUqDa7Y25ZxUFsgE8sIJ6LxjkR pkcxPuUDxpT51ESia5aYl8Vv+HB1BcfeZ/JxjF+ZSvlicDTJPezanme4TdZ1QaS9n2 jTqqcOQfhp2RVdTOS8hdSmkSqahhcN9+BLulO/vqKR2RMVNX3E2X/0GWI7M7p3aVIj nV8/APqqVSzNoUY3CvlYhrqJNi2gYHRYT/nN9mqsGnp6xXtmYjkuCXDmF65Oc0qdG7 Wf5d4eonqAaZnfGBUVNgf0nuuHisG2IdljczeguUXmr19+SGWct/bbRVH3lUu0W5TZ K7rMyYF+b0dqOowFq47b5KxIDblVJuDG0LBbVrOKFnLZwyQPpubI1QcjmhTQe4esRs eEP9xfGz+tx9RkzFoEorgjNRN8n0UAtXFDb3WLaFsj3nNoeIp3viSWtiAqmKp8m0Lw B0u2M+qrylCARZ5J8tl66VXGl90F4h8hzygQyB3L32QCAFpHxqmkJHiKASUCVvrNVC BbGuu96L+GqCcF63AN4Yz2ZDYLvucqnFQaVCBcH57n1Fwu0zc8lXKdDWGMCTsKB00D EX1tsbH0hf3a8uCJVPWTvGF8= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id D85DC2C5E0 for ; Thu, 11 Apr 2019 02:22:18 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by luna.archlinux.org (Postfix) with ESMTPS for ; Thu, 11 Apr 2019 02:22:18 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 4B83511E26B3EC; Thu, 11 Apr 2019 02:22:12 +0000 (UTC) Received: from localhost.localdomain (ool-3f8fe1f1.dyn.optonline.net [63.143.225.241]) (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 B211011E26B3EB; Thu, 11 Apr 2019 02:22:11 +0000 (UTC) To: arch-projects@archlinux.org Date: Wed, 10 Apr 2019 22:21:47 -0400 Message-Id: <20190411022147.28703-2-eschwartz@archlinux.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190411022147.28703-1-eschwartz@archlinux.org> References: <20190411022147.28703-1-eschwartz@archlinux.org> MIME-Version: 1.0 Subject: [arch-projects] [namcap] [PATCH 2/2] add support for new checksum algorithm in pacman-git 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 Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" It is now possible to use b2sums to verify file integrity. See https://git.archlinux.org/pacman.git/commit/?id=e03752e6adc86cbb4cb4f52a38f6e3e98cbe9dd5 Signed-off-by: Eli Schwartz --- Namcap/rules/arrays.py | 9 +++++---- Namcap/rules/extravars.py | 9 +++++---- Namcap/rules/missingvars.py | 6 +++--- parsepkgbuild.sh | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Namcap/rules/arrays.py b/Namcap/rules/arrays.py index 5ca33cc..f841ca1 100644 --- a/Namcap/rules/arrays.py +++ b/Namcap/rules/arrays.py @@ -1,7 +1,7 @@ -# +# # namcap rules - array # Copyright (C) 2003-2009 Jesse Young -# +# # 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 @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# """Verifies that array variables are actually arrays""" @@ -29,7 +29,8 @@ class package(PkgbuildRule): arrayvars = ['arch', 'license', 'groups', 'depends', 'makedepends', 'optdepends', 'checkdepends', 'provides', 'conflicts', 'replaces', 'backup', 'options', 'source', 'noextract', 'md5sums', 'sha1sums', - 'sha224sums', 'sha256sums', 'sha384sums', 'sha512sums', 'validpgpkeys'] + 'sha224sums', 'sha256sums', 'sha384sums', 'sha512sums', 'b2sums', + 'validpgpkeys'] for i in pkginfo.pkgbuild: m = re.match('\s*(.*)\s*=\s*(.*)$', i) for j in arrayvars: diff --git a/Namcap/rules/extravars.py b/Namcap/rules/extravars.py index 81084f8..bea575a 100644 --- a/Namcap/rules/extravars.py +++ b/Namcap/rules/extravars.py @@ -1,7 +1,7 @@ -# +# # namcap rules - extravars # Copyright (C) 2003-2009 Jesse Young -# +# # 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 @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# from itertools import product from Namcap.ruleclass import * @@ -26,7 +26,8 @@ class package(PkgbuildRule): def analyze(self, pkginfo, tar): carch_vars = ['checkdepends', 'conflicts', 'depends', 'makedepends', 'optdepends', 'provides', 'replaces', 'source', 'md5sums', - 'sha224sums', 'sha1sums', 'sha256sums', 'sha384sums', 'sha512sums'] + 'sha224sums', 'sha1sums', 'sha256sums', 'sha384sums', + 'sha512sums', 'b2sums'] stdvars = ['arch', 'license', 'backup', 'noextract', 'pkgname', 'pkgbase', 'pkgver', 'pkgrel', 'epoch', 'pkgdesc', 'groups', 'url', 'install', 'changelog', diff --git a/Namcap/rules/missingvars.py b/Namcap/rules/missingvars.py index 25445e2..5814037 100644 --- a/Namcap/rules/missingvars.py +++ b/Namcap/rules/missingvars.py @@ -3,7 +3,7 @@ # namcap rules - missingvars # Copyright (C) 2003-2009 Jason Chu # Copyright (C) 2011 Rémy Oudompheng -# +# # 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 @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# """Checks for missing variables in PKGBUILD""" @@ -30,7 +30,7 @@ class ChecksumsRule(PkgbuildRule): name = "checksums" description = "Verifies checksums are included in a PKGBUILD" def analyze(self, pkginfo, tar): - checksums=[('md5', 32), ('sha1', 40), ('sha224', 56), ('sha256', 64), ('sha384', 96), ('sha512', 128)] + checksums=[('md5', 32), ('sha1', 40), ('sha224', 56), ('sha256', 64), ('sha384', 96), ('sha512', 128), ('b2', 128)] if "source" in pkginfo: haschecksums = False diff --git a/parsepkgbuild.sh b/parsepkgbuild.sh index 66cea40..4ac996a 100644 --- a/parsepkgbuild.sh +++ b/parsepkgbuild.sh @@ -21,7 +21,7 @@ fi meta_keys=(groups url license arch builddate packager replaces force depends makedepends optdepends conflicts provides backup options source - validpgpkeys {md5,sha{1,224,256,384,512}}sums install) + validpgpkeys {md5,sha{1,224,256,384,512},b2}sums install) for key in "${meta_keys[@]}"; do arr="$key[@]" if [[ -n ${!key} ]]; then