4

While building kernel rpm packagerpmbuild does it's slow "Checking for unpackaged file(s)" check:

$ make -j$(nproc) binrpm-pkg
...
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/user/rpmbuild/BUI
LDROOT/kernel-4.17.0_rc5_next_20180517_3.gd86d9e8_default+-98.x86_64

For kernel even on powerful machine it takes 30 mins. How to avoid that? I've tried to to avoid it with _unpackaged_files_terminate_build, but it didn't help:

echo "%_unpackaged_files_terminate_build    0" >> ~/.rpmmacros

Also adding --nocheck to rpmbuild call to binrpm-pkg target in scripts/package/Makefile didn't help.

But maybe it's something else wrong. When I build with configuration make allyesconfig rpm file has 168MB. RPM file builded with openSUSE Tumbleweed config has 647MB.

pevik
  • 4,523
  • 3
  • 33
  • 44

3 Answers3

3

Got same issue and found out what was happening.

If your rpmbuild is slow to process it doesn't come from /usr/lib/rpm/check-files script:
try to comment all its lines, you'll see that it's still hanging after that, even if this script is basically doing nothing anymore.

Executing :

strace -f -s900 rpmbuild [your args]

You'll see that between hangs, DNS calls are issued (calls to /usr/lib64/libresolv.so library) trying to resolve the hostname of your build machine, which fall on timeout after some time and then retries .

If your machine have a faulty DNS configuration or if your DNS server is not working, the rpmbuild process will hang on each launch.

To avoid those hangs:

  • correct your DNS configuration on your build machine, or
  • sudo rm -f /etc/resolv.conf on your build machine

The real question remaining is: Why a local process like rpmbuild is doing DNS calls?

pevik
  • 4,523
  • 3
  • 33
  • 44
  • 1
    I poked at the source code and added it to an answer below. TLDR: _buildhost is being set by RPM and for some reason it's deciding to canonicalize the hostname of the local machine. If you override it with a --define it skips the check. Useful for when you have 10s of RPMs. – ListsOfArrays Aug 30 '23 at 00:30
  • I'm not really sure if `sudo rm -f /etc/resolv.conf` is a good suggestion. (Maybe NetworkManager will survive this, but how about Wicked used in openSUSE?) – pevik Aug 30 '23 at 15:44
1

Unfortunately, I'm pretty sure you cannot stop it. Is it on a slow drive? Are you in an enterprise environment where /home/user is network-mounted?

What you tried to change simply says "if you find files that I didn't account for, make it a warning not an error."

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
  • I think the problem is in some config: when I build with configuration make allyesconfig rpm file has 168MB. RPM file builded with openSUSE Tumbleweed's config has 647MB and takes so long. No idea how to find "problematic" option. – pevik Jul 11 '18 at 08:42
1

For future reference, the problem line is in buildHost(void) inside build RPM.

Code:

    bhMacro = rpmExpand("%{?_buildhost}", NULL);
    if (strcmp(bhMacro, "") != 0) {
        rasprintf(&hostname, "%s", bhMacro);
    } else {
    hostname = rcalloc(NI_MAXHOST + 1, sizeof(*hostname));
    if (gethostname(hostname, NI_MAXHOST) == 0) {
        struct addrinfo *ai, hints;
        memset(&hints, 0, sizeof(hints));
        hints.ai_flags = AI_CANONNAME;

        if (getaddrinfo(hostname, NULL, &hints, &ai) == 0) {
        strcpy(hostname, ai->ai_canonname);
        freeaddrinfo(ai);
        } else {
        rpmlog(RPMLOG_WARNING,
                    _("Could not canonicalize hostname: %s\n"), hostname);
        }
    }

If you define _buildhost with hostname, it will skip the DNS call.

Example:

rpmbuild -bb --define "_buildhost $(hostname)" ./path/to/spec/file.spec

Note: the install will still hang on the "check files" part, but it's doing other stuff in the background, and the DNS call itself will be skipped.

pevik
  • 4,523
  • 3
  • 33
  • 44
ListsOfArrays
  • 442
  • 6
  • 14