nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1#!/usr/bin/env bash
2
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
6
7DEB_URL=https://sources.debian.org/data/main
8declare -a deb_patches
9mapfile -t deb_patches < $1
10
11pkgname="${deb_patches[0]}"
12# See https://sources.debian.org/data/main/ for patterns of prefixes
13if [[ $pkgname == lib* ]]; then
14 sub_prefix="${pkgname:3:1}"
15 deb_prefix="lib${sub_prefix}"
16else
17 deb_prefix="${pkgname:0:1}"
18fi
19
20prefix="${DEB_URL}/${deb_prefix}/${pkgname}/debian/patches"
21
22if [[ -n "$2" ]]; then
23 exec 1> $2
24fi
25
26cat <<EOF
27# Generated by $(basename $0) from $(basename $1)
28let
29 prefix = "${prefix}";
30in
31[
32EOF
33for ((i=1;i < ${#deb_patches[@]}; ++i)); do
34 url="${prefix}/${deb_patches[$i]}"
35 sha256=$(nix-prefetch-url $url)
36 echo " {"
37 echo " url = \"\${prefix}/${deb_patches[$i]}\";"
38 echo " sha256 = \"$sha256\";"
39 echo " }"
40done
41echo "]"