Skip to content

Commit

Permalink
rename a few parameters and internal method names
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Oct 12, 2019
1 parent 5913227 commit ab1f0a9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
16 changes: 12 additions & 4 deletions src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java
Expand Up @@ -1259,10 +1259,10 @@ public String getOverrideGroupName()
}

@Override
public void configureReproducible( Date outputTimestamp )
public void configureReproducible( Date lastModifiedDate )
{
// 1. force last modified date
setLastModifiedDate( convertOutputTimestamp( outputTimestamp ) );
setLastModifiedDate( normalizeLastModifiedDate( lastModifiedDate ) );

// 2. sort filenames in each directory when scanning filesystem
setFilenameComparator( new Comparator<String>()
Expand All @@ -1286,8 +1286,16 @@ public int compare( String s1, String s2 )
setOverrideGroupName( "root" );
}

protected Date convertOutputTimestamp( Date outputTimestamp )
/**
* Normalize last modified time value to get reproducible archive entries, based on
* archive binary format (tar uses UTC timestamp but zip uses local time then requires
* tweaks to make the value reproducible whatever the current timezone is).
*
* @param lastModifiedDate
* @return
*/
protected Date normalizeLastModifiedDate( Date lastModifiedDate )
{
return outputTimestamp;
return lastModifiedDate;
}
}
15 changes: 9 additions & 6 deletions src/main/java/org/codehaus/plexus/archiver/Archiver.java
Expand Up @@ -423,7 +423,6 @@ ResourceIterator getResources()
void setFilenameComparator( Comparator<String> filenameComparator );

/**
<<<<<<< reproducible
* @since 4.2.0
*/
void setOverrideUid( int uid );
Expand Down Expand Up @@ -464,12 +463,16 @@ ResourceIterator getResources()
String getOverrideGroupName();

/**
* Configure the archiver to get reproducible archives (see <a href="https://reproducible-builds.org/>Reproducible
* Builds</a>). This will require reproducible archive entries order, defined entries timestamp and reproducible
* entries Unix mode.
* Configure the archiver to create archives in a reproducible way (see <a
* href="https://reproducible-builds.org/>Reproducible Builds</a>). This will configure:
* <ul>
* <li>reproducible archive entries order,</li>
* <li>defined entries timestamp</li>
* <li>and reproducible entries Unix mode.</li>
* <ul>
*
* @param outputTimestamp the date to use for archive entries last modified time
* @param lastModifiedDate the date to use for archive entries last modified time
* @since 4.2.0
*/
void configureReproducible( Date outputTimestamp );
void configureReproducible( Date lastModifiedDate );
}
Expand Up @@ -400,9 +400,9 @@ public String getOverrideGroupName()
}

@Override
public void configureReproducible( Date outputTimestamp )
public void configureReproducible( Date lastModifiedDate )
{
target.configureReproducible( outputTimestamp );
target.configureReproducible( lastModifiedDate );
}

}
Expand Up @@ -415,7 +415,7 @@ public String getOverrideGroupName()
}

@Override
public void configureReproducible( Date outputTimestamp )
public void configureReproducible( Date lastModifiedDate )
{

}
Expand Down
Expand Up @@ -470,7 +470,7 @@ public String getOverrideGroupName()
}

@Override
public void configureReproducible( Date outputTimestamp )
public void configureReproducible( Date lastModifiedDate )
{
}
}
Expand Up @@ -836,12 +836,12 @@ protected String getArchiveType()
}

@Override
protected Date convertOutputTimestamp( Date outputTimestamp )
protected Date normalizeLastModifiedDate( Date lastModifiedDate )
{
// timestamp of zip entries at zip storage level ignores timezone: managed in ZipEntry.setTime,
// that turns javaToDosTime: need to revert the operation here to get reproducible
// zip entry time
return new Date( dosToJavaTime( outputTimestamp.getTime() ) );
return new Date( dosToJavaTime( lastModifiedDate.getTime() ) );
}

/**
Expand Down

0 comments on commit ab1f0a9

Please sign in to comment.