I'm aiming to translate a Debian package to an RPM package to install it on a CentOS Linux 7 (Red Hat). I used alien to accomplish it: alien --to-rpm --scripts --keep-version --generate debian_pkg.deb. I use the --generate flag to create a directory for building a package from, because I want to add the runtime dependencies to the spec file. To do so, I add this line: Requires: nodejs tomcat8 java-1.8.0-openjdk java-1.8.0-openjdk-devel. Then I try to create the package: rpmbuild -ba <package_name>.spec, but it ends abruptly with this error:

Processing files: <package_name>
error: Directory not found: /root/rpmbuild/BUILDROOT/<package_name>/srv
error: Directory not found: /root/rpmbuild/BUILDROOT/<package_name>/srv/tmp
error: File not found: /root/rpmbuild/BUILDROOT/<package_name>/srv/tmp/file.tar.gz
error: File not found: /root/rpmbuild/BUILDROOT/<package_name>/usr/share/doc/frontend/README.Debian
error: File not found: /root/rpmbuild/BUILDROOT/<package_name>/usr/share/doc/frontend/changelog.Debian.gz
error: File not found: /root/rpmbuild/BUILDROOT/<package_name>/usr/share/doc/frontend/copyright

RPM build errors:
    Directory not found: /root/rpmbuild/BUILDROOT/<package_name>/srv
    Directory not found: /root/rpmbuild/BUILDROOT/<package_name>/srv/tmp
    File not found: /root/rpmbuild/BUILDROOT/<package_name>/srv/tmp/file.tar.gz
    File not found: /root/rpmbuild/BUILDROOT/<package_name>/usr/share/doc/frontend/README.Debian
    File not found: /root/rpmbuild/BUILDROOT/<package_name>/usr/share/doc/frontend/changelog.Debian.gz
    File not found: /root/rpmbuild/BUILDROOT/<package_name>/usr/share/doc/frontend/copyright

I searched the internet and found that it's linked to the %install section and more specifically %{buildroot}, but I can't get my head around the problem and fix it. Can somebody give me a hand?



Here is the spec file in essence:

Buildroot: /home/<package_dir>
Version: 1.0
Release: 849
Distribution: Debian
Group: Converted/misc
Requires: nodejs tomcat8 java-1.8.0-openjdk java-1.8.0-openjdk-devel

%define _rpmdir ../
%define _rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
%define _unpackaged_files_terminate_build 0

# some shell script

# some shell script

mkdir -p %{buildroot}/usr/share/doc/
mkdir -p %{buildroot}/usr/share/doc/frontend/

%dir "/srv/"
%dir "/srv/tmp/"
%dir "/usr/"
%dir "/usr/share/"
%dir "/usr/share/doc/"
%dir "/usr/share/doc/frontend/"
  • It's hard to debug this without more context... Can you post more from the spec file? What about the build logs leading to.that point? – filbranden Feb 6 '19 at 14:02
  • @filbranden thanks for your reply. I've updated the post with a summary of the spec file. – Bastian Nanchen Feb 6 '19 at 14:16

UPDATE: The problem you're having is with the Buildroot: tag in the specfile.

In modern systems (and perhaps yours included), Buildroot: in a spec file is no longer supported and it's now ignored.

See this post on LinuxQuestions about that:

Fedora (as of F-10) does not require the presence of the BuildRoot tag in the spec and if one is defined it will be ignored.

You can work around this by passing rpmbuild a --buildroot argument so it uses /home/<package_dir>. (It's possible this might have adverse side effects such as removing those contents after the build is done, which apparently is also the default now.)

In fact, passing rpmbuild and explicit --buildroot is what alien started doing since rpm 4.7.0 started ignoring Buildroot:, as you can see in this commit.

The specfile isn't really installing any sources or creating any files.

The only thing happening in the %install section is creating an (empty) /usr/share/doc/frontend/ directory.

Since the specfile starts by specifying Buildroot: /home/<package_dir>, I imagine it expected that directory to be previously populated, so that the rpmbuild step would be able to simply pick up the already staged contents from there and just package them.

If you run alien again from the same .deb (in other words, start over), do you get a /home/<package_dir> that is populated with e.g. srv/tmp/file.tar.gz? If so, rpmbuild will work when you run it at that point.

It is possible some macro in your rpmbuild is cleaning %{buildroot} after building the rpm (though I'd say that's unusual, since typically that requires a %clean section in your specfile.) Check whether that's the case, if right after a first (successful) rpmbuild, the files under /home/<package_dir> are gone, in which case further runs of rpmbuild will fail as you describe...

  • Yes, when running alien I get two directories besides the spec file; srv/tmp/, which contains file.tar.gz and usr/share/doc/dblab-frontend/ which contains README.Debian, copyright and changelog.Debian.gz. – Bastian Nanchen Feb 6 '19 at 14:50
  • Ah! So it seems there's a disconnect between /root/rpmbuild/BUILDROOT/<package_name> and /home/<package_dir> specified as Buildroot:! Have you tried to use rpmbuild (and alien) as a non-root user? – filbranden Feb 6 '19 at 14:57
  • I've just tried to run rpmbuild as a non-root user, but it gives the same errors as before. Should I specify another Buildroot maybe? – Bastian Nanchen Feb 6 '19 at 15:05
  • If you pass rpmbuild a --buildroot /home/<package_dir> explicitly, does that work? Or do you still get the /root/rpmbuild/BUILDROOT paths? – filbranden Feb 6 '19 at 15:31
  • 1
    Thanks for your time @filbranden. I appreciate it :) – Bastian Nanchen Feb 7 '19 at 7:19

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.