Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / maintainers / scripts / debian-patches.sh
blob1f021c224c3af6a83941f91609c45d9691c2428d
1 #!/usr/bin/env bash
3 # Download patches from debian project
4 # Usage $0 debian-patches.txt debian-patches.nix
5 # An example input and output files can be found in tools/graphics/plotutils
7 DEB_URL=https://sources.debian.org/data/main
8 declare -a deb_patches
9 mapfile -t deb_patches < $1
11 # First letter
12 deb_prefix="${deb_patches[0]:0:1}"
13 prefix="${DEB_URL}/${deb_prefix}/${deb_patches[0]}/debian/patches"
15 if [[ -n "$2" ]]; then
16 exec 1> $2
19 cat <<EOF
20 # Generated by $(basename $0) from $(basename $1)
21 let
22 prefix = "${prefix}";
25 EOF
26 for ((i=1;i < ${#deb_patches[@]}; ++i)); do
27 url="${prefix}/${deb_patches[$i]}"
28 sha256=$(nix-prefetch-url $url)
29 echo " {"
30 echo " url = \"\${prefix}/${deb_patches[$i]}\";"
31 echo " sha256 = \"$sha256\";"
32 echo " }"
33 done
34 echo "]"