Skip to content
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 send you account related emails.

Already on GitHub? Sign in to your account

Apply rules to implicitly created directories (Issue #85) #86

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions src/it/test19-intermediate-directories-collect/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.dentrassi.maven.rpm.test</groupId>
<artifactId>test19</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Test Package #19</name>
<description>
Test explicitly adding and applying rules for implicitly created intermediate directories with collect entries.
</description>

<url>http://dentrassi.de</url>

<organization>
<name>Jens Reimann</name>
<url>http://dentrassi.de</url>
</organization>

<licenses>
<license>
<name>Eclipse Public License - v 1.0</name>
<distribution>repo</distribution>
<url>https://www.eclipse.org/legal/epl-v10.html</url>
</license>
</licenses>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<skipSigning>true</skipSigning>
<!-- use a predictable timestamp -->
<project.build.outputTimestamp>2009-01-01T12:00:00+01:00</project.build.outputTimestamp>
</properties>

<build>

<plugins>
<plugin>
<groupId>de.dentrassi.maven</groupId>
<artifactId>rpm</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>rpm</goal>
</goals>
<configuration>
<attach>false</attach>
<group>Application/Misc</group>

<signature>
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

<generateIntermediateDirectories>
<baseDirecotry>/opt/mycompany/myapp</baseDirecotry>
</generateIntermediateDirectories>

<rulesets>
<ruleset>
<id>my-default</id>
<rules>
<rule>
<when>
<prefix>/opt/mycompany</prefix>
</when>
<user>mygeneraluser</user>
<group>mygeneralgroup</group>
<mode>0111</mode>
</rule>
<rule>
<when>
<prefix>/opt/mycompany/myapp</prefix>
</when>
<user>myuser</user>
<group>mygroup</group>
<mode>0555</mode>
</rule>
<rule>
<when>
<prefix>/opt/mycompany/myapp</prefix>
<type>directory</type>
</when>
<mode>0777</mode>
</rule>
</rules>
</ruleset>
</rulesets>

<entries>
<entry>
<name>/opt/mycompany/myapp/a/b</name>
<collect>
<from>${project.basedir}/src/main/data</from>
<directories>false</directories> <!-- make explicit directories -->
</collect>
<ruleset>my-default</ruleset>
</entry>
<entry>
<name>/opt/mycompany/myapp/c/d</name>
<collect>
<from>${project.basedir}/src/main/data</from>
<directories>true</directories> <!-- make explicit directories -->
</collect>
<ruleset>my-default</ruleset>
</entry>
</entries>

</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>sign</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<skipSigning>false</skipSigning>
</properties>
</profile>
</profiles>

</project>
Empty file.
25 changes: 25 additions & 0 deletions src/it/test19-intermediate-directories-collect/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def dump() {
Process proc = ('rpm -q --dump -p ' + basedir + "/target/*.rpm").execute()
return proc.in.getText().trim()
}

def actual = dump()
println "Dump:\n" + actual

def expected = """\
/opt/mycompany/myapp 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040777 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/a 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040777 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/a/b 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040777 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/a/b/x/y/foobar 0 1230807600 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0100555 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/c 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040777 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/c/d 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040777 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/c/d/x 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040777 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/c/d/x/y 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040777 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/c/d/x/y/foobar 0 1230807600 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0100555 myuser mygroup 0 0 0 X""".stripIndent()

if (actual != expected) {
System.out.format("RPM dump doesn't match - actual:%n%s%nexpected:%n%s%n", actual, expected);
return false;
}

return true;
141 changes: 141 additions & 0 deletions src/it/test19-intermediate-directories/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.dentrassi.maven.rpm.test</groupId>
<artifactId>test19</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Test Package #19</name>
<description>
Test explicitly adding and applying rules for implicitly created intermediate directories.
</description>

<url>http://dentrassi.de</url>

<organization>
<name>Jens Reimann</name>
<url>http://dentrassi.de</url>
</organization>

<licenses>
<license>
<name>Eclipse Public License - v 1.0</name>
<distribution>repo</distribution>
<url>https://www.eclipse.org/legal/epl-v10.html</url>
</license>
</licenses>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<skipSigning>true</skipSigning>
<!-- use a predictable timestamp -->
<project.build.outputTimestamp>2009-01-01T12:00:00+01:00</project.build.outputTimestamp>
</properties>

<build>

<plugins>
<plugin>
<groupId>de.dentrassi.maven</groupId>
<artifactId>rpm</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>rpm</goal>
</goals>
<configuration>
<attach>false</attach>
<group>Application/Misc</group>

<signature>
<keyId>${keyId}</keyId>
<keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
<passphrase>${passphrase}</passphrase>
<hashAlgorithm>SHA1</hashAlgorithm>
<skip>${skipSigning}</skip>
</signature>

<generateIntermediateDirectories>
<baseDirectory>/etc/mycompany/myapp</baseDirectory>
<baseDirecotry>/opt/mycompany/myapp</baseDirecotry>
</generateIntermediateDirectories>

<rulesets>
<ruleset>
<id>my-default</id>
<rules>
<rule>
<when>
<prefix>/opt/mycompany</prefix>
</when>
<user>mygeneraluser</user>
<group>mygeneralgroup</group>
<mode>0111</mode>
</rule>
<rule>
<when>
<prefix>/opt/mycompany/myapp</prefix>
</when>
<user>myuser</user>
<group>mygroup</group>
<mode>0555</mode>
</rule>
<rule>
<when>
<prefix>/opt/mycompany/myapp</prefix>
<type>directory</type>
</when>
<mode>0777</mode>
</rule>
</rules>
</ruleset>
</rulesets>

<entries>
<entry>
<name>/opt/mycompany/myapp/a/b/c/foobar</name>
<file>${project.basedir}/src/main/data/foobar</file>
<ruleset>my-default</ruleset>
</entry>
<entry>
<name>/opt/mycompany/myapp</name>
<directory>true</directory>
<ruleset>my-default</ruleset>
</entry>
<entry>
<name>/etc/mycompany/myapp/defaults</name>
<directory>true</directory>
<ruleset>my-default</ruleset>
</entry>
<entry>
<name>/opt/mycompany/otherapp/a/b/c/foobar</name>
<file>${project.basedir}/src/main/data/foobar</file>
<ruleset>my-default</ruleset>
</entry>
</entries>

</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>sign</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<skipSigning>false</skipSigning>
</properties>
</profile>
</profiles>

</project>
Empty file.
24 changes: 24 additions & 0 deletions src/it/test19-intermediate-directories/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def dump() {
Process proc = ('rpm -q --dump -p ' + basedir + "/target/*.rpm").execute()
return proc.in.getText().trim()
}

def actual = dump()
println "Dump:\n" + actual

def expected = """\
/etc/mycompany/myapp 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040755 root root 0 0 0 X
/etc/mycompany/myapp/defaults 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040755 root root 0 0 0 X
/opt/mycompany/myapp 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040777 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/a 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040777 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/a/b 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040777 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/a/b/c 0 1230807600 0000000000000000000000000000000000000000000000000000000000000000 040777 myuser mygroup 0 0 0 X
/opt/mycompany/myapp/a/b/c/foobar 0 1230807600 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0100555 myuser mygroup 0 0 0 X
/opt/mycompany/otherapp/a/b/c/foobar 0 1230807600 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0100111 mygeneraluser mygeneralgroup 0 0 0 X""".stripIndent()

if (actual != expected) {
System.out.format("RPM dump doesn't match - actual:%n%s%nexpected:%n%s%n", actual, expected);
return false;
}

return true;
22 changes: 22 additions & 0 deletions src/main/java/de/dentrassi/rpm/builder/BuilderContextListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* Copyright (c) 2023 Fraunhofer-Institut fuer Optronik, Systemtechnik und Bildauswertung IOSB and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0
*
* Contributors:
* Fraunhofer-Institut fuer Optronik, Systemtechnik und Bildauswertung IOSB - initial API and implementation
*******************************************************************************/
package de.dentrassi.rpm.builder;

import org.eclipse.packager.rpm.build.FileInformationProvider;

public interface BuilderContextListener {

void notifyFileAdded(String name, FileInformationProvider<Object> provider);

void notifyDirectoryAdded(String name, FileInformationProvider<Object> provider);

void notifySymbolicLinkAdded(String name, FileInformationProvider<Object> provider);
}
Loading
Loading