forked from pop-os/iso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiso.mk
201 lines (158 loc) · 6.76 KB
/
iso.mk
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
$(BUILD)/iso_create.tag:
# Remove old ISO
sudo rm -rf "$(BUILD)/iso"
# Create new ISO
mkdir -p "$(BUILD)/iso"
touch "$@"
$(BUILD)/iso_casper.tag: $(BUILD)/live $(BUILD)/chroot.tag $(BUILD)/live.tag $(BUILD)/iso_create.tag
# Remove old casper directory
sudo rm -rf "$(BUILD)/iso/casper"*
# Create new casper directory
mkdir -p "$(BUILD)/iso/$(CASPER_PATH)"
# Copy vmlinuz
if [ -e "$(BUILD)/live/boot/vmlinuz" ]; then \
sudo cp "$(BUILD)/live/boot/vmlinuz" "$(BUILD)/iso/$(CASPER_PATH)/vmlinuz.efi"; \
else \
sudo cp "$(BUILD)/live/vmlinuz" "$(BUILD)/iso/$(CASPER_PATH)/vmlinuz.efi"; \
fi
# Copy initrd
if [ -e "$(BUILD)/live/boot/initrd.img" ]; then \
sudo cp "$(BUILD)/live/boot/initrd.img" "$(BUILD)/iso/$(CASPER_PATH)/initrd.gz"; \
else \
sudo cp "$(BUILD)/live/initrd.img" "$(BUILD)/iso/$(CASPER_PATH)/initrd.gz"; \
fi
# Update manifest
cp "$(BUILD)/live.tag" "$(BUILD)/iso/$(CASPER_PATH)/filesystem.manifest"
grep -F -x -v -f "$(BUILD)/chroot.tag" "$(BUILD)/live.tag" | cut -f1 > "$(BUILD)/iso/$(CASPER_PATH)/filesystem.manifest-remove"
# Update filesystem size
sudo du -sx --block-size=1 "$(BUILD)/live" | cut -f1 > "$(BUILD)/iso/$(CASPER_PATH)/filesystem.size"
# Rebuild filesystem image
sudo mksquashfs "$(BUILD)/live" "$(BUILD)/iso/$(CASPER_PATH)/filesystem.squashfs" -noappend -fstime "$(DISTRO_EPOCH)"
sudo chown -R "$(USER):$(USER)" "$(BUILD)/iso/$(CASPER_PATH)"
ln -sf "$(CASPER_PATH)" "$(BUILD)/iso/casper"
touch "$@"
$(BUILD)/iso_pool.tag: $(BUILD)/pool $(BUILD)/iso_create.tag
# Remove dists and pool directory
sudo rm -rf "$(BUILD)/iso/dists" "$(BUILD)/iso/pool"
# Copy package pool
sudo cp -r "$</pool" "$(BUILD)/iso/pool"
sudo chown -R "$(USER):$(USER)" "$(BUILD)/iso/pool"
# Update pool package lists
cd "$(BUILD)/iso" && \
mkdir -p "dists/$(UBUNTU_CODE)" && \
for pool in $$(ls -1 pool); do \
mkdir -p "dists/$(UBUNTU_CODE)/$$pool/binary-amd64" && \
apt-ftparchive packages "pool/$$pool" > "dists/$(UBUNTU_CODE)/$$pool/binary-amd64/Packages" && \
gzip -k "dists/$(UBUNTU_CODE)/$$pool/binary-amd64/Packages" && \
sed "s|COMPONENT|$$pool|g; $(SED)" "../../../../data/Release" > "dists/$(UBUNTU_CODE)/$$pool/binary-amd64/Release"; \
done; \
apt-ftparchive \
-o "APT::FTPArchive::Release::Acquire-By-Hash=yes" \
-o "APT::FTPArchive::Release::Architectures=amd64" \
-o "APT::FTPArchive::Release::Codename=$(UBUNTU_CODE)" \
-o "APT::FTPArchive::Release::Components=$$(ls -1 pool | tr $$'\n' ' ')" \
-o "APT::FTPArchive::Release::Description=$(DISTRO_CODE) $(DISTRO_VERSION)" \
-o "APT::FTPArchive::Release::Label=Ubuntu" \
-o "APT::FTPArchive::Release::Origin=Ubuntu" \
-o "APT::FTPArchive::Release::Suite=$(UBUNTU_CODE)" \
-o "APT::FTPArchive::Release::Version=$(DISTRO_VERSION)" \
release "dists/$(UBUNTU_CODE)" \
> "dists/$(UBUNTU_CODE)/Release" && \
gpg --batch --yes --digest-algo sha512 --sign --detach-sign --armor --local-user "$(GPG_NAME)" -o "dists/$(UBUNTU_CODE)/Release.gpg" "dists/$(UBUNTU_CODE)/Release" && \
cd "dists" && \
ln -s "$(UBUNTU_CODE)" stable && \
ln -s "$(UBUNTU_CODE)" unstable
touch "$@"
$(BUILD)/grub:
rm -rf "[email protected]"
mkdir "[email protected]"
grub-mkimage \
--directory /usr/lib/grub/i386-pc \
--prefix /boot/grub \
--output "[email protected]/eltorito.img" \
--format i386-pc-eltorito \
--compression auto \
--config data/grub/load.cfg \
biosdisk iso9660
rm -rf "$(BUILD)/iso/efi"
mkdir -p "$(BUILD)/iso/efi/boot/"
cp -r "data/efi/shimx64.efi.signed" "$(BUILD)/iso/efi/boot/bootx64.efi"
cp -r "data/efi/gcdx64.efi.signed" "$(BUILD)/iso/efi/boot/grubx64.efi"
mkfs.vfat -C "[email protected]/efi.img" 4096
mcopy -s -i "[email protected]/efi.img" "$(BUILD)/iso/efi" ::/
touch "[email protected]"
mv "[email protected]" "$@"
$(BUILD)/iso_data.tag: $(BUILD)/iso_create.tag $(BUILD)/grub
git submodule update --init data/grub-theme
# Replace disk info
rm -rf "$(BUILD)/iso/.disk"
mkdir -p "$(BUILD)/iso/.disk"
sed "$(SED)" "data/disk/info" > "$(BUILD)/iso/.disk/info"
# Copy isolinux files
rm -rf "$(BUILD)/iso/isolinux"
mkdir -p "$(BUILD)/iso/isolinux"
cp /usr/lib/ISOLINUX/isolinux.bin "$(BUILD)/iso/isolinux/isolinux.bin"
cp /usr/lib/syslinux/modules/bios/ldlinux.c32 "$(BUILD)/iso/isolinux/ldlinux.c32"
sed "$(SED)" "data/isolinux/isolinux.cfg" > "$(BUILD)/iso/isolinux/isolinux.cfg"
# Update grub config
rm -rf "$(BUILD)/iso/boot/grub"
mkdir -p "$(BUILD)/iso/boot/grub"
sed "$(SED)" "data/grub/grub.cfg" > "$(BUILD)/iso/boot/grub/grub.cfg"
cp /usr/share/grub/unicode.pf2 "$(BUILD)/iso/boot/grub/font.pf2"
# Copy grub modules (BIOS)
mkdir -p "$(BUILD)/iso/boot/grub/i386-pc"
cp "$(BUILD)/grub/eltorito.img" "/usr/lib/grub/i386-pc/"*.mod "$(BUILD)/iso/boot/grub/i386-pc/"
# Copy grub modules (EFI)
cp "$(BUILD)/grub/efi.img" "$(BUILD)/iso/boot/grub"
mkdir -p "$(BUILD)/iso/boot/grub/x86_64-efi"
cp "/usr/lib/grub/x86_64-efi/"*.mod "$(BUILD)/iso/boot/grub/x86_64-efi/"
# Copy grub theme
cp -r "data/grub-theme/usr/share/grub/themes" "$(BUILD)/iso/boot/grub/themes"
touch "$@"
$(BUILD)/iso_sum.tag: $(BUILD)/iso_casper.tag $(BUILD)/iso_pool.tag $(BUILD)/iso_data.tag
# Calculate md5sum
cd "$(BUILD)/iso" && \
rm -f md5sum.txt && \
find -type f -print0 | sort -z | xargs -0 md5sum > md5sum.txt
touch "$@"
$(TAR): $(BUILD)/iso_sum.tag
tar --create \
--mtime="@$(DISTRO_EPOCH)" --sort=name \
--owner=0 --group=0 --numeric-owner --mode='a=,u+rX' \
--file "[email protected]" --directory "$(BUILD)/iso" .
mv "[email protected]" "$@"
$(USB): $(BUILD)/iso_sum.tag
scripts/usb.sh "$(BUILD)" "[email protected]"
mv "[email protected]" "$@"
$(ISO): $(BUILD)/iso_sum.tag
ifeq ($(GRUB_BIOS),1)
xorriso -as mkisofs \
--protective-msdos-label \
-b boot/grub/i386-pc/eltorito.img \
-no-emul-boot -boot-load-size 4 -boot-info-table \
--grub2-boot-info --grub2-mbr /usr/lib/grub/i386-pc/boot_hybrid.img \
--efi-boot "boot/grub/efi.img" -efi-boot-part --efi-boot-image \
-r -V "$(DISTRO_NAME) $(DISTRO_VERSION) amd64" \
-o "[email protected]" "$(BUILD)/iso" -- \
-volume_date all_file_dates ="$(DISTRO_EPOCH)"
else
xorriso -as mkisofs \
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
-c isolinux/boot.cat -b isolinux/isolinux.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-eltorito-alt-boot -e boot/grub/efi.img \
-no-emul-boot -isohybrid-gpt-basdat \
-r -V "$(DISTRO_NAME) $(DISTRO_VERSION) amd64" \
-o "[email protected]" "$(BUILD)/iso" -- \
-volume_date all_file_dates ="$(DISTRO_EPOCH)"
endif
mv "[email protected]" "$@"
$(ISO).zsync: $(ISO)
cd "$(BUILD)" && zsyncmake -o "`basename "[email protected]"`" "`basename "$<"`"
mv "[email protected]" "$@"
$(BUILD)/SHA256SUMS: $(ISO)
cd "$(BUILD)" && sha256sum -b "`basename "$<"`" > "`basename "[email protected]"`"
mv "[email protected]" "$@"
$(BUILD)/SHA256SUMS.gpg: $(BUILD)/SHA256SUMS
cd "$(BUILD)" && gpg --batch --yes --output "`basename "[email protected]"`" --detach-sig "`basename "$<"`"
mv "[email protected]" "$@"