]> git.ipfire.org Git - ipfire-2.x.git/blob - lfs/cdrom
Merge remote-tracking branch 'origin/next'
[ipfire-2.x.git] / lfs / cdrom
1 ###############################################################################
2 # #
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2021 IPFire Team <info@ipfire.org> #
5 # #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
10 # #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
18 # #
19 ###############################################################################
20
21 ###############################################################################
22 # Definitions
23 ###############################################################################
24
25 include Config
26
27 VER = ipfire
28
29 THISAPP = cdrom
30 TARGET = $(DIR_INFO)/$(THISAPP)
31
32 # Fail when there is an error in the tar pipe
33 SHELL=/bin/bash -o pipefail
34
35 HAS_MEMTEST = 0
36 HAS_IPXE = 0
37 HAS_ISOLINUX = 0
38 HAS_KERNEL = 1
39
40 ifeq "$(BUILD_PLATFORM)" "x86"
41 HAS_MEMTEST = 1
42 HAS_IPXE = 1
43 HAS_ISOLINUX = 1
44 endif
45
46 ifeq "$(BUILD_ARCH)" "armv6l"
47 HAS_KERNEL = 0
48 endif
49
50 ISO_ARGS = -J -r -v \
51 -A "$(NAME) $(VERSION) $(BUILD_ARCH)" \
52 -V "$(NAME) $(VERSION) $(BUILD_ARCH)"
53
54 ISOHYBRID_ARGS =
55
56 ifeq "$(HAS_ISOLINUX)" "1"
57 ISO_ARGS += \
58 -no-emul-boot \
59 -boot-load-size 4 \
60 -boot-info-table \
61 -b boot/isolinux/isolinux.bin \
62 -c boot/isolinux/boot.catalog
63 endif
64
65 ifeq "$(EFI)" "1"
66 ISO_ARGS += \
67 -eltorito-alt-boot \
68 -e boot/isolinux/efiboot.img \
69 -no-emul-boot
70
71 ISOHYBRID_ARGS += --uefi
72 endif
73
74 GRUB_EFI_MODULES = \
75 all_video \
76 at_keyboard \
77 boot \
78 bitmap_scale \
79 cat \
80 chain \
81 configfile \
82 disk \
83 echo \
84 efi_gop \
85 efi_uga \
86 ext2 \
87 extcmd \
88 fat \
89 file \
90 font \
91 fxterm_menu \
92 gfxterm \
93 gfxmenu \
94 gfxterm_background \
95 gzio \
96 halt \
97 help \
98 iso9660 \
99 jpeg \
100 loadbios \
101 loadenv \
102 loopback \
103 linux \
104 ls \
105 memdisk \
106 minicmd \
107 nativedisk \
108 normal \
109 ntfs \
110 part_gpt \
111 part_msdos \
112 png \
113 probe \
114 reboot \
115 regexp \
116 search \
117 search_fs_file \
118 search_fs_uuid \
119 search_label \
120 tar \
121 test \
122 tga \
123 true \
124 usb_keyboard
125
126 ISO_FILE = /install/images/$(SNAME)-$(VERSION)-core$(CORE)-$(BUILD_ARCH).iso
127
128 ###############################################################################
129 # Top-level Rules
130 ###############################################################################
131
132 install : $(TARGET)
133
134 check :
135
136 download :
137
138 b2 :
139
140 ###############################################################################
141 # Installation Details
142 ###############################################################################
143
144 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
145 # Update /etc/system-release, because the string might have changed
146 # since stage2 has been executed..
147 echo "$(SYSTEM_RELEASE)" > /etc/system-release
148
149 # Create a directory to authorise the CDROM in
150 rm -rf $(DIR_TMP)/cdrom && mkdir -p $(DIR_TMP)/cdrom
151
152 # Clear mtab (prevents .journal problems)
153 rm -vf /etc/mtab
154 ln -s /proc/self/mounts /etc/mtab
155
156 # Create filelist for packaging.
157 BUILDTARGET="$(BUILDTARGET)" BUILD_ARCH="$(BUILD_ARCH)" KVER="$(KVER)" \
158 $(DIR_SRC)/src/scripts/archive.files \
159 $(DIR_SRC)/config/rootfiles/common \
160 > $(DIR_TMP)/ROOTFILES
161
162 # Compress root filesystem
163 # Reason for this tar+untar+tar is removing of entries listed two or more in src/ROOTFILES
164 rm -rf $(DIR_TMP)/root && mkdir -p $(DIR_TMP)/root
165 tar $(TAR_OPTIONS) -c --exclude='#*' --exclude='proc/*' --exclude='dev/pts/*' --exclude='tmp/*' \
166 --exclude='__pycache__' \
167 -C / --files-from=$(DIR_TMP)/ROOTFILES | tar $(TAR_OPTIONS) -x -C $(DIR_TMP)/root
168 rm -f $(DIR_TMP)/ROOTFILES
169 mkdir $(DIR_TMP)/root/sys
170 cd $(DIR_TMP)/root && tar $(TAR_OPTIONS) -cf - * | zstd $(ZSTD_OPTIONS) > $(DIR_TMP)/cdrom/distro.img
171 rm -rf $(DIR_TMP)/root
172
173 # Other files
174 touch $(DIR_TMP)/cdrom/$(SNAME)-$(VERSION)-core$(CORE).media
175 sed 's/VERSION/$(VERSION)/' $(DIR_SRC)/config/cdrom/README.txt > $(DIR_TMP)/cdrom/README.txt
176 cp $(DIR_SRC)/doc/COPYING $(DIR_TMP)/cdrom/
177
178 # Install documentation
179 -mkdir -pv $(DIR_TMP)/cdrom/doc
180 cp $(DIR_SRC)/doc/{ChangeLog,packages-list.txt} $(DIR_TMP)/cdrom/doc
181
182 mkdir -p $(DIR_TMP)/cdrom/boot/isolinux
183
184 ifeq "$(HAS_KERNEL)" "1"
185 cp /boot/vmlinuz-$(KVER)-ipfire $(DIR_TMP)/cdrom/boot/isolinux/vmlinuz
186 dracut --force -a "installer" --strip $(DIR_TMP)/cdrom/boot/isolinux/instroot $(KVER)-ipfire
187 endif
188
189 ifeq "$(HAS_ISOLINUX)" "1"
190 dd if=/dev/zero bs=1k count=2 > $(DIR_TMP)/cdrom/boot/isolinux/boot.catalog
191 cp $(DIR_SRC)/config/syslinux/boot.png $(DIR_TMP)/cdrom/boot/isolinux/boot.png
192 cp /usr/share/syslinux/isolinux.bin $(DIR_TMP)/cdrom/boot/isolinux/isolinux.bin
193 cp /usr/share/hwdata/pci.ids $(DIR_TMP)/cdrom/boot/isolinux/pci.ids
194 cp -vf /usr/share/syslinux/*.c32 $(DIR_TMP)/cdrom/boot/isolinux/
195 sed -e "s/VERSION/$(VERSION) - Core $(CORE)/g" \
196 $(DIR_SRC)/config/syslinux/syslinux.cfg \
197 > $(DIR_TMP)/cdrom/boot/isolinux/isolinux.cfg
198 endif
199
200 ifeq "$(HAS_MEMTEST)" "1"
201 # Install memtest
202 cp /usr/lib/memtest86+/memtest.bin $(DIR_TMP)/cdrom/boot/isolinux/memtest
203 endif
204
205 ifeq "$(HAS_IPXE)" "1"
206 cp /usr/share/ipfire-netboot/ipxe.lkrn $(DIR_TMP)/cdrom/boot/isolinux/netboot
207 endif
208
209 ifeq "$(EFI)" "1"
210 # Generate embedded GRUB configuration
211 sed -e "s/NAME/$(NAME)/g" -e "s/VERSION/$(VERSION)/g" -e "s/ARCH/$(BUILD_ARCH)/g" \
212 $(DIR_SRC)/config/cdrom/grub-efi.cfg > /tmp/grub-efi.cfg
213
214 # Build a GRUB EFI image
215 mkdir -pv $(DIR_TMP)/cdrom/EFI/BOOT
216 grub-mkimage \
217 --format=$(GRUB_ARCH)-efi \
218 --output=$(DIR_TMP)/cdrom/EFI/BOOT/boot$(EFI_ARCH).efi \
219 --config=$(DIR_TMP)/grub-efi.cfg \
220 --compression=xz \
221 --prefix=/EFI/BOOT \
222 $$(for mod in $(GRUB_EFI_MODULES); do [ -f "/usr/lib/grub/$(GRUB_ARCH)-efi/$${mod}.mod" ] && echo "$${mod}"; done)
223
224 # Install GRUB configuration
225 mkdir -pv $(DIR_TMP)/cdrom/EFI/BOOT
226 sed -e "s/NAME/$(NAME)/g" -e "s/VERSION/$(VERSION)/g" -e "s/ARCH/$(BUILD_ARCH)/g" \
227 < $(DIR_SRC)/config/cdrom/grub.cfg > $(DIR_TMP)/cdrom/EFI/BOOT/grub.cfg
228
229 # Create the EFI Eltorito image
230 dd if=/dev/zero of=$(DIR_TMP)/cdrom/boot/isolinux/efiboot.img bs=1k count=1440
231 mkdosfs -F 12 -n "IPFIRE_EFI" $(DIR_TMP)/cdrom/boot/isolinux/efiboot.img
232
233 # Mount the EFI image
234 mkdir -pv $(DIR_TMP)/efiboot.img
235 mount -o loop $(DIR_TMP)/cdrom/boot/isolinux/efiboot.img $(DIR_TMP)/efiboot.img
236
237 # Copy the bootloader into the image
238 mkdir -p $(DIR_TMP)/efiboot.img/EFI/BOOT
239 cp -a $(DIR_TMP)/cdrom/EFI/BOOT/boot$(EFI_ARCH).efi \
240 $(DIR_TMP)/efiboot.img/EFI/BOOT/boot$(EFI_ARCH).efi
241
242 # Cleanup
243 umount $(DIR_TMP)/efiboot.img
244 rm -rf $(DIR_TMP)/efiboot.img $(DIR_TMP)/grub-efi.cfg
245 endif
246
247 cd $(DIR_TMP)/cdrom && find -type f ! -name md5sum.txt | grep -v "./boot" | \
248 xargs md5sum > md5sum.txt
249
250 mkdir -p /install/images
251 cd $(DIR_TMP)/cdrom && mkisofs $(ISO_ARGS) -o $(ISO_FILE) .
252
253 ifeq "$(HAS_ISOLINUX)" "1"
254 isohybrid $(ISOHYBRID_ARGS) $(ISO_FILE)
255 endif