0

I'm trying to create a fake /etc/hosts to set the hostname in a Mock-built RPM. This is CentOS7 and the Mock/rpmbuild are not new enough to understand the new Fedora _buildhost macro.

So I configured a file thusly:

config_opts['files']['etc/hosts']="""\
127.0.0.1 build.machine.com
"""

This is at the end of my target specific config file. Unfortunately this seems to be completely ignored.

I've looked at the /var/lib/mock/<target>/root/etc/hosts and this is identical to the build machine's standard /etc/hosts.

Anyone able to shed some light on what I'm doing wrong?

  • OK, managed to get at least the file to be written but this seems to have no affect. The ../root/etc/hosts is as I expect but the build host in the resulting RPMs is always the true hostname of my machine not the 'dummy' name that I actually wanted. – Paul D Smith Aug 6 '18 at 9:24
1

If you are using 1.4.x version of Mock then it use by default systemd-nspawn container which overwrite some file. At least resolv.conf and may overwrite hosts as well. You may try --old-chroot option of Mock.

But if you want just overwrite hostname then you can put in config:

config_opts['hostname'] = 'my.own.hostname'
  • Thanks - looks like CentOS 7 is still using quite an old Mock (1.2.17) but it does have the '--old-chroot' option so perhaps I'll give that a try. – Paul D Smith Aug 9 '18 at 16:04
  • The new version is in EPEL fedoraproject.org/wiki/EPEL – msuchy Aug 11 '18 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.