fall back to MD5 file digests as default because rpm on RHEL9/F37 is annoying us
This commit is contained in:
parent
f4ec0b1acb
commit
d0bbd3b1a9
15 changed files with 110 additions and 40 deletions
|
@ -6,7 +6,7 @@ plugins {
|
||||||
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
|
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
|
||||||
id "org.cyclonedx.bom" version "1.7.2"
|
id "org.cyclonedx.bom" version "1.7.2"
|
||||||
id "com.github.spotbugs" version "5.0.13"
|
id "com.github.spotbugs" version "5.0.13"
|
||||||
id "org.xbib.gradle.plugin.asciidoctor" version "2.5.2.2"
|
id "org.xbib.gradle.plugin.asciidoctor" version "3.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper {
|
wrapper {
|
||||||
|
@ -34,5 +34,7 @@ subprojects {
|
||||||
apply from: rootProject.file('gradle/repositories/maven.gradle')
|
apply from: rootProject.file('gradle/repositories/maven.gradle')
|
||||||
apply from: rootProject.file('gradle/compile/java.gradle')
|
apply from: rootProject.file('gradle/compile/java.gradle')
|
||||||
apply from: rootProject.file('gradle/test/junit5.gradle')
|
apply from: rootProject.file('gradle/test/junit5.gradle')
|
||||||
apply from: rootProject.file('gradle/publishing/maven.gradle')
|
apply from: rootProject.file('gradle/publish/maven.gradle')
|
||||||
}
|
}
|
||||||
|
apply from: rootProject.file('gradle/publish/sonatype.gradle')
|
||||||
|
apply from: rootProject.file('gradle/publish/forgejo.gradle')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
group = org.xbib
|
group = org.xbib
|
||||||
name = rpm
|
name = rpm
|
||||||
version = 3.0.0
|
version = 3.0.1
|
||||||
|
|
||||||
org.gradle.warning.mode = ALL
|
org.gradle.warning.mode = ALL
|
||||||
|
|
16
gradle/publish/forgejo.gradle
Normal file
16
gradle/publish/forgejo.gradle
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
if (project.hasProperty('forgeJoToken')) {
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url 'https://xbib.org/api/packages/joerg/maven'
|
||||||
|
credentials(HttpHeaderCredentials) {
|
||||||
|
name = "Authorization"
|
||||||
|
value = "token ${project.property('forgeJoToken')}"
|
||||||
|
}
|
||||||
|
authentication {
|
||||||
|
header(HttpHeaderAuthentication)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
gradle/publish/ivy.gradle
Normal file
27
gradle/publish/ivy.gradle
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
apply plugin: 'ivy-publish'
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
ivy {
|
||||||
|
url = "https://xbib.org/repo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
publications {
|
||||||
|
ivy(IvyPublication) {
|
||||||
|
from components.java
|
||||||
|
descriptor {
|
||||||
|
license {
|
||||||
|
name = 'The Apache License, Version 2.0'
|
||||||
|
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||||
|
}
|
||||||
|
author {
|
||||||
|
name = 'Jörg Prante'
|
||||||
|
url = 'http://example.com/users/jane'
|
||||||
|
}
|
||||||
|
descriptor.description {
|
||||||
|
text = rootProject.ext.description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
gradle/publish/sonatype.gradle
Normal file
11
gradle/publish/sonatype.gradle
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
|
||||||
|
nexusPublishing {
|
||||||
|
repositories {
|
||||||
|
sonatype {
|
||||||
|
username = project.property('ossrhUsername')
|
||||||
|
password = project.property('ossrhPassword')
|
||||||
|
packageGroup = "org.xbib"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +0,0 @@
|
||||||
|
|
||||||
if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) {
|
|
||||||
|
|
||||||
apply plugin: 'io.codearte.nexus-staging'
|
|
||||||
|
|
||||||
nexusStaging {
|
|
||||||
username = project.property('ossrhUsername')
|
|
||||||
password = project.property('ossrhPassword')
|
|
||||||
packageGroup = "org.xbib"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,4 +15,5 @@ module org.xbib.rpm {
|
||||||
requires transitive org.bouncycastle.provider;
|
requires transitive org.bouncycastle.provider;
|
||||||
requires org.xbib.io.compress.bzip;
|
requires org.xbib.io.compress.bzip;
|
||||||
requires org.xbib.io.compress.xz;
|
requires org.xbib.io.compress.xz;
|
||||||
|
requires java.logging;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,8 @@ public class RpmBuilder {
|
||||||
|
|
||||||
private HashAlgo privateKeyHashAlgo;
|
private HashAlgo privateKeyHashAlgo;
|
||||||
|
|
||||||
|
private HashAlgo fileDigestsAlgo;
|
||||||
|
|
||||||
private int triggerCounter = 0;
|
private int triggerCounter = 0;
|
||||||
|
|
||||||
private final CompressionType compressionType;
|
private final CompressionType compressionType;
|
||||||
|
@ -107,7 +109,7 @@ public class RpmBuilder {
|
||||||
private String packageName;
|
private String packageName;
|
||||||
|
|
||||||
public RpmBuilder() {
|
public RpmBuilder() {
|
||||||
this(HashAlgo.SHA1, CompressionType.GZIP);
|
this(HashAlgo.SHA1, HashAlgo.MD5, CompressionType.GZIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,8 +117,9 @@ public class RpmBuilder {
|
||||||
* @param privateKeyHashAlgo the hash algo
|
* @param privateKeyHashAlgo the hash algo
|
||||||
* @param compressionType compression type
|
* @param compressionType compression type
|
||||||
*/
|
*/
|
||||||
public RpmBuilder(HashAlgo privateKeyHashAlgo, CompressionType compressionType) {
|
public RpmBuilder(HashAlgo privateKeyHashAlgo, HashAlgo fileDigestsAlgo, CompressionType compressionType) {
|
||||||
this.privateKeyHashAlgo = privateKeyHashAlgo;
|
this.privateKeyHashAlgo = privateKeyHashAlgo;
|
||||||
|
this.fileDigestsAlgo = fileDigestsAlgo;
|
||||||
this.compressionType = compressionType;
|
this.compressionType = compressionType;
|
||||||
format.getHeader().createEntry(HeaderTag.HEADERI18NTABLE, "C");
|
format.getHeader().createEntry(HeaderTag.HEADERI18NTABLE, "C");
|
||||||
format.getHeader().createEntry(HeaderTag.BUILDTIME, (int) (System.currentTimeMillis() / 1000));
|
format.getHeader().createEntry(HeaderTag.BUILDTIME, (int) (System.currentTimeMillis() / 1000));
|
||||||
|
@ -1091,6 +1094,15 @@ public class RpmBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hash algo for the file digests.
|
||||||
|
*
|
||||||
|
* @param fileDigestsAlgo the file digests hash algo, default is MD5.
|
||||||
|
*/
|
||||||
|
public void setFileDigestsAlgo(HashAlgo fileDigestsAlgo) {
|
||||||
|
this.fileDigestsAlgo = fileDigestsAlgo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set RPM package name.
|
* Set RPM package name.
|
||||||
*
|
*
|
||||||
|
@ -1170,8 +1182,9 @@ public class RpmBuilder {
|
||||||
format.getHeader().createEntry(HeaderTag.TRIGGERSCRIPTPROG, triggerscriptprogs.toArray(new String[0]));
|
format.getHeader().createEntry(HeaderTag.TRIGGERSCRIPTPROG, triggerscriptprogs.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
if (contents.size() > 0) {
|
if (contents.size() > 0) {
|
||||||
format.getHeader().createEntry(HeaderTag.FILEDIGESTALGOS, HashAlgo.SHA256.num());
|
StringList digests = contents.getDigests(fileDigestsAlgo);
|
||||||
format.getHeader().createEntry(HeaderTag.FILEDIGESTS, contents.getDigests(HashAlgo.SHA256));
|
format.getHeader().createEntry(HeaderTag.FILEDIGESTALGOS, fileDigestsAlgo.num());
|
||||||
|
format.getHeader().createEntry(HeaderTag.FILEDIGESTS, digests);
|
||||||
format.getHeader().createEntry(HeaderTag.FILESIZES, contents.getSizes());
|
format.getHeader().createEntry(HeaderTag.FILESIZES, contents.getSizes());
|
||||||
format.getHeader().createEntry(HeaderTag.FILEMODES, contents.getModes());
|
format.getHeader().createEntry(HeaderTag.FILEMODES, contents.getModes());
|
||||||
format.getHeader().createEntry(HeaderTag.FILERDEVS, contents.getRdevs());
|
format.getHeader().createEntry(HeaderTag.FILERDEVS, contents.getRdevs());
|
||||||
|
@ -1255,18 +1268,22 @@ public class RpmBuilder {
|
||||||
|
|
||||||
private OutputStream createCompressedStream(OutputStream outputStream) throws IOException {
|
private OutputStream createCompressedStream(OutputStream outputStream) throws IOException {
|
||||||
switch (compressionType) {
|
switch (compressionType) {
|
||||||
case NONE:
|
case NONE -> {
|
||||||
return outputStream;
|
return outputStream;
|
||||||
case GZIP:
|
}
|
||||||
|
case GZIP -> {
|
||||||
return new GZIPOutputStream(outputStream, true);
|
return new GZIPOutputStream(outputStream, true);
|
||||||
case BZIP2:
|
}
|
||||||
|
case BZIP2 -> {
|
||||||
return new Bzip2OutputStream(outputStream);
|
return new Bzip2OutputStream(outputStream);
|
||||||
case XZ:
|
}
|
||||||
|
case XZ -> {
|
||||||
X86Options x86 = new X86Options();
|
X86Options x86 = new X86Options();
|
||||||
LZMA2Options lzma2 = new LZMA2Options();
|
LZMA2Options lzma2 = new LZMA2Options();
|
||||||
FilterOptions[] options = {x86, lzma2};
|
FilterOptions[] options = {x86, lzma2};
|
||||||
return new XZOutputStream(outputStream, options);
|
return new XZOutputStream(outputStream, options);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// not reached
|
// not reached
|
||||||
return outputStream;
|
return outputStream;
|
||||||
}
|
}
|
||||||
|
@ -1466,6 +1483,4 @@ public class RpmBuilder {
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.nio.BufferUnderflowException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.ReadableByteChannel;
|
import java.nio.channels.ReadableByteChannel;
|
||||||
import java.nio.channels.WritableByteChannel;
|
import java.nio.channels.WritableByteChannel;
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
|
@ -135,6 +135,7 @@ public class Contents {
|
||||||
CpioHeader header = new CpioHeader(path);
|
CpioHeader header = new CpioHeader(path);
|
||||||
header.setType(CpioHeader.SYMLINK);
|
header.setType(CpioHeader.SYMLINK);
|
||||||
header.setFileSize(target.length());
|
header.setFileSize(target.length());
|
||||||
|
header.setChecksum(0);
|
||||||
header.setMtime(System.currentTimeMillis());
|
header.setMtime(System.currentTimeMillis());
|
||||||
header.setUid(uid == -1 ? DEFAULT_UID : uid);
|
header.setUid(uid == -1 ? DEFAULT_UID : uid);
|
||||||
header.setGid(gid == -1 ? DEFAULT_GID : gid);
|
header.setGid(gid == -1 ? DEFAULT_GID : gid);
|
||||||
|
@ -229,6 +230,7 @@ public class Contents {
|
||||||
header.setGid(gid == -1 ? (int) Files.getAttribute(source, "unix:gid") : gid);
|
header.setGid(gid == -1 ? (int) Files.getAttribute(source, "unix:gid") : gid);
|
||||||
header.setPermissions(permissions == -1 ? DEFAULT_FILE_PERMISSION : permissions);
|
header.setPermissions(permissions == -1 ? DEFAULT_FILE_PERMISSION : permissions);
|
||||||
header.setVerifyFlags(verifyFlags);
|
header.setVerifyFlags(verifyFlags);
|
||||||
|
header.setChecksum(0);
|
||||||
headers.add(header);
|
headers.add(header);
|
||||||
UserGroup userGroup = new UserGroup();
|
UserGroup userGroup = new UserGroup();
|
||||||
userGroup.user = getDefaultIfMissing(uname, DEFAULT_USERNAME);
|
userGroup.user = getDefaultIfMissing(uname, DEFAULT_USERNAME);
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class CpioHeader {
|
||||||
|
|
||||||
private int rdevMajor;
|
private int rdevMajor;
|
||||||
|
|
||||||
private int checksum;
|
private int checksum; // ignored!
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ public class CpioHeader {
|
||||||
public CpioHeader(String name, URL url) {
|
public CpioHeader(String name, URL url) {
|
||||||
try {
|
try {
|
||||||
URLConnection connection = url.openConnection();
|
URLConnection connection = url.openConnection();
|
||||||
mtime = connection.getLastModified();
|
this.mtime = connection.getLastModified();
|
||||||
filesize = connection.getContentLength();
|
this.filesize = connection.getContentLength();
|
||||||
this.name = normalizePath(name);
|
this.name = normalizePath(name);
|
||||||
setType(FILE);
|
setType(FILE);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -97,8 +97,8 @@ public class CpioHeader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CpioHeader(String name, Path path) throws IOException {
|
public CpioHeader(String name, Path path) throws IOException {
|
||||||
mtime = Files.getLastModifiedTime(path).toMillis();
|
this.mtime = Files.getLastModifiedTime(path).toMillis();
|
||||||
filesize = (int) Files.size(path);
|
this.filesize = (int) Files.size(path);
|
||||||
this.name = normalizePath(name);
|
this.name = normalizePath(name);
|
||||||
setType(Files.isDirectory(path) ? DIR : FILE);
|
setType(Files.isDirectory(path) ? DIR : FILE);
|
||||||
}
|
}
|
||||||
|
@ -226,6 +226,14 @@ public class CpioHeader {
|
||||||
this.filesize = filesize;
|
this.filesize = filesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getChecksum() {
|
||||||
|
return checksum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChecksum(int checksum) {
|
||||||
|
this.checksum = checksum;
|
||||||
|
}
|
||||||
|
|
||||||
protected ByteBuffer writeSix(CharSequence data) {
|
protected ByteBuffer writeSix(CharSequence data) {
|
||||||
return charset.encode(pad(data, 6));
|
return charset.encode(pad(data, 6));
|
||||||
}
|
}
|
||||||
|
@ -354,6 +362,7 @@ public class CpioHeader {
|
||||||
"RDevMinor: " + rdevMinor + "\n" +
|
"RDevMinor: " + rdevMinor + "\n" +
|
||||||
"RDevMajor: " + rdevMajor + "\n" +
|
"RDevMajor: " + rdevMajor + "\n" +
|
||||||
"NameSize: " + (name.length() + 1) + "\n" +
|
"NameSize: " + (name.length() + 1) + "\n" +
|
||||||
"Name: " + name + "\n";
|
"Name: " + name + "\n" +
|
||||||
|
"Checksum: " + checksum + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package org.xbib.rpm.security;
|
package org.xbib.rpm.security;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumeration of hash algorithms as of RFC 4880.
|
* Enumeration of hash algorithms as of RFC 4880.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public enum HashAlgo {
|
public enum HashAlgo {
|
||||||
|
|
||||||
|
@ -19,9 +17,9 @@ public enum HashAlgo {
|
||||||
SHA512("SHA-512", 10),
|
SHA512("SHA-512", 10),
|
||||||
SHA224("SHA-224", 11);
|
SHA224("SHA-224", 11);
|
||||||
|
|
||||||
String algo;
|
final String algo;
|
||||||
|
|
||||||
int num;
|
final int num;
|
||||||
|
|
||||||
HashAlgo(String algo, int num) {
|
HashAlgo(String algo, int num) {
|
||||||
this.algo = algo;
|
this.algo = algo;
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class RpmBuilderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBzip2Build() throws Exception {
|
public void testBzip2Build() throws Exception {
|
||||||
RpmBuilder rpmBuilder = new RpmBuilder(HashAlgo.SHA256, CompressionType.GZIP);
|
RpmBuilder rpmBuilder = new RpmBuilder(HashAlgo.SHA256, HashAlgo.MD5, CompressionType.GZIP);
|
||||||
rpmBuilder.setPackage("test-compressed", "1.0", "1");
|
rpmBuilder.setPackage("test-compressed", "1.0", "1");
|
||||||
rpmBuilder.setBuildHost("localhost");
|
rpmBuilder.setBuildHost("localhost");
|
||||||
rpmBuilder.setLicense("GPL");
|
rpmBuilder.setLicense("GPL");
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
package org.xbib.rpm;
|
package org.xbib.rpm;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.xbib.rpm.lead.Architecture;
|
import org.xbib.rpm.lead.Architecture;
|
||||||
import org.xbib.rpm.lead.Os;
|
import org.xbib.rpm.lead.Os;
|
||||||
import org.xbib.rpm.lead.PackageType;
|
import org.xbib.rpm.lead.PackageType;
|
||||||
|
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import org.xbib.rpm.payload.Directive;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SimpleRpmTest {
|
public class SimpleRpmTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -28,6 +27,8 @@ public class SimpleRpmTest {
|
||||||
rpmBuilder.setPackager("Jane Doe");
|
rpmBuilder.setPackager("Jane Doe");
|
||||||
rpmBuilder.setUrl("http://example.org");
|
rpmBuilder.setUrl("http://example.org");
|
||||||
rpmBuilder.setProvides("test");
|
rpmBuilder.setProvides("test");
|
||||||
|
rpmBuilder.addFile("/etc", Paths.get("build.gradle"), 0, 0,
|
||||||
|
EnumSet.of(Directive.NONE), "root", "root", false);
|
||||||
rpmBuilder.build(Paths.get("build"));
|
rpmBuilder.build(Paths.get("build"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue