1#!/usr/bin/env nix-shell
2#!nix-shell --pure -i bash -p nix cacert git getopt
3
4# shellcheck shell=bash
5
6if [ ! -d .git ]; then
7 echo "This script needs to be run from the root directory of nixpkgs. Exiting."
8 exit 1
9fi
10
11pkg_dir="$(dirname "$0")"
12
13src="$(nix-build . --no-out-link -A coreboot-toolchain.i386.src)"
14urls=$("${src}/util/crossgcc/buildgcc" -u)
15
16tmp=$(mktemp)
17echo '{ fetchurl }: [' >"$tmp"
18
19for url in $urls; do
20 name="$(basename "$url")"
21 hash="$(nix-prefetch-url "$url")"
22
23 cat <<EOF >>"$tmp"
24 {
25 name = "$name";
26 archive = fetchurl {
27 sha256 = "$hash";
28 url = "$url";
29 };
30 }
31EOF
32done
33
34echo ']' >>"$tmp"
35
36sed -i -e 's/https\:\/\/ftpmirror\.gnu\.org/mirror\:\/\/gnu/g' "$tmp"
37
38mv "$tmp" "${pkg_dir}/sources.nix"