From patchwork Fri Feb 15 21:08:01 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: 1043193 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.137; helo=fraxinus.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="pA4OFfFe"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 441Qpb6Ylxz9sMl for ; Sat, 16 Feb 2019 08:08:23 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 52DC786433; Fri, 15 Feb 2019 21:08:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UvOCZho7GdpO; Fri, 15 Feb 2019 21:08:21 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id A754B86451; Fri, 15 Feb 2019 21:08:21 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 018351BF83A for ; Fri, 15 Feb 2019 21:08:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id F2FB287E65 for ; Fri, 15 Feb 2019 21:08:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vRFgwgPGDeu1 for ; Fri, 15 Feb 2019 21:08:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by hemlock.osuosl.org (Postfix) with ESMTPS id 3EBE18571C for ; Fri, 15 Feb 2019 21:08:16 +0000 (UTC) Received: by mail-ed1-f47.google.com with SMTP id m12so8986723edv.4 for ; Fri, 15 Feb 2019 13:08:16 -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=sYzFEHK1ICiZgeR7mV60VcbW065VW1aisE6zIyAgonY=; b=pA4OFfFeMiXnUriihkbSvbynfcX2NER3bBxlwTEa6x/m2+siXMxrzvTOl3t2FPXJmP tVuiTsyaLg2DxXcQYRLiR7Pwt+/qQio+Y3eBy/sGSutBmLkIq+UKnS6YP6hx6Pudo/bH 9PS4c48kkQXy/Rki02pvCDJpGujqGY05c7cTWgfwDS+XZBY6My8Jk7yuACGCXgsDuUlc aR/FmoD5PHFxRTQDRMXUd9xl/xbjYpin6xRT695DQK4LSc359n17BRCGlV9uS821w94f +VW2WfkDTIld4flfOTRsxZxPRsbKn317VR8mPAYxLXiUm252mfMzzHR1DvkQd8HLGxVl FLAA== 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=sYzFEHK1ICiZgeR7mV60VcbW065VW1aisE6zIyAgonY=; b=m8ey2/QHwv8I+o5jqHY+9NnxiizmfRfNI2ZxaBRByXJILfE9ce4qoai7q1a2zM+94B 9UfXSkPDWFXuFiIHcLOIH4xkx9kGTudDQ/DH98rOZGDBjeY1VuVhoPdE8wMXVp5Bo0hk 0c0HvqKQ32MxLoT4dlfaUZ7Ggekd7dWTmvmuABtVcBb/EhfqXtwq0Mh7nLNIfRAjY4Ra gtF1Lx9Er72a8C6zk+hrJKSg08tGqyjKE2iVhIpq90PiBgNIA7scxQENW5CiWV86SSRF hbxwpJP5kEygw9IkHBsUw69zw4fg2rJNJxWAve/lcL2Y6WgT/qCnk7DvfwfQFw0ZPLv6 PFVQ== X-Gm-Message-State: AHQUAuZLHAYiW6EjY/LrMRbyfFnN6UQ86xPpgX4bwm9PDbXgfoNbZYPC tk+3HFgyi+G2a2wiOjm85rvRr4Bt/gQ= X-Google-Smtp-Source: AHgI3IZUgg94wXCq0hEoDqcis5SfWNrYNJkUvmAS3hKu6k8USoXmFMPbPdkC9UZLfNwjBwDM6jQD8Q== X-Received: by 2002:a17:906:f43:: with SMTP id h3mr7983463ejj.179.1550264894387; Fri, 15 Feb 2019 13:08:14 -0800 (PST) Received: from localhost.localdomain (d54c493b0.access.telenet.be. [84.196.147.176]) by smtp.gmail.com with ESMTPSA id z42sm1052652edd.29.2019.02.15.13.08.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 13:08:13 -0800 (PST) From: Thomas De Schampheleire To: buildroot@buildroot.org Date: Fri, 15 Feb 2019 22:08:01 +0100 Message-Id: <20190215210803.8969-6-patrickdepinguin@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190215210803.8969-1-patrickdepinguin@gmail.com> References: <20190215210803.8969-1-patrickdepinguin@gmail.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCHv4 6/8] 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(+) 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}'"