]>
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 | ############################################################################### | |
47 | IMGinst := /install/images/$(SNAME)-$(VERSION).1gb-ext2.$(MACHINE)-$(ED)-core$(CORE).img | |
48 | IMGinsts := /install/images/$(SNAME)-$(VERSION).1gb-ext2-scon.$(MACHINE)-$(ED)-core$(CORE).img | |
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 | |
57 | SIZEvar := 450 | |
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 | |
71 | mkfs.ext2 -F $(IMGboot) | |
72 | mkfs.ext2 -F $(IMGroot) | |
73 | mkfs.ext2 -F $(IMGvar) | |
74 | ||
75 | # Mount Images | |
76 | mount -o loop $(IMGroot) $(MNThdd) | |
77 | mkdir $(MNThdd)/boot | |
78 | mkdir $(MNThdd)/var | |
79 | mount -o loop $(IMGboot) $(MNThdd)/boot | |
80 | mount -o loop $(IMGvar) $(MNThdd)/var | |
81 | ||
82 | # Install IPFire | |
83 | tar -C $(MNThdd)/ -xvjf /install/cdrom/$(SNAME)-$(VERSION).tbz2 | |
84 | touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep | |
85 | mv $(MNThdd)/bin/uname.bak $(MNThdd)/bin/uname | |
86 | mkdir $(MNThdd)/proc | |
87 | mount --bind /proc $(MNThdd)/proc | |
88 | mount --bind /dev $(MNThdd)/dev | |
89 | mount --bind /sys $(MNThdd)/sys | |
90 | chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" | |
91 | sed -i -e "s|MOUNT|ro|g" $(MNThdd)/boot/grub/grub.conf | |
92 | sed -i -e "s|KVER|$(KVER)|g" $(MNThdd)/boot/grub/grub.conf | |
93 | sed -i -e "s|ROOT|/dev/sda3|g" $(MNThdd)/boot/grub/grub.conf | |
94 | ln -s grub.conf $(MNThdd)/boot/grub/menu.lst | |
95 | sed -i -e "s|DEVICE2|#DEVICE2|g" $(MNThdd)/etc/fstab | |
96 | sed -i -e "s|DEVICE|/dev/sda|g" $(MNThdd)/etc/fstab | |
97 | sed -i -e "s|FSTYPE|ext2|g" $(MNThdd)/etc/fstab | |
98 | cp -f $(MNThdd)/etc/mkinitcpio.conf $(MNThdd)/etc/mkinitcpio.conf.org | |
99 | sed -i -e "s| autodetect | |g" $(MNThdd)/etc/mkinitcpio.conf | |
100 | chroot $(MNThdd) /sbin/mkinitcpio -g /boot/ipfirerd-$(KVER)-emergency.img -k $(KVER)-ipfire | |
101 | cp -f $(MNThdd)/etc/mkinitcpio.conf.org $(MNThdd)/etc/mkinitcpio.conf | |
102 | ln -s ipfirerd-$(KVER)-emergency.img $(MNThdd)/boot/ipfirerd-$(KVER).img | |
103 | ||
104 | # Copy grub files manually | |
105 | cp -f $(MNThdd)/usr/lib/grub/i386-pc/* $(MNThdd)/boot/grub/ | |
106 | chroot $(MNThdd) /usr/sbin/grub-set-default 0 | |
107 | ||
108 | # Create a script for rebuild-initrd and setup | |
109 | echo "#!/bin/bash" > $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup | |
110 | echo "/bin/rm -f /boot/ipfirerd-$(KVER).img" >> $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup | |
111 | echo "/usr/local/bin/rebuild-initrd" >> $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup | |
112 | echo "/usr/local/sbin/setup /dev/null INSTALL" >> $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup | |
113 | echo "rm -f /etc/rc.d/rcsysinit.d/S75firstsetup" >> $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup | |
114 | chmod +x $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup | |
115 | ||
116 | # Unmount | |
117 | umount $(MNThdd)/proc | |
118 | umount $(MNThdd)/dev | |
119 | umount $(MNThdd)/sys | |
120 | umount $(MNThdd)/boot | |
121 | umount $(MNThdd)/var | |
122 | umount $(MNThdd) | |
123 | ||
124 | # Cat to an image | |
125 | cat $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) > $(IMGinst) | |
126 | # Write Partition table | |
127 | echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \ | |
128 | | sfdisk -D -uM -H 64 -S 32 $(IMGinst) | |
129 | ||
130 | # Install grub | |
131 | echo "device (hd0) $(IMGinst)" > /tmp/grubinst.tmp | |
132 | echo "root (hd0,0)" >> /tmp/grubinst.tmp | |
133 | echo "setup (hd0)" >> /tmp/grubinst.tmp | |
134 | echo "quit" >> /tmp/grubinst.tmp | |
135 | grub < /tmp/grubinst.tmp | |
136 | rm -f /tmp/grubinst.tmp | |
137 | ||
138 | # Compress Image | |
139 | gzip -f9 $(IMGinst) | |
140 | ||
141 | # Now Build serialcon Version | |
142 | # Mount Images | |
143 | mount -o loop $(IMGroot) $(MNThdd) | |
144 | mount -o loop $(IMGboot) $(MNThdd)/boot | |
145 | ||
146 | sed -i -e "s|splashimage|#splashimage|g" $(MNThdd)/boot/grub/grub.conf | |
147 | sed -i -e "s|#serial|serial|g" $(MNThdd)/boot/grub/grub.conf | |
148 | sed -i -e "s|#terminal|terminal|g" $(MNThdd)/boot/grub/grub.conf | |
149 | sed -i -e "s| panic=10 | console=ttyS0,38400n8 panic=10 |g" $(MNThdd)/boot/grub/grub.conf | |
150 | ||
151 | sed -i -e "s|#7:2345:respawn:|7:2345:respawn:|g" $(MNThdd)/etc/inittab | |
152 | ||
153 | umount $(MNThdd)/boot | |
154 | umount $(MNThdd) | |
155 | ||
156 | # Cat to an image | |
157 | cat $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) > $(IMGinsts) | |
158 | rm -vf $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) | |
159 | # Write Partition table | |
160 | echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \ | |
161 | | sfdisk -D -uM -H 64 -S 32 $(IMGinsts) | |
162 | ||
163 | # Install grub | |
164 | echo "device (hd0) $(IMGinsts)" > /tmp/grubinst.tmp | |
165 | echo "root (hd0,0)" >> /tmp/grubinst.tmp | |
166 | echo "setup (hd0)" >> /tmp/grubinst.tmp | |
167 | echo "quit" >> /tmp/grubinst.tmp | |
168 | grub < /tmp/grubinst.tmp | |
169 | rm -f /tmp/grubinst.tmp | |
170 | ||
171 | # Compress Image | |
172 | gzip -f9 $(IMGinsts) | |
173 | ||
174 | rm -rf $(MNThdd) $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) |