Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not build from makedeb and makepkg #29

Open
gearhead opened this issue Oct 25, 2023 · 8 comments
Open

Does not build from makedeb and makepkg #29

gearhead opened this issue Oct 25, 2023 · 8 comments

Comments

@gearhead
Copy link

gearhead commented Oct 25, 2023

Similar to an issue I set with shairport-sync, this will not build as a package with either makedeb (for debian/RPi) nor makepkg (Arch) due to a permissions problem when it tries to create a group for nqptp.

Using either of these methods allows for nice build of installable/up[grade-able packages, FWIW. Under Arch, this patch allows shairport-sync to build.

I will have to craft a similar one for nqptp.

Thought you'd like to know.

This is the error I get:

[#] Starting package()...
make[1]: Entering directory '/Rune_dev/RuneOS/rpios_packages/nqptp/src/nqptp'
make[1]: Nothing to be done for 'install-data-am'.
 /usr/bin/mkdir -p '/Rune_dev/RuneOS/rpios_packages/nqptp/pkg/nqptp-git//usr/bin'
  /usr/bin/install -c nqptp '/Rune_dev/RuneOS/rpios_packages/nqptp/pkg/nqptp-git//usr/bin'
make  install-exec-hook
make[2]: Entering directory '/Rune_dev/RuneOS/rpios_packages/nqptp/src/nqptp'
getent group nqptp &>/dev/null || groupadd -r nqptp &>/dev/null
make[2]: *** [Makefile:817: install-exec-hook] Error 10
make[2]: Leaving directory '/Rune_dev/RuneOS/rpios_packages/nqptp/src/nqptp'
make[1]: *** [Makefile:734: install-exec-am] Error 2
make[1]: Leaving directory '/Rune_dev/RuneOS/rpios_packages/nqptp/src/nqptp'
make: *** [Makefile:673: install-am] Error 2
[! package()] A failure occurred in package().
    Aborting...
@gearhead gearhead changed the title Doe snot build from makedeb and makepkg Does not build from makedeb and makepkg Oct 25, 2023
@mikebrady
Copy link
Owner

Thanks for the post and the suggestions. Let me take a look and try to understand this.

@gearhead
Copy link
Author

I may have a solution. I comment out the lines in Makefile.am that creates the user and group.

# getent group nqptp &>/dev/null || groupadd -r nqptp &>/dev/null
# getent passwd nqptp &> /dev/null || useradd -r -M -g nqptp -s /usr/sbin/nologin nqptp &>/dev/null

I create a sysusers file that looks like this:

u nqptp - "nqptp user" /dev/null /usr/sbin/nologin
g nqptp -

and then tell the package maker to put this in the package:
install -D -m644 "$srcdir"/nqptp.sysusers "$pkgdir"/usr/lib/sysusers.d/nqptp.conf
I will see if this works. I inferred this from other PKGBUILDs that I use that also create users. No guarantees that it does the same thing....

@mikebrady
Copy link
Owner

This is very interesting, thanks!

@mikebrady
Copy link
Owner

This looks like it would work for systemd-based systems, but not for systems based on the older System V. Very interesting.

@mikebrady
Copy link
Owner

I see some other contributors mentioned this in the past. Sigh.

@mikebrady
Copy link
Owner

Okay, so I've taken a good look at this. Unfortunately, (AFAIK), the otherwise very nice scheme you propose above doesn't quite work.

As you write, if one creates a file nqptp.sysusers with the following contents (slightly different to yours):

u nqptp - "nqptp" /dev/null /usr/sbin/nologin

and if the contents of Makefile.am are changed to:

bin_PROGRAMS = nqptp
nqptp_SOURCES = nqptp.c nqptp-clock-sources.c nqptp-message-handlers.c nqptp-utilities.c general-utilities.c debug.c

AM_CFLAGS = -fno-common -Wall -Wextra -pthread --include=config.h
CLEANFILES =

if USE_GIT_VERSION
nqptp.c: gitversion.h
gitversion.h: .git/index
	echo "// Do not edit!" > gitversion.h
	echo "// This file is automatically generated by 'git describe --tags --dirty --broken', if available." >> gitversion.h
	echo -n "  char git_version_string[] = \"" >> gitversion.h
	git describe --tags --dirty --broken | tr -d '[[:space:]]' >> gitversion.h
	echo "\";" >> gitversion.h
FORCE: ;
CLEANFILES += gitversion.h
endif


install-exec-hook:
if BUILD_FOR_LINUX
# Note: NQPTP runs as user/group nqptp/nqptp on Linux.
# Access is given via AmbientCapabilities in the service file.
# If you want to run it from the command line, e.g. for debugging, run it as root user.
# no installer for System V
if INSTALL_SYSTEMD_STARTUP
	install -d $(DESTDIR)/usr/lib/sysusers.d
	install -m 0644 nqptp.sysusers $(DESTDIR)/usr/lib/sysusers.d/nqptp.conf
	[ -e $(DESTDIR)$(libdir)/systemd/system ] || mkdir -p $(DESTDIR)$(libdir)/systemd/system
# don't replace a service file if it already exists...
	[ -e $(DESTDIR)$(libdir)/systemd/system/nqptp.service ] || cp nqptp.service $(DESTDIR)$(libdir)/systemd/system
endif
endif

if BUILD_FOR_FREEBSD
# NQPTP runs as root on FreeBSD to access ports 319 and 320
if INSTALL_FREEBSD_STARTUP
	cp nqptp.freebsd /usr/local/etc/rc.d/nqptp
	chmod 555 /usr/local/etc/rc.d/nqptp
endif
endif

Then the user and group nqptp will be created. This is a nice "declarative" solution. However, the unfortunate problem (again, AFAIK) is that the nqptp is not created during installation -- it will only be created when the system reboots.

As the Bard didn't quite say: "if this be error, and upon me proved... I'd love to be corrected!"

@gearhead
Copy link
Author

Agreed that the sysusers file is read at boot, but if we need it 'now' can't we not also run 'systemctl restart systemd-sysusers'. Will that solve it for us?

fwcd added a commit to archsink/pkgbuilds that referenced this issue Nov 8, 2023
@mikebrady
Copy link
Owner

Hi there. Just wondering if the most recent change in the development branch will have any positive impact on this -- the systemd DynamicUser facility is used instead of defining the nqptp user and group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants