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