reset file digest algo to MD5, add private key hash algo paramater
This commit is contained in:
parent
f79133d8f5
commit
8550f486b4
6 changed files with 39 additions and 21 deletions
|
@ -113,55 +113,55 @@ class Rpm extends AbstractArchiveTask {
|
|||
@Input
|
||||
@Optional
|
||||
List<Object> getAllConfigurationPaths() {
|
||||
return getConfigurationPaths() + (projectPackagingExtension?.getConfigurationPaths()?: [])
|
||||
getConfigurationPaths() + (projectPackagingExtension?.getConfigurationPaths()?: [])
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
List<Object> getAllPreInstallCommands() {
|
||||
return getPreInstallCommands() + (projectPackagingExtension?.getPreInstallCommands() ?: [])
|
||||
getPreInstallCommands() + (projectPackagingExtension?.getPreInstallCommands() ?: [])
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
List<Object> getAllPostInstallCommands() {
|
||||
return getPostInstallCommands() + (projectPackagingExtension?.getPostInstallCommands() ?: [])
|
||||
getPostInstallCommands() + (projectPackagingExtension?.getPostInstallCommands() ?: [])
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
List<Object> getAllPreUninstallCommands() {
|
||||
return getPreUninstallCommands() + (projectPackagingExtension?.getPreUninstallCommands() ?: [])
|
||||
getPreUninstallCommands() + (projectPackagingExtension?.getPreUninstallCommands() ?: [])
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
List<Object> getAllPostUninstallCommands() {
|
||||
return getPostUninstallCommands() + (projectPackagingExtension?.getPostUninstallCommands() ?: [])
|
||||
getPostUninstallCommands() + (projectPackagingExtension?.getPostUninstallCommands() ?: [])
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
List<Object> getAllPreTransCommands() {
|
||||
return getPreTransCommands() + projectPackagingExtension?.getPreTransCommands()
|
||||
getPreTransCommands() + projectPackagingExtension?.getPreTransCommands()
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
List<Object> getAllPostTransCommands() {
|
||||
return getPostTransCommands() + projectPackagingExtension?.getPostTransCommands()
|
||||
getPostTransCommands() + projectPackagingExtension?.getPostTransCommands()
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
List<Object> getAllCommonCommands() {
|
||||
return getCommonCommands() + projectPackagingExtension?.getCommonCommands()
|
||||
getCommonCommands() + projectPackagingExtension?.getCommonCommands()
|
||||
}
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
List<Object> getAllSupplementaryControlFiles() {
|
||||
return getSupplementaryControlFiles() + (projectPackagingExtension?.getSupplementaryControlFiles() ?: [])
|
||||
getSupplementaryControlFiles() + (projectPackagingExtension?.getSupplementaryControlFiles() ?: [])
|
||||
}
|
||||
|
||||
@Input
|
||||
|
@ -263,6 +263,9 @@ class Rpm extends AbstractArchiveTask {
|
|||
mapping.map('signingKeyRing', {
|
||||
projectPackagingExtension?.getSigningKeyRing()
|
||||
})
|
||||
mapping.map('signingKeyHashAlgo', {
|
||||
projectPackagingExtension?.getSigningKeyHashAlgo()
|
||||
})
|
||||
mapping.map('user', {
|
||||
projectPackagingExtension?.getUser()?:getPackager()
|
||||
})
|
||||
|
|
|
@ -181,6 +181,7 @@ class RpmCopyAction implements CopyAction {
|
|||
builder.setPrivateKeyId task.getSigningKeyId()
|
||||
builder.setPrivateKeyPassphrase task.getSigningKeyPassphrase()
|
||||
builder.setPrivateKeyRing task.getSigningKeyRing()
|
||||
builder.setPrivateKeyHashAlgo task.getSigningKeyHashAlgo()
|
||||
}
|
||||
String sourcePackage = task.sourcePackage
|
||||
if (!sourcePackage) {
|
||||
|
|
|
@ -24,7 +24,7 @@ class RpmPlugin implements Plugin<Project> {
|
|||
project.ext.Rpm = Rpm.class
|
||||
|
||||
RpmBuilder.metaClass.getDefaultSourcePackage() {
|
||||
format.getLead().getName() + "-src.rpm"
|
||||
format.getLead().getName() + ".src.rpm"
|
||||
}
|
||||
|
||||
project.tasks.withType(Rpm) { Rpm task ->
|
||||
|
|
|
@ -36,6 +36,9 @@ class SystemPackagingExtension {
|
|||
@Input @Optional
|
||||
String signingKeyId
|
||||
|
||||
@Input @Optional
|
||||
String signingKeyHashAlgo
|
||||
|
||||
@Input @Optional
|
||||
String user
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
group = org.xbib
|
||||
name = rpm
|
||||
version = 1.0.0
|
||||
version = 1.0.1
|
||||
|
||||
bouncycastle.version = 1.57
|
||||
xbib-archive.version = 0.0.1
|
||||
|
|
|
@ -95,25 +95,25 @@ public class RpmBuilder {
|
|||
|
||||
private String privateKeyPassphrase;
|
||||
|
||||
private int triggerCounter = 0;
|
||||
private HashAlgo privateKeyHashAlgo;
|
||||
|
||||
private HashAlgo hashAlgo;
|
||||
private int triggerCounter = 0;
|
||||
|
||||
private CompressionType compressionType;
|
||||
|
||||
private String packageName;
|
||||
|
||||
public RpmBuilder() {
|
||||
this(HashAlgo.SHA256, CompressionType.GZIP);
|
||||
this(HashAlgo.SHA1, CompressionType.GZIP);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the builder and sets some required fields to known values.
|
||||
* @param hashAlgo the hash algo
|
||||
* @param privateKeyHashAlgo the hash algo
|
||||
* @param compressionType compression type
|
||||
*/
|
||||
public RpmBuilder(HashAlgo hashAlgo, CompressionType compressionType) {
|
||||
this.hashAlgo = hashAlgo;
|
||||
public RpmBuilder(HashAlgo privateKeyHashAlgo, CompressionType compressionType) {
|
||||
this.privateKeyHashAlgo = privateKeyHashAlgo;
|
||||
this.compressionType = compressionType;
|
||||
format.getHeader().createEntry(HeaderTag.HEADERI18NTABLE, "C");
|
||||
format.getHeader().createEntry(HeaderTag.BUILDTIME, (int) (System.currentTimeMillis() / 1000));
|
||||
|
@ -1452,6 +1452,17 @@ public class RpmBuilder {
|
|||
this.privateKeyPassphrase = privateKeyPassphrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash algo for the private key.
|
||||
*
|
||||
* @param privateKeyHashAlgo the private key hash algo
|
||||
*/
|
||||
public void setPrivateKeyHashAlgo(String privateKeyHashAlgo) {
|
||||
if (privateKeyHashAlgo != null) {
|
||||
this.privateKeyHashAlgo = HashAlgo.valueOf(privateKeyHashAlgo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set RPM package name.
|
||||
*
|
||||
|
@ -1538,8 +1549,8 @@ public class RpmBuilder {
|
|||
triggerscriptprogs.toArray(new String[triggerscriptprogs.size()]));
|
||||
}
|
||||
if (contents.size() > 0) {
|
||||
format.getHeader().createEntry(HeaderTag.FILEDIGESTALGOS, hashAlgo.num());
|
||||
format.getHeader().createEntry(HeaderTag.FILEDIGESTS, contents.getDigests(hashAlgo));
|
||||
format.getHeader().createEntry(HeaderTag.FILEDIGESTALGOS, HashAlgo.MD5.num());
|
||||
format.getHeader().createEntry(HeaderTag.FILEDIGESTS, contents.getDigests(HashAlgo.MD5));
|
||||
format.getHeader().createEntry(HeaderTag.FILESIZES, contents.getSizes());
|
||||
format.getHeader().createEntry(HeaderTag.FILEMODES, contents.getModes());
|
||||
format.getHeader().createEntry(HeaderTag.FILERDEVS, contents.getRdevs());
|
||||
|
@ -1566,7 +1577,7 @@ public class RpmBuilder {
|
|||
shaEntry.setSize(SHASIZE);
|
||||
|
||||
SignatureGenerator signatureGenerator = new SignatureGenerator(privateKeyRing, privateKeyId, privateKeyPassphrase);
|
||||
signatureGenerator.prepare(format.getSignatureHeader(), hashAlgo);
|
||||
signatureGenerator.prepare(format.getSignatureHeader(), privateKeyHashAlgo);
|
||||
format.getLead().write(channel);
|
||||
SpecEntry<byte[]> signatureEntry =
|
||||
(SpecEntry<byte[]>) format.getSignatureHeader().addEntry(SignatureTag.SIGNATURES, 16);
|
||||
|
@ -1576,7 +1587,7 @@ public class RpmBuilder {
|
|||
ChannelWrapper.Key<Integer> sigsizekey = output.start();
|
||||
ChannelWrapper.Key<byte[]> shakey = signatureGenerator.startDigest(output, "SHA");
|
||||
ChannelWrapper.Key<byte[]> md5key = signatureGenerator.startDigest(output, "MD5");
|
||||
signatureGenerator.startBeforeHeader(output, hashAlgo);
|
||||
signatureGenerator.startBeforeHeader(output, privateKeyHashAlgo);
|
||||
// Region concept. This tag contains an index record which specifies the portion of the Header Record
|
||||
// which was used for the calculation of a signature. This data shall be preserved or any header-only signature
|
||||
// will be invalidated.
|
||||
|
|
Loading…
Reference in a new issue