-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
109 lines (85 loc) · 4.12 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
ALL_CURL_OPTS := $(CURL_OPTS) -L --fail
#VERSION := 22.03-SNAPSHOT
VERSION := 22.03.5
BOARD := x86
SUBTARGET := 64
BUILDER := openwrt-imagebuilder-$(VERSION)-$(BOARD)-$(SUBTARGET).Linux-x86_64
PROFILE := generic
EXTRA_IMAGE_NAME := iscsi-target-ramdisk
# Example WiFi support: "wpad-openssl kmod-iwlwifi iwlwifi-firmware-iwl8265"
# Example Emulated device support: "kmod-veth wpad-openssl kmod-mac80211-hwsim"
PACKAGES := luci tgt blkid lsblk iperf3 luci-app-commands atop tcpdump ethtool -libustream-wolfssl libustream-openssl luci-ssl-openssl
BUILD_DIR := build
OUTPUT_DIR := $(BUILD_DIR)/$(BUILDER)/bin/targets/$(BOARD)/$(SUBTARGET)
all: images
$(BUILD_DIR)/downloads:
mkdir -p \
$(BUILD_DIR)/downloads.tmp \
$(BUILD_DIR)/downloads.tmp/ipxe/x86 \
$(BUILD_DIR)/downloads.tmp/ipxe/x86_64
# OpenWrt Image Builder
cd $(BUILD_DIR)/downloads.tmp \
&& curl $(ALL_CURL_OPTS) -O https://downloads.openwrt.org/releases/$(VERSION)/targets/$(BOARD)/$(SUBTARGET)/$(BUILDER).tar.xz
# iPXE
cd $(BUILD_DIR)/downloads.tmp/ipxe/x86 \
&& curl $(ALL_CURL_OPTS) -O https://boot.ipxe.org/ipxe.pxe \
&& curl $(ALL_CURL_OPTS) -O https://boot.ipxe.org/undionly.kpxe
cd $(BUILD_DIR)/downloads.tmp/ipxe/x86_64 \
&& curl $(ALL_CURL_OPTS) -O https://boot.ipxe.org/ipxe.efi \
&& curl $(ALL_CURL_OPTS) -O https://boot.ipxe.org/snponly.efi
cd $(BUILD_DIR)/downloads.tmp/ipxe/ \
&& curl $(ALL_CURL_OPTS) -O https://boot.ipxe.org/ipxe.iso \
&& curl $(ALL_CURL_OPTS) -O https://boot.ipxe.org/ipxe.usb
# ISOLINUX for ISO building
cd $(BUILD_DIR)/downloads.tmp \
&& curl $(ALL_CURL_OPTS) -O https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz \
&& tar -xf syslinux-6.03.tar.gz
mv $(BUILD_DIR)/downloads.tmp $(BUILD_DIR)/downloads
rootfs-contents: $(BUILD_DIR)/downloads
rm -rf $(BUILD_DIR)/rootfs
cp -rv rootfs $(BUILD_DIR)/rootfs
cp -f $(BUILD_DIR)/$(BUILDER)/target/linux/generic/other-files/init $(BUILD_DIR)/rootfs/
mkdir -p $(BUILD_DIR)/rootfs/srv/pxe/tftp/ipxe/x86
cp -f $(BUILD_DIR)/downloads/ipxe/x86/ipxe.pxe $(BUILD_DIR)/rootfs/srv/pxe/tftp/ipxe/x86
cp -f $(BUILD_DIR)/downloads/ipxe/x86/undionly.kpxe $(BUILD_DIR)/rootfs/srv/pxe/tftp/ipxe/x86
mkdir -p $(BUILD_DIR)/rootfs/srv/pxe/tftp/ipxe/x86_64
cp -f $(BUILD_DIR)/downloads/ipxe/x86_64/ipxe.efi $(BUILD_DIR)/rootfs/srv/pxe/tftp/ipxe/x86_64
cp -f $(BUILD_DIR)/downloads/ipxe/x86_64/snponly.efi $(BUILD_DIR)/rootfs/srv/pxe/tftp/ipxe/x86_64
$(BUILD_DIR)/$(BUILDER): $(BUILD_DIR)/downloads
cd $(BUILD_DIR) && tar -xf downloads/$(BUILDER).tar.xz
images: $(BUILD_DIR)/$(BUILDER) rootfs-contents
cd $(BUILD_DIR)/$(BUILDER) && make image PROFILE="$(PROFILE)" EXTRA_IMAGE_NAME="$(EXTRA_IMAGE_NAME)" PACKAGES="$(PACKAGES)" FILES="../rootfs"
cat $(OUTPUT_DIR)/sha256sums
mkdir -p $(BUILD_DIR)/images
cp $(OUTPUT_DIR)/openwrt-*-kernel.bin $(BUILD_DIR)/images/$(EXTRA_IMAGE_NAME)-kernel.bin
# TODO: Build initramfs image with OpenWrt ImageBuilder built-in Makefile targets
src/tar2cpio.sh $(OUTPUT_DIR)/openwrt-*-rootfs.tar.gz $(BUILD_DIR)/images/$(EXTRA_IMAGE_NAME)-initrd.img
ls -hs $(BUILD_DIR)/images
iso:
echo "Generating ISO / USB boot image"
src/create-boot-iso.sh \
$(BUILD_DIR)/images/$(EXTRA_IMAGE_NAME).iso \
"$(EXTRA_IMAGE_NAME)" \
$(BUILD_DIR)/downloads/syslinux-6.03 \
$(BUILD_DIR)/images/$(EXTRA_IMAGE_NAME)-kernel.bin \
$(BUILD_DIR)/images/$(EXTRA_IMAGE_NAME)-initrd.img \
"consoleblank=600"
efi:
objcopy \
--add-section .osrel=src/os-release --change-section-vma .osrel=0x20000 \
--add-section .cmdline=src/cmdline.txt --change-section-vma .cmdline=0x30000 \
--add-section .linux=build/images/iscsi-target-ramdisk-kernel.bin --change-section-vma .linux=0x2000000 \
--add-section .initrd=build/images/iscsi-target-ramdisk-initrd.img --change-section-vma .initrd=0x3000000 \
/usr/lib/systemd/boot/efi/linuxx64.efi.stub \
build/images/iscsi-target-ramdisk.efi
keys:
# Create persistent ssh host keys
mkdir -p rootfs/etc/dropbear
ssh-keygen -N "" -t rsa -b 2048 -f rootfs/etc/dropbear/dropbear_rsa_host_key
ssh-keygen -N "" -t ed25519 -b 256 -f rootfs/etc/dropbear/dropbear_ed25519_host_key
qemu:
test/qemu.sh
qemu-pxe:
test/qemu-pxe.sh
clean:
rm -rf build