-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a roundtrip test * Move comparison tests to tests/building.rs and extend them * Use fixture RPMs for new tests in tests/parsing.rs
- Loading branch information
Showing
19 changed files
with
564 additions
and
370 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
#!/bin/sh | ||
|
||
export SOURCE_DATE_EPOCH="1681068559" | ||
REPRODUCIBLE_OPTS=( --define "use_source_date_epoch_as_buildtime 1" --define "_binary_payload w.ufdio" --define "_source_payload w.ufdio" ) | ||
|
||
for spec in SPECS/*.spec; do | ||
rpmbuild --define "_topdir `pwd`" --define "_binary_payload w.ufdio" --define "_source_payload w.ufdio" -ba $spec | ||
rpmbuild --define "_topdir `pwd`" $"${REPRODUCIBLE_OPTS[@]}" -ba $spec | ||
done | ||
|
||
rm -r ./BUILDROOT/ | ||
rm -r ./BUILD/ | ||
|
||
RSA_KEY_OPTS=( --define "_gpg_name rsa3072-rpm-signing-key" ) | ||
EDDSA_KEY_OPTS=( --define "_gpg_name ed25519-rpm-signing-key" ) | ||
|
||
rpmsign --addsign RPMS/x86_64/rpm-empty-0-0.x86_64.rpm $"${EDDSA_KEY_OPTS[@]}" | ||
rpmsign --addsign RPMS/x86_64/rpm-feature-coverage-2.3.4-5.el8.x86_64.rpm $"${RSA_KEY_OPTS[@]}" | ||
|
||
# @todo: how to make IMA signing work? I get errors. | ||
# --define "_file_signing_key rsa3072-rpm-signing-key" --signfiles |
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,18 @@ | ||
# in case we ever need to regenerate these | ||
|
||
# gpg --quick-generate-key 'rpm-rs key rsa3072 <[email protected]>' rsa3072 sign never | ||
# gpg --quick-generate-key 'rpm-rs key ed25519 <[email protected]>' ed25519 sign never | ||
|
||
# gpg --output ./signing_keys/public_rsa3072.asc --armor --export-secret-key [email protected] | ||
# gpg --output ./signing_keys/secret_rsa3072.asc --armor --export-secret-key [email protected] | ||
|
||
# gpg --output ./signing_keys/public_ed25519.asc --armor --export-secret-key [email protected] | ||
# gpg --output ./signing_keys/secret_ed25519.asc --armor --export-secret-key [email protected] | ||
|
||
gpg --import ./signing_keys/public_rsa3072.asc | ||
gpg --import ./signing_keys/secret_rsa3072.asc | ||
gpg --import ./signing_keys/public_ed25519.asc | ||
gpg --import ./signing_keys/secret_ed25519.asc | ||
|
||
sudo rpm --import ./signing_keys/public_rsa3072.asc | ||
sudo rpm --import ./signing_keys/public_ed25519.asc |
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+9.27 KB
test_assets/fixture_packages/rpm-feature-coverage-2.3.4-5.el8.x86_64.rpm
Binary file not shown.
10 changes: 10 additions & 0 deletions
10
test_assets/fixture_packages/signing_keys/public_ed25519.asc
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,10 @@ | ||
-----BEGIN PGP PUBLIC KEY BLOCK----- | ||
|
||
mDMEZDMGvRYJKwYBBAHaRw8BAQdASrUh0HQehtSwizkBSgYgSaACDks9C6yIewrO | ||
UH6ehv60PWVkMjU1MTktcnBtLXNpZ25pbmcta2V5IDxlZDI1NTE5LXJwbS1zaWdu | ||
aW5nLWtleUBleGFtcGxlLmNvbT6IkwQTFgoAOxYhBBgwZgjGUY6zix2XidD75dUz | ||
MrnnBQJkMwa9AhsDBQsJCAcCAiICBhUKCQgLAgQWAgMBAh4HAheAAAoJEND75dUz | ||
MrnnIDQA/07Uwbzl2eIC4UHsepiVbnI73sb+4K3HqVFrM/my+5d+AQC8VmwlX1+y | ||
Khz9gJ17tBAn519tulUxKzZvgoC6EZ11AQ== | ||
=kOIO | ||
-----END PGP PUBLIC KEY BLOCK----- |
24 changes: 24 additions & 0 deletions
24
test_assets/fixture_packages/signing_keys/public_rsa3072.asc
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,24 @@ | ||
-----BEGIN PGP PUBLIC KEY BLOCK----- | ||
|
||
mQGNBGQzBVYBDADgeyneDz+GKSlvUrAxcUt03LbSNKk3Wz/di1U3Wak+OHWk9RZK | ||
Itp17GRVT+Vno9Fz2u/4FvXb3GAzG7tDYeV/kRoyPdEPPoaxwaeukA5rKWlyvkYD | ||
AsRbZYQbCXYjQ04IsWhPGgLTPfFmMT5VEuTXE2Eb9u43bku/iw3DejdXBCNKNBwJ | ||
bTRfdMzfgFybpDCbX4WB27Swtl5MmBlRTRFyvyHoYlAIuiBYGMpLrkRUw+5ZMSI2 | ||
GcmJXp/AqxLD3AiPZYnvBE/PC9Zkb4Ty1+XsJyWlTxKvFO2szj7Qa0lKcr2iGuWZ | ||
rXKJo5uytpMZHmDJZLULHSHSitLJX3Cq8q0oPA3Z0PpijmmnWBIVShjflPGx/jEA | ||
EuCy6ozIK00YyxXgWdt3+LfRdDMx5IHYlpKaEo+KicnWh802CWNEXHHk6VcdvWH+ | ||
KYmBIeYKP2Yay2YWnS8xP3MLk2QRvkwJJ9dnpXVZ9B3pQBTK3oiVWydeE+ZaHiMb | ||
u6186dri1rAxHK0AEQEAAbRTcnNhMzA3Mi1ycG0tc2lnbmluZy1rZXkgKHJzYTMw | ||
NzIgc2lnbmluZyBrZXkpIDxyc2EzMDcyLXJwbS1zaWduaW5nLWtleUBleGFtcGxl | ||
LmNvbT6JAdEEEwEIADsWIQSMEWtRcfe81pf4+FJ+7xRST0FfXQUCZDMFVgIbAwUL | ||
CQgHAgIiAgYVCgkICwIEFgIDAQIeBwIXgAAKCRB+7xRST0FfXecRDACj7kcspbQB | ||
fNzdHUNmpBruEQSnh/tndZLZx8n6fl/Hzke8l/YyAgdZm48PB0JuwVWkI2kQI5nz | ||
taoqP0XgCruN1GO7j1Q5HhNh4qF8quv6jcQP4KXMCG+KsY+nL9yvVPytPzbzeagb | ||
wAPaFsiTV0nba5UeGf4QyHkgzP2aUAxoh8LCfo+DoXU68UbDnpPfcJ5qaQEvcXRK | ||
VirKEDGtN9wm1PXN77jAVg+aZ3I4SPX+05LFsbkq/827XYErbOnU0SrW09a4uHhd | ||
6gHcL5aw7KglsEcUf0hWSeT0mX+TZhiyGHg2aC1ggTsvr4y7J4syVw/2ezGla2aX | ||
n/2BpQET1a77uub2hCAP9iVyrcjXeNl61IsVcHTz7RmRmdG6DdA/MCTBYrwUOUFO | ||
xVAANXpYHE27wsFL3WjoTPSlQAAV9omTu0SJoTYctgfXL7IOl5Uk+18F57KmYmjy | ||
J4us8BaO3oHxzeYG7BOCtCTKQWsQwYMVflTd94DtwBG6F2BhGJfx10I= | ||
=dNgi | ||
-----END PGP PUBLIC KEY BLOCK----- |
11 changes: 11 additions & 0 deletions
11
test_assets/fixture_packages/signing_keys/secret_ed25519.asc
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,11 @@ | ||
-----BEGIN PGP PRIVATE KEY BLOCK----- | ||
|
||
lFgEZDMGvRYJKwYBBAHaRw8BAQdASrUh0HQehtSwizkBSgYgSaACDks9C6yIewrO | ||
UH6ehv4AAQD75kuLc7SufJW2tr5jHglJZTWcW6OcEq58v5Q2JaXSxRCRtD1lZDI1 | ||
NTE5LXJwbS1zaWduaW5nLWtleSA8ZWQyNTUxOS1ycG0tc2lnbmluZy1rZXlAZXhh | ||
bXBsZS5jb20+iJMEExYKADsWIQQYMGYIxlGOs4sdl4nQ++XVMzK55wUCZDMGvQIb | ||
AwULCQgHAgIiAgYVCgkICwIEFgIDAQIeBwIXgAAKCRDQ++XVMzK55yA0AP9O1MG8 | ||
5dniAuFB7HqYlW5yO97G/uCtx6lRazP5svuXfgEAvFZsJV9fsioc/YCde7QQJ+df | ||
bbpVMSs2b4KAuhGddQE= | ||
=OF0p | ||
-----END PGP PRIVATE KEY BLOCK----- |
45 changes: 45 additions & 0 deletions
45
test_assets/fixture_packages/signing_keys/secret_rsa3072.asc
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,45 @@ | ||
-----BEGIN PGP PRIVATE KEY BLOCK----- | ||
|
||
lQVYBGQzBVYBDADgeyneDz+GKSlvUrAxcUt03LbSNKk3Wz/di1U3Wak+OHWk9RZK | ||
Itp17GRVT+Vno9Fz2u/4FvXb3GAzG7tDYeV/kRoyPdEPPoaxwaeukA5rKWlyvkYD | ||
AsRbZYQbCXYjQ04IsWhPGgLTPfFmMT5VEuTXE2Eb9u43bku/iw3DejdXBCNKNBwJ | ||
bTRfdMzfgFybpD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SdtrlR4Z/hDIeSDM/ZpQDGiHwsJ+j4OhdTrxRsOe | ||
k99wnmppAS9xdEpWKsoQMa033CbU9c3vuMBWD5pncjhI9f7TksWxuSr/zbtdgSts | ||
6dTRKtbT1ri4eF3qAdwvlrDsqCWwRxR/SFZJ5PSZf5NmGLIYeDZoLWCBOy+vjLsn | ||
izJXD/Z7MaVrZpef/YGlARPVrvu65vaEIA/2JXKtyNd42XrUixVwdPPtGZGZ0boN | ||
0D8wJMFivBQ5QU7FUAA1elgcTbvCwUvdaOhM9KVAABX2iZO7RImhNhy2B9cvsg6X | ||
lST7XwXnsqZiaPIni6zwFo7egfHN5gbsE4K0JMpBaxDBgxV+VN33gO3AEboXYGEY | ||
l/HXQg== | ||
=K9Te | ||
-----END PGP PRIVATE KEY BLOCK----- |
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,99 @@ | ||
use std::io::Cursor; | ||
|
||
use bstr::ByteSlice; | ||
use pretty_assertions; | ||
|
||
use rpm::*; | ||
|
||
mod common; | ||
|
||
/// Build an empty package and compare it to one built by rpmbuild | ||
#[test] | ||
fn test_empty_package_equivalent() -> Result<(), Box<dyn std::error::Error>> { | ||
let empty_rpm = RPMPackage::open(common::rpm_empty_path())?; | ||
let built_empty_rpm = RPMBuilder::new("rpm-empty", "0", "LGPL", "x86-64", "").build()?; | ||
|
||
// @TODO: currently failing due to missing tags, different checksums, offsets etc. | ||
// empty_rpm.canonicalize()?; | ||
// built_empty_rpm.canonicalize()?; | ||
// pretty_assertions::assert_eq!(empty_rpm.metadata, built_empty_rpm.metadata); | ||
|
||
// Test that the payload generated is equivalent | ||
pretty_assertions::assert_str_eq!( | ||
format!("{:?}", &empty_rpm.content.as_bstr()), | ||
format!("{:?}", &built_empty_rpm.content.as_bstr()), | ||
); | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Build an empty source package and compare it to one built by rpmbuild | ||
/// Blocked on completion of source package support | ||
#[ignore = "https://github.com/rpm-rs/rpm/issues/66"] | ||
#[test] | ||
fn test_empty_source_package_equivalent() -> Result<(), Box<dyn std::error::Error>> { | ||
let empty_rpm = RPMPackage::open(common::rpm_empty_source_path())?; | ||
let built_empty_rpm = RPMBuilder::new("rpm-empty", "0", "LGPL", "x86-64", "").build()?; | ||
|
||
// @TODO: currently failing due to missing tags, different checksums, offsets etc. | ||
// empty_rpm.canonicalize()?; | ||
// built_empty_rpm.canonicalize()?; | ||
// pretty_assertions::assert_eq!(empty_rpm.metadata, built_empty_rpm.metadata); | ||
|
||
// Test that the payload generated is equivalent | ||
pretty_assertions::assert_str_eq!( | ||
format!("{:?}", &empty_rpm.content.as_bstr()), | ||
format!("{:?}", &built_empty_rpm.content.as_bstr()), | ||
); | ||
|
||
Ok(()) | ||
} | ||
|
||
// @todo: turn this into a comparison test for the rpm-feature-coverage RPM | ||
/// Build an RPM using many features of RPM and (eventually) compare it to one built by rpmbuild | ||
#[test] | ||
fn test_rpm_builder() -> Result<(), Box<dyn std::error::Error>> { | ||
use std::str::FromStr; | ||
|
||
let mut buff = Vec::<u8>::new(); | ||
|
||
let pkg = rpm::RPMBuilder::new("test", "1.0.0", "MIT", "x86_64", "some awesome package") | ||
.compression(rpm::Compressor::from_str("gzip")?) | ||
.with_file( | ||
"Cargo.toml", | ||
RPMFileOptions::new("/etc/awesome/config.toml").is_config(), | ||
)? | ||
// file mode is inherited from source file | ||
.with_file("Cargo.toml", RPMFileOptions::new("/usr/bin/awesome"))? | ||
.with_file( | ||
"Cargo.toml", | ||
// you can set a custom mode and custom user too | ||
RPMFileOptions::new("/etc/awesome/second.toml") | ||
.mode(0o100744) | ||
.user("hugo"), | ||
)? | ||
.pre_install_script("echo preinst") | ||
.add_changelog_entry("me", "was awesome, eh?", 123123123) | ||
.add_changelog_entry("you", "yeah, it was", 12312312) | ||
.requires(Dependency::any("wget")) | ||
.vendor("dummy vendor") | ||
.url("dummy url") | ||
.vcs("dummy vcs") | ||
.build()?; | ||
|
||
pkg.write(&mut buff)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Read a package, write it, and read it back - check for equivalence. | ||
#[test] | ||
fn test_rpm_roundtrip() -> Result<(), Box<dyn std::error::Error>> { | ||
let mut buf = Vec::new(); | ||
let rpm = RPMPackage::open(common::rpm_feature_coverage_pkg_path())?; | ||
rpm.write(&mut buf)?; | ||
let roundtripped_rpm = RPMPackage::parse(&mut Cursor::new(buf))?; | ||
|
||
assert_eq!(rpm, roundtripped_rpm); | ||
Ok(()) | ||
} |
Oops, something went wrong.