nebula-plugins / gradle-ospackage-plugin

Gradle plugin for constructing linux packages, specifically RPM and DEBs.
Apache License 2.0
369 stars 129 forks source link

Configuration file flag not added to RPM #445

Open milgner opened 3 months ago

milgner commented 3 months ago

After reading #56 and #118, it seems like the issue was fixed for DEB packages but is still not working for RPMs.

After some experimentation, my Gradle build script now contains:

    from("src/main/resources") {
        fileType = Directive(RPMFILE_CONFIG or RPMFILE_NOREPLACE)
        into("/etc/rebased/conf")
        eachFile {
            configurationFiles.push("/$path")
        }
    }

I have also tried just setting one configurationFile and leaving out the RPMFILE_NOREPLACE flag or the fileType altogether.

But the resulting .rpm file doesn't have any information - about neither the config flag nor the noreplace. The file itself is included as expected, though.

Furthermore, a code search on Github did not turn up any reference to the configurationFiles attribute as part of the rpm packaging plugin.

DanielThomas commented 3 months ago

configurationFiles was added as Debian specific extension, because has a separate conffiles file and no concept of file directives, but for convenience fileType = CONFIG works.

fileType is all you should need, as covered by https://github.com/nebula-plugins/gradle-ospackage-plugin/wiki/RPM-Plugin#example. The directive is looked up on each copy spec:

https://github.com/nebula-plugins/gradle-ospackage-plugin/blob/7f0a8aa0d31176788590b9cc86bc3c6a655741aa/src/main/groovy/com/netflix/gradle/plugins/rpm/RpmCopyAction.groovy#L159

The comment on https://github.com/nebula-plugins/gradle-ospackage-plugin/blob/main/src/main/groovy/com/netflix/gradle/plugins/packaging/CopySpecEnhancement.groovy#L16-L28 seems to indicate that either syntax should work fine.

milgner commented 3 months ago

That is very strange. I have tried a few more approaches, but the RPM file never lists the file(s) as config files. My latest approach is

    from("src/main/resources") {
        into("/etc/rebased/conf")
        eachFile {
            fileType = Directive(RPMFILE_CONFIG or RPMFILE_NOREPLACE)
        }
    }

I'm checking with rpm -q --configfiles my.rpm and would expect the file to show up there, too.

DanielThomas commented 3 months ago

At a glance, you'll want to drop the eachFile there, fileType is something we add on the FileCopySpec and it applies to everything in the from.

milgner commented 3 months ago

That was my very first approach. When that didn't work, I tried all kinds of variations, without success.