recommends = new LinkedList<> ();;
/**
- * An optional signature descriptor for GPP signing the final RPM
+ * An optional signature descriptor for GPG signing the final RPM
*
* Also see signing
*
@@ -640,6 +642,40 @@ public void setMaximumSupportedRpmVersion ( final String maximumSupportedRpmVers
this.maximumSupportedRpmVersion = Version.fromVersionString ( maximumSupportedRpmVersion ).orElseThrow ( () -> new IllegalArgumentException ( String.format ( "Version '%s' is unknown", maximumSupportedRpmVersion ) ) );
}
+ /**
+ * Specify the "hint" for a provider of a signature configuration.
+ *
+ * By default the RPM writer will calculate and add information like MD5,
+ * SHA1, SHA256, etc. to the signature header of the RPM file. However,
+ * some, especially older (really old) RPM versions, have issues when the
+ * encounter signature information they don't understand. This parameter
+ * allows you to configure this process.
+ *
+ * What you configure here is the so called "hint" (Plexus component
+ * name/hint) of the provider to use. This plexus component has to be found
+ * in the class path of the plugin, during runtime. There are two default
+ * providers available, one is default
and the other is
+ * md5-only
. The latter only adds MD5 checksum information.
+ *
+ * The default is to add as much information as possible to the RPM. So
+ * normally you don't need this parameter.
+ *
+ * Specifying a configuration provider which cannot be found during the
+ * build, will fail the build.
+ *
+ * @since 1.4.0
+ */
+ @Parameter
+ private String signatureConfiguration;
+
+ public void setSignatureConfiguration ( final String signatureConfiguration )
+ {
+ this.signatureConfiguration = signatureConfiguration;
+ }
+
+ @Component ( role = SignatureConfiguration.class )
+ protected Map signatureConfigurationProviders;
+
@Override
public void execute () throws MojoExecutionException, MojoFailureException
{
@@ -718,7 +754,18 @@ public void execute () throws MojoExecutionException, MojoFailureException
fillPayload ( builder );
fillPrefixes ( builder );
- // add signer
+ // setup basic signature processors
+
+ if ( this.signatureConfiguration != null )
+ {
+ this.logger.info ( "Initialize with custom signature configuration: %s (%s)", this.signatureConfiguration, this.signatureConfiguration.getClass () );
+ final SignatureConfiguration provider = this.signatureConfigurationProviders.get ( this.signatureConfiguration );
+ if ( provider == null )
+ {
+ throw new MojoExecutionException ( String.format ( "Unable to find requested signature configuration provider '%s', have: %s", this.signatureConfiguration, this.signatureConfigurationProviders.keySet () ) );
+ }
+ provider.apply ( builder );
+ }
if ( !this.skipSigning && this.signature != null )
{
diff --git a/src/main/java/de/dentrassi/rpm/builder/signatures/DefaultSignatureConfiguration.java b/src/main/java/de/dentrassi/rpm/builder/signatures/DefaultSignatureConfiguration.java
new file mode 100644
index 0000000..dd45da4
--- /dev/null
+++ b/src/main/java/de/dentrassi/rpm/builder/signatures/DefaultSignatureConfiguration.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat Inc 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:
+ * Red Hat Inc - initial API and implementation
+ *******************************************************************************/
+package de.dentrassi.rpm.builder.signatures;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.eclipse.packager.rpm.build.RpmBuilder;
+
+@Component ( role = SignatureConfiguration.class, hint = "default" )
+public class DefaultSignatureConfiguration implements SignatureConfiguration
+{
+
+ @Override
+ public void apply ( final RpmBuilder builder )
+ {
+ builder.removeAllSignatureProcessors ();
+ builder.addDefaultSignatureProcessors ();
+ }
+
+}
diff --git a/src/main/java/de/dentrassi/rpm/builder/signatures/Md5OnlySignatureConfiguration.java b/src/main/java/de/dentrassi/rpm/builder/signatures/Md5OnlySignatureConfiguration.java
new file mode 100644
index 0000000..7c51681
--- /dev/null
+++ b/src/main/java/de/dentrassi/rpm/builder/signatures/Md5OnlySignatureConfiguration.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat Inc 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:
+ * Red Hat Inc - initial API and implementation
+ *******************************************************************************/
+package de.dentrassi.rpm.builder.signatures;
+
+import org.codehaus.plexus.component.annotations.Component;
+import org.eclipse.packager.rpm.build.RpmBuilder;
+import org.eclipse.packager.rpm.signature.SignatureProcessors;
+
+@Component ( role = SignatureConfiguration.class, hint = "md5-only" )
+public class Md5OnlySignatureConfiguration implements SignatureConfiguration
+{
+
+ @Override
+ public void apply ( final RpmBuilder builder )
+ {
+ builder.removeAllSignatureProcessors ();
+ builder.addSignatureProcessor ( SignatureProcessors.size () );
+ builder.addSignatureProcessor ( SignatureProcessors.md5 () );
+ builder.addSignatureProcessor ( SignatureProcessors.payloadSize () );
+ }
+
+}
diff --git a/src/main/java/de/dentrassi/rpm/builder/signatures/SignatureConfiguration.java b/src/main/java/de/dentrassi/rpm/builder/signatures/SignatureConfiguration.java
new file mode 100644
index 0000000..e5ef0bf
--- /dev/null
+++ b/src/main/java/de/dentrassi/rpm/builder/signatures/SignatureConfiguration.java
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Red Hat Inc 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:
+ * Red Hat Inc - initial API and implementation
+ *******************************************************************************/
+package de.dentrassi.rpm.builder.signatures;
+
+import org.eclipse.packager.rpm.build.RpmBuilder;
+
+public interface SignatureConfiguration
+{
+ public void apply ( RpmBuilder builder );
+}