From patchwork Fri May 5 22:41:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luke Shumaker X-Patchwork-Id: 167 Return-Path: Delivered-To: patchwork@archlinux.org Received: from nymeria.archlinux.org by nymeria.archlinux.org (Dovecot) with LMTP id eSnyEbX/DFkdHwAAtiB/HQ for ; Sat, 06 May 2017 00:41:57 +0200 Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 4A3B540660; Sat, 6 May 2017 00:41:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on nymeria.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.5 tests=BAYES_00,RCVD_IN_DNSWL_MED shortcircuit=no autolearn=unavailable autolearn_force=no version=3.4.1 Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS; Sat, 6 May 2017 00:41:56 +0200 (CEST) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 63C772C091; Fri, 5 May 2017 22:41:23 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=none Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 2F4022C08E for ; Fri, 5 May 2017 22:41:21 +0000 (UTC) Received: from nymeria.archlinux.org (nymeria.archlinux.org [IPv6:2a00:1828:2000:547::2]) by luna.archlinux.org (Postfix) with ESMTPS for ; Fri, 5 May 2017 22:41:21 +0000 (UTC) Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id D613040484 for ; Sat, 6 May 2017 00:41:18 +0200 (CEST) Received: from mav.lukeshu.com (mav.lukeshu.com [104.207.138.63]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS for ; Sat, 6 May 2017 00:41:17 +0200 (CEST) Received: from build64-par (unknown [IPv6:2601:803:202:9275:21f:e2ff:fe4d:191b]) by mav.lukeshu.com (Postfix) with ESMTPSA id 9F69783CF4 for ; Fri, 5 May 2017 18:41:15 -0400 (EDT) From: Luke Shumaker To: arch-projects@archlinux.org Date: Fri, 5 May 2017 18:41:09 -0400 Message-Id: <20170505224110.28990-13-lukeshu@parabola.nu> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170505224110.28990-1-lukeshu@parabola.nu> References: <20170505224110.28990-1-lukeshu@parabola.nu> Subject: [arch-projects] [devtools][PATCH 12/13] Make slightly more involved changes to make shellcheck happy. X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Arch Linux projects development discussion Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" X-UID: 385 Status: X-Keywords: Content-Length: 5052 - Use `read -r` instead of other forms of read or looping - Use arrays instead of strings with whitespaces. - In one instance, use ${var%%.*} instead of $(echo $var|cut -f. -d1) --- archrelease.in | 4 ++-- commitpkg.in | 4 ++-- find-libdeps.in | 2 +- finddeps.in | 2 +- lddd.in | 4 ++-- lib/common.sh | 15 +++++++++------ rebuildpkgs.in | 6 +++--- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/archrelease.in b/archrelease.in index 2ba9d48..6b4f1be 100644 --- a/archrelease.in +++ b/archrelease.in @@ -38,7 +38,7 @@ trunk=${PWD##*/} # Normally this should be trunk, but it may be something # such as 'gnome-unstable' IFS='/' read -r -d '' -a parts <<< "$PWD" -if [[ "${parts[@]:(-2):1}" == "repos" ]]; then +if [[ "${parts[*]:(-2):1}" == "repos" ]]; then die 'archrelease: Should not be in repos dir (try from trunk/)' fi unset parts @@ -67,7 +67,7 @@ for tag in "$@"; do while read -r file; do trash+=("repos/$tag/$file") done < <(svn ls "repos/$tag") - [[ $trash ]] && svn rm -q "${trash[@]/%/@}" + [[ ${#trash[@]} == 0 ]] || svn rm -q "${trash[@]/%/@}" else mkdir -p "repos/$tag" svn add --parents -q "repos/$tag" diff --git a/commitpkg.in b/commitpkg.in index 0482170..90210e5 100644 --- a/commitpkg.in +++ b/commitpkg.in @@ -148,9 +148,9 @@ for _arch in "${arch[@]}"; do if [[ ! -f $sigfile ]]; then msg "Signing package %s..." "${pkgfile}" if [[ -n $GPGKEY ]]; then - SIGNWITHKEY="-u ${GPGKEY}" + SIGNWITHKEY=(-u "${GPGKEY}") fi - gpg --detach-sign --use-agent --no-armor ${SIGNWITHKEY} "${pkgfile}" || die + gpg --detach-sign --use-agent --no-armor "${SIGNWITHKEY[@]}" "${pkgfile}" || die fi if ! gpg --verify "$sigfile" >/dev/null 2>&1; then die "Signature %s.sig is incorrect!" "$pkgfile" diff --git a/find-libdeps.in b/find-libdeps.in index 04adebf..1fb1fdf 100644 --- a/find-libdeps.in +++ b/find-libdeps.in @@ -60,7 +60,7 @@ case $script_mode in provides) find_args=(-name '*.so*');; esac -find . -type f "${find_args[@]}" | while read filename; do +find . -type f "${find_args[@]}" | while read -r filename; do if [[ $script_mode = "provides" ]]; then # ignore if we don't have a shared object if ! LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then diff --git a/finddeps.in b/finddeps.in index c71f151..80774bb 100644 --- a/finddeps.in +++ b/finddeps.in @@ -17,7 +17,7 @@ if [[ -z $match ]]; then exit 1 fi -find . -type d | while read d; do +find . -type d | while read -r d; do if [[ -f "$d/PKGBUILD" ]]; then pkgname=() depends=() makedepends=() optdepends=() . "$d/PKGBUILD" diff --git a/lddd.in b/lddd.in index d83c3e6..908923b 100644 --- a/lddd.in +++ b/lddd.in @@ -40,9 +40,9 @@ for tree in $PATH $libdirs $extras; do done grep '^/' "$TEMPDIR/raw.txt" | sed -e 's/://g' >> "$TEMPDIR/affected-files.txt" # invoke pacman -for i in $(cat $TEMPDIR/affected-files.txt); do +while read -r i; do pacman -Qo "$i" | awk '{print $4,$5}' >> "$TEMPDIR/pacman.txt" -done +done < "$TEMPDIR/affected-files.txt" # clean list sort -u "$TEMPDIR/pacman.txt" >> "$TEMPDIR/possible-rebuilds.txt" diff --git a/lib/common.sh b/lib/common.sh index 4a15d9a..ad6194d 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -123,24 +123,27 @@ in_array() { ## get_full_version() { # set defaults if they weren't specified in buildfile - pkgbase=${pkgbase:-${pkgname[0]}} - epoch=${epoch:-0} + local pkgbase=${pkgbase:-${pkgname[0]}} + local epoch=${epoch:-0} + local pkgver=${pkgver} + local pkgrel=${pkgrel} if [[ -z $1 ]]; then if (( ! epoch )); then - echo $pkgver-$pkgrel + printf '%s\n' "$pkgver-$pkgrel" else - echo $epoch:$pkgver-$pkgrel + printf '%s\n' "$epoch:$pkgver-$pkgrel" fi else + local pkgver_override='' pkgrel_override='' epoch_override='' for i in pkgver pkgrel epoch; do local indirect="${i}_override" eval "$(declare -f "package_$1" | sed -n "s/\(^[[:space:]]*$i=\)/${i}_override=/p")" [[ -z ${!indirect} ]] && eval ${indirect}=\"${!i}\" done if (( ! epoch_override )); then - echo $pkgver_override-$pkgrel_override + printf '%s\n' "$pkgver_override-$pkgrel_override" else - echo $epoch_override:$pkgver_override-$pkgrel_override + printf '%s\n' "$epoch_override:$pkgver_override-$pkgrel_override" fi fi } diff --git a/rebuildpkgs.in b/rebuildpkgs.in index be3fd33..a0e8250 100644 --- a/rebuildpkgs.in +++ b/rebuildpkgs.in @@ -40,7 +40,7 @@ bump_pkgrel() { oldrel=$(grep 'pkgrel=' $pbuild | cut -d= -f2) #remove decimals - rel=$(echo $oldrel | cut -d. -f1) + rel=${oldrel%%.*} newrel=$((rel + 1)) @@ -54,7 +54,7 @@ pkg_from_pkgbuild() { } chrootdir="$1"; shift -pkgs="$@" +pkgs=("$@") SVNPATH='svn+ssh://repos.archlinux.org/srv/repos/svn-packages/svn' @@ -67,7 +67,7 @@ cd "$REBUILD_ROOT" /usr/bin/svn co -N $SVNPATH FAILED="" -for pkg in $pkgs; do +for pkg in "${pkgs[@]}"; do cd "$REBUILD_ROOT/svn-packages" msg2 "Building '%s'" "$pkg"