8000 Pass variables from jdeb plugin to postinst script · Issue #816 · tcurdt/jdeb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Pass variables from jdeb plugin to postinst script #816

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 sen 8000 d you account related emails.

Already on GitHub? Sign in to your account

Open
swc-kdzekov opened this issue Mar 14, 2025 · 6 comments
Open

Pass variables from jdeb plugin to postinst script #816

swc-kdzekov opened this issue Mar 14, 2025 · 6 comments

Comments

@swc-kdzekov
Copy link
swc-kdzekov commented Mar 14, 2025

Hello all,

I'm working on migrating .rpm packaging to .deb for a spring boot service. For that reason I use org.vafer:jdeb:1.5.
Most of the feature that were used by the rpm maven plugin were nicely replaced by 'jdeb'. However, I haven't found how to set environmental variables carrying information from the plugin configuration to 'postinst' script. For example: installation path, application name, application version etc. I would like to keep that information in the pom file (where org.vafer:deb is configured), and then use it in postinst script.
Could somebody help here on how if that is possible ?

Here is a piece of the maven pom configuration:

`

    <app.version>1.1.1</app.version> <!-- to remove the -SNAPSHOT -->
    <app.name>cyan-phishing</app.name>
    <app.script.name>cyan-phishing-tmp.sh</app.script.name>
    <app.description>CYAN Phishing</app.description>
    <app.dir>phishing</app.dir>
    <app.base.dir>/opt/cyan/${app.dir}/${app.version}</app.base.dir>
    <app.lib.dir>${app.base.dir}/lib</app.lib.dir>
    <app.conf.dir>${app.base.dir}/configuration</app.conf.dir>
    <app.phish.dir>${app.base.dir}/phish_checker</app.phish.dir>
    <app.pid.dir>/var/run/cyan/${app.dir}/${app.version}</app.pid.dir>
    <app.log.dir>/var/log/cyan/${app.dir}/${app.version}</app.log.dir>
    <app.lock.dir>/var/lock/cyan/${app.dir}/${app.version}</app.lock.dir>
    <app.opt.dir>/var/opt/cyan/${app.dir}/</app.opt.dir>
    <app.artifact.prefix>cyan-phishing</app.artifact.prefix>
    <app.user>phishing</app.user>
    <app.group>cyan</app.group>
    <app.required.hosts>phishing-db-cl</app.required.hosts>

    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <jdeb.version>1.5</jdeb.version>

    <deb.jdk.version>jdk1.8</deb.jdk.version>
    <inew.daemon.version>2.0.9</inew.daemon.version>
    <inew.database.manager.version>1.0.2</inew.database.manager.version>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-libs</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/lib</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>jdeb</artifactId>
            <groupId>org.vafer</groupId>
            <version>${jdeb.version}</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>jdeb</goal>
                    </goals>
                    <configuration>
                        <controlDir>${basedir}/src/deb/control</controlDir>
                        <dataSet>
                            <data>
                                <src>${basedir}/src/main/resources/scripts/${app.script.name}</src>
                                <type>file</type>
                                <mapper>
                                    <type>perm</type>
                                    <prefix>${app.base.dir}</prefix>
                                </mapper>
                            </data>
                            <data>
                                <src>${project.build.directory}/lib</src>
                                <type>directory</type>
                                <mapper>
                                    <type>perm</type>
                                    <prefix>${app.base.dir}/lib</prefix>
                                </mapper>
                            </data>
                            <data>
                                <src>src/main/resources/configuration</src>
                                <type>directory</type>
                                <mapper>
                                    <type>perm</type>
                                    <prefix>${app.base.dir}/configuration</prefix>
                                </mapper>
                            </data>
                            <!-- copy the debian jar file in the lib folder -->
                            <data>
                                <src>${project.build.directory}/${project.artifactId}-${project.version}.jar</src>
                                <type>file</type>
                                <mapper>
                                    <type>perm</type>
                                    <prefix>${app.base.dir}/lib</prefix>
                                </mapper>
                            </data>
                        </dataSet>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>`

Best Regards,
Konstantin

@tcurdt
Copy link
Owner
tcurdt commented Mar 16, 2025

We are passing the variable resolver into the control builder

ControlBuilder(Console console, VariableResolver resolver, String openReplaceToken, String closeReplaceToken, Long outputTimestampMs) {

The postinst should already be filtered.

if (CONFIGURATION_FILENAMES.contains(file.getName()) || MAINTAINER_SCRIPTS.contains(file.getName())) {

The tokens are define here

https://github.com/tcurdt/jdeb/blob/master/src/main/java/org/vafer/jdeb/utils/FilteredFile.java#L29

Does that 8000 help?

@swc-kdzekov
Copy link
Author

Thank you for your response! I will have a look.

@swc-kdzekov
Copy link
Author
swc-kdzekov commented Mar 17, 2025

@tcurdt That is very implementation of the plugin. I'm wondering how to define environmental variables so that I would use them in the pre/post instal scripts?

In rpm maven plugin there is something like < defineStatements > within the configuration where one could define the variables.

@tmortagne
Copy link
Collaborator
tmortagne commented Mar 17, 2025

@tcurdt That is very implementation of the plugin. I'm wondering how to define environmental variables so that I would use them in the pre/post instal scripts?

You don't really need to. All the Maven properties are by default reusable in generated files. See for example https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-solr/xwiki-platform-distribution-debian-solr-cores/xwiki-platform-distribution-debian-solr-core-events/src/deb/control/postinst which is simply printing the content of the Maven property defined in a parent pom at https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-solr/xwiki-platform-distribution-debian-solr-cores/pom.xml#L59.

@swc-kdzekov
Copy link
Author

Alright, this looks more concrete. Thanks!

@tcurdt
Copy link
Owner
tcurdt commented May 18, 2025

@swc-kdzekov can this be closed? or is it still a problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0