Skip to content

Commit 150dd3e

Browse files
committed
hack: test
1 parent 6aae52a commit 150dd3e

File tree

3 files changed

+57
-20
lines changed

3 files changed

+57
-20
lines changed

.packit.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,34 @@ srpm_build_deps:
1515
- git
1616
- libzstd-devel
1717
- openssl-devel
18-
- systemd
1918
- zstd
2019

20+
actions:
21+
# The last setp here is required by Packit to return the archive name
22+
# https://packit.dev/docs/configuration/actions#create-archive
23+
create-archive:
24+
- bash -c "cargo install cargo-vendor-filterer"
25+
- bash -c "cargo xtask spec"
26+
- bash -c "cat target/bootupd.spec"
27+
- bash -c "cp target/bootupd* contrib/packaging/"
28+
- bash -c "ls -1 target/bootupd*.tar.zstd | grep -v 'vendor'"
29+
# Do nothing with spec file. Two steps here are for debugging
30+
fix-spec-file:
31+
- bash -c "cat contrib/packaging/bootupd.spec"
32+
- bash -c "ls -al contrib/packaging/"
33+
2134
jobs:
2235
- job: copr_build
2336
trigger: pull_request
2437
targets:
25-
- centos-stream-9-x86_64
26-
- centos-stream-9-aarch64
27-
- centos-stream-9-s390x
28-
- centos-stream-10-x86_64
29-
- centos-stream-10-aarch64
30-
- centos-stream-10-s390x
31-
- centos-stream-10-ppc64le
32-
- fedora-43-x86_64
33-
- fedora-43-aarch64
34-
- fedora-43-s390x
35-
- fedora-43-ppc64le
36-
- fedora-rawhide-x86_64
3738
- fedora-rawhide-aarch64
38-
- fedora-rawhide-s390x
39-
- fedora-rawhide-ppc64le
39+
- fedora-rawhide-x86_64
4040

4141
- job: tests
4242
trigger: pull_request
4343
targets:
4444
- fedora-rawhide-aarch64
45+
- fedora-rawhide-x86_64
4546
tmt_plan: /tmt/plans/package
4647

4748
- job: propose_downstream

contrib/packaging/bootupd.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Summary: Bootloader updater
99

1010
License: Apache-2.0
1111
URL: https://github.com/coreos/bootupd
12-
Source0: %{crates_source}
12+
Source0: %{url}/releases/download/v%{version}/bootupd-%{version}.tar.zstd
1313
Source1: %{url}/releases/download/v%{version}/bootupd-%{version}-vendor.tar.zstd
1414
%if 0%{?fedora} || 0%{?rhel} >= 10
1515
ExcludeArch: %{ix86}

xtask/src/main.rs

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ fn try_main() -> Result<()> {
3232
"vendor" => vendor,
3333
"package" => package,
3434
"package-srpm" => package_srpm,
35+
"spec" => spec,
3536
_ => print_help,
3637
};
3738
f(&sh)?;
@@ -155,10 +156,9 @@ fn impl_package(sh: &Shell) -> Result<Package> {
155156
)
156157
.run()?;
157158
}
158-
// Compress with gzip and write to crate
159-
let srcpath: Utf8PathBuf = Utf8Path::new("target").join(format!("{namev}.crate"));
160-
cmd!(sh, "gzip --force --best {p}").run()?;
161-
std::fs::rename(format!("{p}.gz"), &srcpath)?;
159+
// Compress with zstd
160+
let srcpath: Utf8PathBuf = format!("{p}.zstd").into();
161+
cmd!(sh, "zstd --rm -f {p} -o {srcpath}").run()?;
162162

163163
Ok(Package {
164164
version: v,
@@ -243,6 +243,42 @@ fn package_srpm(sh: &Shell) -> Result<()> {
243243
Ok(())
244244
}
245245

246+
fn update_spec(sh: &Shell) -> Result<Utf8PathBuf> {
247+
let _targetdir = get_target_dir()?;
248+
let p = Utf8Path::new("target");
249+
let pkg = impl_package(sh)?;
250+
let srcpath = pkg.srcpath.file_name().unwrap();
251+
let v = pkg.version;
252+
let src_vendorpath = pkg.vendorpath.file_name().unwrap();
253+
{
254+
let specin = File::open(format!("contrib/packaging/{NAME}.spec"))
255+
.map(BufReader::new)
256+
.context("Opening spec")?;
257+
let mut o = File::create(p.join(format!("{NAME}.spec"))).map(BufWriter::new)?;
258+
for line in specin.lines() {
259+
let line = line?;
260+
if line.starts_with("Version:") {
261+
writeln!(o, "# Replaced by cargo xtask spec")?;
262+
writeln!(o, "Version: {v}")?;
263+
} else if line.starts_with("Source0") {
264+
writeln!(o, "Source0: {srcpath}")?;
265+
} else if line.starts_with("Source1") {
266+
writeln!(o, "Source1: {src_vendorpath}")?;
267+
} else {
268+
writeln!(o, "{line}")?;
269+
}
270+
}
271+
}
272+
let spec_path = p.join(format!("{NAME}.spec"));
273+
Ok(spec_path)
274+
}
275+
276+
fn spec(sh: &Shell) -> Result<()> {
277+
let s = update_spec(sh)?;
278+
println!("Generated: {s}");
279+
Ok(())
280+
}
281+
246282
fn print_help(_sh: &Shell) -> Result<()> {
247283
eprintln!(
248284
"Tasks:

0 commit comments

Comments
 (0)