From patchwork Mon Feb 19 20:11:43 2018 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: 416 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 667FC21FD229 for ; Mon, 19 Feb 2018 20:11:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIM_SIGNED=0.1, DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,RCVD_IN_DNSWL_MED=-2.3 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-BL-Results: [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 ; Mon, 19 Feb 2018 20:11:36 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id C42038D0ED3B6; Mon, 19 Feb 2018 20:11:27 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Mon, 19 Feb 2018 20:11:24 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 8D0A82D90A; Mon, 19 Feb 2018 20:11:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1519071080; bh=JYMb7Oy+IMiKDdvvdTB23DRUk5QHTgYujqaF9Z47prk=; 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=eRI1lj4eXrOFxGkB/mnJXHO++RLcI29H3my7VrVnjxtvnHKzXPQ9R9O+Jiuwdqw+M iXwKLbLcugAf98j4qCbd5ffq/V7SNLkTwA9L5sU3IHwYOYUnKnXQp2ILwfNjR1lqru DI5DoSigSW5mZ7c7d5csfJANBBlwVYMP0+h/pFlvg6plwK+X13rHoO7HZUdMDc78td uW9s1YjRFI52tQtVNAjWPk3ME+6wyhwTGbxhwuvZVsXiFUdNl6x+zGz4mtJ13NsErd /n2Ybmpf4Ea4uJ8F1jVPM0ab4asl36mmus6hCZdxkws14Surm4JxZggPZRCObDZXxf 4uHT3QiRYrh8j7b54xOBdlaVAxZuR2wISuqFtwghuJkDIqmGrykZfVb40CvbjL/JsD lScSc+1AyiCUykrbQl2vy256YlpTWwjBZc6ADlif/83Nla6uz5JScfmjJ/ILCkKtfl cCKeuhj5alE8p3eO9SpLBuBckJNkz8deUP0XmjC3sQTfxBNIQmZLoYCqZQtSNFn//1 oHHCmewJxkK7ZGeOUU5qbNbigokM56SYPlK3honVjIda4C2atjMliy3ymCsiipcCHU TqGq97nViMP3dYfO5N/PhCplFNWklusB7xas2lSp3fegO4GBHUL0o+BatvY5xoY312 9cw7c4LKSwKhzzmdyLlbvjfg= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 6A5EA2D4C0 for ; Mon, 19 Feb 2018 20:11: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 ; Mon, 19 Feb 2018 20:11:18 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id B9FC88D0ED38A; Mon, 19 Feb 2018 20:11:07 +0000 (UTC) Received: from didactylos.localdomain (unknown [216.97.144.179]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) (Authenticated sender: eschwartz) by orion.archlinux.org (Postfix) with ESMTPSA id 442268D0ED389; Mon, 19 Feb 2018 20:11:07 +0000 (UTC) To: arch-projects@archlinux.org Date: Mon, 19 Feb 2018 15:11:43 -0500 Message-Id: <20180219201145.14057-4-eschwartz@archlinux.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180219201145.14057-1-eschwartz@archlinux.org> References: <20180216034504.27610-1-eschwartz@archlinux.org> <20180219201145.14057-1-eschwartz@archlinux.org> Subject: [arch-projects] [dbscripts] [PATCH v2 3/5] db-update: replace external find command with bash globbing X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.26 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" Don't bother emitting errors. bash doesn't show globbing errors if it cannot read a directory to try globbing there. And the former code never aborted on errors anyway, as without `set -o pipefail` the sort command swallowed the return code. Signed-off-by: Eli Schwartz --- v2: use mapfile as suggested by Luke, rather than running in_array in a loop. db-functions | 4 ++++ db-update | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/db-functions b/db-functions index e8eb2bc..394c7a2 100644 --- a/db-functions +++ b/db-functions @@ -2,6 +2,10 @@ . /usr/share/makepkg/util.sh +# global shell options for enhanced bash scripting +shopt -s globstar nullglob + + # Some PKGBUILDs need CARCH to be set CARCH="x86_64" diff --git a/db-update b/db-update index a8d885a..db12df8 100755 --- a/db-update +++ b/db-update @@ -9,9 +9,14 @@ if (( $# >= 1 )); then fi # Find repos with packages to release -if ! staging_repos=($(find "${STAGING}" -mindepth 1 -type f -name "*${PKGEXTS}" -printf '%h\n' | sort -u)); then - die "Could not read %s" "$STAGING" -fi +mapfile -t -d '' staging_repos < <( + for f in "${STAGING}"/**/*${PKGEXTS}; do + f="${f%/*}" + if [[ -d $f ]]; then + printf '%s\0' "$f" + fi + done | sort -uz +) repos=() for staging_repo in ${staging_repos[@]##*/}; do