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
21
pkgs/test/make-binary-wrapper/add-flags.c
Normal file
21
pkgs/test/make-binary-wrapper/add-flags.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char **argv_tmp = calloc(5 + argc, sizeof(*argv_tmp));
|
||||
assert(argv_tmp != NULL);
|
||||
argv_tmp[0] = argv[0];
|
||||
argv_tmp[1] = "-x";
|
||||
argv_tmp[2] = "-y";
|
||||
argv_tmp[3] = "-z";
|
||||
argv_tmp[4] = "-abc";
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
argv_tmp[4 + i] = argv[i];
|
||||
}
|
||||
argv_tmp[4 + argc] = NULL;
|
||||
argv = argv_tmp;
|
||||
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
2
pkgs/test/make-binary-wrapper/add-flags.cmdline
Normal file
2
pkgs/test/make-binary-wrapper/add-flags.cmdline
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
--add-flags "-x -y -z" \
|
||||
--add-flags -abc
|
||||
6
pkgs/test/make-binary-wrapper/add-flags.env
Normal file
6
pkgs/test/make-binary-wrapper/add-flags.env
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
CWD=SUBST_CWD
|
||||
SUBST_ARGV0
|
||||
-x
|
||||
-y
|
||||
-z
|
||||
-abc
|
||||
7
pkgs/test/make-binary-wrapper/argv0.c
Normal file
7
pkgs/test/make-binary-wrapper/argv0.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
argv[0] = "alternative-name";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
1
pkgs/test/make-binary-wrapper/argv0.cmdline
Normal file
1
pkgs/test/make-binary-wrapper/argv0.cmdline
Normal file
|
|
@ -0,0 +1 @@
|
|||
--argv0 alternative-name
|
||||
2
pkgs/test/make-binary-wrapper/argv0.env
Normal file
2
pkgs/test/make-binary-wrapper/argv0.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
CWD=SUBST_CWD
|
||||
alternative-name
|
||||
7
pkgs/test/make-binary-wrapper/basic.c
Normal file
7
pkgs/test/make-binary-wrapper/basic.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
0
pkgs/test/make-binary-wrapper/basic.cmdline
Normal file
0
pkgs/test/make-binary-wrapper/basic.cmdline
Normal file
2
pkgs/test/make-binary-wrapper/basic.env
Normal file
2
pkgs/test/make-binary-wrapper/basic.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
CWD=SUBST_CWD
|
||||
SUBST_ARGV0
|
||||
11
pkgs/test/make-binary-wrapper/chdir.c
Normal file
11
pkgs/test/make-binary-wrapper/chdir.c
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
assert_success(chdir("./tmp/foo"));
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
1
pkgs/test/make-binary-wrapper/chdir.cmdline
Normal file
1
pkgs/test/make-binary-wrapper/chdir.cmdline
Normal file
|
|
@ -0,0 +1 @@
|
|||
--chdir ./tmp/foo
|
||||
2
pkgs/test/make-binary-wrapper/chdir.env
Normal file
2
pkgs/test/make-binary-wrapper/chdir.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
CWD=SUBST_CWD/tmp/foo
|
||||
SUBST_ARGV0
|
||||
53
pkgs/test/make-binary-wrapper/combination.c
Normal file
53
pkgs/test/make-binary-wrapper/combination.c
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
void set_env_prefix(char *env, char *sep, char *prefix) {
|
||||
char *existing = getenv(env);
|
||||
if (existing) {
|
||||
char *val;
|
||||
assert_success(asprintf(&val, "%s%s%s", prefix, sep, existing));
|
||||
assert_success(setenv(env, val, 1));
|
||||
free(val);
|
||||
} else {
|
||||
assert_success(setenv(env, prefix, 1));
|
||||
}
|
||||
}
|
||||
|
||||
void set_env_suffix(char *env, char *sep, char *suffix) {
|
||||
char *existing = getenv(env);
|
||||
if (existing) {
|
||||
char *val;
|
||||
assert_success(asprintf(&val, "%s%s%s", existing, sep, suffix));
|
||||
assert_success(setenv(env, val, 1));
|
||||
free(val);
|
||||
} else {
|
||||
assert_success(setenv(env, suffix, 1));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
assert_success(setenv("MESSAGE", "HELLO", 0));
|
||||
set_env_prefix("PATH", ":", "/usr/bin/");
|
||||
set_env_suffix("PATH", ":", "/usr/local/bin/");
|
||||
putenv("MESSAGE2=WORLD");
|
||||
|
||||
char **argv_tmp = calloc(4 + argc, sizeof(*argv_tmp));
|
||||
assert(argv_tmp != NULL);
|
||||
argv_tmp[0] = argv[0];
|
||||
argv_tmp[1] = "-x";
|
||||
argv_tmp[2] = "-y";
|
||||
argv_tmp[3] = "-z";
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
argv_tmp[3 + i] = argv[i];
|
||||
}
|
||||
argv_tmp[3 + argc] = NULL;
|
||||
argv = argv_tmp;
|
||||
|
||||
argv[0] = "my-wrapper";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
6
pkgs/test/make-binary-wrapper/combination.cmdline
Normal file
6
pkgs/test/make-binary-wrapper/combination.cmdline
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
--argv0 my-wrapper \
|
||||
--set-default MESSAGE HELLO \
|
||||
--prefix PATH : /usr/bin/ \
|
||||
--suffix PATH : /usr/local/bin/ \
|
||||
--add-flags "-x -y -z" \
|
||||
--set MESSAGE2 WORLD
|
||||
8
pkgs/test/make-binary-wrapper/combination.env
Normal file
8
pkgs/test/make-binary-wrapper/combination.env
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
MESSAGE=HELLO
|
||||
PATH=/usr/bin/:/usr/local/bin/
|
||||
MESSAGE2=WORLD
|
||||
CWD=SUBST_CWD
|
||||
my-wrapper
|
||||
-x
|
||||
-y
|
||||
-z
|
||||
23
pkgs/test/make-binary-wrapper/cross.nix
Normal file
23
pkgs/test/make-binary-wrapper/cross.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{ stdenv
|
||||
, runCommand
|
||||
, makeBinaryWrapper
|
||||
, binutils
|
||||
, expectedArch ? stdenv.hostPlatform.parsed.cpu.name
|
||||
}:
|
||||
|
||||
runCommand "make-binary-wrapper-test-cross" {
|
||||
nativeBuildInputs = [
|
||||
makeBinaryWrapper
|
||||
binutils
|
||||
];
|
||||
inherit expectedArch;
|
||||
} ''
|
||||
touch prog
|
||||
chmod +x prog
|
||||
makeWrapper prog $out
|
||||
read -r _ arch < <($READELF --file-header $out | grep Machine:)
|
||||
if [[ ''${arch,,} != *"''${expectedArch,,}"* ]]; then
|
||||
echo "expected $expectedArch, got $arch"
|
||||
exit 1
|
||||
fi
|
||||
''
|
||||
61
pkgs/test/make-binary-wrapper/default.nix
Normal file
61
pkgs/test/make-binary-wrapper/default.nix
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, pkgsCross
|
||||
, makeBinaryWrapper
|
||||
, writeText
|
||||
, runCommand
|
||||
, runCommandCC
|
||||
}:
|
||||
|
||||
let
|
||||
env = { nativeBuildInputs = [ makeBinaryWrapper ]; };
|
||||
envCheck = runCommandCC "envcheck" env ''
|
||||
cc -Wall -Werror -Wpedantic -o $out ${./envcheck.c}
|
||||
'';
|
||||
makeGoldenTest = testname: runCommand "make-binary-wrapper-test-${testname}" env ''
|
||||
mkdir -p tmp/foo # for the chdir test
|
||||
|
||||
params=$(<"${./.}/${testname}.cmdline")
|
||||
eval "makeCWrapper /send/me/flags $params" > wrapper.c
|
||||
|
||||
diff wrapper.c "${./.}/${testname}.c"
|
||||
|
||||
if [ -f "${./.}/${testname}.env" ]; then
|
||||
eval "makeWrapper ${envCheck} wrapped $params"
|
||||
env -i ./wrapped > env.txt
|
||||
sed "s#SUBST_ARGV0#${envCheck}#;s#SUBST_CWD#$PWD#" \
|
||||
"${./.}/${testname}.env" > golden-env.txt
|
||||
if ! diff env.txt golden-env.txt; then
|
||||
echo "env/argv should be:"
|
||||
cat golden-env.txt
|
||||
echo "env/argv output is:"
|
||||
cat env.txt
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# without a golden env, we expect the wrapper compilation to fail
|
||||
! eval "makeWrapper ${envCheck} wrapped $params" &> error.txt
|
||||
fi
|
||||
|
||||
cp wrapper.c $out
|
||||
'';
|
||||
tests = lib.genAttrs [
|
||||
"add-flags"
|
||||
"argv0"
|
||||
"basic"
|
||||
"chdir"
|
||||
"combination"
|
||||
"env"
|
||||
"inherit-argv0"
|
||||
"invalid-env"
|
||||
"overlength-strings"
|
||||
"prefix"
|
||||
"suffix"
|
||||
] makeGoldenTest // lib.optionalAttrs (! stdenv.isDarwin) {
|
||||
cross = pkgsCross.aarch64-multiplatform.callPackage ./cross.nix { };
|
||||
};
|
||||
in
|
||||
|
||||
writeText "make-binary-wrapper-tests" ''
|
||||
${lib.concatStringsSep "\n" (builtins.attrValues tests)}
|
||||
'' // tests
|
||||
14
pkgs/test/make-binary-wrapper/env.c
Normal file
14
pkgs/test/make-binary-wrapper/env.c
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
putenv("PART1=HELLO");
|
||||
assert_success(setenv("PART2", "WORLD", 0));
|
||||
assert_success(unsetenv("SOME_OTHER_VARIABLE"));
|
||||
putenv("PART3=\"!!\n\"");
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
4
pkgs/test/make-binary-wrapper/env.cmdline
Normal file
4
pkgs/test/make-binary-wrapper/env.cmdline
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
--set PART1 HELLO \
|
||||
--set-default PART2 WORLD \
|
||||
--unset SOME_OTHER_VARIABLE \
|
||||
--set PART3 $'"!!\n"'
|
||||
6
pkgs/test/make-binary-wrapper/env.env
Normal file
6
pkgs/test/make-binary-wrapper/env.env
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
PART1=HELLO
|
||||
PART2=WORLD
|
||||
PART3="!!
|
||||
"
|
||||
CWD=SUBST_CWD
|
||||
SUBST_ARGV0
|
||||
22
pkgs/test/make-binary-wrapper/envcheck.c
Normal file
22
pkgs/test/make-binary-wrapper/envcheck.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char **argv, char **envp) {
|
||||
for (char **env = envp; *env != 0; ++env) {
|
||||
puts(*env);
|
||||
}
|
||||
|
||||
char cwd[PATH_MAX];
|
||||
if (getcwd(cwd, sizeof(cwd))) {
|
||||
printf("CWD=%s\n", cwd);
|
||||
} else {
|
||||
perror("getcwd() error");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int i=0; i < argc; ++i) {
|
||||
puts(argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
6
pkgs/test/make-binary-wrapper/inherit-argv0.c
Normal file
6
pkgs/test/make-binary-wrapper/inherit-argv0.c
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
1
pkgs/test/make-binary-wrapper/inherit-argv0.cmdline
Normal file
1
pkgs/test/make-binary-wrapper/inherit-argv0.cmdline
Normal file
|
|
@ -0,0 +1 @@
|
|||
--inherit-argv0
|
||||
2
pkgs/test/make-binary-wrapper/inherit-argv0.env
Normal file
2
pkgs/test/make-binary-wrapper/inherit-argv0.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
CWD=SUBST_CWD
|
||||
./wrapped
|
||||
14
pkgs/test/make-binary-wrapper/invalid-env.c
Normal file
14
pkgs/test/make-binary-wrapper/invalid-env.c
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
putenv("==TEST1");
|
||||
#error Illegal environment variable name `=` (cannot contain `=`)
|
||||
assert_success(setenv("", "TEST2", 0));
|
||||
#error Environment variable name can't be empty.
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
2
pkgs/test/make-binary-wrapper/invalid-env.cmdline
Normal file
2
pkgs/test/make-binary-wrapper/invalid-env.cmdline
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
--set "=" "TEST1" \
|
||||
--set-default "" "TEST2"
|
||||
25
pkgs/test/make-binary-wrapper/overlength-strings.c
Normal file
25
pkgs/test/make-binary-wrapper/overlength-strings.c
Normal file
File diff suppressed because one or more lines are too long
1
pkgs/test/make-binary-wrapper/overlength-strings.cmdline
Normal file
1
pkgs/test/make-binary-wrapper/overlength-strings.cmdline
Normal file
File diff suppressed because one or more lines are too long
3
pkgs/test/make-binary-wrapper/overlength-strings.env
Normal file
3
pkgs/test/make-binary-wrapper/overlength-strings.env
Normal file
File diff suppressed because one or more lines are too long
26
pkgs/test/make-binary-wrapper/prefix.c
Normal file
26
pkgs/test/make-binary-wrapper/prefix.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
void set_env_prefix(char *env, char *sep, char *prefix) {
|
||||
char *existing = getenv(env);
|
||||
if (existing) {
|
||||
char *val;
|
||||
assert_success(asprintf(&val, "%s%s%s", prefix, sep, existing));
|
||||
assert_success(setenv(env, val, 1));
|
||||
free(val);
|
||||
} else {
|
||||
assert_success(setenv(env, prefix, 1));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
set_env_prefix("PATH", ":", "/usr/bin/");
|
||||
set_env_prefix("PATH", ":", "/usr/local/bin/");
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
2
pkgs/test/make-binary-wrapper/prefix.cmdline
Normal file
2
pkgs/test/make-binary-wrapper/prefix.cmdline
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
--prefix PATH : /usr/bin/ \
|
||||
--prefix PATH : /usr/local/bin/
|
||||
3
pkgs/test/make-binary-wrapper/prefix.env
Normal file
3
pkgs/test/make-binary-wrapper/prefix.env
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
PATH=/usr/local/bin/:/usr/bin/
|
||||
CWD=SUBST_CWD
|
||||
SUBST_ARGV0
|
||||
26
pkgs/test/make-binary-wrapper/suffix.c
Normal file
26
pkgs/test/make-binary-wrapper/suffix.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
void set_env_suffix(char *env, char *sep, char *suffix) {
|
||||
char *existing = getenv(env);
|
||||
if (existing) {
|
||||
char *val;
|
||||
assert_success(asprintf(&val, "%s%s%s", existing, sep, suffix));
|
||||
assert_success(setenv(env, val, 1));
|
||||
free(val);
|
||||
} else {
|
||||
assert_success(setenv(env, suffix, 1));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
set_env_suffix("PATH", ":", "/usr/bin/");
|
||||
set_env_suffix("PATH", ":", "/usr/local/bin/");
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
2
pkgs/test/make-binary-wrapper/suffix.cmdline
Normal file
2
pkgs/test/make-binary-wrapper/suffix.cmdline
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
--suffix PATH : /usr/bin/ \
|
||||
--suffix PATH : /usr/local/bin/
|
||||
3
pkgs/test/make-binary-wrapper/suffix.env
Normal file
3
pkgs/test/make-binary-wrapper/suffix.env
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
PATH=/usr/bin/:/usr/local/bin/
|
||||
CWD=SUBST_CWD
|
||||
SUBST_ARGV0
|
||||
Loading…
Add table
Add a link
Reference in a new issue