Skip to content

Commit

Permalink
MASSEMBLY-941 keep file permission in Reproducible mode (#96)
Browse files Browse the repository at this point in the history
[MASSEMBLY-941] keep file permission in Reproducible mode
  • Loading branch information
hboutemy authored Nov 26, 2022
1 parent 1336ea7 commit f42194b
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ under the License.
</parent>

<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.3-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Apache Maven Assembly Plugin</name>
Expand Down Expand Up @@ -175,7 +175,7 @@ under the License.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>4.4.0</version>
<version>4.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
6 changes: 3 additions & 3 deletions src/it/projects/reproducible/src/assemble/src.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ under the License.
<fileSets>
<fileSet>
<outputDirectory></outputDirectory>
<directory>src</directory>
<directory>src/main/resources</directory>
<filtered>true</filtered>
<lineEnding>lf</lineEnding>
</fileSet>
</fileSets>
<files>
<!--files>
<file>
<source>src/main/resources/executable.txt</source>
<fileMode>0755</fileMode>
<filtered>true</filtered>
<lineEnding>lf</lineEnding>
</file>
</files>
</files-->
</assembly>
28 changes: 23 additions & 5 deletions src/it/projects/reproducible/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,31 @@
* under the License.
*/

//import java.util.zip.*;
import org.apache.commons.compress.archivers.zip.*;
//import java.util.zip.*
import org.apache.commons.compress.archivers.zip.*

File deployDir = new File( basedir, 'target/repo/org/apache/maven/its/reproducible/1.0' )

assert deployDir.exists()

assert new File( deployDir, 'reproducible-1.0-src.zip.sha1' ).text == '5ce34fc133d47cbc9c81195877dbe10b9ec7d864'
assert new File( deployDir, 'reproducible-1.0-src.tar.sha1' ).text == '0b9dc1da069705a93b4954a198c18bd248822bf8'
assert new File( deployDir, 'reproducible-1.0-src.jar.sha1' ).text == '289cb3ecd418b8099deefb930dc7aa39c06888cb'
ZipFile zip = new ZipFile( new File( deployDir, "reproducible-1.0-src.zip" ) )
StringBuilder sb = new StringBuilder()
for( ZipArchiveEntry entry : zip.getEntries() )
{
sb.append( String.format("%o %s\n", entry.getUnixMode(), entry.getName() ) )
}
for( String type : [ "zip", "jar", "tar" ] )
{
String name = "reproducible-1.0-src." + type + ".sha1"
sb.append( String.format("%s %s\n", new File( deployDir, name ).text, name ) )
}

effective = sb.toString()

// 3 different reference results:
// 1. Windows does not support executable flag
// 2. on *nix, based on system configuration, group flag differs
reference = "zip-content-" + ( effective.contains( "644 executable" ) ? "win" : effective.contains( "0775" ) ? "775" : "755" ) + ".txt"
content = new File( basedir, reference ).text.replace( "\r\n", "\n" )

assert content == effective
25 changes: 25 additions & 0 deletions src/it/projects/reproducible/zip-content-755.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
40755 dir-A/
40755 dir-C/
40755 dir-b/
40755 dir-b/B2/
40755 dir-b/B4/
40755 dir-b/b1/
40755 dir-b/b3/
40755 dir-d/
100644 Uppercase.txt
100644 dir-A/A2.txt
100644 dir-A/A4.txt
100644 dir-A/a1.txt
100644 dir-A/a3.txt
100644 dir-C/C.txt
100644 dir-b/B2/B2.txt
100644 dir-b/B4/B4.txt
100644 dir-b/b.txt
100644 dir-b/b1/b1.txt
100644 dir-b/b3/b3.txt
100644 dir-d/d.txt
100755 executable.txt
100644 lowercase.txt
97d0ea3b4a87cd3ea78edd1c3c25914d69ea97f3 reproducible-1.0-src.zip.sha1
a0c4cf1ed244e60221e12367f50ff676066b8e65 reproducible-1.0-src.jar.sha1
bf93dd529253157352b87097d9d23eba8c9ca61a reproducible-1.0-src.tar.sha1
25 changes: 25 additions & 0 deletions src/it/projects/reproducible/zip-content-775.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
40775 dir-A/
40775 dir-C/
40775 dir-b/
40775 dir-b/B2/
40775 dir-b/B4/
40775 dir-b/b1/
40775 dir-b/b3/
40775 dir-d/
100664 Uppercase.txt
100664 dir-A/A2.txt
100664 dir-A/A4.txt
100664 dir-A/a1.txt
100664 dir-A/a3.txt
100664 dir-C/C.txt
100664 dir-b/B2/B2.txt
100664 dir-b/B4/B4.txt
100664 dir-b/b.txt
100664 dir-b/b1/b1.txt
100664 dir-b/b3/b3.txt
100664 dir-d/d.txt
100775 executable.txt
100664 lowercase.txt
50116502c6107740c2a35ef296b5abda08c5dec7 reproducible-1.0-src.zip.sha1
cc7e3a984179f63d6b37bc86c61e9cc461c62288 reproducible-1.0-src.jar.sha1
3efc10ec9c3099ba061e58d5b2a935ba643da237 reproducible-1.0-src.tar.sha1
25 changes: 25 additions & 0 deletions src/it/projects/reproducible/zip-content-win.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
40755 dir-A/
40755 dir-C/
40755 dir-b/
40755 dir-b/B2/
40755 dir-b/B4/
40755 dir-b/b1/
40755 dir-b/b3/
40755 dir-d/
100644 Uppercase.txt
100644 dir-A/A2.txt
100644 dir-A/A4.txt
100644 dir-A/a1.txt
100644 dir-A/a3.txt
100644 dir-C/C.txt
100644 dir-b/B2/B2.txt
100644 dir-b/B4/B4.txt
100644 dir-b/b.txt
100644 dir-b/b1/b1.txt
100644 dir-b/b3/b3.txt
100644 dir-d/d.txt
100644 executable.txt
100644 lowercase.txt
cb1dc226d702733bfa405b7090b74ab7e77bf39e reproducible-1.0-src.zip.sha1
3b31d88a36985f526fb3fe6ba5987387e4887f23 reproducible-1.0-src.jar.sha1
b85f960069d6a444f928a87761b63fde60ea687d reproducible-1.0-src.tar.sha1

0 comments on commit f42194b

Please sign in to comment.