user2939305
user2939305

Reputation: 19

rpm-maven-plugin v2.1.5 automatically gzipping my file

I have a man file that I want installed to /usr/share/man/man8 during the rpm install. This is my mapping.

<mapping>
  <directory>/usr/share/man/man8</directory>
  <documentation>true</documentation> <!-- no difference if I add or remove this -->
  <filemode>644</filemode>
  <username>root</username>
  <groupname>root</groupname>
  <directoryIncluded>false</directoryIncluded>
  <recurseDirectories>false</recurseDirectories>
  <sources>
    <source>
      <location>${project.build.directory}</location>
      <includes>
        <include>mymanpage.8</include>
      </includes>
    </source>
  </sources>
</mapping>

rpm-maven-plugin errors and tells me mymanpage.8 is not found. I verified that mymanpage.8 is in the target directory. Then I noticed that the plugin copied mymanpage.8.gz to the target/rpm/rpmtest/buildroot/usr/share/man/man8 directory. So I'm assuming the plugin recognized somehow that it can gzip this man page and did it but since my mapping is specifically including mymanpage.8 it complains it cannot find it. I tried changing the include to mymanpage.8* and it still gives me the same file not found error.

Has anyone seen this before? What's the fix?

I guess I have a workaround which is to copy the mymanpage.8 file to my install directory and then in the postinstall scriptlet move it to /usr/share/man/man8.

Upvotes: 1

Views: 310

Answers (3)

Vitalii
Vitalii

Reputation: 481

Before rpm packaging, there are man pages with ".8" extension. Rpmbuild compresses man pages forcibly and renames them with .gz extension, so rpm-maven-plugin can't find files with ".8" extension. The first solution is just to rename uncompressed files with .gz extension like this

<mapping>
    <directory>/usr/share/man/man8</directory>
    <directoryIncluded>false</directoryIncluded><!-- required for CentOS 7 -->
    <sources>
        <source>
            <!-- rpmbuild rename manpages from *.8 to *.8.gz, so we should use <destination> tag to set new name -->
            <location>generated-docs/mymanpage.8</location>
            <destination>mymanpage.8.gz</destination>
        </source>
    </sources>
<mapping>

Now rpmbuild doesn't rename file anymore and it works for CentOS 7 (which uses man-db package for working with manpages), but does not work for CentOS 6 (which uses man package for working with manpages), CentOS 6 can't open such man pages.

So for fixing, man pages manually compressing required. For compressing you can use resourcecompressor maven plugin for example

<plugin>
    <groupId>com.github.ryanholdren</groupId>
    <artifactId>resourcecompressor</artifactId>
    <version>2017-06-24</version>
    <executions>
        <execution>
            <goals>
                <goal>compress</goal>
            </goals>
            <configuration>
                <directory>generated-docs/</directory>
                <filter>\.8$</filter>
                <compression>SMALLEST</compression>
            </configuration>
        </execution>
    </executions>
</plugin>

Now, rpm-maven-plugin may be configured to use .gz files (and wildcard expression can be used, if need) and rpmbuild doesn't try to rename and compress man pages.

<mapping>
    <directory>/usr/share/man/man8</directory>
    <directoryIncluded>false</directoryIncluded><!-- required for CentOS 7 -->
    <sources>
        <source>
            <location>generated-docs/</location>
            <includes>
                <include>*.8.gz</include>
            </includes>
        </source>
    </sources>
</mapping>

Upvotes: 0

Siavash Outadi
Siavash Outadi

Reputation: 32

The problem can be that the man page is built in a later phase than package. So when the rpm plugin is trying to package the man page it is not there yet. You can find the life cycles here:

https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

So make sure the man page is created and end up in build directory before package phase like in generate-resources for example.

Upvotes: 0

Quentin
Quentin

Reputation: 519

The rpm-maven-plugin delegates the work to the rpmbuild command. This ones compress the man pages for you.

You can use the location tag to specify a directory but also a file.

<mapping>
  <directory>/usr/share/man/man8</directory>
  <filemode>644</filemode>
  <username>root</username>
  <groupname>root</groupname>
  <directoryIncluded>false</directoryIncluded>
  <recurseDirectories>false</recurseDirectories>
  <sources>
    <source>
      <location>${project.build.directory}/mymanpage.8</location>
    </source>
  </sources>
</mapping>

If you prefer to use includes, you must use wildcard pattern.

The documentation tag is not intended for manpages but for other documentation as changelogs for example. See rpm-maven-plugin documentation.

Upvotes: 0

Related Questions