From f150b9aeb4fcfcab8975e9ecad34f4521fd83fe3 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Sat, 30 Nov 2024 10:48:44 -0500 Subject: [PATCH] Update to 9.1.3 (close RHBZ#2329572) --- .gitignore | 2 ++ 653.patch | 21 +++++++++++++ get_source | 49 ++++++++++++++++++++++++++++++ oxipng-fix-metadata-auto.diff | 8 ++--- rust-oxipng.spec | 40 +++++++++++++++++++++--- rust2rpm.toml | 57 ++++++++++++++++++++++++++++++++++- sources | 3 +- 7 files changed, 170 insertions(+), 10 deletions(-) create mode 100644 653.patch create mode 100755 get_source diff --git a/.gitignore b/.gitignore index e4d81ac..0f2af7a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ /oxipng-9.0.0.crate /oxipng-9.1.1.crate /oxipng-9.1.2.crate +/oxipng-9.1.3.crate +/oxipng-9.1.3-filtered.tar.gz diff --git a/653.patch b/653.patch new file mode 100644 index 0000000..3940877 --- /dev/null +++ b/653.patch @@ -0,0 +1,21 @@ +From 112aa06a6db85bb1d8dd00530e7a8e0808bcbeb0 Mon Sep 17 00:00:00 2001 +From: Andrew +Date: Sat, 30 Nov 2024 21:16:36 +1300 +Subject: [PATCH] Fix manpage for `--zi` + +--- + src/cli.rs | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/cli.rs b/src/cli.rs +index cc861650..373d4141 100644 +--- a/src/cli.rs ++++ b/src/cli.rs +@@ -344,6 +344,7 @@ Recommended use is with '-o max' and '--fast'.") + Set the number of iterations to use for Zopfli compression. Using fewer iterations may \ + speed up compression for large files. This option requires '--zopfli' to be set.") + .long("zi") ++ .value_name("iterations") + .default_value("15") + .value_parser(1..=255) + .requires("zopfli"), diff --git a/get_source b/get_source new file mode 100755 index 0000000..f386276 --- /dev/null +++ b/get_source @@ -0,0 +1,49 @@ +#!/bin/sh +set -o errexit +set -o nounset + +if [ "$#" != '1' ] +then + cat 1>&2 < Downloading: ${URL}" 1>&2 +curl -L -O "${URL}" + +ARCHIVE="$(find . -mindepth 1 -maxdepth 1 -type f -name '*.tar.gz' -print -quit)" +echo "--> Extracting: $(basename "${ARCHIVE}")" 1>&2 +tar -xzf "${ARCHIVE}" +echo '--> Removing tests/files/ due to licensing issues' 1>&2 +TARDIR="$(basename "${ARCHIVE}" '.tar.gz')" +MTIME="$(stat -c '%Y' "${TARDIR}")" +rm -rv "${TARDIR}/tests/files/" +# Make sure the original mtime is preserved even if we modified the base +# directory by removing something at the top level. (So far, we didn’t.) +touch -d @"${MTIME}" "${TARDIR}" +FILTERED="$(basename "${ARCHIVE}" .tar.gz)-filtered.tar.gz" +echo "--> Re-archiving: ${FILTERED}" 1>&2 +# https://www.gnu.org/software/tar/manual/html_section/Reproducibility.html +TZ=UTC LC_ALL=C tar \ + --create \ + --sort=name \ + --format=posix \ + --numeric-owner --owner=0 --group=0 \ + --mode=go+u,go-w \ + --pax-option='delete=atime,delete=ctime' \ + "${TARDIR}/" | + gzip -9 > "${FILTERED}" +mv -v "${FILTERED}" "${OUTDIR}" +echo 'Done.' 1>&2 diff --git a/oxipng-fix-metadata-auto.diff b/oxipng-fix-metadata-auto.diff index d1216c1..db4d355 100644 --- a/oxipng-fix-metadata-auto.diff +++ b/oxipng-fix-metadata-auto.diff @@ -1,6 +1,6 @@ ---- oxipng-9.1.2/Cargo.toml 1970-01-01T00:00:01+00:00 -+++ oxipng-9.1.2/Cargo.toml 2024-07-15T22:13:30.187640+00:00 -@@ -150,7 +150,6 @@ +--- oxipng-9.1.3/Cargo.toml 1970-01-01T00:00:01+00:00 ++++ oxipng-9.1.3/Cargo.toml 2024-11-30T18:06:52.515550+00:00 +@@ -149,7 +149,6 @@ [features] binary = [ "dep:clap", @@ -8,7 +8,7 @@ "dep:env_logger", ] default = [ -@@ -169,13 +168,10 @@ +@@ -168,13 +167,10 @@ sanity-checks = ["dep:image"] zopfli = ["dep:zopfli"] diff --git a/rust-oxipng.spec b/rust-oxipng.spec index 0c7ae78..e046853 100644 --- a/rust-oxipng.spec +++ b/rust-oxipng.spec @@ -1,18 +1,30 @@ -# Generated by rust2rpm 26 -%bcond_without check +# Generated by rust2rpm 27 +%bcond check 1 %global crate oxipng Name: rust-oxipng -Version: 9.1.2 +Version: 9.1.3 Release: %autorelease Summary: Lossless PNG compression optimizer License: MIT URL: https://crates.io/crates/oxipng Source: %{crates_source} +# * We need the GitHub archive, in addition to the .crate from crates.io, +# because the crate does not contain the xtask/ directory required for +# generating a man page. However, because of some dubiously-licensed test +# files (https://github.com/shssoichiro/oxipng/issues/655), we must use a +# filtered version of the GitHub archive, obtained by running the script in +# Source11. We have asked upstream to simply include the contents of xtask/ in +# the published crates, https://github.com/shssoichiro/oxipng/issues/654. +Source10: https://github.com/shssoichiro/oxipng/archive/v%{version}/oxipng-%{version}-filtered.tar.gz +# * Script used to obtain Source10: ./get_source %%{version} +Source11: get_source # Automatically generated patch to strip dependencies and normalize metadata Patch: oxipng-fix-metadata-auto.diff +# * Fix manpage for --zi +Patch10: https://github.com/shssoichiro/oxipng/pull/653.patch BuildRequires: cargo-rpm-macros >= 24 @@ -153,19 +165,39 @@ use the "zopfli" feature of the "%{crate}" crate. %prep %autosetup -n %{crate}-%{version} -p1 +# Unpacks to oxipng-%%{version}/, *inside* the extracted crate +%setup -q -T -D -a 10 -c -n %{crate}-%{version} + +# Required for generating the man page: +# +# Note that the mangen xtask has its own dependencies, so we must run +# %%cargo_generate_buildrequires in the xtask directory if we are to invoke it +# in the build. +mv -v oxipng-%{version}/xtask ./ +# We can’t respect upstream’s lock file, though: +rm xtask/Cargo.lock + +# Demonstrate that sources from GitHub are not used to build the executable: +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust/#_package_sources +rm -r -v oxipng-%{version} %cargo_prep %generate_buildrequires %cargo_generate_buildrequires +pushd xtask >/dev/null +%cargo_generate_buildrequires +popd >/dev/null %build %cargo_build %{cargo_license_summary} %{cargo_license} > LICENSE.dependencies +# Generate the man page +%{__cargo} run --manifest-path xtask/Cargo.toml -- mangen %install %cargo_install -mansrc='target/release/assets/oxipng.1' +mansrc='target/xtask/mangen/manpages/oxipng.1' mandest='%{buildroot}%{_mandir}/man1' install -t "${mandest}" -D -p -m 0644 "${mansrc}" diff --git a/rust2rpm.toml b/rust2rpm.toml index ffd8b6d..81f3317 100644 --- a/rust2rpm.toml +++ b/rust2rpm.toml @@ -3,9 +3,64 @@ extra-files = [ "%{_mandir}/man1/oxipng.1*", ] +[[package.extra-sources]] +number = 10 +file = "https://github.com/shssoichiro/oxipng/archive/v%{version}/oxipng-%{version}-filtered.tar.gz" +comments = [ + """\ + We need the GitHub archive, in addition to the .crate from crates.io, \ + because the crate does not contain the xtask/ directory required for \ + generating a man page. However, because of some dubiously-licensed test \ + files (https://github.com/shssoichiro/oxipng/issues/655), we must use a \ + filtered version of the GitHub archive, obtained by running the script in \ + Source11. We have asked upstream to simply include the contents of xtask/ \ + in the published crates, https://github.com/shssoichiro/oxipng/issues/654.\ + """, +] +[[package.extra-sources]] +number = 11 +file = "get_source" +comments = [ + "Script used to obtain Source10: ./get_source %%{version}", +] + +[[package.extra-patches]] +number = 10 +file = "https://github.com/shssoichiro/oxipng/pull/653.patch" +comments = [ + "Fix manpage for --zi", +] + +[scripts.prep] +pre = [ + """\ +# Unpacks to oxipng-%%{version}/, *inside* the extracted crate +%setup -q -T -D -a 10 -c -n %{crate}-%{version} + +# Required for generating the man page: +# +# Note that the mangen xtask has its own dependencies, so we must run +# %%cargo_generate_buildrequires in the xtask directory if we are to invoke it +# in the build. +mv -v oxipng-%{version}/xtask ./ +# We can’t respect upstream’s lock file, though: +rm xtask/Cargo.lock + +# Demonstrate that sources from GitHub are not used to build the executable: +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust/#_package_sources +rm -r -v oxipng-%{version}\ + """ +] + +[scripts.build] +post = [ + "# Generate the man page", + "%{__cargo} run --manifest-path xtask/Cargo.toml -- mangen", +] + [scripts.install] post = [ - "mansrc='target/release/assets/oxipng.1'", + "mansrc='target/xtask/mangen/manpages/oxipng.1'", "mandest='%{buildroot}%{_mandir}/man1'", "install -t \"${mandest}\" -D -p -m 0644 \"${mansrc}\"", ] diff --git a/sources b/sources index f98f1f1..f2f1c4b 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ -SHA512 (oxipng-9.1.2.crate) = 23bba0a62add3c8224845c9d01d8414f2f8b27a694d50b23e048722a4562b0c39e88f8db5b42c9020563383e761816f1cb7188d9cfafad88c75131adaad96ae0 +SHA512 (oxipng-9.1.3.crate) = 72c53f29216b34fdc88b9d71842a7fd32cba3c9ef3556f9c35cb28eed527029d8ad78ea20b2e2174041542fb05a74288d2d08455fd487451637d781c8c286ce9 +SHA512 (oxipng-9.1.3-filtered.tar.gz) = 09ab91d1513e59b01a8fcf07c154e7dd056c09eab286a27edec10efb093b2a2e94084d85e3c901b4d3470762119796b9192163064c2806a273207063178050ce