-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
66 lines (59 loc) · 2.48 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
mypath = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
TOPSRCDIR ?= $(shell git rev-parse --show-toplevel)
GITREV = $(shell git rev-parse HEAD)
PACKAGE = console-login-helper-messages
PACKAGE_DIR = $(TOPSRCDIR)/$(PACKAGE)
PACKAGESRC_URL = "https://src.fedoraproject.org/rpms/$(PACKAGE)"
PREFIX ?= /usr
SYSCONFDIR ?= /etc
libexecdir ?= $(PREFIX)/libexec
# A starter Makefile which may be useful in a developer workflow for testing
# and iteration.
.PHONY: all
all:
@echo "(Nothing to build)"
.PHONY: install
install: all
(set -euo pipefail; \
# package-specific directories \
# external directories \
mkdir -p $(DESTDIR)$(SYSCONFDIR)/issue.d; \
mkdir -p $(DESTDIR)$(SYSCONFDIR)/profile.d; \
# install \
# udev rules are not installed by default. \
# install -DZ -m 0644 usr/lib/udev/rules.d/* \
# -t $(DESTDIR)$(PREFIX)/lib/udev/rules.d/; \
install -DZ -m 0644 usr/lib/$(PACKAGE)/* \
-t $(DESTDIR)$(PREFIX)/lib/$(PACKAGE)/; \
install -DZ -m 0644 usr/lib/systemd/system/* \
-t $(DESTDIR)$(PREFIX)/lib/systemd/system/; \
install -DZ -m 0644 usr/lib/tmpfiles.d/* \
-t $(DESTDIR)$(PREFIX)/lib/tmpfiles.d/; \
install -DZ -m 0755 usr/libexec/$(PACKAGE)/* \
-t $(DESTDIR)$(libexecdir)/$(PACKAGE)/; \
install -DZ -m 0644 usr/share/$(PACKAGE)/* \
-t $(DESTDIR)$(PREFIX)/share/$(PACKAGE)/; \
install -DZ -m 0744 etc/NetworkManager/dispatcher.d/* \
-t $(DESTDIR)$(SYSCONFDIR)/NetworkManager/dispatcher.d)
# Generate rpms including the content committed at the current git checked-out
# HEAD. The built RPM files are named as
# PACKAGE*-GITREV-<release-number-in-specfile>.rpm.
rpm:
(set -exuo pipefail; \
git archive --format=tar --prefix=$(PACKAGE)-$(GITREV)/ $(GITREV) > $(GITREV).tar; \
test ! -e $(TOPSRCDIR)/$(PACKAGE)/$(PACKAGE).spec && (cd $(TOPSRCDIR) && git clone $(PACKAGESRC_URL)); \
mv $(GITREV).tar $(TOPSRCDIR)/$(PACKAGE); \
(cd $(TOPSRCDIR)/$(PACKAGE); \
sed --in-place -e "s/Version:.*/Version: $(GITREV)/g" $(PACKAGE).spec; \
sed --in-place -e "s/Source0:.*/Source0: $(GITREV).tar/g" $(PACKAGE).spec; \
rpmbuild -ba --define "_sourcedir $(PACKAGE_DIR)" \
--define "_specdir $(PACKAGE_DIR)" \
--define "_builddir $(PACKAGE_DIR)/.build" \
--define "_srcrpmdir $(PACKAGE_DIR)/rpms" \
--define "_rpmdir $(PACKAGE_DIR)/rpms" \
--define "_buildrootdir $(PACKAGE_DIR)/.buildroot" $(PACKAGE).spec; \
rm -rf "$(PACKAGE_DIR)/.build";))
# Remove archives and RPM artifacts from previous builds.
clean_rpm:
rm -rf $(TOPSRCDIR)/$(PACKAGE)/rpms/*; \
rm -f $(TOPSRCDIR)/$(PACKAGE)/*.tar