From 16515a8f8be4aa04541073e9ecede23566fc534f Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Jan 22 2025 21:48:03 +0000 Subject: spec: generate from template Overwriting a VCS-controlled file and then cleaning up the change is error-prone. Instead, keep a spec template and then generate and delete the versioned spec as needed. --- diff --git a/.gitignore b/.gitignore index 3d58e8c..72f8885 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,11 @@ aarch64 build dist flatpak_module_tools.egg-info +flatpak-module-tools.spec htmlcov x86_64 VERSION .tox *.pyc +*.src.rpm +*.tar.gz diff --git a/flatpak-module-tools.spec b/flatpak-module-tools.spec deleted file mode 100644 index 79d89cb..0000000 --- a/flatpak-module-tools.spec +++ /dev/null @@ -1,121 +0,0 @@ -%global srcname flatpak-module-tools -%global project_version @PROJECT_VERSION@ - -Name: %{srcname} -Version: @RPM_VERSION@ -Release: %autorelease -Summary: Tools for maintaining Flatpak applications and runtimes as Fedora modules - -License: MIT -URL: https://pagure.io/flatpak-module-tools -Source0: https://releases.pagure.org/flatpak-module-tools/flatpak-module-tools-%{project_version}.tar.gz - -BuildArch: noarch -# i386 is not supported by flatpak_module_tools.utils.Arch -ExcludeArch: %{ix86} - -BuildRequires: python3-build -BuildRequires: python3-devel -BuildRequires: python3-pip -BuildRequires: python3-setuptools -BuildRequires: python3-setuptools_scm+toml -BuildRequires: python3-wheel -BuildRequires: python3-zstandard - -# For tests -BuildRequires: createrepo_c -BuildRequires: flatpak -BuildRequires: git-core -BuildRequires: libappstream-glib -BuildRequires: libmodulemd -BuildRequires: librsvg2 -BuildRequires: ostree -BuildRequires: python3-click -BuildRequires: python3-gobject-base -BuildRequires: python3-jinja2 -BuildRequires: python3-koji -# GI overrides for Modulemd -BuildRequires: python3-libmodulemd -BuildRequires: python3-networkx -BuildRequires: python3-pytest -BuildRequires: python3-requests -BuildRequires: python3-responses -BuildRequires: python3-rpm -BuildRequires: python3-yaml -BuildRequires: zstd - -Requires: python3-%{srcname} = %{version}-%{release} -Requires: python3-jinja2 -Requires: python3-koji -Requires: python3-networkx -Requires: python3-requests-toolbelt -Requires: python3-solv - -%description -flatpak-module-tools is a set of command line tools (all accessed via a single -'flatpak-module' executable) for operations related to maintaining Flatpak -applications and runtimes as Fedora modules. - -%package -n python3-%{srcname} -Summary: Shared code for building Flatpak applications and runtimes from Fedora modules - -# Note - pythonN-flatpak-modules-tools subpackage contains all the Python files from -# the upstream distribution, but some of them are only useful for the CLI, not -# for using this as a library for atomic-reactor. The dependencies here are those -# needed for library usage, the main package has the remainder. - -Requires: createrepo_c -Requires: flatpak -# For appstream-compose -Requires: libappstream-glib -# for SVG gdk-pixbuf loader -Requires: librsvg2 -Requires: ostree -Requires: python3-click -Requires: python3-gobject-base -Requires: python3-requests -Requires: python3-rpm -Requires: python3-yaml -Requires: python3-zstandard -Requires: zstd - -# Output changed from .oci.tar.gz to .oci.tar -Conflicts: koji-flatpak <= 0.2 - -%description -n python3-%{srcname} -Python3 library for Flatpak handling - -%prep -%autosetup -p1 -n %{srcname}-%{project_version} -# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters -sed -i -e '/pytest-cov/d' -e '/addopts/s/--cov[^ "]*//g' pyproject.toml - - -%build -export SETUPTOOLS_SCM_PRETEND_VERSION=%{project_version} -%pyproject_wheel - - -%check -# Tests using RPM don't work well inside %%check -%pytest -k "not test_create_rpm_manifest" - - -%install -%pyproject_install - - -%files -%license LICENSE -%doc README.md -%{_bindir}/flatpak-module -%{_bindir}/flatpak-module-depchase - - -%files -n python3-%{srcname} -%license LICENSE -%{python3_sitelib}/* - - -%changelog -%autochangelog diff --git a/flatpak-module-tools.spec.in b/flatpak-module-tools.spec.in new file mode 100644 index 0000000..79d89cb --- /dev/null +++ b/flatpak-module-tools.spec.in @@ -0,0 +1,121 @@ +%global srcname flatpak-module-tools +%global project_version @PROJECT_VERSION@ + +Name: %{srcname} +Version: @RPM_VERSION@ +Release: %autorelease +Summary: Tools for maintaining Flatpak applications and runtimes as Fedora modules + +License: MIT +URL: https://pagure.io/flatpak-module-tools +Source0: https://releases.pagure.org/flatpak-module-tools/flatpak-module-tools-%{project_version}.tar.gz + +BuildArch: noarch +# i386 is not supported by flatpak_module_tools.utils.Arch +ExcludeArch: %{ix86} + +BuildRequires: python3-build +BuildRequires: python3-devel +BuildRequires: python3-pip +BuildRequires: python3-setuptools +BuildRequires: python3-setuptools_scm+toml +BuildRequires: python3-wheel +BuildRequires: python3-zstandard + +# For tests +BuildRequires: createrepo_c +BuildRequires: flatpak +BuildRequires: git-core +BuildRequires: libappstream-glib +BuildRequires: libmodulemd +BuildRequires: librsvg2 +BuildRequires: ostree +BuildRequires: python3-click +BuildRequires: python3-gobject-base +BuildRequires: python3-jinja2 +BuildRequires: python3-koji +# GI overrides for Modulemd +BuildRequires: python3-libmodulemd +BuildRequires: python3-networkx +BuildRequires: python3-pytest +BuildRequires: python3-requests +BuildRequires: python3-responses +BuildRequires: python3-rpm +BuildRequires: python3-yaml +BuildRequires: zstd + +Requires: python3-%{srcname} = %{version}-%{release} +Requires: python3-jinja2 +Requires: python3-koji +Requires: python3-networkx +Requires: python3-requests-toolbelt +Requires: python3-solv + +%description +flatpak-module-tools is a set of command line tools (all accessed via a single +'flatpak-module' executable) for operations related to maintaining Flatpak +applications and runtimes as Fedora modules. + +%package -n python3-%{srcname} +Summary: Shared code for building Flatpak applications and runtimes from Fedora modules + +# Note - pythonN-flatpak-modules-tools subpackage contains all the Python files from +# the upstream distribution, but some of them are only useful for the CLI, not +# for using this as a library for atomic-reactor. The dependencies here are those +# needed for library usage, the main package has the remainder. + +Requires: createrepo_c +Requires: flatpak +# For appstream-compose +Requires: libappstream-glib +# for SVG gdk-pixbuf loader +Requires: librsvg2 +Requires: ostree +Requires: python3-click +Requires: python3-gobject-base +Requires: python3-requests +Requires: python3-rpm +Requires: python3-yaml +Requires: python3-zstandard +Requires: zstd + +# Output changed from .oci.tar.gz to .oci.tar +Conflicts: koji-flatpak <= 0.2 + +%description -n python3-%{srcname} +Python3 library for Flatpak handling + +%prep +%autosetup -p1 -n %{srcname}-%{project_version} +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters +sed -i -e '/pytest-cov/d' -e '/addopts/s/--cov[^ "]*//g' pyproject.toml + + +%build +export SETUPTOOLS_SCM_PRETEND_VERSION=%{project_version} +%pyproject_wheel + + +%check +# Tests using RPM don't work well inside %%check +%pytest -k "not test_create_rpm_manifest" + + +%install +%pyproject_install + + +%files +%license LICENSE +%doc README.md +%{_bindir}/flatpak-module +%{_bindir}/flatpak-module-depchase + + +%files -n python3-%{srcname} +%license LICENSE +%{python3_sitelib}/* + + +%changelog +%autochangelog diff --git a/make-rpm.sh b/make-rpm.sh index 715f0ec..f904067 100755 --- a/make-rpm.sh +++ b/make-rpm.sh @@ -3,20 +3,7 @@ set -ex topdir=$(cd "$(dirname $0)" && pwd) -specfile=$topdir/flatpak-module-tools.spec - -cp "$specfile"{,.bak} - -cleanup() { - if cmp -s "$specfile"{,.bak} ; then - rm "$specfile".bak - else - mv "$specfile"{.bak,} - fi -} - -trap cleanup EXIT . "$topdir/make-sources.sh" rpmbuild --define "_sourcedir $topdir" -ba flatpak-module-tools.spec -rm -f flatpak-module-tools-$PROJECT_VERSION.tar.gz flatpak_module_tools-$PROJECT_VERSION*.whl +rm -f flatpak-module-tools-$PROJECT_VERSION.tar.gz flatpak_module_tools-$PROJECT_VERSION*.whl flatpak-module-tools.spec diff --git a/make-sources.sh b/make-sources.sh index b550116..83837c5 100755 --- a/make-sources.sh +++ b/make-sources.sh @@ -39,4 +39,4 @@ set -x sed -E \ -e 's/^(Version:[ ]*).*/\1'"$RPM_VERSION"/ \ -e 's/^(%global project_version *).*/\1'"$PROJECT_VERSION"/ \ - -i flatpak-module-tools.spec + flatpak-module-tools.spec.in > flatpak-module-tools.spec