]>
Commit | Line | Data |
---|---|---|
52ca8220 AF |
1 | ############################################################################### |
2 | # # | |
3 | # IPFire.org - A linux based firewall # | |
4 | # Copyright (C) 2007 Michael Tremer & Christian Schmidt # | |
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 | ############################################################################### | |
3c937429 MT |
47 | IMGinst := /install/images/$(SNAME)-$(VERSION).1gb-ext2.$(MACHINE)-full-core$(CORE).img |
48 | IMGinsts := /install/images/$(SNAME)-$(VERSION).1gb-ext2-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 | |
53 | SIZEboot := 20 | |
54 | IMGroot := /install/images/rootfs | |
55 | SIZEroot := 500 | |
56 | IMGvar := /install/images/varfs | |
cd0cfb61 | 57 | SIZEvar := 430 |
52ca8220 AF |
58 | |
59 | $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) | |
60 | rm -rf $(MNThdd) $(IMGinst) $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) && mkdir -p $(MNThdd) | |
61 | ||
62 | # Create first 32 sectors of image | |
63 | dd bs=1k if=/dev/zero of=$(IMGpart) count=16 | |
64 | ||
65 | # Create images for filesystems | |
66 | dd bs=1K if=/dev/zero of=$(IMGboot) count=20464 # 20MB-16K | |
67 | dd bs=1M if=/dev/zero of=$(IMGroot) count=$(SIZEroot) | |
68 | dd bs=1M if=/dev/zero of=$(IMGvar) count=$(SIZEvar) | |
69 | ||
70 | # Format them | |
185f92e1 MT |
71 | ifeq "$(MACHINE_TYPE)" "arm" |
72 | mkfs.vfat $(IMGboot) | |
73 | else | |
52ca8220 | 74 | mkfs.ext2 -F $(IMGboot) |
185f92e1 | 75 | endif |
52ca8220 AF |
76 | mkfs.ext2 -F $(IMGroot) |
77 | mkfs.ext2 -F $(IMGvar) | |
78 | ||
79 | # Mount Images | |
80 | mount -o loop $(IMGroot) $(MNThdd) | |
81 | mkdir $(MNThdd)/boot | |
82 | mkdir $(MNThdd)/var | |
6fafd272 | 83 | mkdir $(MNThdd)/var/log |
52ca8220 AF |
84 | mount -o loop $(IMGboot) $(MNThdd)/boot |
85 | mount -o loop $(IMGvar) $(MNThdd)/var | |
86 | ||
87 | # Install IPFire | |
185f92e1 | 88 | tar -C $(MNThdd)/ -xvaf /install/cdrom/$(SNAME)-$(VERSION).tlz |
6fafd272 AF |
89 | echo "LANGUAGE=en" >> $(MNThdd)/var/ipfire/main/settings |
90 | echo "HOSTNAME=$(SNAME)" >> $(MNThdd)/var/ipfire/main/settings | |
91 | echo "THEME=ipfire" >> $(MNThdd)/var/ipfire/main/settings | |
185f92e1 | 92 | -touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep |
52ca8220 AF |
93 | mv $(MNThdd)/bin/uname.bak $(MNThdd)/bin/uname |
94 | mkdir $(MNThdd)/proc | |
95 | mount --bind /proc $(MNThdd)/proc | |
96 | mount --bind /dev $(MNThdd)/dev | |
97 | mount --bind /sys $(MNThdd)/sys | |
98 | chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" | |
3cbeb8c7 | 99 | sed -i -e "s|DEVICE1|UUID=$$(blkid -sUUID $(IMGboot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab |
185f92e1 MT |
100 | ifeq "$(MACHINE_TYPE)" "arm" |
101 | # ARM flash images have a VFAT partition for /boot. | |
102 | sed -i -e "s|ext2|vfat|" $(MNThdd)/etc/fstab | |
103 | endif | |
52ca8220 | 104 | sed -i -e "s|DEVICE2|#DEVICE2|g" $(MNThdd)/etc/fstab |
3cbeb8c7 AF |
105 | sed -i -e "s|DEVICE3|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab |
106 | sed -i -e "s|DEVICE4|UUID=$$(blkid -sUUID $(IMGvar) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab | |
52ca8220 | 107 | sed -i -e "s|FSTYPE|ext2|g" $(MNThdd)/etc/fstab |
52ca8220 | 108 | |
185f92e1 MT |
109 | ifneq "$(MACHINE_TYPE)" "arm" |
110 | sed -i -e "s|MOUNT|ro|g" $(MNThdd)/boot/grub/grub.conf | |
111 | sed -i -e "s|KVER|$(KVER)|g" $(MNThdd)/boot/grub/grub.conf | |
112 | sed -i -e "s|ROOT|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/boot/grub/grub.conf | |
113 | ln -s grub.conf $(MNThdd)/boot/grub/menu.lst | |
114 | ||
52ca8220 | 115 | # Copy grub files manually |
05ffd50f | 116 | cp -f $(MNThdd)/usr/share/grub/i386-pc/* $(MNThdd)/boot/grub/ |
185f92e1 | 117 | endif |
6fafd272 | 118 | |
52ca8220 AF |
119 | # Unmount |
120 | umount $(MNThdd)/proc | |
121 | umount $(MNThdd)/dev | |
122 | umount $(MNThdd)/sys | |
123 | umount $(MNThdd)/boot | |
124 | umount $(MNThdd)/var | |
125 | umount $(MNThdd) | |
126 | ||
dfc4bc56 | 127 | # zerofree the ext3 images to get better compression |
185f92e1 | 128 | ifneq "$(MACHINE_TYPE)" "arm" |
dfc4bc56 | 129 | zerofree $(IMGboot) |
185f92e1 | 130 | endif |
dfc4bc56 AF |
131 | zerofree $(IMGroot) |
132 | zerofree $(IMGvar) | |
133 | ||
52ca8220 AF |
134 | # Cat to an image |
135 | cat $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) > $(IMGinst) | |
136 | # Write Partition table | |
137 | echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \ | |
138 | | sfdisk -D -uM -H 64 -S 32 $(IMGinst) | |
139 | ||
185f92e1 | 140 | ifneq "$(MACHINE_TYPE)" "arm" |
52ca8220 AF |
141 | # Install grub |
142 | echo "device (hd0) $(IMGinst)" > /tmp/grubinst.tmp | |
143 | echo "root (hd0,0)" >> /tmp/grubinst.tmp | |
144 | echo "setup (hd0)" >> /tmp/grubinst.tmp | |
145 | echo "quit" >> /tmp/grubinst.tmp | |
146 | grub < /tmp/grubinst.tmp | |
147 | rm -f /tmp/grubinst.tmp | |
185f92e1 | 148 | endif |
52ca8220 AF |
149 | |
150 | # Compress Image | |
151 | gzip -f9 $(IMGinst) | |
152 | ||
153 | # Now Build serialcon Version | |
154 | # Mount Images | |
155 | mount -o loop $(IMGroot) $(MNThdd) | |
156 | mount -o loop $(IMGboot) $(MNThdd)/boot | |
157 | ||
185f92e1 | 158 | ifneq "$(MACHINE_TYPE)" "arm" |
52ca8220 AF |
159 | sed -i -e "s|splashimage|#splashimage|g" $(MNThdd)/boot/grub/grub.conf |
160 | sed -i -e "s|#serial|serial|g" $(MNThdd)/boot/grub/grub.conf | |
161 | sed -i -e "s|#terminal|terminal|g" $(MNThdd)/boot/grub/grub.conf | |
185f92e1 MT |
162 | sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" $(MNThdd)/boot/grub/grub.conf |
163 | endif | |
52ca8220 | 164 | |
3e962cfa CS |
165 | sed -i -e "s|1:2345:respawn:|#1:2345:respawn:|g" $(MNThdd)/etc/inittab |
166 | sed -i -e "s|2:2345:respawn:|#2:2345:respawn:|g" $(MNThdd)/etc/inittab | |
167 | sed -i -e "s|3:2345:respawn:|#3:2345:respawn:|g" $(MNThdd)/etc/inittab | |
168 | sed -i -e "s|4:2345:respawn:|#4:2345:respawn:|g" $(MNThdd)/etc/inittab | |
169 | sed -i -e "s|5:2345:respawn:|#5:2345:respawn:|g" $(MNThdd)/etc/inittab | |
170 | sed -i -e "s|6:2345:respawn:|#6:2345:respawn:|g" $(MNThdd)/etc/inittab | |
52ca8220 AF |
171 | sed -i -e "s|#7:2345:respawn:|7:2345:respawn:|g" $(MNThdd)/etc/inittab |
172 | ||
173 | umount $(MNThdd)/boot | |
174 | umount $(MNThdd) | |
175 | ||
dfc4bc56 | 176 | # zerofree the ext3 images to get better compression |
185f92e1 | 177 | ifneq "$(MACHINE_TYPE)" "arm" |
dfc4bc56 | 178 | zerofree $(IMGboot) |
185f92e1 | 179 | endif |
dfc4bc56 AF |
180 | zerofree $(IMGroot) |
181 | zerofree $(IMGvar) | |
182 | ||
52ca8220 AF |
183 | # Cat to an image |
184 | cat $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) > $(IMGinsts) | |
185 | rm -vf $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) | |
186 | # Write Partition table | |
187 | echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \ | |
188 | | sfdisk -D -uM -H 64 -S 32 $(IMGinsts) | |
189 | ||
185f92e1 | 190 | ifneq "$(MACHINE_TYPE)" "arm" |
52ca8220 AF |
191 | # Install grub |
192 | echo "device (hd0) $(IMGinsts)" > /tmp/grubinst.tmp | |
193 | echo "root (hd0,0)" >> /tmp/grubinst.tmp | |
194 | echo "setup (hd0)" >> /tmp/grubinst.tmp | |
195 | echo "quit" >> /tmp/grubinst.tmp | |
196 | grub < /tmp/grubinst.tmp | |
197 | rm -f /tmp/grubinst.tmp | |
185f92e1 | 198 | endif |
52ca8220 AF |
199 | |
200 | # Compress Image | |
201 | gzip -f9 $(IMGinsts) | |
202 | ||
203 | rm -rf $(MNThdd) $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) | |
3e962cfa | 204 |