support patches download

This commit is contained in:
Solene Rapenne 2022-08-28 13:44:53 +02:00
parent efafcb8788
commit c93e9fecd3
1 changed files with 21 additions and 3 deletions

View File

@ -11,7 +11,7 @@ my @text = decode_json($json);
my @data = @{$text[0]};
foreach my $val (@data) {
print "Fetching $val->{name}\n";
print "Fetching $val->{name} from $val->{url} with $val->{hash}\n";
my $url = $val->{url};
$url =~ s,^mirror://savannah/,https://mirror.easyname.at/nongnu/,;
$url =~ s,^mirror://alsa/,https://www.alsa-project.org/files/pub/,;
@ -52,6 +52,24 @@ foreach my $val (@data) {
$url =~ s,^mirror://opensuse/,https://ftp.opensuse.org/pub/opensuse/distribution/,;
$url =~ s,^mirror://ubuntu/,https://nl.archive.ubuntu.com/ubuntu/,;
$url =~ s,^mirror://openbsd/,https://ftp.openbsd.org/pub/OpenBSD/,;
my $return = `nix-instantiate --eval -E 'builtins.fetchurl { url = $url ; sha256 = "$val->{hash}"; }'`;
print $return;
if ($val->{f}) {
my $TMPFILE = `mktemp /tmp/patch.XXXXXXXXXXXXXXX`;
chomp($TMPFILE);
open(OUT, ">","/tmp/script.sh");
print OUT "#!/usr/bin/env nix-shell\n";
print OUT "#! nix-shell -i bash -p patchutils_0_3_3\n";
print OUT "export LC_ALL=C\n";
print OUT "curl -L -o $TMPFILE $url\n";
print OUT "out=\"$TMPFILE\"\n";
print OUT "$val->{f}\n";
`sed 's,.*/lsdiff.*,lsdiff \\\\,g ; s,.*/filterdiff.*,filterdiff \\\\,g' -i /tmp/script.sh`;
`chmod +x /tmp/script.sh`;
`/tmp/script.sh "$url" "$TMPFILE"`;
my $return = `nix-instantiate --eval -E 'builtins.fetchurl { url = "file://$TMPFILE" ; sha256 = "$val->{hash}"; }'`;
print $return;
} else {
my $return = `nix-instantiate --eval -E 'builtins.fetchurl { url = $url ; sha256 = "$val->{hash}"; }'`;
print $return;
}
}