]> git.ipfire.org Git - ipfire-2.x.git/blob - lfs/cdrom
cdrom: Do not write the temporary tarball to disk
[ipfire-2.x.git] / lfs / cdrom
1 ###############################################################################
2 # #
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2018 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 ifeq "$(BUILD_PLATFORM)" "arm"
36 TAR_OPTIONS =
37 else
38 TAR_OPTIONS = --lzma
39 endif
40
41 HAS_MEMTEST = 0
42 HAS_IPXE = 0
43 HAS_ISOLINUX = 0
44 HAS_KERNEL = 1
45
46 ifeq "$(BUILD_PLATFORM)" "x86"
47 HAS_MEMTEST = 1
48 HAS_IPXE = 1
49 HAS_ISOLINUX = 1
50 endif
51
52 ifeq "$(BUILD_ARCH)" "armv5tel"
53 HAS_KERNEL = 0
54 endif
55
56 ISO_ARGS = -J -r -v \
57 -A "$(NAME) $(VERSION) $(BUILD_ARCH)" \
58 -V "$(NAME) $(VERSION) $(BUILD_ARCH)"
59
60 ISOHYBRID_ARGS =
61
62 ifeq "$(HAS_ISOLINUX)" "1"
63 ISO_ARGS += \
64 -no-emul-boot \
65 -boot-load-size 4 \
66 -boot-info-table \
67 -b boot/isolinux/isolinux.bin \
68 -c boot/isolinux/boot.catalog
69 endif
70
71 ifeq "$(EFI)" "1"
72 ISO_ARGS += \
73 -eltorito-alt-boot \
74 -e boot/isolinux/efiboot.img \
75 -no-emul-boot
76
77 ISOHYBRID_ARGS += --uefi
78 endif
79
80 GRUB_EFI_MODULES = \
81 all_video \
82 at_keyboard \
83 boot \
84 bitmap_scale \
85 cat \
86 chain \
87 configfile \
88 disk \
89 echo \
90 efi_gop \
91 efi_uga \
92 ext2 \
93 extcmd \
94 fat \
95 file \
96 font \
97 fxterm_menu \
98 gfxterm \
99 gfxmenu \
100 gfxterm_background \
101 gzio \
102 halt \
103 help \
104 iso9660 \
105 jpeg \
106 loadbios \
107 loadenv \
108 loopback \
109 linux \
110 ls \
111 memdisk \
112 minicmd \
113 nativedisk \
114 normal \
115 ntfs \
116 part_gpt \
117 part_msdos \
118 png \
119 probe \
120 reboot \
121 regexp \
122 search \
123 search_fs_file \
124 search_fs_uuid \
125 search_label \
126 tar \
127 test \
128 tga \
129 true \
130 usb_keyboard
131
132 ###############################################################################
133 # Top-level Rules
134 ###############################################################################
135
136 install : $(TARGET)
137
138 check :
139
140 download :
141
142 md5 :
143
144 ###############################################################################
145 # Installation Details
146 ###############################################################################
147
148 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
149 # Update /etc/system-release, because the string might have changed
150 # since stage2 has been executed..
151 echo "$(SYSTEM_RELEASE)" > /etc/system-release
152
153 rm -rf /install/cdrom
154 mkdir -p /install/cdrom/doc
155
156 # Clear mtab (prevents .journal problems)
157 rm -vf /etc/mtab
158 echo > /etc/mtab
159
160 # Create filelist for packaging.
161 BUILDTARGET="$(BUILDTARGET)" BUILD_ARCH="$(BUILD_ARCH)" KVER="$(KVER)" \
162 $(DIR_SRC)/src/scripts/archive.files \
163 $(DIR_SRC)/config/rootfiles/common \
164 > $(DIR_TMP)/ROOTFILES
165
166 # Compress root filesystem
167 # Reason for this tar+untar+tar is removing of entries listed two or more in src/ROOTFILES
168 rm -rf $(DIR_TMP)/root && mkdir -p $(DIR_TMP)/root
169 tar -c --exclude='#*' --exclude='proc/*' --exclude='dev/pts/*' --exclude='tmp/*' \
170 --exclude='__pycache__' \
171 -C / --files-from=$(DIR_TMP)/ROOTFILES | tar -x -C $(DIR_TMP)/root
172 rm -f $(DIR_TMP)/ROOTFILES
173 mkdir $(DIR_TMP)/root/sys
174 cd $(DIR_TMP)/root && tar cf - * | xz $(XZ_OPT) > /install/cdrom/distro.img
175 rm -rf $(DIR_TMP)/root
176
177 # Other files
178 touch /install/cdrom/$(SNAME)-$(VERSION)-core$(CORE).media
179 sed 's/VERSION/$(VERSION)/' $(DIR_SRC)/config/cdrom/README.txt > /install/cdrom/README.txt
180 cp $(DIR_SRC)/doc/COPYING /install/cdrom/
181 cp $(DIR_SRC)/doc/{ChangeLog,packages-list.txt} /install/cdrom/doc
182
183 mkdir -p /install/cdrom/boot/isolinux
184
185 ifeq "$(HAS_KERNEL)" "1"
186 cp /boot/vmlinuz-$(KVER)-ipfire /install/cdrom/boot/isolinux/vmlinuz
187 dracut --force --early-microcode -a "installer" --strip --xz /install/cdrom/boot/isolinux/instroot $(KVER)-ipfire
188 endif
189
190 ifeq "$(HAS_ISOLINUX)" "1"
191 dd if=/dev/zero bs=1k count=2 > /install/cdrom/boot/isolinux/boot.catalog
192 cp $(DIR_SRC)/config/syslinux/boot.png /install/cdrom/boot/isolinux/boot.png
193 cp /usr/share/syslinux/isolinux.bin /install/cdrom/boot/isolinux/isolinux.bin
194 cp /usr/share/hwdata/pci.ids /install/cdrom/boot/isolinux/pci.ids
195 cp -vf /usr/share/syslinux/*.c32 /install/cdrom/boot/isolinux/
196 sed -e "s/VERSION/$(VERSION) - Core $(CORE)/g" \
197 $(DIR_SRC)/config/syslinux/syslinux.cfg \
198 > /install/cdrom/boot/isolinux/isolinux.cfg
199 endif
200
201 ifeq "$(HAS_MEMTEST)" "1"
202 # Install memtest
203 cp /usr/lib/memtest86+/memtest.bin /install/cdrom/boot/isolinux/memtest
204 endif
205
206 ifeq "$(HAS_IPXE)" "1"
207 cp /usr/share/ipfire-netboot/ipxe.lkrn /install/cdrom/boot/isolinux/netboot
208 endif
209
210 ifeq "$(EFI)" "1"
211 # Generate embedded GRUB configuration
212 sed -e "s/NAME/$(NAME)/g" -e "s/VERSION/$(VERSION)/g" -e "s/ARCH/$(BUILD_ARCH)/g" \
213 $(DIR_SRC)/config/cdrom/grub-efi.cfg > /tmp/grub-efi.cfg
214
215 # Build a GRUB EFI image
216 mkdir -pv /install/cdrom/EFI/BOOT
217 grub-mkimage \
218 --format=$(GRUB_ARCH)-efi \
219 --output=/install/cdrom/EFI/BOOT/boot$(EFI_ARCH).efi \
220 --config=/tmp/grub-efi.cfg \
221 --compression=xz \
222 --prefix=/EFI/BOOT \
223 $$(for mod in $(GRUB_EFI_MODULES); do [ -f "/usr/lib/grub/$(GRUB_ARCH)-efi/$${mod}.mod" ] && echo "$${mod}"; done)
224
225 # Install GRUB configuration
226 mkdir -pv /install/cdrom/EFI/BOOT
227 sed -e "s/NAME/$(NAME)/g" -e "s/VERSION/$(VERSION)/g" -e "s/ARCH/$(BUILD_ARCH)/g" \
228 < $(DIR_SRC)/config/cdrom/grub.cfg > /install/cdrom/EFI/BOOT/grub.cfg
229
230 # Create the EFI Eltorito image
231 dd if=/dev/zero of=/install/cdrom/boot/isolinux/efiboot.img bs=1k count=1440
232 mkdosfs -F 12 -n "IPFIRE_EFI" /install/cdrom/boot/isolinux/efiboot.img
233
234 # Mount the EFI image
235 mkdir -pv /install/efiboot.img
236 mount -o loop /install/cdrom/boot/isolinux/efiboot.img /install/efiboot.img
237
238 # Copy the bootloader into the image
239 mkdir -pv /install/efiboot.img/EFI/BOOT
240 cp -a /install/cdrom/EFI/BOOT/boot$(EFI_ARCH).efi \
241 /install/efiboot.img/EFI/BOOT/boot$(EFI_ARCH).efi
242
243 # Cleanup
244 umount /install/efiboot.img
245 rm -rf /install/efiboot.img /tmp/grub-efi.cfg
246 endif
247
248 cd /install/cdrom && find -type f ! -name md5sum.txt | grep -v "./boot" | \
249 xargs md5sum > md5sum.txt
250
251 mkdir -p /install/images
252 cd /install/cdrom && mkisofs $(ISO_ARGS) \
253 -o /install/images/$(SNAME)-$(VERSION).$(BUILD_ARCH)-full-core$(CORE).iso .
254
255 ifeq "$(HAS_ISOLINUX)" "1"
256 isohybrid $(ISOHYBRID_ARGS) /install/images/$(SNAME)-$(VERSION).$(BUILD_ARCH)-full-core$(CORE).iso
257 endif