-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for SHA256HEADER, FILE_DIGESTALGO, and Zstd compression
Signed-off-by: David Walluck <dwalluck@redhat.com>
- Loading branch information
Showing
18 changed files
with
927 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
rpm/src/main/java/org/eclipse/packager/rpm/build/BZip2PayloadCoding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Copyright (c) 2015, 2019 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
package org.eclipse.packager.rpm.build; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.util.Optional; | ||
|
||
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; | ||
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; | ||
import org.eclipse.packager.rpm.deps.Dependency; | ||
import org.eclipse.packager.rpm.deps.RpmDependencyFlags; | ||
|
||
public class BZip2PayloadCoding implements PayloadCoding | ||
{ | ||
protected BZip2PayloadCoding () | ||
{ | ||
|
||
} | ||
|
||
@Override | ||
public String getCoding () | ||
{ | ||
return "bzip2"; | ||
} | ||
|
||
@Override | ||
public Optional<Dependency> getDependency () | ||
{ | ||
return Optional.of ( new Dependency ( "PayloadIsBzip2", "3.0.5-1", RpmDependencyFlags.LESS, RpmDependencyFlags.EQUAL, RpmDependencyFlags.RPMLIB ) ); | ||
} | ||
|
||
@Override | ||
public InputStream createInputStream ( final InputStream in ) throws IOException | ||
{ | ||
return new BZip2CompressorInputStream ( in ); | ||
} | ||
|
||
@Override | ||
public OutputStream createOutputStream ( final OutputStream out, final Optional<String> optionalFlags ) throws IOException | ||
{ | ||
final String flags; | ||
|
||
final int blockSize; | ||
|
||
if ( optionalFlags.isPresent () && ( flags = optionalFlags.get () ).length() > 0 ) | ||
{ | ||
blockSize = Integer.parseInt ( flags.substring ( 0, 1 ) ); | ||
} | ||
else | ||
{ | ||
blockSize = BZip2CompressorOutputStream.MAX_BLOCKSIZE; | ||
} | ||
|
||
return new BZip2CompressorOutputStream ( out, blockSize ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
rpm/src/main/java/org/eclipse/packager/rpm/build/DigestAlgorithm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2015, 2019 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
package org.eclipse.packager.rpm.build; | ||
|
||
import java.io.IOException; | ||
|
||
import org.bouncycastle.bcpg.HashAlgorithmTags; | ||
|
||
public enum DigestAlgorithm | ||
{ | ||
MD5 ( "MD5", HashAlgorithmTags.MD5 ), | ||
SHA1 ( "SHA", HashAlgorithmTags.SHA1 ), | ||
RIPEMD160 ( "RIPE-MD160", HashAlgorithmTags.RIPEMD160 ), | ||
DOUBLE_SHA ( "Double-SHA", HashAlgorithmTags.DOUBLE_SHA ), | ||
MD2 ( "MD2", HashAlgorithmTags.MD2 ), | ||
TIGER_192 ( "Tiger-192", HashAlgorithmTags.TIGER_192 ), | ||
HAVAL_5_160 ( "Haval-5-160", HashAlgorithmTags.HAVAL_5_160 ), | ||
SHA256 ( "SHA-256", HashAlgorithmTags.SHA256 ), | ||
SHA384 ( "SHA-384", HashAlgorithmTags.SHA384 ), | ||
SHA512 ( "SHA-512", HashAlgorithmTags.SHA512 ), | ||
SHA224 ( "SHA-224", HashAlgorithmTags.SHA224 ); | ||
|
||
private String algorithm; | ||
|
||
private int tag; | ||
|
||
private DigestAlgorithm ( final String algorithm, final int tag ) | ||
{ | ||
this.algorithm = algorithm; | ||
this.tag = tag; | ||
} | ||
|
||
public String getAlgorithm () | ||
{ | ||
return algorithm; | ||
} | ||
|
||
public int getTag () | ||
{ | ||
return tag; | ||
} | ||
|
||
public static DigestAlgorithm fromTag ( final int tag ) throws IOException | ||
{ | ||
for ( DigestAlgorithm digestAlgorithm : DigestAlgorithm.values () ) | ||
{ | ||
if ( tag == digestAlgorithm.getTag () ) | ||
{ | ||
return digestAlgorithm; | ||
} | ||
} | ||
|
||
throw new IOException ( String.format ( "Unknown tag: %d", tag ) ); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
rpm/src/main/java/org/eclipse/packager/rpm/build/GzipPayloadCoding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Copyright (c) 2015, 2019 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
package org.eclipse.packager.rpm.build; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.util.Optional; | ||
import java.util.zip.Deflater; | ||
|
||
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; | ||
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream; | ||
import org.apache.commons.compress.compressors.gzip.GzipParameters; | ||
import org.eclipse.packager.rpm.deps.Dependency; | ||
|
||
public class GzipPayloadCoding implements PayloadCoding | ||
{ | ||
protected GzipPayloadCoding () | ||
{ | ||
|
||
} | ||
|
||
@Override | ||
public String getCoding () | ||
{ | ||
return "gzip"; | ||
} | ||
|
||
@Override | ||
public Optional<Dependency> getDependency () | ||
{ | ||
return Optional.empty (); | ||
} | ||
|
||
@Override | ||
public InputStream createInputStream ( final InputStream in ) throws IOException | ||
{ | ||
return new GzipCompressorInputStream ( in ); | ||
} | ||
|
||
@Override | ||
public OutputStream createOutputStream ( final OutputStream out, final Optional<String> optionalFlags ) throws IOException | ||
{ | ||
final String flags; | ||
final int compressionLevel; | ||
|
||
if ( optionalFlags.isPresent () && ( flags = optionalFlags.get () ).length() > 0 ) | ||
{ | ||
compressionLevel = Integer.parseInt ( flags.substring ( 0, 1 ) ); | ||
} | ||
else | ||
{ | ||
compressionLevel = Deflater.BEST_COMPRESSION; | ||
} | ||
|
||
final GzipParameters parameters = new GzipParameters (); | ||
|
||
parameters.setCompressionLevel ( compressionLevel ); | ||
|
||
return new GzipCompressorOutputStream ( out, parameters ); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
rpm/src/main/java/org/eclipse/packager/rpm/build/LZMAPayloadCoding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Copyright (c) 2015, 2019 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
package org.eclipse.packager.rpm.build; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.util.Optional; | ||
|
||
import org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream; | ||
import org.apache.commons.compress.compressors.lzma.LZMACompressorOutputStream; | ||
import org.eclipse.packager.rpm.deps.Dependency; | ||
import org.eclipse.packager.rpm.deps.RpmDependencyFlags; | ||
|
||
public class LZMAPayloadCoding implements PayloadCoding | ||
{ | ||
protected LZMAPayloadCoding () | ||
{ | ||
|
||
} | ||
|
||
@Override | ||
public String getCoding () | ||
{ | ||
return "lzma"; | ||
} | ||
|
||
@Override | ||
public Optional<Dependency> getDependency () | ||
{ | ||
return Optional.of ( new Dependency ( "PayloadIsLzma", "4.4.6-1", RpmDependencyFlags.LESS, RpmDependencyFlags.EQUAL, RpmDependencyFlags.RPMLIB ) ); | ||
} | ||
|
||
@Override | ||
public InputStream createInputStream ( final InputStream in ) throws IOException | ||
{ | ||
return new LZMACompressorInputStream ( in ); | ||
} | ||
|
||
@Override | ||
public OutputStream createOutputStream ( final OutputStream out, final Optional<String> optionalFlags ) throws IOException | ||
{ | ||
return new LZMACompressorOutputStream ( out ); | ||
} | ||
} |
Oops, something went wrong.