mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-03-08 01:24:09 +01:00
41 lines
976 B
Bash
Executable file
41 lines
976 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Download patches from debian project
|
|
# Usage $0 debian-patches.txt debian-patches.nix
|
|
# An example input and output files can be found in tools/graphics/plotutils
|
|
|
|
DEB_URL=https://sources.debian.org/data/main
|
|
declare -a deb_patches
|
|
mapfile -t deb_patches < $1
|
|
|
|
pkgname="${deb_patches[0]}"
|
|
# See https://sources.debian.org/data/main/ for patterns of prefixes
|
|
if [[ $pkgname == lib* ]]; then
|
|
sub_prefix="${pkgname:3:1}"
|
|
deb_prefix="lib${sub_prefix}"
|
|
else
|
|
deb_prefix="${pkgname:0:1}"
|
|
fi
|
|
|
|
prefix="${DEB_URL}/${deb_prefix}/${pkgname}/debian/patches"
|
|
|
|
if [[ -n "$2" ]]; then
|
|
exec 1> $2
|
|
fi
|
|
|
|
cat <<EOF
|
|
# Generated by $(basename $0) from $(basename $1)
|
|
let
|
|
prefix = "${prefix}";
|
|
in
|
|
[
|
|
EOF
|
|
for ((i=1;i < ${#deb_patches[@]}; ++i)); do
|
|
url="${prefix}/${deb_patches[$i]}"
|
|
sha256=$(nix-prefetch-url $url)
|
|
echo " {"
|
|
echo " url = \"\${prefix}/${deb_patches[$i]}\";"
|
|
echo " sha256 = \"$sha256\";"
|
|
echo " }"
|
|
done
|
|
echo "]"
|