So as part of my migration from C7 to R9 I need to install INN on my new machine. Previously I used the version from EPEL, but this hasn’t been built for 9. And there’s a new version out. So I thought I’d build my own, based on the work EPEL had previously done.
Now I can get most of the way, but as part of the “install” phase it tries to install files as news:news. That’d imply creating the user on my build server and running rpmbuild as root.
Looking further, It’s clearly not meant to be run on the host OS 'cos of sections like this in %post
So I thought I’d try out mock. But this fails the same way, the user doesn’t exist. And, of course, the build environments are transitory so even if I do a mock --shell and add the user/group the next time I try to do a rebuild from the SRPM it does a clean up
So how can I add users and groups inside the mock tree during this build? I don’t see CLI options. Google isn’t helpful 'cos all the questions referring to users is talking about the OS environment. I also tried to find EPEL build logs to see if they had a hint, but I was unsuccessful at finding them as well!
Am I going about this the right way, or is there a different tool that should be used to build this?
To clarify what you’re seeing (and for other readers who stumble upon this post): You’re still talking about the %build phase. It looks like things are “installing” during the build, but that’s not actually the case. This is just what is happening during make. The actual “install” is during %install where make install is ran.
If you look at %build and %install in the spec file, there’s nothing that implies news exists on the builder. (The %configure part of %build does not count). The implication is that %pre creates the user and ownership of files/directories is taken care of by %files during package installation, not build. Remember this for later down in this post.
You should almost never build a package in a non-clean environment. Always, always, always use mock to build an RPM.
You don’t. The issue is how you’re invoking/running mock. The behavior you’re describing is not what is occurring for me.
But I think you’ve provided a clue, anyway… the FC41 version of the srpm has only the one patch file (the epel version has 11), and this make it clearer what’s going on; this one patch file is mangling the makefile.in to remove references to “-o news -g news” and that’s howo it’s working around it.
There is also a reason for the number of patches between EPEL7 (2.5.5) and Fedora (2.7.1). A lot of patches in EPEL7 made changes that aren’t needed in 2.7.X.
[rpmbuild@router inn-2.5.5]$ grep 'xroot' * -R
backends/Makefile: if [ x"$$ME" = xroot ] ; then \
. . .
touch $@
chown $(RUNASUSER) $@
chgrp $(RUNASGROUP) $@
chmod $(FILEMODE) $@
. . .
[rpmbuild@router inn-2.7.1]$ grep xroot * -R
backends/Makefile: if [ x"$$ME" = xroot ] ; then \
Makefile: if [ x"$$ME" = xroot ] ; then \
site/Makefile: if [ x"$$ME" = xroot ] ; then \
site/Makefile: if [ x"$$ME" = xroot ] ; then \
site/Makefile: if [ x"$$ME" = xroot ] || [ x"$$ME" = x"$(RUNASUSER)" ] ; then \
. . .
if [ x"$$ME" = xroot ] ; then \
chown $(RUNASUSER) $@ ; \
chgrp $(RUNASGROUP) $@ ; \
fi
. . .
This was the only reason why I brought up root. The assumption is you were using the same singular patch between the two and even with it, you were still getting errors due to running as root.
Yeah, the patch needed a minor adjustment to work with 2.7.2 and there’s a few extra files to add in to the spec file, but I’ve been able to build a new rpm.