Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong order of entries can produce uninstallable RPMs #14

Open
oreinert opened this issue May 15, 2017 · 1 comment
Open

Wrong order of entries can produce uninstallable RPMs #14

oreinert opened this issue May 15, 2017 · 1 comment

Comments

@oreinert
Copy link

Consider the example in the following archive:
pluginbug.zip

It contains sources for building a simple RPM containing:

  • the directory /opt/test, and
  • the file /opt/test/README.md.

There's a pom.xml file for building the RPM via the Maven RPM plugin, and a .spec file for building the same RPM using the rpmbuild command (by running rpmbuild --define="%_topdir $PWD" -bb SPECS/rpm-plugin-test.spec).

In the example, %dir /opt/test is specified after the file, and this causes the Maven plugin to generate an RPM that can't be installed:

$ sudo rpm -i target/rpm-plugin-test-0.1.0-1-noarch.rpm
error: unpacking of archive failed on file /opt/test/README.md;59198b61: cpio: open failed - No such file or directory
error: rpm-plugin-test-0.1.0-1.noarch: install failed

The same RPM generated using rpmbuild installs without issue. Looking at the entries in the cpio archive within the two RPMs seems revealing:

$ rpm2cpio target/rpm-plugin-test-0.1.0-1-noarch.rpm | cpio -tv
-rw-r--r--   1 root     root           48 May 15 12:51 ./opt/test/README.md
drwxr-xr-x   2 root     root            0 May 15 12:51 ./opt/test
1 block
$ rpm2cpio RPMS/noarch/rpm-plugin-test-0.1.0-0.noarch.rpm | cpio -tv
drwxr-xr-x   2 root     root            0 May 15 12:51 ./opt/test
-rw-r--r--   1 root     root           48 May 15 12:51 ./opt/test/README.md
1 block

The problem seems to be that the RPM generated by the plugin fails to install because cpio can't write the README.md file because the folder it should be in doesn't exist yet. The Maven plugin should order entries in the archive in such a way that it can always be installed, like the rpmbuild command.

Fixing the given example is trivial, of course - just swap the order of the entries. However, for more complicated builds, this may not be possible, especially when profiles are used to contribute independent parts of the RPM plugin config using stuff like http://blog.sonatype.com/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/ .

@ctron
Copy link
Owner

ctron commented May 15, 2017

Yes it is true, this condition is not being checked. And I agree, although there is a workaround for that, there should be some proper solution.

@ctron ctron changed the title Plugin can produce uninstallable RPMs Wrong order of entries can produce uninstallable RPMs May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants