From 4b7d9dc86800fa7b861f47ae0e6e3a8f097f9ce7 Mon Sep 17 00:00:00 2001
From: nyanloutre <paul@nyanlout.re>
Date: Thu, 21 Feb 2019 16:27:09 +0100
Subject: [PATCH] fetch-kde-qt.sh: get hashes from metadata

---
 maintainers/scripts/fetch-kde-qt.sh                | 9 +++++----
 pkgs/applications/kde/fetch.sh                     | 2 +-
 pkgs/desktops/plasma-5/fetch.sh                    | 2 +-
 pkgs/development/libraries/kde-frameworks/fetch.sh | 2 +-
 pkgs/development/libraries/qt-5/5.11/fetch.sh      | 3 +--
 pkgs/development/libraries/qt-5/5.12/fetch.sh      | 3 +--
 pkgs/development/libraries/qt-5/5.6/fetch.sh       | 3 +--
 pkgs/development/libraries/qt-5/5.9/fetch.sh       | 3 +--
 8 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/maintainers/scripts/fetch-kde-qt.sh b/maintainers/scripts/fetch-kde-qt.sh
index 1357f87aaa5..a267a5fa871 100755
--- a/maintainers/scripts/fetch-kde-qt.sh
+++ b/maintainers/scripts/fetch-kde-qt.sh
@@ -14,12 +14,13 @@ fi
 
 tmp=$(mktemp -d)
 pushd $tmp >/dev/null
-wget -nH -r -c --no-parent "${WGET_ARGS[@]}" >/dev/null
+wget -nH -r -c --no-parent "${WGET_ARGS[@]}" -A '*.tar.xz.sha256' -A '*.mirrorlist' >/dev/null
+find -type f -name '*.mirrorlist' -delete
 
 csv=$(mktemp)
 find . -type f | while read src; do
     # Sanitize file name
-    filename=$(basename "$src" | tr '@' '_')
+    filename=$(gawk '{ print $2 }' "$src" | tr '@' '_')
     nameVersion="${filename%.tar.*}"
     name=$(echo "$nameVersion" | sed -e 's,-[[:digit:]].*,,' | sed -e 's,-opensource-src$,,' | sed -e 's,-everywhere-src$,,')
     version=$(echo "$nameVersion" | sed -e 's,^\([[:alpha:]][[:alnum:]]*-\)\+,,')
@@ -38,8 +39,8 @@ gawk -F , "{ print \$1 }" $csv | sort | uniq | while read name; do
     latestVersion=$(echo "$versions" | sort -rV | head -n 1)
     src=$(gawk -F , "/^$name,$latestVersion,/ { print \$3 }" $csv)
     filename=$(gawk -F , "/^$name,$latestVersion,/ { print \$4 }" $csv)
-    url="${src:2}"
-    sha256=$(nix-hash --type sha256 --base32 --flat "$src")
+    url="$(dirname "${src:2}")/$filename"
+    sha256=$(gawk '{ print $1 }' "$src")
     cat >>"$SRCS" <<EOF
   $name = {
     version = "$latestVersion";
diff --git a/pkgs/applications/kde/fetch.sh b/pkgs/applications/kde/fetch.sh
index 6f6acd1e8bb..8d37e4144fa 100644
--- a/pkgs/applications/kde/fetch.sh
+++ b/pkgs/applications/kde/fetch.sh
@@ -1 +1 @@
-WGET_ARGS=( https://download.kde.org/stable/applications/18.12.1/ -A '*.tar.xz' )
+WGET_ARGS=( https://download.kde.org/stable/applications/18.12.1/ )
diff --git a/pkgs/desktops/plasma-5/fetch.sh b/pkgs/desktops/plasma-5/fetch.sh
index 814795499a9..5c27d0d2f18 100644
--- a/pkgs/desktops/plasma-5/fetch.sh
+++ b/pkgs/desktops/plasma-5/fetch.sh
@@ -1 +1 @@
-WGET_ARGS=( https://download.kde.org/stable/plasma/5.14.5/ -A '*.tar.xz' )
+WGET_ARGS=( https://download.kde.org/stable/plasma/5.14.5/ )
diff --git a/pkgs/development/libraries/kde-frameworks/fetch.sh b/pkgs/development/libraries/kde-frameworks/fetch.sh
index ce41ffa4929..f240ad124c8 100644
--- a/pkgs/development/libraries/kde-frameworks/fetch.sh
+++ b/pkgs/development/libraries/kde-frameworks/fetch.sh
@@ -1 +1 @@
-WGET_ARGS=( https://download.kde.org/stable/frameworks/5.54/ -A '*.tar.xz' )
+WGET_ARGS=( https://download.kde.org/stable/frameworks/5.54/ )
diff --git a/pkgs/development/libraries/qt-5/5.11/fetch.sh b/pkgs/development/libraries/qt-5/5.11/fetch.sh
index dc1088fc371..2ab3dd71c24 100644
--- a/pkgs/development/libraries/qt-5/5.11/fetch.sh
+++ b/pkgs/development/libraries/qt-5/5.11/fetch.sh
@@ -1,2 +1 @@
-WGET_ARGS=( http://download.qt.io/official_releases/qt/5.11/5.11.3/submodules/ \
-            -A '*.tar.xz' )
+WGET_ARGS=( http://download.qt.io/official_releases/qt/5.11/5.11.3/submodules/ )
diff --git a/pkgs/development/libraries/qt-5/5.12/fetch.sh b/pkgs/development/libraries/qt-5/5.12/fetch.sh
index b77a58cafa2..aa3a0fe9489 100644
--- a/pkgs/development/libraries/qt-5/5.12/fetch.sh
+++ b/pkgs/development/libraries/qt-5/5.12/fetch.sh
@@ -1,2 +1 @@
-WGET_ARGS=( http://download.qt.io/official_releases/qt/5.12/5.12.0/submodules/ \
-            -A '*.tar.xz' )
+WGET_ARGS=( http://download.qt.io/official_releases/qt/5.12/5.12.0/submodules/ )
diff --git a/pkgs/development/libraries/qt-5/5.6/fetch.sh b/pkgs/development/libraries/qt-5/5.6/fetch.sh
index ee3a5ddf8de..bb9eb66a01d 100644
--- a/pkgs/development/libraries/qt-5/5.6/fetch.sh
+++ b/pkgs/development/libraries/qt-5/5.6/fetch.sh
@@ -1,3 +1,2 @@
 WGET_ARGS=( http://download.qt.io/official_releases/qt/5.6/5.6.3/submodules/ \
-            http://download.qt.io/community_releases/5.6/5.6.3/ \
-            -A '*.tar.xz' )
+            http://download.qt.io/community_releases/5.6/5.6.3/ )
diff --git a/pkgs/development/libraries/qt-5/5.9/fetch.sh b/pkgs/development/libraries/qt-5/5.9/fetch.sh
index e631d3ae9b0..17ebe1e532d 100644
--- a/pkgs/development/libraries/qt-5/5.9/fetch.sh
+++ b/pkgs/development/libraries/qt-5/5.9/fetch.sh
@@ -1,2 +1 @@
-WGET_ARGS=( http://download.qt.io/official_releases/qt/5.9/5.9.7/submodules/ \
-            -A '*.tar.xz' )
+WGET_ARGS=( http://download.qt.io/official_releases/qt/5.9/5.9.7/submodules/ )