-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
212 lines (166 loc) · 7.27 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
PKGNAME = dnfdaemon
APPNAME = $(PKGNAME)
DATADIR := /usr/share
SYSCONFDIR := /etc
PKGDIR = $(DATADIR)/$(PKGNAME)
SYSTEMDSYSTEMUNITDIR := /usr/lib/systemd/system
ORG_NAME = org.baseurl.DnfSystem
ORG_RO_NAME = org.baseurl.DnfSession
SUBDIRS = python
VERSION=$(shell awk '/Version:/ { print $$2 }' ${PKGNAME}.spec)
TESTLIBS=python/:test/
PYVER3 := $(shell python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
GITDATE=git$(shell date +%Y%m%d)
VER_REGEX=\(^Version:\s*[0-9]*\.[0-9]*\.\)\(.*\)
BUMPED_MINOR=${shell VN=`cat ${APPNAME}.spec | grep Version| sed 's/${VER_REGEX}/\2/'`; echo $$(($$VN + 1))}
NEW_VER=${shell cat ${APPNAME}.spec | grep Version| sed 's/\(^Version:\s*\)\([0-9]*\.[0-9]*\.\)\(.*\)/\2${BUMPED_MINOR}/'}
NEW_REL=0.1.${GITDATE}
DIST=${shell rpm --eval "%{dist}"}
GIT_MASTER=master
CURDIR = ${shell pwd}
BUILDDIR= $(CURDIR)/build
all: subdirs
subdirs:
for d in $(SUBDIRS); do make -C $$d; [ $$? = 0 ] || exit 1 ; done
clean:
@rm -fv *~ *.tar.gz *.list *.lang
for d in $(SUBDIRS); do make -C $$d clean ; done
install:
mkdir -p $(DESTDIR)$(DATADIR)/dbus-1/system-services
mkdir -p $(DESTDIR)$(DATADIR)/dbus-1/services
mkdir -p $(DESTDIR)$(SYSCONFDIR)/dbus-1/system.d
mkdir -p $(DESTDIR)$(DATADIR)/polkit-1/actions
mkdir -p $(DESTDIR)$(PKGDIR)
mkdir -p $(DESTDIR)/usr/lib/systemd/system
install -m644 dbus/$(ORG_NAME).service $(DESTDIR)$(DATADIR)/dbus-1/system-services/.
install -m644 dbus/dnfdaemon.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)/.
install -m644 dbus/$(ORG_RO_NAME).service $(DESTDIR)$(DATADIR)/dbus-1/services/.
install -m644 dbus/$(ORG_NAME).conf $(DESTDIR)$(SYSCONFDIR)/dbus-1/system.d/.
install -m644 policykit1/$(ORG_NAME).policy $(DESTDIR)$(DATADIR)/polkit-1/actions/.
install -m755 daemon/dnfdaemon-system.py $(DESTDIR)/$(PKGDIR)/dnfdaemon-system
install -m755 daemon/dnfdaemon-session.py $(DESTDIR)/$(PKGDIR)/dnfdaemon-session
for d in $(SUBDIRS); do make DESTDIR=$(DESTDIR) -C $$d install; [ $$? = 0 ] || exit 1; done
uninstall:
rm -f $(DESTDIR)$(DATADIR)/dbus-1/system-services/$(ORG_NAME).*
rm -f $(DESTDIR)$(DATADIR)/dbus-1/services/$(ORG_RO_NAME).*
rm -f $(DESTDIR)$(SYSCONFDIR)/dbus-1/system.d/$(ORG_NAME).*
rm -r $(DESTDIR)$(DATADIR)/polkit-1/actions/$(ORG_NAME).*
rm -rf $(DESTDIR)/$(PKGDIR)/
selinux:
@$(MAKE) install
semanage fcontext -a -t rpm_exec_t $(DESTDIR)/$(PKGDIR)/dnfdaemon-system
restorecon $(DESTDIR)/$(PKGDIR_DNF)/dnfdaemon-system
# Run as root or you will get a password prompt
run-tests-system: FORCE
@sudo PYTHONPATH=$(TESTLIBS) nosetests-$(PYVER3) -v test/test-system-*.py
# Run as root or you will get a password prompt
run-tests-system-verbose: FORCE
@sudo PYTHONPATH=$(TESTLIBS) nosetests-$(PYVER3) -v -s test/test-system-*.py
# Run as root or you will get a password prompt
run-tests-system-rw: FORCE
@sudo PYTHONPATH=$(TESTLIBS) nosetests-$(PYVER3) -v test/test-system-rw.py
run-tests-system-ro: FORCE
@sudo PYTHONPATH=$(TESTLIBS) nosetests-$(PYVER3) -v test/test-system-ro.py
run-tests-session: FORCE
@PYTHONPATH=$(TESTLIBS) nosetests-$(PYVER3) -v test/test-session-api.py
run-tests-session-verbose: FORCE
@PYTHONPATH=$(TESTLIBS) nosetests-$(PYVER3) -v -s test/test-session-api.py
run-tests-devel: FORCE
@PYTHONPATH=$(TESTLIBS) nosetests-$(PYVER3) -v -s test/unit-devel.py
run-tests-unit: FORCE
@PYTHONPATH=$(TESTLIBS) nosetests-$(PYVER3) -v -s test/test_common.py
instdeps:
sudo dnf install python3-gobject pygobject3 python3-nose
get-builddeps:
sudo dnf install perl-TimeDate gettext intltool rpmdevtools python3-devel python3-nose tito
build-setup:
@rm -rf build/ &>/dev/null ||:
@mkdir -p build/SOURCES ||:
@mkdir -p build/SRPMS ||:
@mkdir -p build/RPMS ||:
@mkdir -p build/BUILD ||:
@mkdir -p build/BUILDROOT ||:
test-repo-build:
@cd test/pkgs/ && ./build-rpms.sh
@# Dnf cant clean a local repo
@sudo rm -rf /var/cache/dnf/*/20/dnf-daemon-test
@sudo rm -f /var/cache/dnf/*/20/dnf-daemon-test*
test-inst:
$(MAKE) test-release
@sudo dnf install --setopt=installonly_limit=0 build/RPMS/noarch/*$(PKGNAME)*.rpm
test-reinst:
$(MAKE) test-release
@sudo dnf reinstall --setopt=installonly_limit=0 build/RPMS/noarch/*$(PKGNAME)*.rpm
test-upd:
$(MAKE) test-release
@sudo dnf update --setopt=installonly_limit=0 build/RPMS/noarch/*$(PKGNAME)*.rpm
rpms:
$(MAKE) build-setup
$(MAKE) archive
@rpmbuild --define '_topdir $(BUILDDIR)' -ba $(PKGNAME).spec
archive:
git archive --prefix=$(PKGNAME)-$(VERSION)/ HEAD | xz > build/SOURCES/$(PKGNAME)-$(VERSION).tar.xz
@echo "The archive is in build/SOURCES/$(PKGNAME)-$(VERSION).tar.xz"
# needs perl-TimeDate for git2cl
changelog:
@git log --pretty --numstat --summary | tools/git2cl > ChangeLog
release-branch:
@git branch -m ${GIT_MASTER} release-${VERSION}
release-publish:
@git checkout release-${VERSION}
@git commit -a -m "bumped version to $(VERSION)"
@$(MAKE) changelog
@git commit -a -m "updated ChangeLog"
@git checkout release-devel
@git merge --no-ff release-${VERSION} -m "merge ${APPNAME}-${VERSION} release"
@git tag -f -m "Added ${APPNAME}-${VERSION} release tag" ${APPNAME}-${VERSION}
@git push --tags origin
@$(MAKE) rpms
release-cleanup:
@git branch -D release-${VERSION}
test-cleanup:
@rm -rf ${APPNAME}-${VERSION}.test.tar.gz
@echo "Cleanup the git release-test local branch"
@git checkout -f
@git checkout ${GIT_MASTER}
@git branch -D release-test
show-vars:
@echo ${GITDATE}
@echo ${BUMPED_MINOR}
@echo ${NEW_VER}-${NEW_REL}
test-release:
$(MAKE) build-setup
@git checkout -b release-test
# +1 Minor version and add 0.1-gitYYYYMMDD release
@cat ${APPNAME}.spec | sed -e 's/${VER_REGEX}/\1${BUMPED_MINOR}/' -e 's/\(^Release:\s*\)\([0-9]*\)\(.*\)./\10.1.${GITDATE}%{?dist}/' > ${APPNAME}-test.spec ; mv ${APPNAME}-test.spec ${APPNAME}.spec
@git commit -a -m "bumped ${APPNAME} version ${NEW_VER}-${NEW_REL}"
# Make Changelog
@git log --pretty --numstat --summary | ./tools/git2cl > ChangeLog
@git commit -a -m "updated ChangeLog"
# Make archive
@rm -rf ${APPNAME}-${NEW_VER}.tar.gz
@git archive --format=tar --prefix=$(PKGNAME)-$(NEW_VER)/ HEAD | xz >build/SOURCES/${PKGNAME}-$(NEW_VER).tar.xz
# Build RPMS
@-rpmbuild --define '_topdir $(BUILDDIR)' -ba ${PKGNAME}.spec
@$(MAKE) test-cleanup
exit-session:
@/usr/bin/dbus-send --session --print-reply --dest="org.baseurl.DnfSession" / org.baseurl.DnfSession.Exit
exit-system:
@sudo /usr/bin/dbus-send --system --print-reply --dest="org.baseurl.DnfSystem" / org.baseurl.DnfSystem.Exit
exit-both:
@/usr/bin/dbus-send --session --print-reply --dest="org.baseurl.DnfSession" / org.baseurl.DnfSession.Exit
@sudo /usr/bin/dbus-send --system --print-reply --dest="org.baseurl.DnfSystem" / org.baseurl.DnfSystem.Exit
start-session:
PYTHONPATH=python/ daemon/dnfdaemon-session.py -d -v --notimeout
kill-both:
@-sudo killall -9 -r "dnfdaemon-system\.py" &> /dev/null
@-sudo killall -9 -r "dnfdaemon-session\.py" &> /dev/null
@-sudo killall -9 -r "dnfdaemon-system" &> /dev/null
@-sudo killall -9 -r "dnfdaemon-session" &> /dev/null
start-system:
@sudo PYTHONPATH=python/ daemon/dnfdaemon-system.py -d -v --notimeout
monitor-session:
dbus-monitor "type='signal',sender='org.baseurl.DnfSession',interface='org.baseurl.DnfSession'"
monitor-system:
dbus-monitor "type='signal',sender='org.baseurl.DnfSystem',interface='org.baseurl.DnfSystem'"
FORCE: