GithubHelp home page GithubHelp logo

ctron / rpm-builder Goto Github PK

View Code? Open in Web Editor NEW
55.0 7.0 32.0 2.63 MB

Maven RPM builder plugin

Home Page: https://ctron.github.io/rpm-builder

License: Eclipse Public License 2.0

Groovy 6.90% Java 92.91% CSS 0.02% Shell 0.11% Dockerfile 0.06%
rpm-builder rpm rpmbuild maven maven-plugin

rpm-builder's Introduction

RPM builder plugin CI Maven Central

This is a Maven Plugin which can build RPM files using plain Java. It does not require the rpmbuild command line tool.

Usage

For more information about how to use this plugin see the documentation.

License

This plugin is open source and licensed under the EPL. See also LICENSE.

rpm-builder's People

Contributors

berndwarmuth avatar ctron avatar dependabot[bot] avatar dranuhl avatar dwalluck avatar elkman avatar hochraldo avatar jarkkosonninen avatar lburja avatar moedan avatar olivermatz avatar olley avatar proggerpete avatar singhald avatar thorasgarddev avatar tisoft avatar tksopra avatar tomylobo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpm-builder's Issues

File flags readme etc can be set indifferently with either true or false

The following two entry declarations in the file pom.xml are equivalent:

<entry>
     <name>/opt/foo</name>
     <file>foo</file>
     <readme>false</readme>
</entry>
<entry>
     <name>/opt/foo</name>
     <file>foo</file>
     <readme>true</readme>
</entry>

In both cases, the value entry foo will be flagged as a readme file.
The same applies to the other Boolean file flags, i.e. configuration, documentation, license, ghost, missingOk, noreplace.

This is not intuitive. As a user, I would assume that false and true are different. I think false should be equivalent to ommitting the xml-element.

I stumbled over this while reviewing the code of de.dentrassi.rpm.builder.EntryDetails.apply: It does not make any difference whether the value of, say, EntryDetails.readme is set to Boolean.TRUE or Boolean.FALSE. The corresponing file flag will be set in both cases.

I am currently fixing #41 and I am uncertain whether I should do the same there.

ghost entries

I would like to specify a ghost entry, but the plugin requires a file, directory or collect element to be specified for it anyway, which does not seem to make much sense to me.

For example:

  <entry>
    <name>/var/log/myapp.log</name>
    <ghost>true</ghost>
  </entry>

Yields:
[ERROR] Failed to execute goal de.dentrassi.maven:rpm:1.6.0:rpm (default) on project myapp: Exactly one of 'file', 'directory', 'linkTo' or 'collect' must be specified.

If adding a file element referring to a non-existing file to the above entry, will lead to the following trace:

    at org.eclipse.packager.rpm.build.RpmBuilder$1.addFile (RpmBuilder.java:1355)
    at de.dentrassi.rpm.builder.RpmMojo.fillFromEntryFile (RpmMojo.java:1118)
    at de.dentrassi.rpm.builder.RpmMojo.fillFromEntry (RpmMojo.java:1094)
    at de.dentrassi.rpm.builder.RpmMojo.fillPayload (RpmMojo.java:1063)
    at de.dentrassi.rpm.builder.RpmMojo.execute (RpmMojo.java:787)

Using collect element that does not find a file, will not lead to an error, but the produced RPM will not know about the ghost file either.
Using skip will not lead to an error in either case, but the produced RPM will not know about the ghost file either.

So it seems that currently the only way to refer to an existing empty file, which seems to be cumbersome and not intuitive.

Using identical terminal directory names in collectors doesn't work

If I use a collector like this :

<entry>
   <name>${rpm.appdir}/bin</name>
   <collect>
     <from>foo/bin</from>
     <from>bar/bin</from>
   </collect>
</entry>

In this example, foo/bin will be used and and files in bar/bin will not be found in the RPM. Workarounds are :

  • naming terminal directories differently (foo/bin1 and bar/bin2);
  • split the entry with different collectors:
<entry>
   <name>${rpm.appdir}/bin</name>
   <collect>
     <from>foo/bin</from>
   </collect>
</entry>
<entry>
   <name>${rpm.appdir}/bin</name>
   <collect>
     <from>bar/bin</from>
   </collect>
</entry>

Signed RPM failed to install using `dnf` on RHEL8 and RHEL9

reported by: @tobias1703

A package that is signed, can be successfully verified on RHEL7, 8, 9 (using rpm -K), but when creating a YUM repository using createrepo, it fails to install on RHEL 8 and 9 with the following error:

Package test.rpm is not signed
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: GPG check FAILED

Reproducer: https://github.com/tobias1703/rpm-builder-test

Remaining tasks:

  • eclipse/packager#42 - so that rpmkeys finds the V3 header
  • eclipse/packager#43 - so that rpmkeys finds the full payload digest
  • Release Eclipse Packager
  • Make use of this functionality in the RPM builder

Using <release> with other than "1" causes rpm-builder to produce 2 RPMs

Using with other than "1" causes rpm-builder to produce 2 RPMs.
rpm-build will call both "(default-rpm)" and then "(default)", where the first will produce with release .1 and the second with my custom release value.
The problem is that CDCI tools to pick the output doesn't know which RPM file to chose.

Also the provided integration tests like test14-forcerelease does this.

Make configuration files being ignored during verify

We are facing essentially the same problem as described in
https://stackoverflow.com/questions/38993603/rpm-verify-ignore-config-files:
The pom.xml contains an entry like this:

<entry>
  <name>/opt/foo/configure-foo.properties</name>
  <file>${project.build.directory}/configure-foo.properties</file>
  <mode>0666</mode>
  <configuration>true</configuration>
</entry>

The rpm-maven-plugin creates an rpm file that contains a configuration file configure-foo.properties.
After the user has edited that file and uses RPM's verification as described in
https://www.linux.co.cr/distributions/review/2002/red-hat-8.0/maximum-rpm-1.0/ch-rpm-verify.html
that tool treats this as a mismatch.

I would expect the file configure-foo.properties to be ignored, which should be possible with the spec file directive %verify(owner group) /opt/foo/configure-foo.properties.
Basically, I see three ways to achieve this in our build process:

  1. No change to the pom.xml is needed and the rpm-builder
    plugin adds a suitable %verify directive by default, or
  2. I add a nested element such as <verifyexclude>true</verifyexclude> to the respective entry in the pom.xml, or
  3. I write a separate nested such as <verifyparams>owner group</verifyparams> to the respective entry in the pom.xml

I slightly favour the first option.
This issues is related to #7

How to get rpm output file name

You can set outputFileName and snapshotBuildId, but if they are not set, how would you get the output file name ?

I want to continue processing the rpm in the next maven phases, but I cannot grab the rpm file name.
It would be nice, if the file name and other generated info was set to properties.

Missing boolean dependencies support in Requires, Recommends, Suggests, Supplements, Enhances and Conflicts

Boolean dependencies are supported since RPM >= 4.13

http://rpm.org/user_doc/boolean_dependencies.html

I find this very useful, when it come to rely on a specific Java version for example, as too many Oracle, OpenJDK...savors exist and without this ability it is impossible to produce RPM builds having a great compatibility among all the Debian based Linux distributions or avoid unecessary dependencies download.

EDIT:
Recommends and Suggests dependencies types implementation should be great as well ๐Ÿ˜‰

Be able to Sign existing RPM file

Hello @ctron,

I'm looking for a way to sign existing RPM files with Java and to include the signature in the header.
Reading your code really help me to understand how RPM is built and how rpm-packager works.

Actually I didn't find any way to sign an existing RPM. So I would like to know your opinion to make this, or if there is a simplier way that I don't know.

For the moment, I was thinking about a Class RpmOutputStream wich would be construct with a RpmInputStream and allows to modify somes part of the file like metadatas ...

Rules are not applied to implicit created directories

Hello,

I have noticed that rules are not applied to implicitly created directories. For example, when a file is created in a target directory that does not yet exist, no rules are applied to these directories. For explicitly created directories, the rules are applied (see example below).

I am not sure if this is a bug or the expected behavior. I would have expected that the rules are applied to all applicable intermediate directories in a path as well.

Can you please clarify that? Thanks in advance!


Example

To reproduce the described problem, I have attached a simplified MWE (Used rpm-bilder-Plugin 1.11.0): mwe.zip

Ruleset:

<ruleset>
    <id>my-default</id>
    <rules>
        <rule>
            <when>
                <prefix>/opt/mycompany</prefix>
            </when>
            <user>myuser</user>
            <group>mygroup</group>
        </rule>
        <rule>
            <when>
                <prefix>/opt/mycompany</prefix>
                <type>directory</type>
            </when>
            <mode>0777</mode>
        </rule>
    </rules>
</ruleset>

Entries:

<entries>
    <entry>
        <!-- implicitly create directories "mycompany/mwe/a/b/c/" in "/opt" -->
        <name>/opt/mycompany/mwe/a/b/c/someFile.txt</name>
        <file>${project.basedir}/src/main/resources/someFile.txt</file>
        <ruleset>my-default</ruleset>
    </entry>
    <entry>
        <!-- explicitly create directory "mwe/" in "/opt/mycompany" -->
        <name>/opt/mycompany/mwe</name>
        <directory>true</directory>
        <ruleset>my-default</ruleset>
    </entry>
</entries>

Output of created files/directroies with permissions after installation of built rpm from MWE:

[/]$ ls -alpR /opt
/opt:
total 20
drwxr-xr-x. 1 root root 4096 Nov 29 10:28 ./
dr-xr-xr-x. 1 root root 4096 Nov 29 10:28 ../
drwxr-xr-x. 3 root root 4096 Nov 29 10:28 mycompany/

/opt/mycompany:
total 16
drwxr-xr-x. 3 root   root    4096 Nov 29 10:28 ./
drwxr-xr-x. 1 root   root    4096 Nov 29 10:28 ../
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:14 mwe/

/opt/mycompany/mwe:
total 12
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:14 ./
drwxr-xr-x. 3 root   root    4096 Nov 29 10:28 ../
drwxr-xr-x. 3 root   root    4096 Nov 29 10:28 a/

/opt/mycompany/mwe/a:
total 12
drwxr-xr-x. 3 root   root    4096 Nov 29 10:28 ./
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:14 ../
drwxr-xr-x. 3 root   root    4096 Nov 29 10:28 b/

/opt/mycompany/mwe/a/b:
total 12
drwxr-xr-x. 3 root root 4096 Nov 29 10:28 ./
drwxr-xr-x. 3 root root 4096 Nov 29 10:28 ../
drwxr-xr-x. 2 root root 4096 Nov 29 10:28 c/

/opt/mycompany/mwe/a/b/c:
total 12
drwxr-xr-x. 2 root   root    4096 Nov 29 10:28 ./
drwxr-xr-x. 3 root   root    4096 Nov 29 10:28 ../
-rw-r--r--. 1 myuser mygroup   11 Nov 29 10:14 someFile.txt

Expected output of created files/directroies:

[/]$ ls -alpR /opt
/opt:
total 20
drwxr-xr-x. 1 root   root    4096 Nov 29 10:28 ./
dr-xr-xr-x. 1 root   root    4096 Nov 29 10:28 ../
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:28 mycompany/

/opt/mycompany:
total 16
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:28 ./
drwxr-xr-x. 1 root   root    4096 Nov 29 10:28 ../
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:14 mwe/

/opt/mycompany/mwe:
total 12
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:14 ./
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:28 ../
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:28 a/

/opt/mycompany/mwe/a:
total 12
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:28 ./
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:14 ../
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:28 b/

/opt/mycompany/mwe/a/b:
total 12
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:28 ./
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:28 ../
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:28 c/

/opt/mycompany/mwe/a/b/c:
total 12
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:28 ./
drwxrwxrwx. 3 myuser mygroup 4096 Nov 29 10:28 ../
-rw-r--r--. 1 myuser mygroup   11 Nov 29 10:14 someFile.txt

Digest mismatch for RPM install with FIPS mode enabled

Installing RPM Packages generated with rpm-builder (v 1.9.0) fails when fips mode is enabled (tested with AlmaLinux 8):

rpm -ihv test-1-1.noarch.rpm

Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:test-1-1 ################################# [100%]
error: unpacking of archive failed on file [...]: cpio: Digest mismatch
error: test-1-1.noarch: install failed

The reason is that fips expects the file digest to be atleast a sha256:

rpm -ihv --nofiledigest test-1-1.noarch.rpm

succeeds (but is not an always an option depending on security standards/guidelines for the target system).

To see the file digest use:

rpm -q --dump --scripts -p test-1-1.noarch.rpm

-> [...] 166 1673000915 af90be808ed1abd48b3c0b5026056903 0100644 root root 0 0 0 X

The package can be fixed by running rpmrebuild (%_source_filedigest_algorithm 8 + %_binary_filedigest_algorithm 8) - but this depends on the rpm-builder which i want to avoid (otherwise i could use rpm-maven-plugin to generate the rpm in the first place):

rpmrebuild -p test-1-1.noarch.rpm
rpm -q --dump --scripts -p rpmbuild/RPMS/noarch/test-1-1.noarch.rpm

-> [...] 166 1673363869 e988af6edb29fc324dfd847607b9fe9991c8f6476d23f99eed60a2d0040259dd 0100644 root root 0 0 0 X

So to fix this properly the rpm-builder would need to generate the file digest with the sha256 algorithm or (probably even better) allow the algorithm to be specified via configuration.

add verbose option

There is no output during creation of a yum repository, which can make Jenkins think the build is stalled. I suggest to add a verbose option, so that one can see each file which is added during creation.

Customize archive name format

Is it possible to customize format used to create archive's name?
Currently it is created with "-arch.rpm" suffix, but there is also convention to use ".arch.rpm" (with dot before arch name).

version parameter is ignored on SNAPSHOT builds

Hi,

is there a good reason that in the case of a snapshot build, an explicitly defined version string via the <version> parameter is ignored?

In our case, the Maven version contains a hyphen (i.e. 2021-1.0.1-SNAPSHOT or 2021-1.0.1 for the release).
The extra hyphen confuses zypper and a snapshot RPM like foo-2021-1.0.1-0.202101020304.noarch.rpm cannot be removed via:
zypper remove foo -> Error: RPM failed: error: package foo-2021-1.0.1-0.202101020304.noarch is not installed.

So we use something like 2021_1.0.1 derived from the project version and use it with the <version> parameter tag for our release packages, but always have to remove the shapshot RPMs with rpm -e ... by hand.

I have already created a patch to try this out, but would need to adjust the tests to submit a PR.
Additionally, a new parameter could be introduced to switch between old and new behavior if needed.

Already thanks for feedback and all the great work that went into this plugin.

Install produced RPM file into Maven repository

At the moment produced RPM file is not installed into Maven repository or Artifactory.
I tried to add maven config into pom file but it fails, because I need to know exactly file name of the artifact and ${project.version} is not equal to the RPM version.

How it is possible to deploy RPM to Artifactory?
How to access filename of RPM file in the POM?

Below is configuration I tried to use to install RPM file:

  	<plugin>
  		<groupId>org.apache.maven.plugins</groupId>
  		<artifactId>maven-install-plugin</artifactId>
  		<executions>
  			<execution>
  				<phase>install</phase>
  				<goals>
  					<goal>install-file</goal>
  				</goals>
  				<configuration>
  					<packaging>rpm</packaging>
  					<artifactId>${project.artifactId}</artifactId>
  					<groupId>${project.groupId}</groupId>
  					<version>${project.version}</version>
  					<file>
  						${project.build.directory}/${project.artifactId}-${project.version}-noarch.rpm
  					</file>
  				</configuration>
  			</execution>
  		</executions>
  	</plugin>

Add option to preserve file permissions when collecting files for RPM from a POSIX file system

It's quite annoying to explicitly specify file permissions when building an RPM, especially when files are collected from multiple sources maintained by different teams or there are many executable files in a directory, but not all of them. The problem is not only in having a long list of rules/entries, but also in having to track new files or file permission changes in all the sources.

The following is stated in the documentation:

This information is not read from the filesystem, since this may not work on some platforms. RPM does assume a POSIX like system, so building on a Windows system may not provide enough information to properly fill out all required information in the file.

which is a bit odd given that building RPM packages on Windows or on any other non-POSIX systems is quite rare. So I don't quite see why file permissions are not preserved if possible, by default.

It is suggested to make preserving file permissions the default behaviour on POSIX systems. Alternatively, there should be a global or an entry level configuration option (or both), for example:

<entry>
    ...
    <mode>original</mode>
    ...
</entry>

Signing is not ignored when skipSigning tag is used.

      if ( !this.skipSigning && this.signature != null )
        {
            final SignatureProcessor signer = makeRsaSigner ( this.signature );
            if ( signer != null )
            {
                builder.addSignatureProcessor ( signer );
            }
        }

is causing problem to skip signature in RpmMojo.java

add plugin-specific skip parameter

Hello,
Can we have -Dskip.rpm (or similar) parameter and XML config parameter for just skipping RPM build?
Useful for int.tests building where I don't need to have RPM.

Right now I run mvn verify -Dmaven.test.skip -Dskip.npm -Dskip.webpack (skipping non-needed UI packing and unit tests) but I cannot skip RPM. Playing around profile-specific plugin configuration makes pom much less readable.
Thank you.

Entryset Collect not excluding directories

Given the following entry:

<entry>
    <name>${my-deploy.dir}</name>
    <collect>
      <from>../rpm-module-a/target/</from>
      <directories>false</directories>
    </collect>
    <user>jboss1</user>
    <group>jboss1</group>
    <mode>0640</mode>
</entry>

I find directories from the ../rpm-module-a/target/ are still included in the .rpm archive.
How is one supposed to exclude directories and / or filter files included using a 'collect'.

I am using version 0.8.0 of the plugin and currently have no rulesets defined in the pom.xml.

RPM containing file with special characters causes repo-creation to fail

When trying to build a repository RPM with the rpm package of the puppet-agent in it (https://yum.puppetlabs.com/puppet5/el/7/x86_64/puppet-agent-5.3.8-1.el7.x86_64.rpm) the goal yum-repository fails with:
[ERROR] Failed to execute goal de.dentrassi.maven:rpm:0.9.2:yum-repository (create-yum-repo-puppet) on project xvp-repo-puppet: Execution create-yum-repo-puppet of goal de.dentrassi.maven:rpm:0.9.2:yum-repository failed: java.nio.charset.MalformedInputException: Input length = 1 -> [Help 1]

The file that causes the exception is located in the puppet-agent rpm at ".\opt\puppetlabs\puppet\lib\ruby\gems\2.4.0\gems\hocon-1.2.5\spec\fixtures\test_utils\resources\แš แ›‡แšป.conf".

mvn install name

I've started using this so I can produce rpms on my mac

Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T15:00:29-04:00)
Maven home: /opt/local/share/java/maven3
Java version: 1.8.0_201, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.5", arch: "x86_64", family: "mac"

I've got this configuration

        <plugins>
            <plugin>
                <groupId>org.codehaus.groovy.maven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>groovy-is-trimming-your-version</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <source>project.properties.rpmversion = project.version.minus("-SNAPSHOT");</source>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.4.1</version>
            </plugin>
            <plugin>
                <!-- https://ctron.github.io/rpm-builder/ -->
                <groupId>de.dentrassi.maven</groupId>
                <artifactId>rpm</artifactId>
                <version>1.2.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>rpm</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <entries>
                        <entry>
                            <name>/var/www/domains/home.net</name>
                            <collect>
                                <from>${project.build.directory}/working/home.net</from>
                            </collect>
                        </entry>
                    </entries>
                    <skipSigning>true</skipSigning>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/working/home.net</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>./</directory>
                                    <filtering>false</filtering>
                                    <excludes>
                                        <exclude>**/.git/**</exclude>
                                        <exclude>**/.gitignore</exclude>
                                        <exclude>robots.txt</exclude>
                                        <exclude>.project</exclude>
                                        <exclude>pom.xml</exclude>
                                        <exclude>target/**</exclude>
                                        <exclude>archive/**</exclude>
                                        <exclude>resources/**</exclude>
                                        <exclude>tests/**</exclude>
                                        <exclude>test/**</exclude>
                                        <exclude>content.spec</exclude>
                                        <exclude>**/README*</exclude>
                                    </excludes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
</plugins>

when i run mvn package it builds the file nice as you please
content-3.45.0.2-0.201907022042.noarch.rpm

but mvn install (I actually noticed it during release:prepare release:perform but narrowed down)

[INFO] Installing /Users/dsinghal/git/content/target/content-3.45.0.2-0.201907022042.noarch.rpm to /Users/dsinghal/.m2/repository/com/home/content/3.45.0.2-SNAPSHOT/content-3.45.0.2-SNAPSHOT-rpm.rpm

then nothing can find it b/c it's not got the rpm name it built

Why is this happening and how do i get it to install with the right name so release:perform can still find it? Is this a bug or a misused feature?

Ability to allow configuration changes on local files e.g. %config(noreplace)

I believe handling RMP updated would be much easier with standard %config(noreplace)

e.g. modified configuration files would remain on disk as is
and edited in distribution file from the update in new file .rpmnew.
(as it is right now with %config edited config file will end-up in .rpmsave)


Suggestion to have the parameter extended to minimize upgrade issues.

<configuration>true</configuration>
<configuration>false</configuration>
<configuration>noreplace</configuration>

as done in here: http://www.mojohaus.org/rpm-maven-plugin/map-params.html

Support for long package names

I wanted to create an RPM with a package name longer than 66 bytes and received an exception (Name exceeds 66 bytes).
According to http://ftp.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html (as well as experience with rpmbuild, which I wanted to replace with this plugin), it is possible to store longer names.

Going through the sources, it seems that this is a current limitation of eclipse/packagedrone. I've file an issue there: eclipse-archived/packagedrone#136 .

This issue here to mark the necessary update of the plugin dependencies (and/or update of the plugin, should the responsibility be shifted to the user of packagedrone...) .

Provide a way to override the rpm release number suffix for snapshot builds.

The plugin currently provides a way to override the rpm release number for release builds by specifying the 'release' parameter.

For snapshot builds you can override the rpm release prefix with the 'snapshotReleasePrefix' parameter.

However there is no way to override the rpm release suffix. In my case I would like to set a 'snapshotReleaseSuffix' parameter and make it equal to the build number from our automated build system. (Instead of the default timestamp suffix.)

That way I can easily reference the rpm I've just built in later build steps.

Specify name of rpm package

Is there a way to manually specify the name of the created rpm package?
As fas as I understand your example you're using the name property inside the pom.xml file by default, I think it would be useful to specify the package name manually.
I'm not using rpm myself, but debian. On debian I've discovered that package names containing (spaces) are bad. Is this true for rpm packages too, if yes does the plugin cover that?

Required Class ZstdUtils not found

Hi,
Version 1.2. works fine. Update to 1.3 on Win10 throw this Exception:

[ERROR] Failed to execute goal de.dentrassi.maven:rpm:1.3.0:rpm (default) on project ee_server_rpm_konfig_test: Execution default of goal de.dentrassi.maven:rpm:1.3.0:rpm failed: A required class was missing while executing de.dentrassi.maven:rpm:1.3.0:rpm: org/apache/commons/compress/compressors/zstandard/ZstdUtils [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>de.dentrassi.maven:rpm:1.3.0 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/c:/Entwicklung/.m2/repository/de/dentrassi/maven/rpm/1.3.0/rpm-1.3.0.jar [ERROR] urls[1] = file:/c:/Entwicklung/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar [ERROR] urls[2] = file:/c:/Entwicklung/.m2/repository/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar [ERROR] urls[3] = file:/c:/Entwicklung/.m2/repository/org/apache/maven/maven-builder-support/3.3.9/maven-builder-support-3.3.9.jar [ERROR] urls[4] = file:/c:/Entwicklung/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar [ERROR] urls[5] = file:/c:/Entwicklung/.m2/repository/org/eclipse/aether/aether-util/1.0.2.v20150114/aether-util-1.0.2.v20150114.jar [ERROR] urls[6] = file:/c:/Entwicklung/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar [ERROR] urls[7] = file:/c:/Entwicklung/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar [ERROR] urls[8] = file:/c:/Entwicklung/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.2/org.eclipse.sisu.inject-0.3.2.jar [ERROR] urls[9] = file:/c:/Entwicklung/.m2/repository/com/google/inject/guice/4.0/guice-4.0-no_aop.jar [ERROR] urls[10] = file:/c:/Entwicklung/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar [ERROR] urls[11] = file:/c:/Entwicklung/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.21/plexus-interpolation-1.21.jar [ERROR] urls[12] = file:/c:/Entwicklung/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.6/plexus-component-annotations-1.6.jar [ERROR] urls[13] = file:/c:/Entwicklung/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar [ERROR] urls[14] = file:/c:/Entwicklung/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar [ERROR] urls[15] = file:/c:/Entwicklung/.m2/repository/org/eclipse/packager/packager-rpm/0.16.0/packager-rpm-0.16.0.jar [ERROR] urls[16] = file:/c:/Entwicklung/.m2/repository/org/bouncycastle/bcpg-jdk15on/1.63/bcpg-jdk15on-1.63.jar [ERROR] urls[17] = file:/c:/Entwicklung/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.63/bcprov-jdk15on-1.63.jar [ERROR] urls[18] = file:/c:/Entwicklung/.m2/repository/commons-codec/commons-codec/1.12/commons-codec-1.12.jar [ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]] [ERROR] [ERROR] -----------------------------------------------------: org.apache.commons.compress.compressors.zstandard.ZstdUtils

Separate RPM API

Can you separate the RPM API into a separate jar? It would be extremely beneficial for a single RPM API, as this project is more focused on the building of RPMs, and packagedrone's copy is more focused on extracting metadata from RPMs.

I'm working on a pure-Java yum repodata generator, and I don't like that I have to keep copying packages out of other repositories to dependency free access to them.... It doesn't let me easily write something using your amazing RPM APIs, and I honestly don't want to maintain a fork that has no git log ties to yours.

RPM builds are not reproducible

RPMs build by the rpm-builder are not reproducible.

Following issues have been found:

  • Dependency sorting is not stable, if two dependencies are equal in name and version, but differ in their flags, they are sorted differently each time, leading to a different RPM (Caused by eclipse/packager#18, fixed by eclipse/packager#19)
  • Inode numbers are not reproducible
  • timestamps can't be set

yum-repository goal creates wrong repodata for multiple RPMs

When creating a yum repository using the yum-repository goal with more than one RPM, the RPMs are successfully copied into the packages folder, but the metadata folder contains only metadata for one package. This is easily reproducible by running the plugin with more than one RPM to add and afterwards checking the *-filelists.xml file in the repodata directory.

Running Maven with multiple threads gives warning about thread safety

Running Maven for example using mvn -T 1C package to get one thread per processor core yields the following warning about the RPM plug-in:

[WARNING] *****************************************************************                                                                                                                                 
[WARNING] * Your build is requesting parallel execution, but project      *                                                                                                                                 
[WARNING] * contains the following plugin(s) that have goals not marked   *                                                                                                                                 
[WARNING] * as @threadSafe to support parallel building.                  *                                                                                                                                 
[WARNING] * While this /may/ work fine, please look for plugin updates    *                                                                                                                                 
[WARNING] * and/or request plugins be made thread-safe.                   *                                                                                                                                 
[WARNING] * If reporting an issue, report it against the plugin in        *                                                                                                                                 
[WARNING] * question, not against maven-core                              *                                                                                                                                 
[WARNING] *****************************************************************                                                                                                                                 
[WARNING] The following plugins are not marked @threadSafe in test-project:                                                                                                                          
[WARNING] de.dentrassi.maven:rpm:0.9.2                                                                                                                                                                      
[WARNING] Enable debug to see more precisely which goals are not marked @threadSafe.                                                                                                                        
[WARNING] *****************************************************************                        

If the plug-in actually is thread-safe, would it please be possible to mark it as such to avoid this large warning? Being able to run with multiple threads can speed up builds considerably. Thank you.

Wrong scope of Maven artifacts

Using this plugin in a project that is build with a newer maven version leads to the following plugin validation warning:

[WARNING]  * de.dentrassi.maven:rpm:1.10.1
[WARNING]   Plugin EXTERNAL issue(s):
[WARNING]    * Plugin should declare Maven artifacts in `provided` scope. If the plugin already declares them in `provided` scope, update the maven-plugin-plugin to latest version. Artifacts found with wrong scope: [org.apache.maven:maven-artifact:3.3.9, org.apache.maven:maven-core:3.3.9, org.apache.maven:maven-plugin-api:3.3.9, org.apache.maven:maven-model:3.3.9]

The reason is an outdated version of the maven-plugin-plugin and wrong scope for the listed artifacts.

Wrong order of entries can produce uninstallable RPMs

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

Apply script end line characters to target system

Description:

  • the RPM is build on windows
  • pom.xml defines target system:
    <leadOverrideOperatingSystem>LINUX</leadOverrideOperatingSystem>
  • pom.xml defines a script:
    <afterInstallation> <interpreter>/bin/bash</interpreter> <file>${project.basedir}/scripts/post.sh</file> </afterInstallation>
  • RPM is installed on linux
  • execution of script fails with:
    /var/tmp/rpm-tmp.7IH57w: /etc/init.d/eftd: /bin/bash^M: bad interpreter: No such file or directory

Question:

The error message shows how there is a bad end line character added during the RPM build, resulting in the script failing.
The question is now, if this might be due to faulty configuration on my side, or if this can be considered a feature/bug.

Allow setting compression level for RPMs

It would be useful if the RPM builder Maven plug-in provided a way to the compression level for generated RPMs. This could also be used to completely disable compression of RPM files, which makes them more suitable for use with content-addressable storage and transfer mechanisms (see for example https://github.com/systemd/casync) which make optimizations using similarities between different versions of files. Applying compression to the RPM makes it difficult to find common chunks with a previous version of the same RPM file and eliminates possible savings in transfer bandwidth and storage utilization from reusing chunks common to both files. Being able to speed up the transfer of RPM files between hosts can be especially useful in development mode, when multiple iterations produce many similar versions of large RPM files.

Compression can be disabled using the following statements in an RPM spec file:

%define _source_payload w0.gzdio
%define _binary_payload w0.gzdio

But how can this be translated to the RPM builder Maven plug-in? It would be great if it could be exposed as a setting. But if that is not possible, then perhaps add documentation on how it can be achieved otherwise. If pointers are given to what the best approach would be, I can try to come up with a patch and a pull request.

Directories being <collect> are not following rules as expected

I am collecting all the configuration files under a 2 directory trees to make the rpm. Under rules I have a directory rule to do a chmod, user, and group. However, none of the directories are set right and they are all owned by root and defaulting to 755. If I use the include 1 directory example the target directory is created with the correct user/group and permission so that's working. The example posted in the documentation does a chmod on any directory to 750, so I attempted to do only that but with 0770 but again the directories were all 755. This is my pom.ml file. I am doing a mvn package command on the command line via a java application on RH 8.6 using:

mvn -version
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /usr/local/apache-maven-3.8.6
Java version: 1.8.0_242, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-1.el7.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1127.el7.x86_64", arch: "amd64", family: "unix"

example of what I am see after rpm -i the file:
drwxr-xr-x 4 root root 4096 Nov 23 19:50 RTConfigurationFiles
drwxr-xr-x 8 root root 4096 Nov 23 19:50 RTConfigurationFiles/configuration
-rw-rw---- 1 developer developer 1369 Nov 23 19:50 RTConfigurationFiles/metadata.xml
drwxr-xr-x 5 root root 4096 Nov 23 19:50 RTConfigurationFiles/resources
etc.

pom.xml.txt

The pom.xml is successfully setting all the files to the user account and the target path is to the user home directory as expected. The only thing that is wrong is every directory is root root 755 vs. developer developer 770.

[email protected]

P.S.
I also emailed if it was possible to directly call the lib classes from a java application to make the rpm via the application running mvn on the command line to do it.

debug: spec file and src.rpm

Hi,

If i want to debug the package, there is some option that allows to see the spec file generated or something like that?

changelog tag

is possible to implement a changelog tag, which simulates "%changelog", to keep track of the changes.

thank you

wildcard management in File system collector

It would be useful to handle wildcards or regex in file system collector in order to filter files easily.

example :

<entry>
  <name>/usr/lib/foo</name>
  <collect>
    <from>target/*/*.so</from>
  </collect>
</entry>

postrans missing

RPM's scriptlet execution order is the following (rpm -U, triggers not included)

  1. %pretrans of the new package
  2. %pre of the new package
  3. (unpack new files)
  4. %post of the new package
  5. %preun of the old package
  6. (delete old leftover files)
  7. %postun of the old package
  8. %posttrans of the new package

(See also https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#ordering)
If you naively stop your service in %preun and start it in %post, you end up with the service not running after an update, because %preun runs after %post.

Since the scriptlets get arguments depending on whether they're being upgraded, removed or freshly installed, a workaround is to place the start command into the install-only part of %post and into the upgrade-only part of %postun.
To be on the safe side, one would have to mirror this change for stopping the service, but that is usually not that critical.

But since %preun and %postun reside in the old package, while %pre and %post reside in the new package, you run into a problem if the commands needed to start the service ever need to be changed.

This is why we usually start our services in %posttrans instead of %post.
Recently, we decided we don't want to depend on the unportable rpm-maven-plugin anymore and wanted to switch to rpm-builder.
Unfortunately, rpm-builder does not support %posttrans.

Btw, I tried to develop a patch, but while I can build the plugin, I didn't have any luck building the packagedrone dependency, which also needs to be changed.

EDIT: I did some research, the tag IDs for %pretrans and %posttrans are as follows:

RPMTAG_PRETRANS = 1151,
RPMTAG_POSTTRANS = 1152,
RPMTAG_PRETRANSPROG = 1153,
RPMTAG_POSTTRANSPROG = 1154, 

Source: http://ftp.rpm.org/api/4.11.1/group__rpmtag.html

See also:
#49
eclipse/packager#11

RPM Package Name in Unnecessary Lowercase

Hello, when we are using your plugin, we would like to have the RPMs case-sensitive. However, current names are created with toLowerCase() in RpmMojo.java, line 711 (makePackageName).

We modified it to

private String makePackageName ()
    {
        return this.packageName.trim();
    }

and it works like a charm.

Missing Recommends and Suggests dependencies

http://rpm.org/user_doc/boolean_dependencies.html

I don't know if it is a shared opinion, but i find Recommends dependency useful for automatically download the enhancement libraries need for the project after the user approval.
That make things much easy for the users while still leaving the user choice approval choice.

I see the Suggests dependency as useful when users don't read your Wiki or other documentation, and since they often just run it...
At least this way they have the advices under their eyes at install time.

yum meta-data is not created correctly for special rpm packages

The yum metadata created by the plugin does not contain the right data in some cases. When a package declares itself to require some file that itself provides (see real-world example below), then yum is unable to install this package from a repo that has been created with this maven plugin.

For example, the package ruby defines to require /usr/bin/ruby:

# list rpm requirements of ruby
$ rpm -qpR ruby-2.0.0.648-34.el7_6.x86_64.rpm
/usr/bin/ruby
libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libcrypt.so.1()(64bit)
libdl.so.2()(64bit)
libm.so.6()(64bit)
libpthread.so.0()(64bit)
librt.so.1()(64bit)
libruby.so.2.0()(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
ruby(rubygems) >= 2.0.14.1
ruby-libs(x86-64) = 2.0.0.648-34.el7_6
rubygem(bigdecimal) >= 1.2.0
rpmlib(PayloadIsXz) <= 5.2-1

However, itself provides /usr/bin/ruby:

# list files provided by this rpm
$ rpm -qpl ruby-2.0.0.648-34.el7_6.x86_64.rpm
/usr/bin/erb
/usr/bin/ruby
/usr/bin/testrb
/usr/share/doc/ruby-2.0.0.648
/usr/share/doc/ruby-2.0.0.648/COPYING
/usr/share/doc/ruby-2.0.0.648/COPYING.ja
/usr/share/doc/ruby-2.0.0.648/GPL
/usr/share/doc/ruby-2.0.0.648/LEGAL
/usr/share/man/man1/erb.1.gz
/usr/share/man/man1/ruby.1.gz

The resulting XML metadata generated by the maven plugin reflects it exactly like this:

  <package type="rpm">
    <name>ruby</name>
    <arch>x86_64</arch>
    <version epoch="0" rel="34.el7_6" ver="2.0.0.648"/>
...
      <rpm:provides>
        <rpm:entry epoch="0" flags="EQ" name="ruby" rel="34.el7_6" ver="2.0.0.648"/>
        <rpm:entry epoch="0" flags="EQ" name="ruby(runtime_executable)" ver="2.0.0"/>
        <rpm:entry epoch="0" flags="EQ" name="ruby(x86-64)" rel="34.el7_6" ver="2.0.0.648"/>
      </rpm:provides>
      <rpm:requires>
        <rpm:entry name="/usr/bin/ruby"/>
        <rpm:entry name="libc.so.6()(64bit)"/>
        <rpm:entry name="libc.so.6(GLIBC_2.2.5)(64bit)"/>
        <rpm:entry name="libcrypt.so.1()(64bit)"/>
        <rpm:entry name="libdl.so.2()(64bit)"/>
        <rpm:entry name="libm.so.6()(64bit)"/>
        <rpm:entry name="libpthread.so.0()(64bit)"/>
        <rpm:entry name="librt.so.1()(64bit)"/>
        <rpm:entry name="libruby.so.2.0()(64bit)"/>
        <rpm:entry name="rtld(GNU_HASH)"/>
        <rpm:entry epoch="0" flags="GE" name="ruby(rubygems)" ver="2.0.14.1"/>
        <rpm:entry epoch="0" flags="EQ" name="ruby-libs(x86-64)" rel="34.el7_6" ver="2.0.0.648"/>
        <rpm:entry epoch="0" flags="GE" name="rubygem(bigdecimal)" ver="1.2.0"/>
      </rpm:requires>
      <rpm:conflicts/>
      <rpm:obsoletes/>
    </format>
    <file>/usr/bin/erb</file>
    <file>/usr/bin/ruby</file>
    <file>/usr/bin/testrb</file>
  </package>

When trying to install ruby, it fails because it says that it cannot resolve the dependency to /usr/bin/ruby.

When generating the repo-metadata with 'createrepo', the meta-data looks like the following:

<package type="rpm">
  <name>ruby</name>
  <arch>x86_64</arch>
  <version epoch="0" ver="2.0.0.648" rel="34.el7_6"/>
...
    <rpm:provides>
      <rpm:entry name="ruby" flags="EQ" epoch="0" ver="2.0.0.648" rel="34.el7_6"/>
      <rpm:entry name="ruby(runtime_executable)" flags="EQ" epoch="0" ver="2.0.0"/>
      <rpm:entry name="ruby(x86-64)" flags="EQ" epoch="0" ver="2.0.0.648" rel="34.el7_6"/>
    </rpm:provides>
    <rpm:requires>
      <rpm:entry name="libc.so.6(GLIBC_2.2.5)(64bit)"/>
      <rpm:entry name="libcrypt.so.1()(64bit)"/>
      <rpm:entry name="libdl.so.2()(64bit)"/>
      <rpm:entry name="libm.so.6()(64bit)"/>
      <rpm:entry name="libpthread.so.0()(64bit)"/>
      <rpm:entry name="librt.so.1()(64bit)"/>
      <rpm:entry name="libruby.so.2.0()(64bit)"/>
      <rpm:entry name="rtld(GNU_HASH)"/>
      <rpm:entry name="ruby(rubygems)" flags="GE" epoch="0" ver="2.0.14.1"/>
      <rpm:entry name="ruby-libs(x86-64)" flags="EQ" epoch="0" ver="2.0.0.648" rel="34.el7_6"/>
      <rpm:entry name="rubygem(bigdecimal)" flags="GE" epoch="0" ver="1.2.0"/>
    </rpm:requires>
  <file>/usr/bin/erb</file>
  <file>/usr/bin/ruby</file>
  <file>/usr/bin/testrb</file>
  </format>
</package>

As it can be seen, the "requires" entry for /usr/bin/ruby is removed automatically by createrepo.

This special-case is handled in createrepo (actually in a class of yum) here:
https://github.com/rpm-software-management/yum/blob/master/yum/packages.py#L1294

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.