aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorChristian Marangi <ansuelsmth@gmail.com>2022-09-26 20:48:25 +0200
committerChristian Marangi <ansuelsmth@gmail.com>2022-09-26 20:50:10 +0200
commitf1b3958d02ba8b8a8bf2182599653ddd553906a8 (patch)
treea122389c63971ae22f0014f19f5398c1a2983615 /scripts
parent5df60f5c24e40fc373178427a6b654826edbe885 (diff)
downloadupstream-f1b3958d02ba8b8a8bf2182599653ddd553906a8.tar.gz
upstream-f1b3958d02ba8b8a8bf2182599653ddd553906a8.tar.bz2
upstream-f1b3958d02ba8b8a8bf2182599653ddd553906a8.zip
scripts/download.pl: fix support for aria2c download tool on macos
Currently we use /dev/shm to place aria2c tmp file. This is not present on macos. Use the openwrt tmp directory instead of the linux-only /dev/shm to save compatibility with more os. Fixes: d39123626931 ("download.pl: add aria2c support") Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/download.pl14
1 files changed, 8 insertions, 6 deletions
diff --git a/scripts/download.pl b/scripts/download.pl
index 51a816cff4..ad4fde7333 100755
--- a/scripts/download.pl
+++ b/scripts/download.pl
@@ -78,7 +78,7 @@ sub download_cmd {
my $additional_mirrors = join(" ", map "$_/$filename", @_);
my @chArray = ('a'..'z', 'A'..'Z', 0..9);
- my $rfn = join '', map{ $chArray[int rand @chArray] } 0..9;
+ my $rfn = join '', "${filename}_", map{ $chArray[int rand @chArray] } 0..9;
if (open CURL, '-|', 'curl', '--version') {
if (defined(my $line = readline CURL)) {
$have_curl = 1 if $line =~ /^curl /;
@@ -94,13 +94,15 @@ sub download_cmd {
if ($have_aria2c) {
@mirrors=();
- return join(" ", "touch /dev/shm/${rfn}_spp;",
+ return join(" ", "[ -d $ENV{'TMPDIR'}/aria2c ] || mkdir $ENV{'TMPDIR'}/aria2c;",
+ "touch $ENV{'TMPDIR'}/aria2c/${rfn}_spp;",
qw(aria2c --stderr -c -x2 -s10 -j10 -k1M), $url, $additional_mirrors,
$check_certificate ? () : '--check-certificate=false',
- "--server-stat-of=/dev/shm/${rfn}_spp",
- "--server-stat-if=/dev/shm/${rfn}_spp",
- "-d /dev/shm -o $rfn;",
- "cat /dev/shm/$rfn;", "rm /dev/shm/$rfn /dev/shm/${rfn}_spp");
+ "--server-stat-of=$ENV{'TMPDIR'}/aria2c/${rfn}_spp",
+ "--server-stat-if=$ENV{'TMPDIR'}/aria2c/${rfn}_spp",
+ "-d $ENV{'TMPDIR'}/aria2c -o $rfn;",
+ "cat $ENV{'TMPDIR'}/aria2c/$rfn;",
+ "rm $ENV{'TMPDIR'}/aria2c/$rfn $ENV{'TMPDIR'}/aria2c/${rfn}_spp");
} elsif ($have_curl) {
return (qw(curl -f --connect-timeout 20 --retry 5 --location),
$check_certificate ? () : '--insecure',