-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
108 lines (82 loc) · 3.28 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
include const.mk
LN ?= ln
INSTALL ?= install -p
PYTHON ?= python
PYTHON_VERSION=$(shell $(PYTHON) -c \
"import sys; print(sys.version_info.major)")
PYTHON_LIBDIR=$(shell $(PYTHON) -c \
"from distutils import sysconfig; print(sysconfig.get_python_lib())")
PLUGINDIR=$(PYTHON_LIBDIR)/dnf-plugins
UNITDIR=$(shell pkg-config systemd --variable systemdsystemunitdir)
TARGET_WANTSDIR=$(UNITDIR)/system-update.target.wants
LOCALEDIR ?= /usr/share/locale
TEXTDOMAIN = $(PACKAGE)
LANGUAGES = $(patsubst po/%.po,%,$(wildcard po/*.po))
MSGFILES = $(patsubst %,po/%.mo,$(LANGUAGES))
BINDIR ?= /usr/bin
FEDUP_SCRIPT = fedup.sh
SERVICE = dnf-system-upgrade.service
PLUGIN = system_upgrade.py
MANDIR ?= /usr/share/man
MANPAGE = doc/dnf.plugin.system-upgrade.8
build: $(MSGFILES)
po/$(TEXTDOMAIN).pot: $(PLUGIN) $(FEDUP_SCRIPT)
xgettext -c -s -d $(TEXTDOMAIN) -o $@ $^
po/%.mo : po/%.po
msgfmt $< -o $@
install: install-plugin install-service install-bin install-lang install-man
install-plugin: $(PLUGIN)
$(INSTALL) -d $(DESTDIR)$(PLUGINDIR)
$(INSTALL) -m644 $(PLUGIN) $(DESTDIR)$(PLUGINDIR)
$(PYTHON) -m py_compile $(DESTDIR)$(PLUGINDIR)/$(PLUGIN)
$(PYTHON) -O -m py_compile $(DESTDIR)$(PLUGINDIR)/$(PLUGIN)
install-service: $(SERVICE)
$(INSTALL) -d $(DESTDIR)$(UNITDIR)
$(INSTALL) -d $(DESTDIR)$(TARGET_WANTSDIR)
$(INSTALL) -m644 $(SERVICE) $(DESTDIR)$(UNITDIR)
$(LN) -sf ../$(SERVICE) $(DESTDIR)$(TARGET_WANTSDIR)/$(SERVICE)
install-bin: $(FEDUP_SCRIPT)
$(INSTALL) -d $(DESTDIR)$(BINDIR)
$(INSTALL) -m755 $(FEDUP_SCRIPT) $(DESTDIR)$(BINDIR)/fedup
install-lang: $(MSGFILES)
for lang in $(LANGUAGES); do \
langdir=$(DESTDIR)$(LOCALEDIR)/$${lang}/LC_MESSAGES; \
$(INSTALL) -d $$langdir; \
$(INSTALL) po/$${lang}.mo $${langdir}/$(TEXTDOMAIN).mo;\
done
install-man: $(MANPAGE)
$(INSTALL) -d $(DESTDIR)$(MANDIR)/man8
$(INSTALL) -m644 $(MANPAGE) $(DESTDIR)$(MANDIR)/man8
$(LN) -sf $(notdir $(MANPAGE)) $(DESTDIR)$(MANDIR)/man8/fedup.8
clean:
rm -rf *.py[co] __pycache__ tests/*.py[co] tests/__pycache__ \
$(PACKAGE)-*.tar.gz $(PACKAGE)-*.spec po/*.mo rpm/
check: po/zh_CN.mo
$(PYTHON) -m unittest discover tests
archive: $(PACKAGE)-$(VERSION).tar.gz
$(PACKAGE)-$(VERSION).tar.gz: version-check
git archive --prefix=$(PACKAGE)-$(VERSION)/ --output=$@ $(VERSION)
version-check:
git describe --tags $(VERSION)
grep '^Version:\s*$(VERSION)' $(PACKAGE).spec
grep '^\.TH .* "$(VERSION)"' $(MANPAGE)
SNAPVER = $(shell git describe --long --tags --match="*.*.*" 2>/dev/null || \
echo $(VERSION)-0-x0000000)
SNAPREL = snap$(subst -,.,$(patsubst $(VERSION)-%,%,$(SNAPVER)))
SNAPARCHIVE = $(PACKAGE)-$(SNAPVER).tar.gz
SNAPSPEC = $(PACKAGE)-$(SNAPVER).spec
$(SNAPARCHIVE):
git archive --prefix=$(PACKAGE)-$(VERSION)/ --output=$@ HEAD
$(SNAPSPEC): $(PACKAGE).spec
sed -e 's/^Release:.*$$/Release: $(SNAPREL)%{?dist}/' \
-e 's/^Source0:.*$$/Source0: $(SNAPARCHIVE)/' \
$< > $@ || { rm -f $@; false; }
snapshot-archive: $(SNAPARCHIVE)
snapshot-spec: $(SNAPSPEC)
snapshot-rpm: $(SNAPARCHIVE) $(SNAPSPEC)
rpmbuild -bb $(SNAPSPEC) \
--define '_sourcedir $(CURDIR)' \
--define '_rpmdir $(CURDIR)/rpm'
.PHONY: build install clean check archive version-check
.PHONY: install-plugin install-service install-bin install-lang install-man
.PHONY: snapshot-archive snapshot-spec snapshot-rpm