ausbin/nsdo

Package fails to build on Arch Linux

Closed this issue · 2 comments

Hi, I wanted to try nsdo-git from the AUR. Build fails with the below warnings and error:

cc -march=native -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now  nsdo.c   -o nsdo
gzip --best -f -k nsdo.1
sed 's|PREFIX|/usr|g' <netns@.service.proto >netns@.service
sed 's|PREFIX|/usr|g' <anyconnect/openconnect@.service.proto >anyconnect/openconnect@.service
nsdo.c: In function ‘inode_in_nspath’:
nsdo.c:107:13: warning: implicit declaration of function ‘asprintf’; did you mean ‘vsprintf’? [-Wimplicit-function-declaration]
  107 |         if (asprintf(&nspath, "%s/%s", NETNS_PATH, ns->d_name) == -1) {
      |             ^~~~~~~~
      |             vsprintf
nsdo.c: In function ‘lookup_and_setns’:
nsdo.c:182:9: warning: implicit declaration of function ‘setns’; did you mean ‘setenv’? [-Wimplicit-function-declaration]
  182 |     if (setns(nsfd, nstype) == -1) {
      |         ^~~~~
      |         setenv
nsdo.c: In function ‘main’:
nsdo.c:229:56: error: ‘CLONE_NEWNET’ undeclared (first use in this function)
  229 |     if (!lookup_and_setns(argv[ARG_NETNS], NETNS_PATH, CLONE_NEWNET, 0))
      |                                                        ^~~~~~~~~~~~
nsdo.c:229:56: note: each undeclared identifier is reported only once for each function it appears in
nsdo.c:243:58: error: ‘CLONE_NEWNS’ undeclared (first use in this function)
  243 |     if (!lookup_and_setns(argv[ARG_NETNS], MOUNTNS_PATH, CLONE_NEWNS, 1))
      |                                                          ^~~~~~~~~~~
make: *** [<builtin>: nsdo] Error 1
==> ERROR: A failure occurred in build().
    Aborting...

Is there a way to fix this?

For the first one, asprintf is a GNU extension, so you need to tell the compiler that. I am guessing that your $CFLAGS environment variable is set to something and is wiping out this default CFLAGS value in the Makefile:

https://github.com/ausbin/nsdo/blob/master/Makefile#L1

I would unset CFLAGS and try again

Thanks, that worked!