]>
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 | # / : 700MB | |
69 | S_BOOT := $(shell echo $$(( 131072 - $(S_OFFSET) ))) | |
70 | S_ROOT := 1433600 | |
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 | cp -v /boot/zImage-ipfire-multi $(MNThdd)/boot/ | |
106 | sync | |
107 | umount $(MNThdd)/boot | |
108 | mount -o loop $(IMGboot) $(MNThdd)/boot | |
109 | endif | |
110 | ||
111 | # Install IPFire | |
112 | tar -C $(MNThdd)/ -xvaf /install/cdrom/$(SNAME)-$(VERSION).tlz | |
113 | echo "LANGUAGE=en" >> $(MNThdd)/var/ipfire/main/settings | |
114 | echo "HOSTNAME=$(SNAME)" >> $(MNThdd)/var/ipfire/main/settings | |
115 | echo "THEME=ipfire" >> $(MNThdd)/var/ipfire/main/settings | |
116 | -touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep | |
117 | mkdir $(MNThdd)/proc | |
118 | mount --bind /proc $(MNThdd)/proc | |
119 | mount --bind /dev $(MNThdd)/dev | |
120 | mount --bind /sys $(MNThdd)/sys | |
121 | chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" | |
122 | sed -i -e "s|DEVICE1|UUID=$$(blkid -sUUID $(IMGboot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab | |
123 | ifeq "$(PART_TYPE)" "c" | |
124 | # ARM flash images have a VFAT partition for /boot. | |
125 | sed -i -e "s|ext2|vfat|" $(MNThdd)/etc/fstab | |
126 | endif | |
127 | sed -i -e "s|DEVICE2|#DEVICE2|g" $(MNThdd)/etc/fstab | |
128 | sed -i -e "s|DEVICE3|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab | |
129 | sed -i -e "s|DEVICE4|#DEVICE4|g" $(MNThdd)/etc/fstab | |
130 | sed -i -e "s|FSTYPE|ext4|g" $(MNThdd)/etc/fstab | |
131 | ||
132 | ifneq "$(MACHINE_TYPE)" "arm" | |
133 | sed -i -e "s|MOUNT|ro|g" $(MNThdd)/boot/grub/grub.conf | |
134 | sed -i -e "s|KVER|$(KVER)|g" $(MNThdd)/boot/grub/grub.conf | |
135 | sed -i -e "s|ROOT|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/boot/grub/grub.conf | |
136 | ln -s grub.conf $(MNThdd)/boot/grub/menu.lst | |
137 | ||
138 | # Copy grub files manually | |
139 | cp -f $(MNThdd)/usr/lib/grub/i386-pc/* $(MNThdd)/boot/grub/ | |
140 | endif | |
141 | ||
142 | # Setup symlink for partresize at first boot... | |
143 | ln -sf ../init.d/partresize $(MNThdd)/etc/rc.d/rcsysinit.d/S25partresize | |
144 | # Setup symlink for fsresize at second boot... | |
145 | ln -sf ../init.d/fsresize $(MNThdd)/etc/rc.d/rcsysinit.d/S42fsresize | |
146 | ||
147 | # Unmount | |
148 | umount $(MNThdd)/proc | |
149 | umount $(MNThdd)/dev | |
150 | umount $(MNThdd)/sys | |
151 | umount $(MNThdd)/boot | |
152 | umount $(MNThdd) | |
153 | ||
154 | # zerofree the ext2 images to get better compression | |
155 | ifneq "$(PART_TYPE)" "c" | |
156 | zerofree $(IMGboot) | |
157 | -fsck.ext2 -f -y $(IMGboot) | |
158 | fsck.ext2 -f -y $(IMGboot) | |
159 | endif | |
160 | zerofree $(IMGroot) | |
161 | -fsck.ext4 -f -y $(IMGroot) | |
162 | fsck.ext4 -f -y $(IMGroot) | |
163 | ||
164 | # Cat to an image | |
165 | cat $(IMGpart) $(IMGboot) $(IMGroot) > $(IMGinst) | |
166 | ||
167 | # Write Partition table | |
168 | echo -e "$(S_OFFSET),$(S_BOOT),$(PART_TYPE),*\n,0,0\n$$(( $(S_BOOT) + $(S_OFFSET) )),$(S_ROOT),L\n,0,0\n" \ | |
169 | | sfdisk -D -uS -H 64 -S 32 $(IMGinst) | |
170 | ||
171 | ifneq "$(MACHINE_TYPE)" "arm" | |
172 | # Install grub | |
173 | echo "device (hd0) $(IMGinst)" > /tmp/grubinst.tmp | |
174 | echo "root (hd0,0)" >> /tmp/grubinst.tmp | |
175 | echo "setup (hd0)" >> /tmp/grubinst.tmp | |
176 | echo "quit" >> /tmp/grubinst.tmp | |
177 | grub < /tmp/grubinst.tmp | |
178 | rm -f /tmp/grubinst.tmp | |
179 | endif | |
180 | ||
181 | # Compress Image | |
182 | gzip -f9 $(IMGinst) | |
183 | ||
184 | # Now Build serialcon Version | |
185 | # Mount Images | |
186 | mount -o loop $(IMGroot) $(MNThdd) | |
187 | mount -o loop $(IMGboot) $(MNThdd)/boot | |
188 | ||
189 | ifneq "$(MACHINE_TYPE)" "arm" | |
190 | sed -i -e "s|splashimage|#splashimage|g" $(MNThdd)/boot/grub/grub.conf | |
191 | sed -i -e "s|#serial|serial|g" $(MNThdd)/boot/grub/grub.conf | |
192 | sed -i -e "s|#terminal|terminal|g" $(MNThdd)/boot/grub/grub.conf | |
193 | sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" $(MNThdd)/boot/grub/grub.conf | |
194 | else | |
195 | sed -i -e "s| console=tty1 | console=ttyAMA0,115200n8 |g" $(MNThdd)/boot/cmdline.txt | |
196 | sed -i -e "s| console=tty1 | console=ttyO2,115200n8 |g" $(MNThdd)/boot/boot.script | |
197 | cd $(MNThdd)/boot && ./convert_bootscript | |
198 | endif | |
199 | ||
200 | sed -i -e "s|1:2345:respawn:|#1:2345:respawn:|g" $(MNThdd)/etc/inittab | |
201 | sed -i -e "s|2:2345:respawn:|#2:2345:respawn:|g" $(MNThdd)/etc/inittab | |
202 | sed -i -e "s|3:2345:respawn:|#3:2345:respawn:|g" $(MNThdd)/etc/inittab | |
203 | sed -i -e "s|4:2345:respawn:|#4:2345:respawn:|g" $(MNThdd)/etc/inittab | |
204 | sed -i -e "s|5:2345:respawn:|#5:2345:respawn:|g" $(MNThdd)/etc/inittab | |
205 | sed -i -e "s|6:2345:respawn:|#6:2345:respawn:|g" $(MNThdd)/etc/inittab | |
206 | sed -i -e "s|#7:2345:respawn:|7:2345:respawn:|g" $(MNThdd)/etc/inittab | |
207 | ||
208 | umount $(MNThdd)/boot | |
209 | umount $(MNThdd) | |
210 | ||
211 | # zerofree the ext3 images to get better compression | |
212 | ifneq "$(PART_TYPE)" "c" | |
213 | zerofree $(IMGboot) | |
214 | -fsck.ext2 -f -y $(IMGboot) | |
215 | fsck.ext2 -f -y $(IMGboot) | |
216 | endif | |
217 | zerofree $(IMGroot) | |
218 | -fsck.ext4 -f -y $(IMGroot) | |
219 | fsck.ext4 -f -y $(IMGroot) | |
220 | ||
221 | # Cat to an image | |
222 | cat $(IMGpart) $(IMGboot) $(IMGroot) > $(IMGinsts) | |
223 | rm -vf $(IMGpart) $(IMGboot) $(IMGroot) | |
224 | ||
225 | # Write Partition table | |
226 | echo -e "$(S_OFFSET),$(S_BOOT),$(PART_TYPE),*\n,0,0\n$$(( $(S_BOOT) + $(S_OFFSET) )),$(S_ROOT),L\n,0,0\n" \ | |
227 | | sfdisk -D -uS -H 64 -S 32 $(IMGinsts) | |
228 | ||
229 | ifneq "$(MACHINE_TYPE)" "arm" | |
230 | # Install grub | |
231 | echo "device (hd0) $(IMGinsts)" > /tmp/grubinst.tmp | |
232 | echo "root (hd0,0)" >> /tmp/grubinst.tmp | |
233 | echo "setup (hd0)" >> /tmp/grubinst.tmp | |
234 | echo "quit" >> /tmp/grubinst.tmp | |
235 | grub < /tmp/grubinst.tmp | |
236 | rm -f /tmp/grubinst.tmp | |
237 | endif | |
238 | ||
239 | # Compress Image | |
240 | gzip -f9 $(IMGinsts) | |
241 | ||
242 | rm -rf $(MNThdd) $(IMGpart) $(IMGboot) $(IMGroot) |