-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
127 lines (96 loc) · 3.53 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
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
-include config.mk
BOARD ?= rpi
PLATFORM ?= v0-hdmi
SUFFIX ?=
STAGES ?= __init__ os pikvm-repo watchdog ro no-audit pikvm __cleanup__
HOSTNAME ?= pikvm
LOCALE ?= en_US
TIMEZONE ?= Europe/Moscow
REPO_URL ?= http://archive.dskyio.com/archlinuxarm_2022-01-08
BUILD_OPTS ?=
ROOT_PASSWD ?= root
WEBUI_ADMIN_PASSWD ?= admin
IPMI_ADMIN_PASSWD ?= admin
CARD ?= /dev/mmcblk0
DEPLOY_USER ?= root
# =====
SHELL = /usr/bin/env bash
_BUILDER_DIR = ./.pi-builder/$(PLATFORM)-$(BOARD)$(SUFFIX)
define optbool
$(filter $(shell echo $(1) | tr A-Z a-z),yes on 1)
endef
define fv
$(shell curl --silent "https://files.pikvm.org/repos/arch/$(BOARD)/latest/$(1)")
endef
# =====
all:
@ echo "Available commands:"
@ echo " make # Print this help"
@ echo " make os # Build OS with your default config"
@ echo " make shell # Run Arch-ARM shell"
@ echo " make install # Install rootfs to partitions on $(CARD)"
@ echo " make image # Create a binary image for burning outside of make install"
@ echo " make scan # Find all RPi devices in the local network"
@ echo " make clean # Remove the generated rootfs"
@ echo " make clean-all # Remove the generated rootfs and pi-builder toolchain"
shell: $(_BUILDER_DIR)
$(MAKE) -C $(_BUILDER_DIR) shell
os: $(_BUILDER_DIR)
rm -rf $(_BUILDER_DIR)/stages/{pikvm,pikvm-otg-console}
cp -a pikvm pikvm-otg-console $(_BUILDER_DIR)/stages
$(MAKE) -C $(_BUILDER_DIR) os \
NC=$(NC) \
BUILD_OPTS=' $(BUILD_OPTS) \
--build-arg PLATFORM=$(PLATFORM) \
--build-arg VERSIONS=$(call fv,ustreamer)/$(call fv,kvmd)/$(call fv,kvmd-webterm)/$(call fv,kvmd-oled)/$(call fv,kvmd-fan) \
--build-arg OLED=$(call optbool,$(OLED)) \
--build-arg FAN=$(call optbool,$(FAN)) \
--build-arg ROOT_PASSWD=$(ROOT_PASSWD) \
--build-arg WEBUI_ADMIN_PASSWD=$(WEBUI_ADMIN_PASSWD) \
--build-arg IPMI_ADMIN_PASSWD=$(IPMI_ADMIN_PASSWD) \
' \
PROJECT=pikvm-os-$(PLATFORM)$(SUFFIX) \
BOARD=$(BOARD) \
STAGES='$(STAGES)' \
HOSTNAME=$(HOSTNAME) \
LOCALE=$(LOCALE) \
TIMEZONE=$(TIMEZONE) \
REPO_URL=$(REPO_URL)
$(_BUILDER_DIR):
mkdir -p `dirname $(_BUILDER_DIR)`
git clone --depth=1 https://github.com/Hummtaro/pi1kvm-builder $(_BUILDER_DIR)
update: $(_BUILDER_DIR)
cd $(_BUILDER_DIR) && git pull --rebase
git pull --rebase
install: $(_BUILDER_DIR)
$(MAKE) -C $(_BUILDER_DIR) install \
CARD=$(CARD) \
CARD_DATA_FS_TYPE=$(if $(findstring v2,$(PLATFORM))$(findstring v3,$(PLATFORM)),ext4,) \
CARD_DATA_FS_FLAGS="-m0 -L PIMSD" \
CARD_DATA_BEGIN_AT=6400
scan: $(_BUILDER_DIR)
$(MAKE) -C $(_BUILDER_DIR) scan
clean: $(_BUILDER_DIR)
$(MAKE) -C $(_BUILDER_DIR) clean
clean-all:
- $(MAKE) -C $(_BUILDER_DIR) clean-all
rm -rf $(_BUILDER_DIR)
- rmdir `dirname $(_BUILDER_DIR)`
_IMAGE_DATED := $(PLATFORM)-$(BOARD)$(SUFFIX)-$(shell date +%Y%m%d).img
_IMAGE_LATEST := $(PLATFORM)-$(BOARD)$(SUFFIX)-latest.img
image:
which xz
mkdir -p images
sudo bash -x -c ' \
truncate images/$(_IMAGE_DATED) -s 6G \
&& device=`losetup --find --show images/$(_IMAGE_DATED)` \
&& $(MAKE) install CARD=$$device \
&& losetup -d $$device \
'
sudo chown $(shell id -u):$(shell id -g) images/$(_IMAGE_DATED)
xz -9 --compress images/$(_IMAGE_DATED)
sha1sum images/$(_IMAGE_DATED).xz | awk '{print $$1}' > images/$(_IMAGE_DATED).xz.sha1
cd images && ln -sf $(_IMAGE_DATED).xz $(_IMAGE_LATEST).xz
cd images && ln -sf $(_IMAGE_DATED).xz.sha1 $(_IMAGE_LATEST).xz.sha1
upload:
rsync -rl --progress images/ $(DEPLOY_USER)@files.pikvm.org:/var/www/files.pikvm.org/images