]>
Commit | Line | Data |
---|---|---|
1 | ############################################################################### | |
2 | # # | |
3 | # IPFire.org - A linux based firewall # | |
4 | # Copyright (C) 2007-2012 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 = flash-image | |
30 | TARGET = $(DIR_INFO)/$(THISAPP) | |
31 | ||
32 | ############################################################################### | |
33 | # Top-level Rules | |
34 | ############################################################################### | |
35 | ||
36 | install : $(TARGET) | |
37 | ||
38 | check : | |
39 | ||
40 | download : | |
41 | ||
42 | md5 : | |
43 | ||
44 | ############################################################################### | |
45 | # Installation Details | |
46 | ############################################################################### | |
47 | IMGinst := /install/images/$(SNAME)-$(VERSION).1gb-ext4.$(MACHINE)-full-core$(CORE).img | |
48 | IMGinsts := /install/images/$(SNAME)-$(VERSION).1gb-ext4-scon.$(MACHINE)-full-core$(CORE).img | |
49 | MNThdd := /install/harddisk | |
50 | IMGpart := /install/images/part_area | |
51 | IMGboot := /install/images/bootfs | |
52 | IMGroot := /install/images/rootfs | |
53 | ||
54 | # All sizes in blocks | |
55 | ifeq "$(MACHINE_TYPE)" "arm" | |
56 | S_OFFSET = 8192 | |
57 | ||
58 | # FAT32 | |
59 | PART_TYPE = c | |
60 | else | |
61 | S_OFFSET = 32 | |
62 | ||
63 | # Logical | |
64 | PART_TYPE = L | |
65 | endif | |
66 | ||
67 | # /boot: 64MB - OFFSET | |
68 | # / : 600MB | |
69 | S_BOOT := $(shell echo $$(( 131072 - $(S_OFFSET) ))) | |
70 | S_ROOT := 1228800 | |
71 | ||
72 | $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) | |
73 | rm -rf $(MNThdd) $(IMGinst) $(IMGpart) $(IMGboot) $(IMGroot) && mkdir -p $(MNThdd) | |
74 | ||
75 | # Create first 32 sectors of image | |
76 | dd if=/dev/zero of=$(IMGpart) bs=512 count=$(S_OFFSET) | |
77 | ||
78 | # Create images for filesystems | |
79 | dd if=/dev/zero of=$(IMGboot) bs=512 count=$(S_BOOT) | |
80 | dd if=/dev/zero of=$(IMGroot) bs=512 count=$(S_ROOT) | |
81 | ||
82 | # Format them | |
83 | ifeq "$(PART_TYPE)" "c" | |
84 | mkfs.vfat $(IMGboot) | |
85 | else | |
86 | mkfs.ext2 -F $(IMGboot) | |
87 | endif | |
88 | mkfs.ext4 -O ^has_journal,extent -F $(IMGroot) | |
89 | ||
90 | # Most systems that use Flashimages has no RTC at boot | |
91 | # so the interval check should disables | |
92 | tune2fs -i0 $(IMGroot) | |
93 | ||
94 | # Mount Images | |
95 | mount -o loop $(IMGroot) $(MNThdd) | |
96 | mkdir $(MNThdd)/boot | |
97 | mkdir $(MNThdd)/var | |
98 | mkdir $(MNThdd)/var/log | |
99 | mount -o loop $(IMGboot) $(MNThdd)/boot | |
100 | ||
101 | # Install MLO and uboot first | |
102 | ifeq "$(MACHINE_TYPE)" "arm" | |
103 | cp -v /boot/MLO $(MNThdd)/boot/ | |
104 | cp -v /boot/u-boot.img $(MNThdd)/boot/ | |
105 | sync | |
106 | umount $(MNThdd)/boot | |
107 | mount -o loop $(IMGboot) $(MNThdd)/boot | |
108 | endif | |
109 | ||
110 | # Install IPFire | |
111 | tar -C $(MNThdd)/ -xvaf /install/cdrom/$(SNAME)-$(VERSION).tlz | |
112 | echo "LANGUAGE=en" >> $(MNThdd)/var/ipfire/main/settings | |
113 | echo "HOSTNAME=$(SNAME)" >> $(MNThdd)/var/ipfire/main/settings | |
114 | echo "THEME=ipfire" >> $(MNThdd)/var/ipfire/main/settings | |
115 | -touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep | |
116 | mkdir $(MNThdd)/proc | |
117 | mount --bind /proc $(MNThdd)/proc | |
118 | mount --bind /dev $(MNThdd)/dev | |
119 | mount --bind /sys $(MNThdd)/sys | |
120 | chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" | |
121 | sed -i -e "s|DEVICE1|UUID=$$(blkid -sUUID $(IMGboot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab | |
122 | ifeq "$(PART_TYPE)" "c" | |
123 | # ARM flash images have a VFAT partition for /boot. | |
124 | sed -i -e "s|ext2|vfat|" $(MNThdd)/etc/fstab | |
125 | endif | |
126 | sed -i -e "s|DEVICE2|#DEVICE2|g" $(MNThdd)/etc/fstab | |
127 | sed -i -e "s|DEVICE3|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab | |
128 | sed -i -e "s|DEVICE4|#DEVICE4|g" $(MNThdd)/etc/fstab | |
129 | sed -i -e "s|FSTYPE|ext4|g" $(MNThdd)/etc/fstab | |
130 | ||
131 | ifneq "$(MACHINE_TYPE)" "arm" | |
132 | sed -i -e "s|MOUNT|ro|g" $(MNThdd)/boot/grub/grub.conf | |
133 | sed -i -e "s|KVER|$(KVER)|g" $(MNThdd)/boot/grub/grub.conf | |
134 | sed -i -e "s|ROOT|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/boot/grub/grub.conf | |
135 | ln -s grub.conf $(MNThdd)/boot/grub/menu.lst | |
136 | ||
137 | # Copy grub files manually | |
138 | cp -f $(MNThdd)/usr/lib/grub/i386-pc/* $(MNThdd)/boot/grub/ | |
139 | endif | |
140 | ||
141 | # Setup symlink for partresize at first boot... | |
142 | ln -sf ../init.d/partresize $(MNThdd)/etc/rc.d/rcsysinit.d/S25partresize | |
143 | # Setup symlink for fsresize at second boot... | |
144 | ln -sf ../init.d/fsresize $(MNThdd)/etc/rc.d/rcsysinit.d/S42fsresize | |
145 | ||
146 | # Unmount | |
147 | umount $(MNThdd)/proc | |
148 | umount $(MNThdd)/dev | |
149 | umount $(MNThdd)/sys | |
150 | umount $(MNThdd)/boot | |
151 | umount $(MNThdd) | |
152 | ||
153 | # zerofree the ext2 images to get better compression | |
154 | ifneq "$(PART_TYPE)" "c" | |
155 | zerofree $(IMGboot) | |
156 | -fsck.ext2 -f -y $(IMGboot) | |
157 | fsck.ext2 -f -y $(IMGboot) | |
158 | endif | |
159 | zerofree $(IMGroot) | |
160 | -fsck.ext4 -f -y $(IMGroot) | |
161 | fsck.ext4 -f -y $(IMGroot) | |
162 | ||
163 | # Cat to an image | |
164 | cat $(IMGpart) $(IMGboot) $(IMGroot) > $(IMGinst) | |
165 | ||
166 | # Write Partition table | |
167 | echo -e "$(S_OFFSET),$(S_BOOT),$(PART_TYPE),*\n,0,0\n$$(( $(S_BOOT) + $(S_OFFSET) )),$(S_ROOT),L\n,0,0\n" \ | |
168 | | sfdisk -D -uS -H 64 -S 32 $(IMGinst) | |
169 | ||
170 | ifneq "$(MACHINE_TYPE)" "arm" | |
171 | # Install grub | |
172 | echo "device (hd0) $(IMGinst)" > /tmp/grubinst.tmp | |
173 | echo "root (hd0,0)" >> /tmp/grubinst.tmp | |
174 | echo "setup (hd0)" >> /tmp/grubinst.tmp | |
175 | echo "quit" >> /tmp/grubinst.tmp | |
176 | grub < /tmp/grubinst.tmp | |
177 | rm -f /tmp/grubinst.tmp | |
178 | endif | |
179 | ||
180 | # Compress Image | |
181 | gzip -f9 $(IMGinst) | |
182 | ||
183 | # Now Build serialcon Version | |
184 | # Mount Images | |
185 | mount -o loop $(IMGroot) $(MNThdd) | |
186 | mount -o loop $(IMGboot) $(MNThdd)/boot | |
187 | ||
188 | ifneq "$(MACHINE_TYPE)" "arm" | |
189 | sed -i -e "s|splashimage|#splashimage|g" $(MNThdd)/boot/grub/grub.conf | |
190 | sed -i -e "s|#serial|serial|g" $(MNThdd)/boot/grub/grub.conf | |
191 | sed -i -e "s|#terminal|terminal|g" $(MNThdd)/boot/grub/grub.conf | |
192 | sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" $(MNThdd)/boot/grub/grub.conf | |
193 | else | |
194 | sed -i -e "s| console=tty1 | console=ttyAMA0,115200n8 |g" $(MNThdd)/boot/cmdline.txt | |
195 | sed -i -e "s| console=tty1 | console=ttyO2,115200n8 |g" $(MNThdd)/boot/boot.script | |
196 | cd $(MNThdd)/boot && ./convert_bootscript | |
197 | endif | |
198 | ||
199 | sed -i -e "s|1:2345:respawn:|#1:2345:respawn:|g" $(MNThdd)/etc/inittab | |
200 | sed -i -e "s|2:2345:respawn:|#2:2345:respawn:|g" $(MNThdd)/etc/inittab | |
201 | sed -i -e "s|3:2345:respawn:|#3:2345:respawn:|g" $(MNThdd)/etc/inittab | |
202 | sed -i -e "s|4:2345:respawn:|#4:2345:respawn:|g" $(MNThdd)/etc/inittab | |
203 | sed -i -e "s|5:2345:respawn:|#5:2345:respawn:|g" $(MNThdd)/etc/inittab | |
204 | sed -i -e "s|6:2345:respawn:|#6:2345:respawn:|g" $(MNThdd)/etc/inittab | |
205 | sed -i -e "s|#7:2345:respawn:|7:2345:respawn:|g" $(MNThdd)/etc/inittab | |
206 | ||
207 | umount $(MNThdd)/boot | |
208 | umount $(MNThdd) | |
209 | ||
210 | # zerofree the ext3 images to get better compression | |
211 | ifneq "$(PART_TYPE)" "c" | |
212 | zerofree $(IMGboot) | |
213 | -fsck.ext2 -f -y $(IMGboot) | |
214 | fsck.ext2 -f -y $(IMGboot) | |
215 | endif | |
216 | zerofree $(IMGroot) | |
217 | -fsck.ext4 -f -y $(IMGroot) | |
218 | fsck.ext4 -f -y $(IMGroot) | |
219 | ||
220 | # Cat to an image | |
221 | cat $(IMGpart) $(IMGboot) $(IMGroot) > $(IMGinsts) | |
222 | rm -vf $(IMGpart) $(IMGboot) $(IMGroot) | |
223 | ||
224 | # Write Partition table | |
225 | echo -e "$(S_OFFSET),$(S_BOOT),$(PART_TYPE),*\n,0,0\n$$(( $(S_BOOT) + $(S_OFFSET) )),$(S_ROOT),L\n,0,0\n" \ | |
226 | | sfdisk -D -uS -H 64 -S 32 $(IMGinsts) | |
227 | ||
228 | ifneq "$(MACHINE_TYPE)" "arm" | |
229 | # Install grub | |
230 | echo "device (hd0) $(IMGinsts)" > /tmp/grubinst.tmp | |
231 | echo "root (hd0,0)" >> /tmp/grubinst.tmp | |
232 | echo "setup (hd0)" >> /tmp/grubinst.tmp | |
233 | echo "quit" >> /tmp/grubinst.tmp | |
234 | grub < /tmp/grubinst.tmp | |
235 | rm -f /tmp/grubinst.tmp | |
236 | endif | |
237 | ||
238 | # Compress Image | |
239 | gzip -f9 $(IMGinsts) | |
240 | ||
241 | rm -rf $(MNThdd) $(IMGpart) $(IMGboot) $(IMGroot) |