From patchwork Wed Nov 18 15:24:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Bauer X-Patchwork-Id: 1402293 X-Patchwork-Delegate: mail@david-bauer.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=david-bauer.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=ilKivval; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cbmr917Xsz9sPB for ; Thu, 19 Nov 2020 02:26:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe :List-Id:MIME-Version:Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=GR3FUaIEgudzVK163I46hc9DgP45MSzL0rmSyHjtYqk=; b=ilKivvalz7lICkivBPnRXuVuDb JcfAkxOIYnt6iMoGBQbAFpUdflH0Mn6j3PtquJ5yFY9g/+FZjinAoJwuLYRirGbSWttlswO3GcDrd 6jVmbImFWTyJJSvSdGgAheLFQkag6cTJdf6A+Lce85RVdjHXGJf9IjpQaF5RLBggPvOOseGhSAxrK fXs9AR9a6LbPwNw1EeqJzgU3bYp3TE/0TTUxkzWJdE5yP8TOnv7cMC5YhJ9JjX/hul+hrC8ByMjL+ liOtEnzjJ6aufsA6m7gBnAtWaVw35DOIo837j+viAub/zd8P8UGg9wqf4IYyMBen614byQELVfeDq DEhaku2Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfPKC-000372-2y; Wed, 18 Nov 2020 15:24:48 +0000 Received: from mars.blocktrron.ovh ([2001:41d0:401:3000::cbd] helo=mail.blocktrron.ovh) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfPK8-00031D-Ff for openwrt-devel@lists.openwrt.org; Wed, 18 Nov 2020 15:24:45 +0000 Received: from localhost.localdomain (p200300e53f17690096037fcc4f66e0fe.dip0.t-ipconnect.de [IPv6:2003:e5:3f17:6900:9603:7fcc:4f66:e0fe]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.blocktrron.ovh (Postfix) with ESMTPSA id 22DFD279CC for ; Wed, 18 Nov 2020 16:24:27 +0100 (CET) From: David Bauer To: openwrt-devel@lists.openwrt.org Subject: [PATCH] scripts: download.pl: retry download using filename Date: Wed, 18 Nov 2020 16:24:14 +0100 Message-Id: <20201118152414.35309-1-mail@david-bauer.net> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201118_102444_650510_7AF43E75 X-CRM114-Status: GOOD ( 14.75 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org With this commit, the download script will try downloading source files using the filename instead of the url-filename in case the previous download attempt using the url-filename failed. This is required, as the OpenWrt sources mirrors serve files using the filename files might be renamed to after downloading. If the original mirror for a file where url-filename and filename do not match goes down, the download failed prior to this patch. Further improvement can be done by performing this only for the OpenWrt sources mirrors. Signed-off-by: David Bauer --- scripts/download.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/download.pl b/scripts/download.pl index cdccae133f..351b06a08b 100755 --- a/scripts/download.pl +++ b/scripts/download.pl @@ -93,6 +93,7 @@ $hash_cmd or ($file_hash eq "skip") or die "Cannot find appropriate hash command sub download { my $mirror = shift; + my $download_filename = shift; $mirror =~ s!/$!!; @@ -139,7 +140,7 @@ sub download } }; } else { - my @cmd = download_cmd("$mirror/$url_filename"); + my @cmd = download_cmd("$mirror/$download_filename"); print STDERR "+ ".join(" ",@cmd)."\n"; open(FETCH_FD, '-|', @cmd) or die "Cannot launch curl or wget.\n"; $hash_cmd and do { @@ -265,7 +266,10 @@ while (!-f "$target/$filename") { my $mirror = shift @mirrors; $mirror or die "No more mirrors to try - giving up.\n"; - download($mirror); + download($mirror, $url_filename); + if (!-f "$target/$filename" && $url_filename ne $filename) { + download($mirror, $filename); + } } $SIG{INT} = \&cleanup;