add scripts to download tarballs

This commit is contained in:
Solene Rapenne 2022-08-15 17:02:46 +02:00
parent ddb9c20bc6
commit ff7064ea6d
2 changed files with 87 additions and 0 deletions

57
mirror.pl Executable file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env nix-shell
#! nix-shell -i perl -p perlPackages.JSON perl
use strict;
use warnings;
use JSON;
use Data::Dumper;
my $json = do { local $/; <> };
my @text = decode_json($json);
my @data = @{$text[0]};
foreach my $val (@data) {
print "Fetching $val->{name}\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/,;
$url =~ s,^mirror://apache/,https://dlcdn.apache.org/,;
$url =~ s,^mirror://bloc/,https://bioconductor.statistik.tu-dortmund.de/packages/,;
$url =~ s,^mirror://bitlbee/,https://get.bitlbee.org/,;
$url =~ s,^mirror://gcc/,ftp://gcc.gnu.org/pub/gcc/,;
$url =~ s,^mirror://gnome/,https://download.gnome.org/,;
$url =~ s,^mirror://gnu/,https://ftpmirror.gnu.org/,;
$url =~ s,^mirror://gnupg/,https://gnupg.org/ftp/gcrypt/,;
$url =~ s,^mirror://ibiblioPubLinux/,https://www.ibiblio.org/pub/Linux/,;
$url =~ s,^mirror://imagemagick/,https://www.imagemagick.org/download/,;
$url =~ s,^mirror://kde/,https://download.kde.org/download.php?url=,;
$url =~ s,^mirror://kernel/,https://cdn.kernel.org/pub/,;
$url =~ s,^mirror://mysql/,https://cdn.mysql.com/Downloads/,;
$url =~ s,^mirror://maven/,https://repo1.maven.org/maven2/,;
$url =~ s,^mirror://mozilla/,https://download.cdn.mozilla.net/pub/mozilla.org/,;
$url =~ s,^mirror://osdn/,https://osdn.dl.osdn.jp/,;
$url =~ s,^mirror://postgresql/,https://ftp.postgresql.org/pub/,;
$url =~ s,^mirror://qt/,https://download.qt.io/,;
$url =~ s,^mirror://roy/,https://roy.marples.name/downloads/,;
$url =~ s,^mirror://sageupstream/,https://www-ftp.lip6.fr/pub/math/sagemath/spkg/upstream/,;
$url =~ s,^mirror://samba/,https://www.samba.org/ftp/,;
$url =~ s,^mirror://sourceforge/,https://downloads.sourceforge.net/,;
$url =~ s,^mirror://steamrt/,https://repo.steampowered.com/steamrt/,;
$url =~ s,^mirror://tcsh/,https://astron.com/pub/tcsh/,;
$url =~ s,^mirror://xfce/,https://archive.xfce.org/,;
$url =~ s,^mirror://xorg/,https://xorg.freedesktop.org/releases/,;
$url =~ s,^mirror://cpan/,https://cpan.metacpan.org/,;
$url =~ s,^mirror://hackage/,https://hackage.haskell.org/package/,;
$url =~ s,^mirror://luarocks/,https://luarocks.org/,;
$url =~ s,^mirror://pypi/,https://pypi.io/packages/source/,;
$url =~ s,^mirror://testpypi/,https://test.pypi.io/packages/source/,;
$url =~ s,^mirror://centos/,https://vault.centos.org/,;
$url =~ s,^mirror://debian/,https://httpredir.debian.org/debian/,;
$url =~ s,^mirror://fedora/,https://archives.fedoraproject.org/pub/fedora/,;
$url =~ s,^mirror://gentoo/,https://distfiles.gentoo.org/,;
$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;
}

30
run.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
set -x
NIXPKGS='<nixpkgs/maintainers/scripts/find-tarballs.nix>'
while getopts "f:" arg; do
case ${arg} in
f)
NIXPKGS="${OPTARG}/maintainers/scripts/find-tarballs.nix"
shift
shift
;;
h)
echo "$0 [-f path_to_nixpkgs] package1 ..."
exit 2
;;
esac
done
if [ $# -eq 0 ]
then
echo "you need to pass packages"
exit 1
fi
for i in $@
do
echo "DOWNLOADING SOURCES TO BUILD $i"
nix-instantiate --json --eval --strict "${NIXPKGS}" --arg expr "(import <nixpkgs>{}).${i}" | ./mirror.pl
done