From patchwork Thu May 25 19:25:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9749045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4CB9E60388 for ; Thu, 25 May 2017 19:27:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B9D5283BE for ; Thu, 25 May 2017 19:27:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30A45283C3; Thu, 25 May 2017 19:27:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE269283BF for ; Thu, 25 May 2017 19:27:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935957AbdEYT1o (ORCPT ); Thu, 25 May 2017 15:27:44 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35438 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033459AbdEYT06 (ORCPT ); Thu, 25 May 2017 15:26:58 -0400 Received: by mail-pf0-f196.google.com with SMTP id u26so41060257pfd.2 for ; Thu, 25 May 2017 12:26:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fUhdIhDUHbfrCnNFmZenz3JGrr4jYxNrz9zB3+GxGsE=; b=eXJ4MzKDjzmfJ9hkCtKMYEUVicU9utDnp315M18lIPaHH+akOdQ/PdA8iaEYsLqM0f 5CP9dB1CEm8rnKdhRTcwPJo0JsfLBqcxHLKh6SscvvDCYLWi/c3lDUume9PeEJtqMX3U r0F+eEUVTzOmZtJ5FpHyKXsX0736kBXQ5mNQMPM2f2RHk8fDBml2i1Ct0Np1r+oNcgs5 BrPPqc1c9a3vS/Mf5EfeLZ5WSS9kv80s29YbOqJkcewGMBe23QyzgDun9xwvfLTGqAaT 7l8pRKWj7++A9wZZOcJmvkmgwe/WXsP6/on/8XSlwX0Fgp0VsXduXkxuKitoT+hrVPz9 3IrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fUhdIhDUHbfrCnNFmZenz3JGrr4jYxNrz9zB3+GxGsE=; b=iPqu2ZC+Pf6oOfIp8TdKT/pfh+jAwoiKrTBZKoU9ljQBSU0QiRlq4AOCKPoCxMTpO5 ultrq1n/f/R01rGoISy/nW4Br4R6nb6Ju4l90HiEhVmQdC85QpHtQbhERWIKoBQMJOQA 4eG/Pn0G4btYB7yXHhTPkIgtWssZ7PYlTbPswXZuZYIzNnL0w47cgSwPKzE6vgCgpboP MCTw0PbrPSZ455fIOORsB0UST3IgVCrf/UgVvF9dgyHghuhMxcMArot46YYDH6Kvj2VT 3YxQSKX7ZJ1hmOODmMa4Sd5HFh4Bvo1yvgUA9lHx6UMPNXoBpUf2pO8MmGeFx0+KoT0k NsCg== X-Gm-Message-State: AODbwcBmOlVf/EfT9vD3OCvzTS1eOxZlUAxxSKZRwon6ZIVK3Do8TltF fQxcOqE7UzHiDg== X-Received: by 10.84.225.130 with SMTP id u2mr51580323plj.91.1495740417463; Thu, 25 May 2017 12:26:57 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.174.81]) by smtp.gmail.com with ESMTPSA id f86sm14617917pfj.128.2017.05.25.12.26.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 May 2017 12:26:56 -0700 (PDT) From: Eric Biggers To: Theodore Ts'o Cc: fstests@vger.kernel.org, Eric Biggers Subject: [PATCH 1/7] get-all: use helper function to clone repositories Date: Thu, 25 May 2017 12:25:43 -0700 Message-Id: <20170525192549.138518-2-ebiggers3@gmail.com> X-Mailer: git-send-email 2.13.0.219.gdb65acc882-goog In-Reply-To: <20170525192549.138518-1-ebiggers3@gmail.com> References: <20170525192549.138518-1-ebiggers3@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers Add a function which handles cloning a repository and optionally checking out a specific commit, then use it for all the repositories. Signed-off-by: Eric Biggers --- get-all | 119 ++++++++++++++++++++++------------------------------------------ 1 file changed, 40 insertions(+), 79 deletions(-) diff --git a/get-all b/get-all index fc4dc2d..67a54b4 100755 --- a/get-all +++ b/get-all @@ -6,88 +6,49 @@ else . config fi -if test ! -d xfsprogs-dev -then - if test -z "$XFSPROGS_GIT"; then - echo "XFSPROGS_GIT not set; check your config file!" - exit 1 - fi - if ! git clone $XFSPROGS_GIT xfsprogs-dev; then - echo "Failed to get xfsprogs-dev from $XFSPROGS_GIT" - exit 1 - fi - if test -n "$XFSPROGS_COMMIT"; then - cd xfsprogs-dev - git branch xfstests-bld $XFSPROGS_COMMIT - git checkout xfstests-bld - cd .. - fi -fi -if test ! -d xfstests-dev -then - if test -z "$XFSTESTS_GIT"; then - echo "XFSTESTS_GIT not set; check your config file!" - exit 1 - fi - if ! git clone $XFSTESTS_GIT xfstests-dev; then - echo "Failed to get xfstests-dev from $XFSTESTS_GIT" - exit 1 - fi - if test -n "$XFSTESTS_COMMIT"; then - cd xfstests-dev - git branch xfstests-bld $XFSTESTS_COMMIT - git checkout xfstests-bld - cd .. - fi -fi -if test ! -d fio -then - if test -z "$FIO_GIT"; then - echo "FIO_GIT not set; check your config file!" - exit 1 - fi - if ! git clone $FIO_GIT fio; then - echo "Failed to get fio from $FIO_GIT" - exit 1 - fi - if test -n "$FIO_COMMIT"; then - cd fio - git branch xfstests-bld $FIO_COMMIT - git checkout xfstests-bld - cd .. - fi -fi -if test ! -d quota -then - if test -z "$QUOTA_GIT"; then - echo "QUOTA_GIT not set; check your config file!" - exit 1 - fi - if ! git clone $QUOTA_GIT quota; then - echo "Failed to get quota from $QUOTA_GIT" - exit 1 - fi - if test -n "$QUOTA_COMMIT"; then - cd quota - git branch xfstests-bld $QUOTA_COMMIT - git checkout xfstests-bld - cd .. - fi -fi +setup_repo() +{ + local repo_name="$1" + local repo_url_variable="$2" + local repo_url="${!2}" + local commit_variable="$3" + local commit="${!3}" + local required="$4" -if test ! -d stress-ng -a -n "$STRESS_NG_GIT" -then - if ! git clone $STRESS_NG_GIT stress-ng; then - echo "Failed to get stress-ng from $STRESS_NG_GIT" - exit 1 + # Clone the repository if needed. + if [ ! -d "$repo_name" ]; then + if [ -z "$repo_url" ]; then + if ! $required; then + return + fi + echo 1>&2 "$repo_url_variable not set; check your config file!" + exit 1 fi - if test -n "$STRESS_NG_COMMIT"; then - cd stress-ng - git branch xfstests-bld $STRESS_NG_COMMIT - git checkout xfstests-bld - cd .. + + echo + if ! git clone "$repo_url" "$repo_name"; then + echo 1>&2 "Failed to clone $repo_name from $repo_url" + exit 1 fi -fi + + # If a specific commit was specified, check it out. + if [ -n "$commit" ]; then + ( cd "$repo_name"; + git branch xfstests-bld "$commit"; + git checkout xfstests-bld; + ) + fi + fi +} + +# required repositories +setup_repo fio FIO_GIT FIO_COMMIT true +setup_repo quota QUOTA_GIT QUOTA_COMMIT true +setup_repo xfsprogs-dev XFSPROGS_GIT XFSPROGS_COMMIT true +setup_repo xfstests-dev XFSTESTS_GIT XFSTESTS_COMMIT true + +# optional repositories +setup_repo stress-ng STRESS_NG_GIT STRESS_NG_COMMIT false # Make sure acl doesn't try regenerate these files because of the # vagrancies of the timestamps when they were checked out