build: don't move pkg/lib/ to src/lib/

Keep pkg/lib in the same location as it is in the cockpit repository,
and adjust the include path accordingly.

This makes the production of the .pot file somewhat more deterministic:
previously, it would either include or not include the strings from
pkg/lib depending on if it had been checked out or not.  Now it never
includes them.

Cherry-picked from cockpit-podman commit a70630be2139a.
This commit is contained in:
Martin Pitt 2022-06-30 06:57:10 +02:00 committed by Martin Pitt
parent adc3643052
commit b3a9565668
5 changed files with 13 additions and 14 deletions

View file

@ -1,2 +1,2 @@
node_modules/* node_modules/*
src/lib/* pkg/lib/*

2
.gitignore vendored
View file

@ -11,7 +11,7 @@ Test*FAIL*
/bots /bots
test/common/ test/common/
test/images/ test/images/
src/lib/ pkg
*.pot *.pot
POTFILES* POTFILES*
tmp/ tmp/

View file

@ -15,8 +15,8 @@ VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS)
NODE_MODULES_TEST=package-lock.json NODE_MODULES_TEST=package-lock.json
# one example file in dist/ from webpack to check if that already ran # one example file in dist/ from webpack to check if that already ran
WEBPACK_TEST=dist/manifest.json WEBPACK_TEST=dist/manifest.json
# one example file in src/lib to check if it was already checked out # one example file in pkg/lib to check if it was already checked out
LIB_TEST=src/lib/cockpit-po-plugin.js LIB_TEST=pkg/lib/cockpit-po-plugin.js
# common arguments for tar, mostly to make the generated tarballs reproducible # common arguments for tar, mostly to make the generated tarballs reproducible
TAR_ARGS = --sort=name --mtime "@$(shell git show --no-patch --format='%at')" --mode=go=rX,u+rw,a-s --numeric-owner --owner=0 --group=0 TAR_ARGS = --sort=name --mtime "@$(shell git show --no-patch --format='%at')" --mode=go=rX,u+rw,a-s --numeric-owner --owner=0 --group=0
@ -35,10 +35,10 @@ po/$(PACKAGE_NAME).js.pot:
--keyword=gettext:1,1t --keyword=gettext:1c,2,2t \ --keyword=gettext:1,1t --keyword=gettext:1c,2,2t \
--keyword=ngettext:1,2,3t --keyword=ngettext:1c,2,3,4t \ --keyword=ngettext:1,2,3t --keyword=ngettext:1c,2,3,4t \
--keyword=gettextCatalog.getString:1,3c --keyword=gettextCatalog.getPlural:2,3,4c \ --keyword=gettextCatalog.getString:1,3c --keyword=gettextCatalog.getPlural:2,3,4c \
--from-code=UTF-8 $$(find src/ \( -name '*.js' -o -name '*.jsx' \) \! -path 'src/lib/*') --from-code=UTF-8 $$(find src/ \( -name '*.js' -o -name '*.jsx' \))
po/$(PACKAGE_NAME).html.pot: $(NODE_MODULES_TEST) po/$(PACKAGE_NAME).html.pot: $(NODE_MODULES_TEST)
po/html2po -o $@ $$(find src -name '*.html' \! -path 'src/lib/*') po/html2po -o $@ $$(find src -name '*.html')
po/$(PACKAGE_NAME).manifest.pot: $(NODE_MODULES_TEST) po/$(PACKAGE_NAME).manifest.pot: $(NODE_MODULES_TEST)
po/manifest2po src/manifest.json -o $@ po/manifest2po src/manifest.json -o $@
@ -111,7 +111,7 @@ $(TARFILE): $(WEBPACK_TEST) $(SPEC)
touch dist/* touch dist/*
tar --xz $(TAR_ARGS) -cf $(TARFILE) --transform 's,^,$(RPM_NAME)/,' \ tar --xz $(TAR_ARGS) -cf $(TARFILE) --transform 's,^,$(RPM_NAME)/,' \
--exclude packaging/$(SPEC).in --exclude node_modules \ --exclude packaging/$(SPEC).in --exclude node_modules \
$$(git ls-files) src/lib package-lock.json $(SPEC) dist/ $$(git ls-files) pkg/lib package-lock.json $(SPEC) dist/
$(NODE_CACHE): $(NODE_MODULES_TEST) $(NODE_CACHE): $(NODE_MODULES_TEST)
tar --xz $(TAR_ARGS) -cf $@ node_modules tar --xz $(TAR_ARGS) -cf $@ node_modules
@ -187,7 +187,6 @@ $(LIB_TEST):
git fetch --depth=1 https://github.com/cockpit-project/cockpit.git 265; \ git fetch --depth=1 https://github.com/cockpit-project/cockpit.git 265; \
git checkout --force FETCH_HEAD -- pkg/lib; \ git checkout --force FETCH_HEAD -- pkg/lib; \
git reset -- pkg/lib' git reset -- pkg/lib'
mv pkg/lib src/ && rmdir -p pkg
$(NODE_MODULES_TEST): package.json $(NODE_MODULES_TEST): package.json
# if it exists already, npm install won't update it; force that so that we always get up-to-date packages # if it exists already, npm install won't update it; force that so that we always get up-to-date packages

View file

@ -17,7 +17,7 @@
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>. * along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
*/ */
import "./lib/patternfly/patternfly-4-cockpit.scss"; import "patternfly/patternfly-4-cockpit.scss";
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
@ -29,7 +29,7 @@ import { Application } from './app.jsx';
* out of the dist/index.js and since it will maintain the order of the imported CSS, * out of the dist/index.js and since it will maintain the order of the imported CSS,
* the overrides will be correctly in the end of our stylesheet. * the overrides will be correctly in the end of our stylesheet.
*/ */
import "./lib/patternfly/patternfly-4-overrides.scss"; import "patternfly/patternfly-4-overrides.scss";
import './app.scss'; import './app.scss';
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {

View file

@ -7,8 +7,8 @@ const TerserJSPlugin = require('terser-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const CompressionPlugin = require("compression-webpack-plugin"); const CompressionPlugin = require("compression-webpack-plugin");
const ESLintPlugin = require('eslint-webpack-plugin'); const ESLintPlugin = require('eslint-webpack-plugin');
const CockpitPoPlugin = require("./src/lib/cockpit-po-plugin"); const CockpitPoPlugin = require("./pkg/lib/cockpit-po-plugin");
const CockpitRsyncPlugin = require("./src/lib/cockpit-rsync-plugin"); const CockpitRsyncPlugin = require("./pkg/lib/cockpit-rsync-plugin");
/* A standard nodejs and webpack pattern */ /* A standard nodejs and webpack pattern */
const production = process.env.NODE_ENV === 'production'; const production = process.env.NODE_ENV === 'production';
@ -47,11 +47,11 @@ if (production) {
module.exports = { module.exports = {
mode: production ? 'production' : 'development', mode: production ? 'production' : 'development',
resolve: { resolve: {
modules: [ "node_modules", path.resolve(__dirname, 'src/lib') ], modules: [ "node_modules", path.resolve(__dirname, 'pkg/lib') ],
alias: { 'font-awesome': 'font-awesome-sass/assets/stylesheets' }, alias: { 'font-awesome': 'font-awesome-sass/assets/stylesheets' },
}, },
resolveLoader: { resolveLoader: {
modules: [ "node_modules", path.resolve(__dirname, 'src/lib') ], modules: [ "node_modules", path.resolve(__dirname, 'pkg/lib') ],
}, },
watchOptions: { watchOptions: {
ignored: /node_modules/, ignored: /node_modules/,