2015-09-27 17:03:46 +02:00
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p coreutils findutils gnused nix wget
set -x
# The trailing slash at the end is necessary!
2015-11-11 19:40:13 +01:00
WGET_ARGS = 'http://download.kde.org/stable/applications/15.08.3/ http://download.kde.org/stable/applications/15.04.3/src/oxygen-icons-15.04.3.tar.xz -A *.tar.xz'
2015-09-27 17:03:46 +02:00
mkdir tmp; cd tmp
2015-10-02 16:06:05 +02:00
rm -f ../srcs.csv
2015-10-18 15:50:05 +02:00
wget -nH -r -c --no-parent $WGET_ARGS
2015-09-27 17:03:46 +02:00
2015-10-02 16:06:05 +02:00
find . | while read src; do
if [ [ -f " ${ src } " ] ] ; then
# Sanitize file name
filename = $( basename " $src " | tr '@' '_' )
nameVersion = " ${ filename %.tar.* } "
name = $( echo " $nameVersion " | sed -e 's,-[[:digit:]].*,,' | sed -e 's,-opensource-src$,,' )
version = $( echo " $nameVersion " | sed -e 's,^\([[:alpha:]][[:alnum:]]*-\)\+,,' )
echo " $name , $version , $src , $filename " >>../srcs.csv
fi
done
2015-09-27 17:03:46 +02:00
cat >../srcs.nix <<EOF
2015-10-02 16:06:05 +02:00
# DO NOT EDIT! This file is generated automatically by fetchsrcs.sh
2015-09-27 17:03:46 +02:00
{ fetchurl, mirror } :
{
EOF
2015-10-02 16:06:05 +02:00
gawk -F , "{ print \$1 }" ../srcs.csv | sort | uniq | while read name; do
versions = $( gawk -F , " /^ $name ,/ { print \$2 } " ../srcs.csv)
latestVersion = $( echo " $versions " | sort -rV | head -n 1)
src = $( gawk -F , " /^ $name , $latestVersion ,/ { print \$3 } " ../srcs.csv)
filename = $( gawk -F , " /^ $name , $latestVersion ,/ { print \$4 } " ../srcs.csv)
url = " ${ src : 2 } "
sha256 = $( nix-hash --type sha256 --base32 --flat " $src " )
cat >>../srcs.nix <<EOF
2015-09-27 17:03:46 +02:00
$name = {
2015-10-02 16:06:05 +02:00
version = " $latestVersion " ;
2015-09-27 17:03:46 +02:00
src = fetchurl {
url = " \${mirror}/ $url " ;
sha256 = " $sha256 " ;
name = " $filename " ;
} ;
} ;
EOF
done
echo "}" >>../srcs.nix
2015-10-02 16:06:05 +02:00
rm -f ../srcs.csv
2015-09-27 17:03:46 +02:00
cd ..