2024-02-18 12:23:08 -07:00
|
|
|
{
|
|
|
|
writeShellApplication,
|
|
|
|
diffutils,
|
|
|
|
findutils,
|
|
|
|
coreutils,
|
|
|
|
...
|
2023-09-12 08:44:05 -06:00
|
|
|
}:
|
|
|
|
let
|
2023-06-30 07:47:13 -06:00
|
|
|
genPatches = writeShellApplication {
|
|
|
|
name = "gen-patches";
|
2024-02-18 12:23:08 -07:00
|
|
|
runtimeInputs = [
|
|
|
|
diffutils
|
|
|
|
findutils
|
|
|
|
coreutils
|
|
|
|
];
|
2023-06-30 07:47:13 -06:00
|
|
|
text = ''
|
|
|
|
suffix=".orig"
|
|
|
|
srcdir=$PWD
|
|
|
|
output="$PWD/patches"
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
echo "Usage: $0 [-s suffix (default .orig)] [-d source directory (default PWD)] [-o output directory (default PWD/patches)]" 1>&2;
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while getopts "d:ho:s:" arg; do
|
|
|
|
case $arg in
|
|
|
|
d)
|
|
|
|
srcdir=$OPTARG
|
|
|
|
;;
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
s)
|
|
|
|
suffix=$OPTARG
|
|
|
|
;;
|
|
|
|
o)
|
|
|
|
output=$OPTARG
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
mkdir -p "$output"
|
|
|
|
|
|
|
|
# hold my be er!
|
|
|
|
# shellcheck disable=SC2044
|
|
|
|
for patch in $(find "$srcdir" -name "*$suffix"); do
|
|
|
|
fname=$(basename "$patch" "$suffix")
|
|
|
|
dname=$(dirname "$patch")
|
|
|
|
file="$dname/$fname"
|
2023-06-30 11:17:16 -06:00
|
|
|
outfile="$(echo "$dname/$fname" | sed 's;/;_;g').diff"
|
2023-06-30 08:13:56 -06:00
|
|
|
diff -u "$patch" "$file" > "$output/$outfile" || \
|
|
|
|
echo "==> Created patch: $output/$outfile"
|
2023-06-30 07:47:13 -06:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
2023-07-11 09:12:50 -06:00
|
|
|
in
|
2023-09-12 08:44:05 -06:00
|
|
|
genPatches
|