1

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?

Thanks!

UPDATE

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

%pre
# some shell script

%post
# some shell script

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

%files
%dir "/srv/"
%dir "/srv/tmp/"
"/srv/tmp/file.tar.gz"
%dir "/usr/"
%dir "/usr/share/"
%dir "/usr/share/doc/"
%dir "/usr/share/doc/frontend/"
"/usr/share/doc/frontend/README.Debian"
"/usr/share/doc/frontend/changelog.Debian.gz"
"/usr/share/doc/frontend/copyright"

1 Answers1

0

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...

filbranden
  • 21,113
  • 3
  • 58
  • 84
  • 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 06 '19 at 14:50
  • Ah! So it seems there's a disconnect between `/root/rpmbuild/BUILDROOT/` and `/home/` specified as Buildroot:! Have you tried to use `rpmbuild` (and alien) as a non-root user? – filbranden Feb 06 '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 06 '19 at 15:05
  • If you pass `rpmbuild` a `--buildroot /home/` explicitly, does that work? Or do you still get the `/root/rpmbuild/BUILDROOT` paths? – filbranden Feb 06 '19 at 15:31
  • I've eventually managed to make it work. What I did is to add this under the `%install` section: `mkdir -p %{buildroot}/srv/tmp/` `mkdir -p %{buildroot}/usr/share/doc/frontend/` `install -m 0755 /home/frontend-1.0/srv/tmp/file.tar.gz %{buildroot}/srv/tmp/file.tar.gz` `install -m 0755 /home/frontend-1.0/.../frontend/README.Debian %{buildroot}/.../frontend/README.Debian` `install -m 0755 /home/frontend-1.0/.../changelog.Debian.gz %{buildroot}/.../changelog.Debian.gz` `install -m 0755 /home/frontend-1.0/.../frontend/copyright %{buildroot}/.../frontend/copyright` – Bastian Nanchen Feb 06 '19 at 15:43
  • I updated my answer. I just looked at source code of `alien` and confirmed it will call `rpmbuild` passing it a `--buildroot`, so that should work. – filbranden Feb 06 '19 at 15:48
  • See [this commit](https://github.com/mildred/alien/commit/9c28b11e6c996ff0e72c682afcee3dd6023e3121) for the fix to `alien` for recent versions of rpm. – filbranden Feb 06 '19 at 15:53
  • I guess, in short: don't use `alien`! It's unfortunately mostly bitrotten at this point... You're probably better off building an RPM specfile from scratch... – filbranden Feb 06 '19 at 16:00
  • 1
    Thanks for your time @filbranden. I appreciate it :) – Bastian Nanchen Feb 07 '19 at 07:19