1
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-10-18 05:18:14 +02:00

scripts/download.pl: use perl builtins instead of system()

Perl natively supports renaming files and create directories.
Do it without calling system().

Signed-off-by: Matteo Croce <teknoraver@meta.com>
Link: https://github.com/openwrt/openwrt/pull/16542
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Matteo Croce 2024-09-29 00:41:23 +02:00 committed by Hauke Mehrtens
parent a6de2d7784
commit 6e40f98208

@ -11,6 +11,7 @@ use strict;
use warnings; use warnings;
use File::Basename; use File::Basename;
use File::Copy; use File::Copy;
use File::Path;
use Text::ParseWords; use Text::ParseWords;
use JSON::PP; use JSON::PP;
@ -173,7 +174,7 @@ sub download
} }
if (! -d "$target") { if (! -d "$target") {
system("mkdir", "-p", "$target/"); make_path($target);
} }
if (! open TMPDLS, "find $mirror -follow -name $filename 2>/dev/null |") { if (! open TMPDLS, "find $mirror -follow -name $filename 2>/dev/null |") {
@ -244,7 +245,7 @@ sub download
}; };
unlink "$target/$filename"; unlink "$target/$filename";
system("mv", "$target/$filename.dl", "$target/$filename"); move("$target/$filename.dl", "$target/$filename");
cleanup(); cleanup();
} }