-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathMakefile
115 lines (84 loc) · 3.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
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
-include config.mk
PLATFORM ?= v2-hdmi
SUFFIX ?=
export BOARD ?= rpi4
export ARCH ?= arm
export PROJECT ?= pikvm-os.$(PLATFORM)$(SUFFIX)
export STAGES ?= __init__ os pikvm-repo pistat watchdog rootdelay ro pikvm restore-mirrorlist __cleanup__
export NC ?=
export HOSTNAME ?= pikvm
export LOCALE ?= en_US
export TIMEZONE ?= UTC
export ARCH_DIST_REPO_URL ?= http://de3.mirror.archlinuxarm.org
BUILD_OPTS ?=
ROOT_PASSWD ?= root
WEBUI_ADMIN_PASSWD ?= admin
IPMI_ADMIN_PASSWD ?= admin
export DISK ?= $(shell pwd)/disk/$(word 1,$(subst -, ,$(PLATFORM))).conf
export CARD ?= /dev/null
export IMAGE_XZ ?=
DEPLOY_USER ?= root
# =====
SHELL = /usr/bin/env bash
_BUILDER_DIR = ./.pi-builder/$(PLATFORM)-$(BOARD)-$(ARCH)$(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)-$(ARCH)/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/arch/{pikvm,pikvm-otg-console}
cp -a stages/arch/{pikvm,pikvm-otg-console} $(_BUILDER_DIR)/stages/arch
$(MAKE) -C $(_BUILDER_DIR) os \
BUILD_OPTS=' $(BUILD_OPTS) \
--build-arg PLATFORM=$(PLATFORM) \
--build-arg OLED=$(call optbool,$(OLED)) \
--build-arg VERSIONS=$(call fv,ustreamer)/$(call fv,kvmd)/$(call fv,kvmd-webterm)/$(call fv,kvmd-fan) \
--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) \
'
$(_BUILDER_DIR):
mkdir -p `dirname $(_BUILDER_DIR)`
git clone --depth=1 https://github.com/mdevaev/pi-builder $(_BUILDER_DIR)
update: $(_BUILDER_DIR)
cd $(_BUILDER_DIR) && git pull --rebase
git pull --rebase
install: $(_BUILDER_DIR)
$(MAKE) -C $(_BUILDER_DIR) install
image: $(_BUILDER_DIR)
$(eval _dir := images/$(PLATFORM)-$(BOARD)/$(ARCH))
$(eval _dated := $(PLATFORM)-$(BOARD)-$(ARCH)$(SUFFIX)-$(shell date +%Y%m%d).img)
$(eval _latest := $(PLATFORM)-$(BOARD)-$(ARCH)$(SUFFIX)-latest.img)
$(eval _suffix = $(if $(call optbool,$(IMAGE_XZ)),.xz,))
mkdir -p $(_dir)
$(MAKE) -C $(_BUILDER_DIR) image IMAGE=$(shell pwd)/$(_dir)/$(_dated)
cd $(_dir) && ln -sf $(_dated)$(_suffix) $(_latest)$(_suffix)
cd $(_dir) && ln -sf $(_dated)$(_suffix).sha1 $(_latest)$(_suffix).sha1
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)`
upload:
rsync -rl --progress \
images/ \
$(DEPLOY_USER)@files.pikvm.org:/var/www/files.pikvm.org/images