-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
63 lines (45 loc) · 1.56 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
DEST_DIR?=/
PREFIX?=/usr/bin
HOOK_DIR=
DIST?=$(shell cut -d ":" -f6 /etc/system-release-cpe)
MAJOR=0
MINOR=1
RELEASE=1
VERSION=$(MAJOR).$(MINOR)-$(RELEASE)
$(info Building version $(VERSION))
# As long as no-one convince us otherwise, we're assuming the system is using DNF as
# it's default package manager.
HOOK_DIR=/etc/dnf/plugins/post-transaction-actions.d
HOOK_COMMAND=in
ifeq ($(PKG_MANAGER),yum)
HOOK_DIR=/etc/yum/post-actions
HOOK_COMMAND=install
endif
CONF_DIR=/etc/smart-restart-conf.d
HOOK_ACTION=install.action
HOOK_ACTION_TEMPLATE=$(HOOK_ACTION).in
DENYLIST_CONF_FILE=default-denylist
MAN_FILE=smart-restart.man1
MAN_FILE_LOCATION=/usr/share/man/man1
.PHONY: all srpm install
# We're not yet building anything.
all:
$(error There is nothing to build here yet. Please use "make install" to install the config files)
srpm: sources
sources:
tar czf ./smart-restart-v$(VERSION).tar.gz --transform 's,^,smart-restart-v$(VERSION)/,' bin conf Makefile smart-restart.spec doc/smart-restart.man1
install:
$(info Dest: $(DEST_DIR))
$(info Prefix: $(PREFIX))
$(info Hook dir: $(HOOK_DIR))
$(info PWD: $(shell pwd))
mkdir -p $(DEST_DIR)$(CONF_DIR)
mkdir -p $(DEST_DIR)$(PREFIX)
mkdir -p $(DEST_DIR)$(HOOK_DIR)
mkdir -p $(DEST_DIR)$(MAN_FILE_LOCATION)
cp bin/*.sh $(DEST_DIR)$(PREFIX)
cp conf/$(DENYLIST_CONF_FILE) $(DEST_DIR)$(CONF_DIR)
cp doc/$(MAN_FILE) $(DEST_DIR)$(MAN_FILE_LOCATION)/$(MAN_FILE)
sed -e "s%#COMMAND#%$(HOOK_COMMAND)%g" -e "s%#PREFIX#%$(PREFIX)%g" conf/$(HOOK_ACTION_TEMPLATE) > $(DEST_DIR)$(HOOK_DIR)/$(HOOK_ACTION)
test:
$(MAKE) -C tests