#!/usr/bin/env nix-shell
#!nix-shell --pure -i bash -p nix cacert git getopt

rootdir="../../../../../"

src="$(nix-build $rootdir --no-out-link -A coreboot-toolchain.src)"
urls=$($src/util/crossgcc/buildgcc -u)

tmp=$(mktemp)
echo '{ fetchurl }: [' > $tmp

for url in $urls; do
  name="$(basename $url)"
  hash="$(nix-prefetch-url "$url")"

  cat << EOF >> $tmp
  {
    name = "$name";
    archive = fetchurl {
      sha256 = "$hash";
      url = "$url";
    };
  }
EOF
done

echo ']' >> $tmp

sed -ie 's/https\:\/\/ftpmirror\.gnu\.org/mirror\:\/\/gnu/g' $tmp

mv $tmp sources.nix

Introduce script for generating sources file
coreboot-toolchain: Introduce script for generating sources file

Add and adjust update script from
https://git.petabyte.dev/petabyteboy/corenix.

The script is meant to be run from the package directory of the
coreboot-toolchain. The script generates a sources.nix files, which
contains all sources used for the coreboot toolchain and some other
tools. Thus, it needs to be stripped down to the necessary sources.

Signed-off-by: Felix Singer <95be743193f3621c08bfa8789be1d425e843abe6@posteo.net>
