trygvis / unix-maven-plugin

My local copy of the unix-maven-plugin from the Codehaus Mojo project
MIT License
12 stars 24 forks source link

RPM %define support attempt #12

Open ncolton opened 11 years ago

ncolton commented 11 years ago

I can't claim I fully know what I'm doing, but some hacking on the code resulted in what appears to not break things, as the tests pass Let me know your thoughts?

To use the %define support, add in a defineStatements tag with define tags specifying the values to use for %define lines:

<configuration>
  <rpm>
    <defineStatements>
      <define>_source_filedigest_algorithm md5</define>
      <define>_binary_filedigest_algorithm md5</define>
      <define>_source_payload w9.gzdio</define>
      <define>_binary_payload w9.gzdio</define>
    </defineStatements>
...
</configuration>
trygvis commented 11 years ago

That seems like a reasonable approach. I'm not very used to RPM stuff, but I'm wondering if it might better to have a simple include mechanism so people can include anything into the spec file? Something like:

<rpm>
  <fragments>
    <fragment>src/main/unix/fragment/woot</fragment>
  </fragments>
</rpm>

It makes it possible to add any kind of stuff they want.

ncolton commented 11 years ago

Including an external file makes a LOT of sense for the %pre, %prep, %post, %install, etc. script sections, as having those inside the pom would be painful.

SpecFile.java has what looks to be the necessary pieces in it already for nearly all the valid portions of an RPM SPEC file, but there aren't any means of getting values from the pom file through the plugin so that they can be used. As it was already there, I tried to do the minimum amount of code to reasonably expose the mechanism for setting %define values.

trygvis commented 11 years ago

The pre/post install/remove is already supported and works fine, I was more wondering about other parts of the spec file that the plugin doesn't care much about.

The SpecFile is just the DAO object, but your patch itself seems fine. If you want to copy stuff from the file system or access the Maven project the RpmUnixPackage.prepare() where that should happen.

What is the define stuff used for in RPMs? Do you know if there are equivalent features in the deb format?

trygvis commented 11 years ago

The pre/post install/remove is already supported and works fine, I was more wondering about other parts of the spec file that the plugin doesn't care much about.

The SpecFile is just the DAO object, but your patch itself seems fine. If you want to copy stuff from the file system or access the Maven project the RpmUnixPackage.prepare() where that should happen.

What is the define stuff used for in RPMs? Do you know if there are equivalent features in the deb format?

ncolton commented 11 years ago

For RPM land, the %define directive allows creating macros and setting variable values for use in the SPEC file. In some cases these influence the RPM building behavior. For the example I used:

%define _source_filedigest_algorithm md5
%define _binary_filedigest_algorithm md5
%define _source_payload w9.gzdio
%define _binary_payload w9.gzdio

Those settings change the hash generation and compression used for RPM creation so that they are compatible with RHEL 5 (and 4, etc., I think) when created on a RHEL 6 system and it's newer hash and compression settings.

I've had to do some reading, as I knew nothing about Debian packages (and know only a tiny bit now), and it looks like override_dh_auto_install in debian/rules does similar in some cases, but in what appears to be a very different manner.