forked from YasuhiroABE/ub-autoinstall-iso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (78 loc) · 3.31 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
.PHONY: download init setup geniso clean clean-up-all
ISO_URLBASE = https://releases.ubuntu.com/22.04/
ISO_FILENAME = ubuntu-22.04.1-live-server-amd64.iso
ISO_MOUNTPOINT = /mnt/iso
ISO_ROOT = iso_root
## copy files
GRUBCFG_SRC = config/boot/grub/grub.cfg
GRUBCFG_DEST = iso_root/boot/grub/grub.cfg
USERDATA_SRC = config/user-data
USERDATA_DEST = iso_root/user-data
METADATA_SRC = config/meta-data
METADATA_DEST = iso_root/meta-data
EXTRAS_SRCDIR = config/extras/
EXTRAS_DESTDIR = iso_root/
GENISO_LABEL = MYUBISOIMG
GENISO_FILENAME = ubuntu-custom-autoinstaller.$(shell date +%Y%m%d.%H%M%S).iso
GENISO_BOOTIMG = boot/grub/i386-pc/eltorito.img
GENISO_BOOTCATALOG = /boot.catalog
GENISO_START_SECTOR = $(shell sudo fdisk -l $(ISO_FILENAME) |grep iso2 | cut -d' ' -f2)
GENISO_END_SECTOR = $(shell sudo fdisk -l $(ISO_FILENAME) |grep iso2 | cut -d' ' -f3)
## for APU/APU2
GENISO_ISOLINUX = /usr/lib/ISOLINUX/isolinux.bin
GENISO_ISOLINUX_MODULEDIR = /usr/lib/syslinux/modules/bios/
GENISO_HYBRIDMBR = /usr/lib/ISOLINUX/isohdpfx.bin
ISOLINUX_CONFIGDIR = config/isolinux
ISOLINUX_DIRNAME = isolinux
download:
wget -N $(ISO_URLBASE)/$(ISO_FILENAME)
init:
sudo apt install xorriso rsync
( test -d $(ISO_ROOT) && mv -f $(ISO_ROOT) $(ISO_ROOT).$(shell date +%Y%m%d.%H%M%S) ) || true
mkdir -p $(ISO_ROOT)
sudo mkdir -p $(ISO_MOUNTPOINT)
(mountpoint $(ISO_MOUNTPOINT) && sudo umount -q $(ISO_MOUNTPOINT)) || true
sudo mount -o ro,loop $(ISO_FILENAME) $(ISO_MOUNTPOINT)
rsync -av $(ISO_MOUNTPOINT)/. $(ISO_ROOT)/.
sudo umount $(ISO_MOUNTPOINT)
setup:
chmod 755 $(ISO_ROOT)
chmod 644 $(GRUBCFG_DEST)
cp -f $(GRUBCFG_SRC) $(GRUBCFG_DEST)
chmod 755 $(ISO_ROOT)
cp -f $(USERDATA_SRC) $(USERDATA_DEST)
cp -f $(METADATA_SRC) $(METADATA_DEST)
rsync -av $(EXTRAS_SRCDIR)/. $(EXTRAS_DESTDIR)/.
setup-isolinux:
chmod 755 $(ISO_ROOT)
sudo apt install isolinux syslinux-common
cp $(GENISO_ISOLINUX) $(ISO_ROOT)/
mkdir -p $(ISO_ROOT)/$(ISOLINUX_DIRNAME)
rsync -av $(GENISO_ISOLINUX_MODULEDIR)/. $(ISO_ROOT)/$(ISOLINUX_DIRNAME)/.
rsync -av $(ISOLINUX_CONFIGDIR)/. $(ISO_ROOT)/$(ISOLINUX_DIRNAME)/.
geniso:
sudo xorriso -as mkisofs -volid $(GENISO_LABEL) \
-output $(GENISO_FILENAME) \
-eltorito-boot $(GENISO_BOOTIMG) \
-eltorito-catalog $(GENISO_BOOTCATALOG) -no-emul-boot \
-boot-load-size 4 -boot-info-table -eltorito-alt-boot \
-no-emul-boot -isohybrid-gpt-basdat \
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b --interval:local_fs:$(GENISO_START_SECTOR)d-$(GENISO_END_SECTOR)d::'$(ISO_FILENAME)' \
-e '--interval:appended_partition_2_start_1782357s_size_8496d:all::' \
--grub2-mbr --interval:local_fs:0s-15s:zero_mbrpt,zero_gpt:'$(ISO_FILENAME)' \
"${ISO_ROOT}"
geniso-apu:
sudo xorriso -as mkisofs -volid $(GENISO_LABEL) \
-output $(GENISO_FILENAME) \
-eltorito-boot /$(shell basename $(GENISO_ISOLINUX)) \
-eltorito-catalog $(GENISO_BOOTCATALOG) -no-emul-boot \
-boot-load-size 4 -boot-info-table -eltorito-alt-boot \
-no-emul-boot -isohybrid-gpt-basdat \
-append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b --interval:local_fs:$(GENISO_START_SECTOR)d-$(GENISO_END_SECTOR)d::'$(ISO_FILENAME)' \
-isohybrid-mbr $(GENISO_HYBRIDMBR) \
-e '--interval:appended_partition_2_start_1782357s_size_8496d:all::' \
"${ISO_ROOT}"
clean:
find . -type f -a -user "$(shell id -un)" -a -name '*~' -exec rm {} \; -print
clean-up-all: clean
sudo rm -rf iso_root