-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
98 lines (71 loc) · 2.36 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
-include config.mk
ifndef C
$(error C must be defined)
endif
include $C/config.mk
BUILDDIR := $(shell mktemp --dry-run --directory -t imgbldr-XXXXX)
BASEDIR := $(dir $(realpath $(firstword ${MAKEFILE_LIST})))
FILES = ${BUILDDIR}/files
files = files
CACHE = cache/${RELEASE}
DOWNLOADS_BASE = https://downloads.openwrt.org/releases/${RELEASE}/targets/${TARGET}/${SUBTARGET}
INSTRUCTION_SET = $(shell curl --silent ${DOWNLOADS_BASE}/profiles.json | jq --raw-output .arch_packages)
CONFIGS = config.mk $C/config.mk
DEPS += $(shell find ${files} -type f,l)
DEPS += $(shell [ -d $C/files ] && find $C/files -type f,l)
DEPS += ${CONFIGS}
HOSTS ?= $C
SCPOPTS = -O
IMAGE ?= squashfs-sysupgrade.bin
imagebuilder ?= openwrt-imagebuilder-${RELEASE}-${TARGET}-${SUBTARGET}.Linux-x86_64
image ?= openwrt-${RELEASE}-${TARGET}-${SUBTARGET}-${PLATFORM}-${IMAGE}
comment = \#%
parts = $(filter-out ${comment}, $(foreach f,$1,$(file < ${BASEDIR}/lists/$f)))
PACKAGES = \
$(addprefix -,$(call parts,${REMOVE_LISTS})) \
$(addprefix -,$(foreach p,${REMOVE_PKGS},$p)) \
$(call parts,${INSTALL_LISTS}) \
$(filter-out ${comment}, $(foreach p,${INSTALL_PKGS},$p))
# $(foreach p,${INSTALL_PKGS},$p)
all: image
listpks:
@echo ${PACKAGES}
${CACHE}:
mkdir --parents $@
${BUILDDIR}:
mkdir --parents $@
imagebuilder: ${BUILDDIR}/${imagebuilder}
${BUILDDIR}/${imagebuilder}: ${CACHE}/${imagebuilder}.tar.xz ${BUILDDIR}
tar --touch -C ${BUILDDIR} -xf $<
${CACHE}/${imagebuilder}.tar.xz: | ${CACHE}
curl --remote-name --continue-at - --output-dir $| ${DOWNLOADS_BASE}/${@F}
image: $C/${image}
install = rsync --mkpath ${1} ${FILES}${2}
${FILES}:
mkdir ${FILES}
${FILES_INSTALL}
[ ! -d $C/files ] || cp -r -T -f $C/files ${FILES}
files: ${FILES}
$C/${image}: ${BUILDDIR}/${imagebuilder} ${FILES} ${DEPS}
umask 022; $(MAKE) -C $< image \
PROFILE=${PLATFORM} \
PACKAGES="${PACKAGES}" \
FILES=${FILES} \
CONFIG_DOWNLOAD_FOLDER=$(realpath ${CACHE})/${INSTRUCTION_SET}
cp ${BUILDDIR}/${imagebuilder}/bin/targets/${TARGET}/${SUBTARGET}/${image} $@
ifndef LEAVE_BUILD
rm -rf ${BUILDDIR}
else
@echo ${BUILDDIR}
endif
copy: $C/${image}
$(foreach h,${HOSTS}, \
scp ${SCPOPTS} $< $h:/tmp & \
)
install: $C/${image}
$(foreach h,${HOSTS}, ( \
scp ${SCPOPTS} $< $h:/tmp && \
ssh $h sysupgrade -v /tmp/${image} \
)& )
.PHONY: copy listpks image
.SECONDARY: ${BUILDDIR} ${BUILDDIR}/${imagebuilder} ${FILES}