-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·136 lines (112 loc) · 2.97 KB
/
Makefile
File metadata and controls
executable file
·136 lines (112 loc) · 2.97 KB
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
# install/build various repos needed by pionic
# git repos to fetch and build, note we must escape the ":"
repos=https\://github.com/glitchub/beacon
repos+=https\://github.com/glitchub/runfor
repos+=https\://github.com/glitchub/fbput
repos+=https\://github.com/glitchub/FM_Transmitter_RPi3
repos+=https\://github.com/glitchub/i2cio
# apt packages to install
apt=sox graphicsmagick omxplayer dnsmasq
# apt packages to remove
unwanted=resolvconf avahi-daemon
# files to modify
files=/etc/rc.local /boot/config.txt /etc/dhcpcd.conf /etc/dnsmasq.conf
# Text to append to dhcpcd.conf, contstrain dhcp to eth0
define append_dhcpcd_conf
# pionic start
allowinterfaces eth0
noipv6
noipv4ll
# pionic end
endef
export append_dhcpcd_conf
# Text to append to /boot/config.txt
define append_config_txt
# pionic start
hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=16 # 1920x1080
hdmi_blanking=0
hdmi_ignore_edid=0x5a000080
lcd_rotate=2
disable_touchscreen
# pionic end
endef
export append_config_txt
# Text to append to /etc/dnsmasq.conf, fail all dns queries
define append_dnsmasq_conf
# pionic start
interface=eth1
no-dhcp-interface=eth1
resolv-file=/dev/null # cause dns queries to fail!
# pionic end
endef
export append_dnsmasq_conf
# Make sure we're on RPi and not root
ifeq ($(shell grep Raspberry /etc/rpi-issue),)
$(error Can only be run on Raspberry PI))
endif
ifneq ($(filter root,${USER}),)
$(error Must NOT be run as root))
endif
# remove pionic stuff from specified file
define pristine
sudo sed -i '/pionic start/,/pionic end/d' $1;\
sudo sed -i '/pionic/Q' $1;
endef
.PHONY: install
install: ${unwanted} ${apt} ${repos} ${files} ${unwanted}
sudo apt-get -y autoremove
sync
@echo "Reboot to start pionic"
# install repos
.PHONY: ${repos}
${repos}:
[ -d "$(notdir $@)" ] || git clone $@
make -C $(notdir $@)
# clean repos
clean-repos=$(addprefix CR-,$(notdir ${repos}))
.PHONY: ${unistall-repos}
${clean-repos}:
rm -rf ${@:CR-%=%}
# install packages
.PHONY: ${apt}
${apt}:
sudo apt-get -y install $@
# clean packages
clean-apt=${apt:%=CP-%}
.PHONY: ${clean-apt} ${unwanted}
${clean-apt} ${unwanted}:
sudo apt-get -y purge ${@:CP-%=%}
# modify files
# /etc/rc.local is a bit different
.PHONY: ${files}
/etc/rc.local:
sudo sed -i '/pionic/d' $@
sudo sed -i '/^exit/i/home/pi/pionic/pionic.sh start' $@
# all others get pionic text appended
other-files=$(filter-out /etc/rc.local,${files})
${other-files}:
$(call pristine,$@)
echo "$$append_$(subst .,_,$(notdir $@))" | sudo bash -c 'cat >> $@'
# unmodify files
clean-files=${files:%=CF-%}
.PHONY: ${clean-files}
# /etc/rc.local is a bit different
CF-/etc/rc.local:
sudo sed -i '/pionic/d' ${@:CF-%=%}
${other-files:%=CF-%}:
! [ -f ${@:CF-%=%} ] || { $(call pristine,${@:CF-%=%}) }
.PHONY: stop
stop:;sudo ./pionic.sh stop
.PHONY: clean
clean: stop ${clean-files}
sync
.PHONY: uninstall
uninstall: clean ${clean-apt} ${clean-repos}
sudo apt-get -y autoremove
sync
.PHONY: .gitignore
.gitignore:
echo $@ > $@
$(foreach r,$(notdir ${repos}),echo $r >> $@;)