2016-06-17 14:47:16 +00:00
|
|
|
#! /usr/bin/env nix-shell
|
|
|
|
#! nix-shell -i bash -p coreutils findutils gnused nix wget
|
|
|
|
|
2016-09-18 13:16:07 +00:00
|
|
|
set -efuo pipefail
|
|
|
|
|
2016-08-25 15:06:23 +00:00
|
|
|
SRCS=
|
|
|
|
if [ -d "$1" ]; then
|
|
|
|
SRCS="$(pwd)/$1/srcs.nix"
|
|
|
|
. "$1/fetch.sh"
|
|
|
|
else
|
|
|
|
SRCS="$(pwd)/$(dirname $1)/srcs.nix"
|
|
|
|
. "$1"
|
|
|
|
fi
|
|
|
|
|
2016-06-17 14:47:16 +00:00
|
|
|
tmp=$(mktemp -d)
|
|
|
|
pushd $tmp >/dev/null
|
2020-12-24 13:58:53 +00:00
|
|
|
wget -nH -r -c --no-parent "${WGET_ARGS[@]}" >/dev/null
|
2016-06-17 14:47:16 +00:00
|
|
|
|
|
|
|
csv=$(mktemp)
|
|
|
|
find . -type f | while read src; do
|
|
|
|
# Sanitize file name
|
2020-12-24 13:58:53 +00:00
|
|
|
filename=$(basename "$src" | tr '@' '_')
|
2016-06-17 14:47:16 +00:00
|
|
|
nameVersion="${filename%.tar.*}"
|
2018-01-01 20:50:26 +00:00
|
|
|
name=$(echo "$nameVersion" | sed -e 's,-[[:digit:]].*,,' | sed -e 's,-opensource-src$,,' | sed -e 's,-everywhere-src$,,')
|
2016-06-17 14:47:16 +00:00
|
|
|
version=$(echo "$nameVersion" | sed -e 's,^\([[:alpha:]][[:alnum:]]*-\)\+,,')
|
|
|
|
echo "$name,$version,$src,$filename" >>$csv
|
|
|
|
done
|
|
|
|
|
2016-08-25 15:06:23 +00:00
|
|
|
cat >"$SRCS" <<EOF
|
2020-01-27 14:29:28 +00:00
|
|
|
# DO NOT EDIT! This file is generated automatically.
|
|
|
|
# Command: $0 $@
|
2016-06-17 14:47:16 +00:00
|
|
|
{ fetchurl, mirror }:
|
|
|
|
|
|
|
|
{
|
|
|
|
EOF
|
|
|
|
|
|
|
|
gawk -F , "{ print \$1 }" $csv | sort | uniq | while read name; do
|
|
|
|
versions=$(gawk -F , "/^$name,/ { print \$2 }" $csv)
|
|
|
|
latestVersion=$(echo "$versions" | sort -rV | head -n 1)
|
|
|
|
src=$(gawk -F , "/^$name,$latestVersion,/ { print \$3 }" $csv)
|
|
|
|
filename=$(gawk -F , "/^$name,$latestVersion,/ { print \$4 }" $csv)
|
2020-12-24 13:58:53 +00:00
|
|
|
url="${src:2}"
|
|
|
|
sha256=$(nix-hash --type sha256 --base32 --flat "$src")
|
2016-08-25 15:06:23 +00:00
|
|
|
cat >>"$SRCS" <<EOF
|
2016-06-17 14:47:16 +00:00
|
|
|
$name = {
|
|
|
|
version = "$latestVersion";
|
|
|
|
src = fetchurl {
|
|
|
|
url = "\${mirror}/$url";
|
|
|
|
sha256 = "$sha256";
|
|
|
|
name = "$filename";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
EOF
|
|
|
|
done
|
|
|
|
|
2016-08-25 15:06:23 +00:00
|
|
|
echo "}" >>"$SRCS"
|
2016-06-17 14:47:16 +00:00
|
|
|
|
|
|
|
popd >/dev/null
|
|
|
|
rm -fr $tmp >/dev/null
|
|
|
|
|
|
|
|
rm -f $csv >/dev/null
|