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"); +});