void-packages/srcpkgs/elogind/patches/004-musl-program_invocation...

56 lines
2.1 KiB
Diff

Using the libc program_invocation_short_name results in a linker error:
/usr/bin/ld.gold: error: src/login/loginctl.o: cannot make copy relocation
for protected symbol 'program_invocation_short_name', defined in
/usr/lib/gcc/x86_64-linux-musl/6.3.0/../../../../lib/libc.so
Replace it with basename(argv[0]) which gives the same result.
--- src/login/inhibit.c 2015-04-19 13:32:24.639347469 +0200
+++ src/login/inhibit.c 2017-03-04 14:13:27.885132151 +0100
@@ -124,7 +125,8 @@
return 0;
}
-static void help(void) {
+static void help(int argc, char* argv[]) {
+ char* short_name = basename(argv[0]);
printf("%s [OPTIONS...] {COMMAND} ...\n\n"
"Execute a process while inhibiting shutdown/sleep/idle.\n\n"
" -h --help Show this help\n"
@@ -137,7 +139,7 @@
" --why=STRING A descriptive string why is being inhibited\n"
" --mode=MODE One of block or delay\n"
" --list List active inhibitors\n"
- , program_invocation_short_name);
+ , short_name);
}
static int parse_argv(int argc, char *argv[]) {
@@ -172,7 +174,7 @@
switch (c) {
case 'h':
- help();
+ help(argc, argv);
return 0;
case ARG_VERSION:
--- src/login/loginctl.c 2015-09-01 13:12:13.079341932 +0200
+++ src/login/loginctl.c 2017-03-04 14:07:33.971586311 +0100
@@ -1395,6 +1394,7 @@
}
static int help(int argc, char *argv[], void *userdata) {
+ char* short_name = basename(argv[0]);
printf("%s [OPTIONS...] {COMMAND} ...\n\n"
"Send control commands to or query the login manager.\n\n"
@@ -1446,7 +1446,7 @@
" suspend Suspend the machine to memory\n"
" hibernate Suspend the machine to disk\n"
" hybrid-sleep Suspend the machine to memory and disk\n"
- , program_invocation_short_name);
+ , short_name);
return 0;
}