-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (67 loc) · 2.26 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
# MIT License
# Copyright (c) 2021 Sergey B <[email protected]>
.PHONY: all build install uninstall purge clean configure
SHELL=/bin/bash
PYTHON=/usr/bin/python3
SYSTEMD_UNIT_FILE=ambibulb.service
SYSTEMD_LOCAL_DIR=./systemd
SYSTEMD_DIR=~/.config/systemd/user
LIRC_LOCAL_FILE=osram-rgb-led.conf
LIRC_LOCAL_DIR=./lirc_conf
LIRC_DIR=/etc/lirc/lircd.conf.d/
all:
@echo "make build"
@echo " Build ambibulb wheel package."
@echo "make install"
@echo " Build, install ambibulb and its dependencies."
@echo "make configure"
@echo " Configure installed ambibulb, lirc and systemd service."
@echo "make uninstall"
@echo " Uninstall ambibulb service."
@echo "make purge"
@echo " Uninstall ambibulb service and its dependencies."
@echo "make clean"
@echo " Remove python artifacts."
build:
@echo "building ambubulb wheel package..."
pip3 install wheel
${PYTHON} setup.py sdist bdist_wheel
install: build
@echo "install ambubulb package..."
pip3 install dist/ambibulb-*.whl
configure:
@echo "configure ambibulb..."
ambibulb-config
@echo "configure ambibulb systemd service..."
mkdir -p ${SYSTEMD_DIR}
cp ${SYSTEMD_LOCAL_DIR}/${SYSTEMD_UNIT_FILE} ${SYSTEMD_DIR}
sed -i '/\b[Service]\b/a Environment=PYTHONUNBUFFERED=1 PATH='$(PATH) ${SYSTEMD_DIR}/${SYSTEMD_UNIT_FILE}
systemctl --user daemon-reload
@echo "configure lirc..."
sudo cp ${LIRC_LOCAL_DIR}/${LIRC_LOCAL_FILE} ${LIRC_DIR}
sudo systemctl restart lircd
@echo ""
@echo "Commands to run:"
@echo "systemctl --user start ambibulb.service"
@echo " Start ambibulb service."
@echo "systemctl --user stop ambibulb.service"
@echo " Stop ambibulb service."
@echo "systemctl --user status ambibulb.service"
@echo " Check ambibulb service status."
@echo "ambibulb-config"
@echo " Configure ambibulb service."
uninstall:
@echo "uninstall ambibulb package..."
pip3 uninstall -y ambibulb
@echo "remove ambibulb systemd service..."
rm ${SYSTEMD_DIR}/${SYSTEMD_UNIT_FILE}
systemctl --user daemon-reload
@echo "remove lirc configuration..."
sudo rm ${LIRC_DIR}/${LIRC_LOCAL_FILE}
sudo systemctl restart lircd
purge: uninstall
@echo "uninstall ambibulb's dependencies..."
pip3 uninstall -y -r requirements.txt
clean:
@echo "remove python artifacts..."
rm -rf *.eggs *.egg-info dist build .cache