uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
12
pkgs/build-support/trivial-builders/test/concat-test.nix
Normal file
12
pkgs/build-support/trivial-builders/test/concat-test.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{ callPackage, lib, pkgs, runCommand, concatText, writeText, hello, emptyFile }:
|
||||
let
|
||||
stri = writeText "pathToTest";
|
||||
txt1 = stri "abc";
|
||||
txt2 = stri hello;
|
||||
res = concatText "textToTest" [ txt1 txt2 ];
|
||||
in
|
||||
runCommand "test-concatPaths" { } ''
|
||||
diff -U3 <(cat ${txt1} ${txt2}) ${res}
|
||||
diff -U3 ${concatText "void" []} ${emptyFile}
|
||||
touch $out
|
||||
''
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{ pkgs ? import ../../../.. { config = {}; overlays = []; } }:
|
||||
pkgs.lib.mapAttrs
|
||||
(k: v: pkgs.writeDirectReferencesToFile v)
|
||||
(import ./sample.nix { inherit pkgs; })
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{ pkgs ? import ../../../.. { config = {}; overlays = []; } }:
|
||||
pkgs.lib.mapAttrs
|
||||
(k: v: pkgs.writeReferencesToFile v)
|
||||
(import ./sample.nix { inherit pkgs; })
|
||||
62
pkgs/build-support/trivial-builders/test/references-test.sh
Executable file
62
pkgs/build-support/trivial-builders/test/references-test.sh
Executable file
|
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
#
|
||||
# trivial-builders test
|
||||
#
|
||||
# -------------------------------------------------------------------------- #
|
||||
#
|
||||
# This file can be run independently (quick):
|
||||
#
|
||||
# $ pkgs/build-support/trivial-builders/references-test.sh
|
||||
#
|
||||
# or in the build sandbox with a ~20s VM overhead
|
||||
#
|
||||
# $ nix-build -A tests.trivial-builders.references
|
||||
#
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
# strict bash
|
||||
set -euo pipefail
|
||||
|
||||
# debug
|
||||
# set -x
|
||||
# PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
||||
|
||||
cd "$(dirname ${BASH_SOURCE[0]})" # nixpkgs root
|
||||
|
||||
if [[ -z ${SAMPLE:-} ]]; then
|
||||
echo "Running the script directly is currently not supported."
|
||||
echo "If you need to iterate, remove the raw path, which is not returned by nix-build."
|
||||
exit 1
|
||||
# sample=( `nix-build --no-out-link sample.nix` )
|
||||
# directRefs=( `nix-build --no-out-link invoke-writeDirectReferencesToFile.nix` )
|
||||
# references=( `nix-build --no-out-link invoke-writeReferencesToFile.nix` )
|
||||
# echo "sample: ${#sample[@]}"
|
||||
# echo "direct: ${#directRefs[@]}"
|
||||
# echo "indirect: ${#references[@]}"
|
||||
else
|
||||
# Injected by Nix (to avoid evaluating in a derivation)
|
||||
# turn them into arrays
|
||||
sample=($SAMPLE)
|
||||
directRefs=($DIRECT_REFS)
|
||||
references=($REFERENCES)
|
||||
fi
|
||||
|
||||
echo >&2 Testing direct references...
|
||||
for i in "${!sample[@]}"; do
|
||||
echo >&2 Checking '#'$i ${sample[$i]} ${directRefs[$i]}
|
||||
diff -U3 \
|
||||
<(sort <${directRefs[$i]}) \
|
||||
<(nix-store -q --references ${sample[$i]} | sort)
|
||||
done
|
||||
|
||||
echo >&2 Testing closure...
|
||||
for i in "${!sample[@]}"; do
|
||||
echo >&2 Checking '#'$i ${sample[$i]} ${references[$i]}
|
||||
diff -U3 \
|
||||
<(sort <${references[$i]}) \
|
||||
<(nix-store -q --requisites ${sample[$i]} | sort)
|
||||
done
|
||||
|
||||
echo 'OK!'
|
||||
54
pkgs/build-support/trivial-builders/test/references.nix
Normal file
54
pkgs/build-support/trivial-builders/test/references.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{ lib, testers, pkgs, writeText, hello, figlet, stdenvNoCC }:
|
||||
|
||||
# -------------------------------------------------------------------------- #
|
||||
#
|
||||
# trivial-builders test
|
||||
#
|
||||
# -------------------------------------------------------------------------- #
|
||||
#
|
||||
# This file can be run independently (quick):
|
||||
#
|
||||
# $ pkgs/build-support/trivial-builders/references-test.sh
|
||||
#
|
||||
# or in the build sandbox with a ~20s VM overhead
|
||||
#
|
||||
# $ nix-build -A tests.trivial-builders.references
|
||||
#
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
let
|
||||
invokeSamples = file:
|
||||
lib.concatStringsSep " " (
|
||||
lib.attrValues (import file { inherit pkgs; })
|
||||
);
|
||||
in
|
||||
testers.nixosTest {
|
||||
name = "nixpkgs-trivial-builders";
|
||||
nodes.machine = { ... }: {
|
||||
virtualisation.writableStore = true;
|
||||
|
||||
# Test runs without network, so we don't substitute and prepare our deps
|
||||
nix.settings.substituters = lib.mkForce [];
|
||||
environment.etc."pre-built-paths".source = writeText "pre-built-paths" (
|
||||
builtins.toJSON [hello figlet stdenvNoCC]
|
||||
);
|
||||
environment.variables = {
|
||||
SAMPLE = invokeSamples ./sample.nix;
|
||||
REFERENCES = invokeSamples ./invoke-writeReferencesToFile.nix;
|
||||
DIRECT_REFS = invokeSamples ./invoke-writeDirectReferencesToFile.nix;
|
||||
};
|
||||
};
|
||||
testScript =
|
||||
''
|
||||
machine.succeed("""
|
||||
${./references-test.sh} 2>/dev/console
|
||||
""")
|
||||
'';
|
||||
meta = {
|
||||
license = lib.licenses.mit; # nixpkgs license
|
||||
maintainers = with lib.maintainers; [
|
||||
roberth
|
||||
];
|
||||
description = "Run the Nixpkgs trivial builders tests";
|
||||
};
|
||||
}
|
||||
29
pkgs/build-support/trivial-builders/test/sample.nix
Normal file
29
pkgs/build-support/trivial-builders/test/sample.nix
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{ pkgs ? import ../../../.. { config = { }; overlays = [ ]; } }:
|
||||
let
|
||||
inherit (pkgs)
|
||||
figlet
|
||||
zlib
|
||||
hello
|
||||
writeText
|
||||
runCommand
|
||||
;
|
||||
in
|
||||
{
|
||||
hello = hello;
|
||||
figlet = figlet;
|
||||
zlib = zlib;
|
||||
zlib-dev = zlib.dev;
|
||||
norefs = writeText "hi" "hello";
|
||||
norefsDup = writeText "hi" "hello";
|
||||
helloRef = writeText "hi" "hello ${hello}";
|
||||
helloRefDup = writeText "hi" "hello ${hello}";
|
||||
path = ./invoke-writeReferencesToFile.nix;
|
||||
pathLike.outPath = ./invoke-writeReferencesToFile.nix;
|
||||
helloFigletRef = writeText "hi" "hello ${hello} ${figlet}";
|
||||
selfRef = runCommand "self-ref-1" {} "echo $out >$out";
|
||||
selfRef2 = runCommand "self-ref-2" {} ''echo "${figlet}, $out" >$out'';
|
||||
inherit (pkgs)
|
||||
emptyFile
|
||||
emptyDirectory
|
||||
;
|
||||
}
|
||||
34
pkgs/build-support/trivial-builders/test/write-text-file.nix
Normal file
34
pkgs/build-support/trivial-builders/test/write-text-file.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{ writeTextFile }:
|
||||
let
|
||||
veryWeirdName = ''here's a name with some "bad" characters, like spaces and quotes'';
|
||||
in writeTextFile {
|
||||
name = "weird-names";
|
||||
destination = "/etc/${veryWeirdName}";
|
||||
text = ''passed!'';
|
||||
checkPhase = ''
|
||||
# intentionally hardcode everything here, to make sure
|
||||
# Nix does not mess with file paths
|
||||
|
||||
name="here's a name with some \"bad\" characters, like spaces and quotes"
|
||||
fullPath="$out/etc/$name"
|
||||
|
||||
if [ -f "$fullPath" ]; then
|
||||
echo "[PASS] File exists!"
|
||||
else
|
||||
echo "[FAIL] File was not created at expected path!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
content=$(<"$fullPath")
|
||||
expected="passed!"
|
||||
|
||||
if [ "$content" = "$expected" ]; then
|
||||
echo "[PASS] Contents match!"
|
||||
else
|
||||
echo "[FAIL] File contents don't match!"
|
||||
echo " Expected: $expected"
|
||||
echo " Got: $content"
|
||||
exit 2
|
||||
fi
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{ callPackage, lib, pkgs, runCommand, writeText, writeStringReferencesToFile }:
|
||||
let
|
||||
sample = import ./sample.nix { inherit pkgs; };
|
||||
samplePaths = lib.unique (lib.attrValues sample);
|
||||
stri = x: "${x}";
|
||||
sampleText = writeText "sample-text" (lib.concatStringsSep "\n" (lib.unique (map stri samplePaths)));
|
||||
stringReferencesText =
|
||||
writeStringReferencesToFile
|
||||
((lib.concatMapStringsSep "fillertext"
|
||||
stri
|
||||
(lib.attrValues sample)) + ''
|
||||
STORE=${builtins.storeDir};\nsystemctl start bar-foo.service
|
||||
'');
|
||||
in
|
||||
runCommand "test-writeStringReferencesToFile" { } ''
|
||||
diff -U3 <(sort ${stringReferencesText}) <(sort ${sampleText})
|
||||
touch $out
|
||||
''
|
||||
Loading…
Add table
Add a link
Reference in a new issue