From patchwork Tue Feb 19 10:38:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas De Schampheleire X-Patchwork-Id: 1044611 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fsmv0r6Y"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 443cfY3J8Fz9s21 for ; Tue, 19 Feb 2019 21:39:01 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2A46F85CE1; Tue, 19 Feb 2019 10:38:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zik0kPYH4gws; Tue, 19 Feb 2019 10:38:54 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id C362C85D57; Tue, 19 Feb 2019 10:38:54 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 144C61BF283 for ; Tue, 19 Feb 2019 10:38:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 0F18F85CDC for ; Tue, 19 Feb 2019 10:38:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id isQosvR2wQY2 for ; Tue, 19 Feb 2019 10:38:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) by whitealder.osuosl.org (Postfix) with ESMTPS id BED5085D21 for ; Tue, 19 Feb 2019 10:38:51 +0000 (UTC) Received: by mail-ot1-f46.google.com with SMTP id b3so33350889otp.4 for ; Tue, 19 Feb 2019 02:38:51 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=wf1p9MUFfv7Gaz495RXsKwV19Au9dnSKFRHcBr8KC88=; b=fsmv0r6Ykz25tCj6KjgBbahZQRBtEJM1Az0o7CLjN+DI/a0FRZa/19V7ANSkQMU2Db EbH/Yo/EHN6BK7O67mRRTiscMfxaH97uT72GHv4ddF/QB6c9zJDcefSLHd7Kokp7NKw2 uOOUCQ501weLrFIUoJxu1KE/73T9JDlRn7hUO1ef+aRn3il2cbt/6voF5U87eWCPYJaL n90QDcyBosdipfFRk7InXlJzO66XMBgCTFDcvM0VfBa+fRabJZwH7qI3ReZeNoQ6bb2w 1RlwbSOpRiILVoBZX45xukIy/yi53rjQpVA9KKHrQB8P2TMSVJmiiZXDa1l/asZ2VO5O 11Xg== 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:mime-version:content-transfer-encoding; bh=wf1p9MUFfv7Gaz495RXsKwV19Au9dnSKFRHcBr8KC88=; b=MdKVdtUU9c5j189j2KtiY+hmuq9Dlt2M03wgTv8ZM8BvJEYzRSHN1XdsEgPLX+ynzJ MIGCmqomCAxzLJSNbWC8cPqaSubxKsI9TnEa6lDgXzk2OyohitIjFaThTt3GRqQXF2CP wAlA3VOPGmiPHIH6T9Ywvapg4S1PcWXnpIwaeE0+FgydxJw3zEdSXCYNH2r2VbaJhHvI cg51bQiIGiaZPXnF5BIoB83bZ6DwLjxNLHEFw+zWKb151eXr4VrrI+fU8OcII9SUT1sr IN8PiBQ0O3PE92lZqSxBPkSAuP4kMKiO8TWxIfInh1VaKYStW43bULaRRrpXSWx0SqNI IEuA== X-Gm-Message-State: AHQUAuaUOlQqDn7FAGZHYZ18DtvkB2qcUvHG3JwdMiLj+inibou7mwUY 3QGmuUzmKofH0ECFKy75IDQg36yNRoI= X-Google-Smtp-Source: AHgI3IZQxwImpGVrjLZ2nxN9i3piS5yiD4xfdQFgcTkM4/LvdTg0nm4icEBobQHM0HAHtkJXPdMF9Q== X-Received: by 2002:aca:af83:: with SMTP id y125mr2105163oie.174.1550572730647; Tue, 19 Feb 2019 02:38:50 -0800 (PST) Received: from localhost ([131.228.32.166]) by smtp.gmail.com with ESMTPSA id s186sm7054875oif.0.2019.02.19.02.38.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 02:38:50 -0800 (PST) From: Thomas De Schampheleire To: buildroot@buildroot.org Date: Tue, 19 Feb 2019 11:38:37 +0100 Message-Id: <20190219103839.25409-7-patrickdepinguin@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190219103839.25409-1-patrickdepinguin@gmail.com> References: <20190219103839.25409-1-patrickdepinguin@gmail.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCHv5 7/9] support/download/scp: implement source-check X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Yann E. MORIN" , Thomas De Schampheleire Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Thomas De Schampheleire We use 'test -f' rather than 'ls' because 'test' is a mandatory POSIX utility while 'ls' is not. Signed-off-by: Thomas De Schampheleire --- support/download/scp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) v5: no changes v4: (feedback Yann E. Morin) - use true/false as values to 'checkonly' - replace incorrect 'exit $?' by explicit 'exit 0' - use 'test -f' instead of 'ls' which is more certain to be present (POSIX mandatory utility) v3: no changes diff --git a/support/download/scp b/support/download/scp index 80cf495c4e..52ccf06d6e 100755 --- a/support/download/scp +++ b/support/download/scp @@ -7,17 +7,21 @@ set -e # # Options: # -q Be quiet. +# -C Only check that the file exists remotely. # -o FILE Copy to local file FILE. # -f FILE Copy from remote file FILE. # -u URI Download file at URI. # # Environment: # SCP : the scp command to call +# SSH : the ssh command to use for checkonly verbose= +checkonly=false while getopts "${BR_BACKEND_DL_GETOPTS}" OPT; do case "${OPT}" in q) verbose=-q;; + C) checkonly=true;; o) output="${OPTARG}";; f) filename="${OPTARG}";; u) uri="${OPTARG}";; @@ -33,8 +37,19 @@ shift $((OPTIND-1)) # Get rid of our options _scp() { eval ${SCP} "${@}" } +_ssh() { + eval ${SSH} "${@}" +} # Remove any scheme prefix uri="${uri##scp://}" +if ${checkonly}; then + # uri now looks like: foo.example.org:some/directory + domain="${uri%%:*}" + path="${uri#*:}/${filename}" + _ssh ${verbose} "${@}" "'${domain}'" test -f "'${path}'" > /dev/null + exit 0 +fi + _scp ${verbose} "${@}" "'${uri}/${filename}'" "'${output}'"