3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/applications/kde-apps-15.08/fetchsrcs.sh

58 lines
1.5 KiB
Bash
Raw Normal View History

2015-09-27 16:03:46 +01: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!
RELEASE_URL="http://download.kde.org/stable/applications/15.08.1/"
EXTRA_WGET_ARGS='-A *.tar.xz'
mkdir tmp; cd tmp
2015-10-02 15:06:05 +01:00
rm -f ../srcs.csv
2015-09-27 16:03:46 +01:00
wget -nH -r -c --no-parent $RELEASE_URL $EXTRA_WGET_ARGS
2015-10-02 15:06:05 +01: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 16:03:46 +01:00
cat >../srcs.nix <<EOF
2015-10-02 15:06:05 +01:00
# DO NOT EDIT! This file is generated automatically by fetchsrcs.sh
2015-09-27 16:03:46 +01:00
{ fetchurl, mirror }:
{
EOF
2015-10-02 15:06:05 +01: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 16:03:46 +01:00
$name = {
2015-10-02 15:06:05 +01:00
version = "$latestVersion";
2015-09-27 16:03:46 +01:00
src = fetchurl {
url = "\${mirror}/$url";
sha256 = "$sha256";
name = "$filename";
};
};
EOF
done
echo "}" >>../srcs.nix
2015-10-02 15:06:05 +01:00
rm -f ../srcs.csv
2015-09-27 16:03:46 +01:00
cd ..