104 lines
3.4 KiB
Makefile
104 lines
3.4 KiB
Makefile
|
SHELL = /bin/sh
|
||
|
.SUFFIXES:
|
||
|
|
||
|
INSTALL = /usr/bin/install
|
||
|
|
||
|
MNAME := octoprint
|
||
|
MACHINES_DIR := /var/lib/machines
|
||
|
MDIR := $(MACHINES_DIR)/$(MNAME)
|
||
|
TDIR := $(MACHINES_DIR)/$(MNAME)-template
|
||
|
DEVPTN := '/dev/ttyUSB*'
|
||
|
|
||
|
OP = systemd-nspawn --machine=$(MNAME) --hostname=$(MNAME) --directory="$(MDIR)" --tmpfs=/run --tmpfs=/run/lock
|
||
|
|
||
|
all:
|
||
|
@echo Nothing to do.
|
||
|
@echo run 'sudo make install'
|
||
|
.PHONY: all
|
||
|
|
||
|
/usr/bin/systemd-nspawn:
|
||
|
apt install -y systemd-container
|
||
|
|
||
|
/etc/cron-apt/action.d /usr/sbin/cron-apt:
|
||
|
apt install -y cron-apt
|
||
|
|
||
|
/etc/cron-apt/action.d/6-upgrade: /etc/cron-apt/action.d
|
||
|
|
||
|
/etc/cron-apt/action.d/6-upgrade $(MDIR)/etc/cron-apt/action.d/6-upgrade: src/cron-apt-6-upgrade
|
||
|
$(INSTALL) -o root -g root -m 644 $< $@
|
||
|
|
||
|
/usr/sbin/debootstrap:
|
||
|
apt install -y debootstrap
|
||
|
touch "$@"
|
||
|
|
||
|
/etc/systemd/system/octoprint-container@.service: src/octoprint-container@.service
|
||
|
$(INSTALL) -o root -g root -m 0644 $< $@
|
||
|
/etc/systemd/system/multi-user.target.wants/octoprint-container@.service: /etc/systemd/system/octoprint-container@.service
|
||
|
ln -fs $< $@
|
||
|
|
||
|
$(MDIR): /usr/sbin/debootstrap
|
||
|
rm -rf "$@".tmp
|
||
|
debootstrap --include=systemd-container stable "$@".tmp
|
||
|
touch "$@".tmp
|
||
|
mv "$@".tmp "$@"
|
||
|
|
||
|
$(MDIR)/usr/bin/pip3: $(MDIR)
|
||
|
$(OP) apt install -y python3-pip
|
||
|
touch "$@"
|
||
|
$(MDIR)/usr/bin/ffmpeg: $(MDIR)
|
||
|
$(OP) apt install -y ffmpeg
|
||
|
touch "$@"
|
||
|
$(MDIR)/usr/sbin/cron-apt: $(MDIR)
|
||
|
$(OP) apt install -y cron-apt
|
||
|
touch "$@"
|
||
|
$(MDIR)/usr/bin/nullmailer-send: $(MDIR)
|
||
|
$(OP) apt install -y nullmailer
|
||
|
touch "$@"
|
||
|
$(MDIR)/usr/local/bin/octoprint: $(MDIR)/usr/bin/pip3
|
||
|
$(OP) pip3 install octoprint
|
||
|
touch "$@"
|
||
|
|
||
|
install_octoprint: $(MDIR) /usr/bin/systemd-nspawn $(addprefix $(MDIR),/usr/bin/pip3 /usr/bin/ffmpeg /usr/local/bin/octoprint)
|
||
|
$(OP) sh -c 'getent passwd octoprint >/dev/null || useradd -mrUd /var/lib/octoprint -G dialout octoprint'
|
||
|
.PHONY: install_octoprint
|
||
|
|
||
|
$(MDIR)/usr/local/libexec/octoprint-init: src/octoprint-init $(MDIR)/usr/local/libexec
|
||
|
$(INSTALL) -o root -g root -m 0755 $< $@
|
||
|
$(MDIR)/etc/systemd/system/octoprint-init.service: src/octoprint-init.service $(MDIR)
|
||
|
$(INSTALL) -o root -g root -m 0755 $< $@
|
||
|
$(MDIR)/etc/systemd/system/multi-user.target.wants/octoprint-init.service: $(MDIR)/etc/systemd/system/octoprint-init.service
|
||
|
ln -fs $< $@
|
||
|
|
||
|
$(MDIR)/etc/systemd/system/octoprint.service: src/octoprint.service
|
||
|
$(INSTALL) -o root -g root -m 0644 $< $@
|
||
|
|
||
|
TDIR_DIRS = $(addprefix $(TDIR),/dev /media /opt /etc /mnt /usr /usr/lib \
|
||
|
/local /home /srv /run /boot /tmp /root /var /var/backups /var/opt \
|
||
|
/var/lib /var/local /var/spool /var/spool/cron /var/spool/rsyslog \
|
||
|
/var/spool/mail /var/log /var/cache /var/tmp /var/mail /proc /sys)
|
||
|
|
||
|
$(TDIR_DIRS): $(dir $@)
|
||
|
$(INSTALL) -o root -g root -m 0755 -d $@
|
||
|
$(MDIR)/usr/local/libexec:
|
||
|
$(INSTALL) -o root -g root -m 0755 -d $@
|
||
|
$(TDIR):
|
||
|
$(INSTALL) -o root -g root -m 0755 -d $@
|
||
|
|
||
|
##### install*: #####
|
||
|
|
||
|
install_system: /usr/bin/systemd-nspawn /usr/sbin/cron-apt /etc/cron-apt/action.d/6-upgrade
|
||
|
.PHONY: install_system
|
||
|
install_container: install_octoprint \
|
||
|
/etc/systemd/system/octoprint-container@.service \
|
||
|
$(MDIR)/usr/local/libexec/octoprint-init \
|
||
|
$(MDIR)/etc/systemd/system/octoprint-init.service \
|
||
|
$(MDIR)/etc/systemd/system/multi-user.target.wants/octoprint-init.service \
|
||
|
$(MDIR)/etc/systemd/system/octoprint.service \
|
||
|
$(MDIR)/etc/cron-apt/action.d/6-upgrade
|
||
|
.PHONY: install_container
|
||
|
install_template: $(TDIR_DIRS)
|
||
|
.PHONY: install_template
|
||
|
install: install_system install_container install_template
|
||
|
systemctl daemon-reload
|
||
|
.PHONY: install
|