Merge master into staging-next
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
# stripLen acts as the -p parameter when applying a patch.
|
||||
|
||||
{ lib, fetchurl, buildPackages }:
|
||||
let
|
||||
# 0.3.4 would change hashes: https://github.com/NixOS/nixpkgs/issues/25154
|
||||
patchutils = buildPackages.patchutils_0_3_3;
|
||||
in
|
||||
{ stripLen ? 0, extraPrefix ? null, excludes ? [], includes ? [], revert ? false, ... }@args:
|
||||
|
||||
fetchurl ({
|
||||
@@ -14,10 +18,10 @@ fetchurl ({
|
||||
echo "error: Fetched patch file '$out' is empty!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
"${buildPackages.patchutils}/bin/lsdiff" "$out" \
|
||||
"${patchutils}/bin/lsdiff" "$out" \
|
||||
| sort -u | sed -e 's/[*?]/\\&/g' \
|
||||
| xargs -I{} \
|
||||
"${buildPackages.patchutils}/bin/filterdiff" \
|
||||
"${patchutils}/bin/filterdiff" \
|
||||
--include={} \
|
||||
--strip=${toString stripLen} \
|
||||
${lib.optionalString (extraPrefix != null) ''
|
||||
@@ -32,7 +36,7 @@ fetchurl ({
|
||||
cat "$out" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
${buildPackages.patchutils}/bin/filterdiff \
|
||||
${patchutils}/bin/filterdiff \
|
||||
-p1 \
|
||||
${builtins.toString (builtins.map (x: "-x ${lib.escapeShellArg x}") excludes)} \
|
||||
${builtins.toString (builtins.map (x: "-i ${lib.escapeShellArg x}") includes)} \
|
||||
@@ -46,7 +50,7 @@ fetchurl ({
|
||||
exit 1
|
||||
fi
|
||||
'' + lib.optionalString revert ''
|
||||
${buildPackages.patchutils}/bin/interdiff "$out" /dev/null > "$tmpfile"
|
||||
${patchutils}/bin/interdiff "$out" /dev/null > "$tmpfile"
|
||||
mv "$tmpfile" "$out"
|
||||
'' + (args.postFetch or "");
|
||||
meta.broken = excludes != [] && includes != [];
|
||||
|
||||
@@ -79,7 +79,6 @@ rec {
|
||||
(test -n "$executable" && chmod +x "$n") || true
|
||||
'';
|
||||
|
||||
|
||||
/*
|
||||
* Writes a text file to nix store with no optional parameters available.
|
||||
*
|
||||
@@ -92,6 +91,7 @@ rec {
|
||||
*
|
||||
*/
|
||||
writeText = name: text: writeTextFile {inherit name text;};
|
||||
|
||||
/*
|
||||
* Writes a text file to nix store in a specific directory with no
|
||||
* optional parameters available. Name passed is the destination.
|
||||
@@ -105,6 +105,7 @@ rec {
|
||||
*
|
||||
*/
|
||||
writeTextDir = name: text: writeTextFile {inherit name text; destination = "/${name}";};
|
||||
|
||||
/*
|
||||
* Writes a text file to /nix/store/<store path> and marks the file as executable.
|
||||
*
|
||||
@@ -117,13 +118,14 @@ rec {
|
||||
*
|
||||
*/
|
||||
writeScript = name: text: writeTextFile {inherit name text; executable = true;};
|
||||
|
||||
/*
|
||||
* Writes a text file to /nix/store/<store path>/bin/<name> and
|
||||
* marks the file as executable.
|
||||
*
|
||||
* Example:
|
||||
* # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
|
||||
* writeScript "my-file"
|
||||
* writeScriptBin "my-file"
|
||||
* ''
|
||||
* Contents of File
|
||||
* '';
|
||||
@@ -132,12 +134,38 @@ rec {
|
||||
writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";};
|
||||
|
||||
/*
|
||||
* Writes a Shell script and check its syntax. Automatically includes interpreter
|
||||
* above the contents passed.
|
||||
* Similar to writeScript. Writes a Shell script and checks its syntax.
|
||||
* Automatically includes interpreter above the contents passed.
|
||||
*
|
||||
* Example:
|
||||
* # Writes my-file to /nix/store/<store path>/my-file and makes executable.
|
||||
* writeShellScript "my-file"
|
||||
* ''
|
||||
* Contents of File
|
||||
* '';
|
||||
*
|
||||
*/
|
||||
writeShellScript = name: text:
|
||||
writeTextFile {
|
||||
inherit name;
|
||||
executable = true;
|
||||
text = ''
|
||||
#!${runtimeShell}
|
||||
${text}
|
||||
'';
|
||||
checkPhase = ''
|
||||
${stdenv.shell} -n $out
|
||||
'';
|
||||
};
|
||||
|
||||
/*
|
||||
* Similar to writeShellScript and writeScriptBin.
|
||||
* Writes an executable Shell script to /nix/store/<store path>/bin/<name> and checks its syntax.
|
||||
* Automatically includes interpreter above the contents passed.
|
||||
*
|
||||
* Example:
|
||||
* # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable.
|
||||
* writeScript "my-file"
|
||||
* writeShellScriptBin "my-file"
|
||||
* ''
|
||||
* Contents of File
|
||||
* '';
|
||||
|
||||
Reference in New Issue
Block a user