From a3ea5df10c631fe6c1760bb1c3dbacfb030be7d8 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 22 Aug 2017 13:59:55 +0300 Subject: [PATCH] Improve source package slightly This moves us one step closer to a normal source package. The sources are now unpacked and we run "make install". We still don't build since we don't have all the necessary tools. Also, most importantly, the source tarball now includes our actual sources in addition to the prebuilt binaries. --- .gitignore | 3 +++ Makefile | 27 +++++++++++++++++---------- package.json | 2 +- subscription-manager-cockpit.spec | 4 ++-- webpack-with-stats | 21 +++++++++++++++++++++ 5 files changed, 44 insertions(+), 13 deletions(-) create mode 100755 webpack-with-stats diff --git a/.gitignore b/.gitignore index ee24b3c..d681dd2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ node_modules/ dist/ /.vagrant +/webpack.inputs +/subscription-manager-cockpit.tar.gz +/subscription-manager-cockpit-*.*.rpm diff --git a/Makefile b/Makefile index 197fe87..af9d640 100644 --- a/Makefile +++ b/Makefile @@ -5,20 +5,27 @@ clean: rm -rf dist/ rm -rf _install -install: all - mkdir -p /usr/share/cockpit/subscription-manager - cp -r dist/* /usr/share/cockpit/subscription-manager +install: all install-only + +install-only: + mkdir -p $(DESTDIR)/usr/share/cockpit/subscription-manager + cp -r dist/* $(DESTDIR)/usr/share/cockpit/subscription-manager + mkdir -p $(DESTDIR)/usr/share/metainfo/ + cp org.cockpit-project.subscription-manager.metainfo.xml $(DESTDIR)/usr/share/metainfo/ + +EXTRA_DIST = \ + README.md \ + org.cockpit-project.subscription-manager.metainfo.xml \ + package.json \ + .eslintrc.json \ + webpack.config.js \ + webpack-with-stats \ + Makefile # when building a distribution tarball, call webpack with a 'production' environment dist-gzip: NODE_ENV=production dist-gzip: clean all - mkdir -p _install/usr/share/cockpit - cp -r dist/ _install/usr/share/cockpit/subscription-manager - mkdir -p _install/usr/share/metainfo/ - cp *.metainfo.xml _install/usr/share/metainfo/ - cp subscription-manager-cockpit.spec _install/ - tar -C _install/ -czf subscription-manager-cockpit.tar.gz . - rm -rf _install + tar czf subscription-manager-cockpit.tar.gz --transform 's,^,subscription-manager-cockpit/,' $$(cat webpack.inputs) $(EXTRA_DIST) dist/ srpm: dist-gzip rpmbuild -bs \ diff --git a/package.json b/package.json index 70aa94e..b2630f5 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "author": "", "license": "LGPL-2.1", "scripts": { - "build": "webpack" + "build": "./webpack-with-stats" }, "devDependencies": { "babel-core": "^6.25.0", diff --git a/subscription-manager-cockpit.spec b/subscription-manager-cockpit.spec index 0fb6b78..f45373d 100644 --- a/subscription-manager-cockpit.spec +++ b/subscription-manager-cockpit.spec @@ -15,12 +15,12 @@ Requires: subscription-manager Subscription Manager Cockpit UI %prep +%setup -n subscription-manager-cockpit %build %install -mkdir -p %{buildroot} -tar --strip-components=1 -xzf %{sources} -C %{buildroot} +make install-only DESTDIR=%{buildroot} find %{buildroot} -type f >> files.list sed -i "s|%{buildroot}||" *.list diff --git a/webpack-with-stats b/webpack-with-stats new file mode 100755 index 0000000..6f19e30 --- /dev/null +++ b/webpack-with-stats @@ -0,0 +1,21 @@ +#!/usr/bin/env node + +var path = require('path'); +var fs = require('fs'); +var process = require('process'); +var webpack = require('webpack'); +var config = require('./webpack.config.js'); + +webpack(config, function (err, stats) { + if (err) { + console.log(JSON.stringify(err)); + process.exit(1); + return; + } + + var inputs = [ ]; + stats.compilation.fileDependencies.forEach(function(file) { + inputs.push(path.relative(process.cwd(), file)); + }); + fs.writeFileSync('webpack.inputs', inputs.join("\n") + "\n"); +});