From 9574611768d66728983835a77437851cfcc67ca9 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 3 Sep 2021 09:39:04 +0200 Subject: [PATCH] Rebuild webpack during RPM build This is necessary to comply with Fedora's packaging policy: https://docs.fedoraproject.org/en-US/packaging-guidelines/JavaScript/ Include the node cache in the source rpm, unpack it into the main source dir, and force a webpack rebuild in `%build`. --- Makefile | 4 ++-- cockpit-starter-kit.spec.in | 12 ++++++++++-- packit.yaml | 7 ++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index e8aa2a5..d9adb8d 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,7 @@ $(NODE_CACHE): $(NODE_MODULES_TEST) node-cache: $(NODE_CACHE) -srpm: $(TARFILE) cockpit-$(PACKAGE_NAME).spec +srpm: $(TARFILE) $(NODE_CACHE) cockpit-$(PACKAGE_NAME).spec rpmbuild -bs \ --define "_sourcedir `pwd`" \ --define "_srcrpmdir `pwd`" \ @@ -108,7 +108,7 @@ srpm: $(TARFILE) cockpit-$(PACKAGE_NAME).spec rpm: $(RPMFILE) -$(RPMFILE): $(TARFILE) cockpit-$(PACKAGE_NAME).spec +$(RPMFILE): $(TARFILE) $(NODE_CACHE) cockpit-$(PACKAGE_NAME).spec mkdir -p "`pwd`/output" mkdir -p "`pwd`/rpmbuild" rpmbuild -bb \ diff --git a/cockpit-starter-kit.spec.in b/cockpit-starter-kit.spec.in index 76379ff..60d6b18 100644 --- a/cockpit-starter-kit.spec.in +++ b/cockpit-starter-kit.spec.in @@ -4,8 +4,10 @@ Release: 1%{?dist} Summary: Cockpit Starter Kit Example Module License: LGPLv2+ -Source: cockpit-starter-kit-%{version}.tar.xz +Source0: https://github.com/cockpit-project/starter-kit/releases/download/%{version}/cockpit-starter-kit-%{version}.tar.xz +Source1: https://github.com/cockpit-project/starter-kit/releases/download/%{version}/cockpit-starter-kit-node-%{version}.tar.xz BuildArch: noarch +BuildRequires: nodejs BuildRequires: make BuildRequires: libappstream-glib @@ -17,7 +19,13 @@ Requires: cockpit-system Cockpit Starter Kit Example Module %prep -%setup -n cockpit-starter-kit +%setup -q -n cockpit-starter-kit +%setup -q -a 1 -n cockpit-starter-kit + +%build +# ignore pre-built webpack in release tarball and rebuild it +rm -rf dist +NODE_ENV=production make %install %make_install diff --git a/packit.yaml b/packit.yaml index ad67ffe..eab91f3 100644 --- a/packit.yaml +++ b/packit.yaml @@ -4,7 +4,12 @@ specfile_path: cockpit-starter-kit.spec actions: - post-upstream-clone: make cockpit-starter-kit.spec + post-upstream-clone: + post-upstream-clone: + - make cockpit-starter-kit.spec + # replace Source1 manually, as create-archive: can't handle multiple tarballs + - make node-cache + - sh -c 'sed -i "/^Source1:/ s/https:.*/$(ls *-node*.tar.xz)/" cockpit-*.spec' # build in development mode; production mode uses too much memory for limited # sandcastle containers; also reduce memory consumption of webpack # https://github.com/packit/sandcastle/pull/92