-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
132 lines (106 loc) · 4.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
PACKAGE_NAME := $(shell python3 -c "import json; print(json.load(open('package.json'))['name'])")
VERSION := $(shell git describe 2>/dev/null || echo 0.1.0)
ifeq ($(TEST_OS),)
TEST_OS = centos-7
endif
export TEST_OS
VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS)
all: dist/index.js
#
# i18n
#
LINGUAS=$(basename $(notdir $(wildcard po/*.po)))
po/POTFILES.js.in:
mkdir -p $(dir $@)
find src/ -name '*.js' -o -name '*.jsx' -o -name '*.es6' > $@
po/$(PACKAGE_NAME).js.pot: po/POTFILES.js.in
xgettext --default-domain=cockpit --output=$@ --language=C --keyword= \
--keyword=_:1,1t --keyword=_:1c,2,1t --keyword=C_:1c,2 \
--keyword=N_ --keyword=NC_:1c,2 \
--keyword=gettext:1,1t --keyword=gettext:1c,2,2t \
--keyword=ngettext:1,2,3t --keyword=ngettext:1c,2,3,4t \
--keyword=gettextCatalog.getString:1,3c --keyword=gettextCatalog.getPlural:2,3,4c \
--from-code=UTF-8 --files-from=$^
po/POTFILES.html.in:
mkdir -p $(dir $@)
find src -name '*.html' > $@
po/$(PACKAGE_NAME).html.pot: po/POTFILES.html.in
po/html2po -f $^ -o $@
po/$(PACKAGE_NAME).manifest.pot:
po/manifest2po src/manifest.json -o $@
po/$(PACKAGE_NAME).pot: po/$(PACKAGE_NAME).html.pot po/$(PACKAGE_NAME).js.pot po/$(PACKAGE_NAME).manifest.pot
msgcat --sort-output --output-file=$@ $^
# Update translations against current PO template
update-po: po/$(PACKAGE_NAME).pot
for lang in $(LINGUAS); do \
msgmerge --output-file=po/$$lang.po po/$$lang.po $<; \
done
dist/po.%.js: po/%.po
mkdir -p $(dir $@)
po/po2json -m po/po.empty.js -o $@.js.tmp $<
mv $@.js.tmp $@
#
# Build/Install/dist
#
%.spec: %.spec.in
sed -e 's/@VERSION@/$(VERSION)/g' $< > $@
dist/index.js: $(wildcard src/*) package.json webpack.config.js $(patsubst %,dist/po.%.js,$(LINGUAS))
NODE_ENV=$(NODE_ENV) npm run build
clean:
rm -rf dist/
rm -rf _install
rm -f cockpit-$(PACKAGE_NAME).spec
install: dist/index.js
mkdir -p $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME)
cp -r dist/* $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME)
mkdir -p $(DESTDIR)/usr/share/metainfo/
cp io.zeelos.$(PACKAGE_NAME).metainfo.xml $(DESTDIR)/usr/share/metainfo/
# this requires a built source tree and avoids having to install anything system-wide
devel-install: dist/index.js
mkdir -p ~/.local/share/cockpit
ln -s `pwd`/dist ~/.local/share/cockpit/$(PACKAGE_NAME)
# when building a distribution tarball, call webpack with a 'production' environment
dist-gzip: NODE_ENV=production
dist-gzip: clean all
tar czf cockpit-$(PACKAGE_NAME)-$(VERSION).tar.gz --transform 's,^,cockpit-$(PACKAGE_NAME)/,' $$(git ls-files) dist/
srpm: dist-gzip cockpit-$(PACKAGE_NAME).spec
rpmbuild -bs \
--define "_sourcedir `pwd`" \
--define "_srcrpmdir `pwd`" \
cockpit-$(PACKAGE_NAME).spec
rpm: dist-gzip cockpit-$(PACKAGE_NAME).spec
mkdir -p "`pwd`/output"
mkdir -p "`pwd`/rpmbuild"
rpmbuild -bb \
--define "_sourcedir `pwd`" \
--define "_specdir `pwd`" \
--define "_builddir `pwd`/rpmbuild" \
--define "_srcrpmdir `pwd`" \
--define "_rpmdir `pwd`/output" \
--define "_buildrootdir `pwd`/build" \
cockpit-$(PACKAGE_NAME).spec
find `pwd`/output -name '*.rpm' -printf '%f\n' -exec mv {} . \;
rm -r "`pwd`/rpmbuild"
rm -r "`pwd`/output" "`pwd`/build"
# build a VM with locally built rpm installed
$(VM_IMAGE): rpm bots
bots/image-customize -v -r 'rpm -e cockpit-$(PACKAGE_NAME) || true' -i cockpit -i `pwd`/cockpit-$(PACKAGE_NAME)-*.noarch.rpm -s $(CURDIR)/test/vm.install $(TEST_OS)
# convenience target for the above
vm: $(VM_IMAGE)
echo $(VM_IMAGE)
# run the browser integration tests; skip check for SELinux denials
check: node_modules/react-lite $(VM_IMAGE) test/common
TEST_AUDIT_NO_SELINUX=1 test/check-application
# checkout Cockpit's bots/ directory for standard test VM images and API to launch them
# must be from cockpit's master, as only that has current and existing images; but testvm.py API is stable
bots:
git fetch --depth=1 https://github.com/cockpit-project/cockpit.git
git checkout --force FETCH_HEAD -- bots/
git reset bots
# checkout Cockpit's test API; this has no API stability guarantee, so check out a stable tag
# when you start a new project, use the latest relese, and update it from time to time
test/common:
git fetch --depth=1 https://github.com/cockpit-project/cockpit.git 170
git checkout --force FETCH_HEAD -- test/common
git reset test/common
.PHONY: all clean install devel-install dist-gzip srpm rpm check vm update-po