forked from Guake/guake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
428 lines (330 loc) · 13.1 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
.PHONY: build dev
PYTHON_INTERPRETER=python3
MODULE:=guake
DESTDIR:=/
prefix:=/usr/local
exec_prefix:=$(prefix)
bindir = $(exec_prefix)/bin
# findout the dist-package directory name. Under most system, users can install on dist-package.
# On debian, site-package is reserved for the official python packages and has precedence over
# dist-package
PYTHON_SITE_PACKAGE_NAME:=$(shell $(PYTHON_INTERPRETER) -c "import site; import os; print(os.path.basename(site.getsitepackages()[0]))")
PYTHON_SITE_PACKAGE_DIR=$(prefix)/lib/python$(shell $(PYTHON_INTERPRETER) -c "import sys; v = sys.version_info; print('{}.{}'.format(v.major, v.minor))")/$(PYTHON_SITE_PACKAGE_NAME)
OLD_PREFIX:=$(DESTDIR)usr
ROOT_DIR=$(shell pwd)
DATA_DIR=$(ROOT_DIR)/data
COMPILE_SCHEMA:=1
datarootdir:=$(prefix)/share
datadir:=$(datarootdir)
localedir:=$(datarootdir)/locale
gsettingsschemadir:=$(datarootdir)/glib-2.0/schemas
AUTOSTART_FOLDER:=~/.config/autostart
DEV_DATA_DIR:=$(DATA_DIR)
DEV_IMAGE_DIR:=$(DATA_DIR)/pixmaps
DEV_LOCALE_DIR:=$(localedir)
DEV_GLADE_DIR:=$(DATA_DIR)
DEV_SCHEMA_DIR:=$(DATA_DIR)
DEV_GUAKE_THEME_DIR:=$(DATA_DIR)/themes
SHARE_DIR:=$(datadir)/guake
GUAKE_THEME_DIR:=$(SHARE_DIR)/guake
LOGIN_DESTOP_PATH = $(SHARE_DIR)
IMAGE_DIR:=$(SHARE_DIR)/pixmaps
GLADE_DIR:=$(SHARE_DIR)
SCHEMA_DIR:=$(gsettingsschemadir)
SLUG:=fragment_name
default: prepare-install
# 'make' target, so users can install guake without need to install the 'dev' dependencies
prepare-install: generate-desktop generate-paths generate-mo compile-glib-schemas-dev
reset:
dconf reset -f /apps/guake/
all: clean dev style checks dists test docs
dev: clean-ln-venv ensure-pip pipenv-install-dev requirements ln-venv setup-githook prepare-install
ensure-pip:
./scripts/bootstrap-dev-pip.sh
dev-no-pipenv: clean
virtualenv --python $(PYTHON_INTERPRETER) .venv
. .venv/bin/activate && pip install -r requirements.txt -r requirements-dev.txt -e .
pipenv-install-dev:
pipenv install --dev --python $(PYTHON_INTERPRETER); \
ln-venv:
# use that to configure a symbolic link to the virtualenv in .venv
rm -rf .venv
ln -s $$(pipenv --venv) .venv
clean-ln-venv:
@rm -f .venv
install-system: install-schemas compile-shemas install-locale install-guake
install-guake:
# you probably want to execute this target with sudo:
# sudo make install
@echo "Installing from on your system is not recommended."
@echo "Please prefer you application package manager (apt, yum, ...)"
@/usr/bin/env python3 -m pip install -r requirements.txt
@if [ -f guake/paths.py.dev ]; then rm -f guake/paths.py.dev; fi
@if [ -f guake/paths.py ]; then mv guake/paths.py guake/paths.py.dev; fi
@cp -f guake/paths.py.in guake/paths.py
@sed -i -e 's|{{ LOCALE_DIR }}|$(localedir)|g' guake/paths.py
@sed -i -e 's|{{ IMAGE_DIR }}|$(IMAGE_DIR)|g' guake/paths.py
@sed -i -e 's|{{ GLADE_DIR }}|$(GLADE_DIR)|g' guake/paths.py
@sed -i -e 's|{{ GUAKE_THEME_DIR }}|$(GUAKE_THEME_DIR)|g' guake/paths.py
@sed -i -e 's|{{ SCHEMA_DIR }}|$(SCHEMA_DIR)|g' guake/paths.py
@sed -i -e 's|{{ LOGIN_DESTOP_PATH }}|$(LOGIN_DESTOP_PATH)|g' guake/paths.py
@sed -i -e 's|{{ AUTOSTART_FOLDER }}|$(AUTOSTART_FOLDER)|g' guake/paths.py
@$(PYTHON_INTERPRETER) setup.py install --root "$(DESTDIR)" --prefix="$(prefix)" --optimize=1
@rm -f guake/paths.py
@if [ -f guake/paths.py.dev ]; then mv guake/paths.py.dev guake/paths.py; fi
@update-desktop-database || echo "Could not run update-desktop-database, are you root?"
@rm -rfv build *.egg-info
install-locale:
for f in $$(find po -iname "*.mo"); do \
l="$${f%%.*}"; \
lb=$$(basename $$l); \
install -Dm644 "$$f" "$(DESTDIR)$(localedir)/$$lb/LC_MESSAGES/guake.mo"; \
done;
uninstall-locale: install-old-locale
find $(DESTDIR)$(localedir)/ -name "guake.mo" -exec rm -f {} \;
install-old-locale:
@find $(OLD_PREFIX)/share/locale/ -name "guake.mo" -exec rm -f {} \;
install-schemas:
install -Dm644 "$(DEV_DATA_DIR)/guake.desktop" "$(DESTDIR)$(prefix)/share/applications/guake.desktop"
install -Dm644 "$(DEV_DATA_DIR)/guake-prefs.desktop" "$(DESTDIR)$(prefix)/share/applications/guake-prefs.desktop"
mkdir -p $(DESTDIR)$(IMAGE_DIR)
install -Dm644 $(DEV_DATA_DIR)/pixmaps/*.png "$(DESTDIR)$(IMAGE_DIR)/"
install -Dm644 $(DEV_DATA_DIR)/pixmaps/*.svg "$(DESTDIR)$(IMAGE_DIR)/"
install -Dm644 $(DEV_DATA_DIR)/pixmaps/guake.png "$(DESTDIR)$(prefix)/share/pixmaps/guake.png"
mkdir -p $(DESTDIR)$(SHARE_DIR)
mkdir -p $(DESTDIR)$(GLADE_DIR)
install -Dm644 $(DEV_DATA_DIR)/*.glade "$(DESTDIR)$(GLADE_DIR)"
mkdir -p $(DESTDIR)$(SHARE_DIR)
install -Dm644 "$(DEV_DATA_DIR)/autostart-guake.desktop" "$(DESTDIR)$(SHARE_DIR)"
mkdir -p $(DESTDIR)$(SCHEMA_DIR)
install -Dm644 "$(DEV_DATA_DIR)/org.guake.gschema.xml" "$(DESTDIR)$(SCHEMA_DIR)/"
compile-shemas:
if [ $(COMPILE_SCHEMA) = 1 ]; then glib-compile-schemas $(DESTDIR)$(gsettingsschemadir); fi
uninstall-system: uninstall-schemas
@rm -rf $(PYTHON_SITE_PACKAGE_DIR)/guake || true
@rm -f $(bindir)/guake
@rm -f $(bindir)/guake-prefs
purge-system: uninstall-system reset
uninstall-schemas: uninstall-old-schemas
rm -f "$(prefix)/share/applications/guake.desktop"
rm -f "$(prefix)/share/applications/guake-prefs.desktop"
rm -fr "$(IMAGE_DIR)"
rm -fr "$(SHARE_DIR)"
rm -f "$(SCHEMA_DIR)/org.guake.gschema.xml"
uninstall-old-schemas:
@rm -f "$(OLD_PREFIX)/share/applications/guake.desktop"
@rm -f "$(OLD_PREFIX)/share/applications/guake-prefs.desktop"
@rm -f "$(OLD_PREFIX)/share/pixmaps/guake.png"
@rm -f "$(OLD_PREFIX)/share/glib-2.0/schemas/org.guake.gschema.xml"
@rm -f "$(OLD_PREFIX)/share/glib-2.0/schemas/schema.guake.gschema.xml"
@rm -fr "$(OLD_PREFIX)/share/guake"
@rm -f $(OLD_PREFIX)/lib/python$(shell $(PYTHON_INTERPRETER) -c "import sys; v = sys.version_info; print('{}.{}'.format(v.major, v.minor))")/$(PYTHON_SITE_PACKAGE_DIR)/guake/data/schema.guake.gschema.xml
reinstall:
sudo make uninstall && make && sudo make install && $(DESTDIR)$(bindir)/guake
compile-glib-schemas-dev: clean-schemas
glib-compile-schemas --strict $(DEV_DATA_DIR)
clean-schemas:
rm -f $(DEV_DATA_DIR)/gschemas.compiled
style: fiximports autopep8 yapf
fiximports:
@for fil in $$(find setup.py guake -name "*.py"); do \
echo "Sorting imports from: $$fil"; \
pipenv run fiximports $$fil; \
done
autopep8:
pipenv run autopep8 --in-place --recursive setup.py $(MODULE)
yapf:
pipenv run yapf --style .yapf --recursive -i $(MODULE)
checks: flake8 pylint reno-lint
flake8:
pipenv run python setup.py flake8
pylint:
pipenv run pylint --rcfile=.pylintrc --output-format=colorized $(MODULE)
sc: style check
dists: update-po requirements prepare-install rm-dists sdist bdist wheels
build: dists
sdist:
pipenv run python setup.py sdist
rm-dists:
rm -rf build dist
bdist:
pipenv run python setup.py bdist
wheels:
pipenv run python setup.py bdist_wheel
run-local: compile-glib-schemas-dev
pipenv run ./scripts/run-local.sh
run-fr: compile-glib-schemas-dev
LC_ALL=fr_FR.UTF8 pipenv run ./scripts/run-local.sh
shell:
pipenv shell
test:
pipenv run pytest $(MODULE)
test-coverage:
pipenv run py.test -v --cov $(MODULE) --cov-report term-missing
sct: style check update-po requirements test
docs: clean-docs sdist
cd docs && pipenv run make html
docs-open:
xdg-open docs/_build/html/index.html
tag-pbr:
@{ \
set -e ;\
export VERSION=$$(pipenv run python setup.py --version | cut -d. -f1,2,3); \
echo "I: Computed new version: $$VERSION"; \
echo "I: presse ENTER to accept or type new version number:"; \
read VERSION_OVERRIDE; \
VERSION=$${VERSION_OVERRIDE:-$$VERSION}; \
PROJECTNAME=$$(pipenv run python setup.py --name); \
echo "I: Tagging $$PROJECTNAME in version $$VERSION with tag: $$VERSION" ; \
echo "$$ git tag $$VERSION -m \"$$PROJECTNAME $$VERSION\""; \
git tag $$VERSION -m "$$PROJECTNAME $$VERSION"; \
echo "I: Pushing tag $$VERSION, press ENTER to continue, C-c to interrupt"; \
echo "$$ git push upstream $$VERSION"; \
}
@# Note:
@# To sign, need gpg configured and the following command:
@# git tag -s $$VERSION -m \"$$PROJECTNAME $$VERSION\""
pypi-publish: build
pipenv run python setup.py upload -r pypi
update:
pipenv update
pipenv install --dev
lock: pipenv-lock requirements
requirements:
pipenv run pipenv_to_requirements
pipenv-lock:
pipenv lock
freeze:
pipenv run pip freeze
githook:
bash git-hooks/post-commit
setup-githook:
rm -f .git/hooks/post-commit
cp -fv git-hooks/* .git/hooks/
push: githook
git push origin --tags
clean: clean-ln-venv rm-dists clean-docs clean-po clean-schemas clean-py clean-paths
@echo "clean successful"
clean-py:
@pipenv --rm ; true
@find . -name "*.pyc" -exec rm -f {} \;
@rm -f $(DEV_DATA_DIR)/guake-prefs.desktop $(DEV_DATA_DIR)/guake.desktop
@rm -rf .eggs *.egg-info po/*.pot
clean-paths:
rm -f guake/paths.py guake/paths.py.dev
clean-po:
@rm -f po/guake.pot
@find po -name "*.mo" -exec rm -f {} \;
clean-docs:
rm -rf doc/_build
update-po:
echo "generating pot file"
@find guake -iname "*.py" | xargs xgettext --from-code=UTF-8 --output=guake-python.pot
@find $(DEV_DATA_DIR) -iname "*.glade" | sed -E "s#$(ROOT_DIR)/##g" | xargs xgettext --from-code=UTF-8 \
-L Glade \
--output=guake-glade.pot
@(\
find $(DEV_DATA_DIR) -iname "*.desktop" | sed -E "s#$(ROOT_DIR)/##g" | xargs xgettext --from-code=UTF-8 \
-L Desktop \
--output=guake-desktop.pot \
) || ( \
echo "Skipping .desktop files, is your gettext version < 0.19.1?" && \
touch guake-desktop.pot)
@msgcat --use-first guake-python.pot guake-glade.pot guake-desktop.pot > po/guake.pot
@rm guake-python.pot guake-glade.pot guake-desktop.pot
@for f in $$(find po -iname "*.po"); do \
echo "updating $$f"; \
msgcat --use-first "$$f" po/guake.pot > "$$f.new"; \
mv "$$f.new" $$f; \
done;
pot: update-po
generate-mo:
@for f in $$(find po -iname "*.po"); do \
echo "generating $$f"; \
l="$${f%%.*}"; \
msgfmt "$$f" -o "$$l.mo"; \
done;
generate-desktop:
@echo "generating desktop files"
@msgfmt --desktop --template=$(DEV_DATA_DIR)/guake.template.desktop \
-d po \
-o $(DEV_DATA_DIR)/guake.desktop || ( \
echo "Skipping .desktop files, is your gettext version < 0.19.1?" && \
cp $(DEV_DATA_DIR)/guake.template.desktop $(DEV_DATA_DIR)/guake.desktop)
@msgfmt --desktop --template=$(DEV_DATA_DIR)/guake-prefs.template.desktop \
-d po \
-o $(DEV_DATA_DIR)/guake-prefs.desktop || ( \
echo "Skipping .desktop files, is your gettext version < 0.19.1?" && \
cp $(DEV_DATA_DIR)/guake-prefs.template.desktop $(DEV_DATA_DIR)/guake-prefs.desktop)
generate-paths:
cp -f guake/paths.py.in guake/paths.py
# Generic
@sed -i -e 's|{{ LOGIN_DESTOP_PATH }}||g' guake/paths.py
@sed -i -e 's|{{ AUTOSTART_FOLDER }}||g' guake/paths.py
# Dev environment:
sed -i -e 's|{{ LOCALE_DIR }}|$(DEV_LOCALE_DIR)|g' guake/paths.py
sed -i -e 's|{{ IMAGE_DIR }}|$(DEV_IMAGE_DIR)|g' guake/paths.py
sed -i -e 's|{{ GUAKE_THEME_DIR }}|$(DEV_GUAKE_THEME_DIR)|g' guake/paths.py
sed -i -e 's|{{ GLADE_DIR }}|$(DEV_GLADE_DIR)|g' guake/paths.py
sed -i -e 's|{{ SCHEMA_DIR }}|$(DEV_SCHEMA_DIR)|g' guake/paths.py
reno:
pipenv run reno new $(SLUG) --edit
reno-lint:
pipenv run reno -q lint
release-note: reno-lint release-note-news release-note-github
release-note-news: reno-lint
@echo "Generating release note for NEWS file"
@rm -f guake/releasenotes/notes/reno.cache
@pipenv run reno report --title "NEWS" 2>/dev/null | \
pandoc -f rst -t rst --atx-headers --columns=100 --wrap=auto --tab-stop 2 | \
tr '\n' '\r' | \
sed 's/\r-\ \ \r\r\ \ \ /\r- /g' | \
sed 's/\r\r-\ \ /\r- /g' | \
sed 's/~~\r-\ \ /~~\r\r- /g' | \
tr '\r' '\n' \
> NEWS.rst
@cat releasenotes/archive/NEWS.pre-3.0 >> NEWS.rst
release-note-github: reno-lint
@echo
@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
@echo "!! Generating release note for GitHub !!"
@echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
@echo "-------- copy / paste from here --------"
@# markdown_github to be avoided => gfm output comes in pandoc 2.0.4 release dec 2017
@pipenv run reno report 2>/dev/null | \
pandoc -f rst -t markdown --atx-headers --wrap=none --tab-stop 2 | \
tr '\n' '\r' | \
sed 's/\r<!-- -->\r//g' | \
sed 's/\r\-\ \r\r\ /\r-/g' | \
sed 's/\r\ \ \:\ \ \ /\r /g' | \
sed 's/\r\r\ \ \ \ \-\ /\r - /g' | \
sed 's/\r\ \ \ \ \-\ /\r - /g' | \
sed 's/\r\ \ >\ \-\ /\r - /g' | \
sed 's/\\\#/\#/g' | \
tr '\r' '\n'
release: git-pull-rebase tag-pbr release-note-news rm-dists update-po dists release-git-tag release-note-github
git-pull-rebase:
@git pull --rebase
release-git-tag:
@{ \
set -x \
export VERSION=$$(pipenv run python setup.py --version | cut -d. -f1,2,3); \
git commit --all -m "Release $$VERSION"; \
PROJECTNAME=$$(pipenv run python setup.py --name); \
git tag -d $$VERSION; \
echo "Note: tag has been removed. Use 'make tag-pbr' to tag and push to origin"; \
}
# aliases to gracefully handle typos on poor dev's terminal
check: checks
devel: dev
develop: dev
dist: dists
doc: docs
install: install-system
purge: purge-system
pypi: pypi-publish
run: run-local
styles: style
uninstall: uninstall-system
upgrade: update
wheel: wheels