1 ###############################################################################
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2011 IPFire Team <info@ipfire.org> #
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. #
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. #
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/>. #
19 ###############################################################################
21 ###############################################################################
23 ###############################################################################
30 TARGET = $(DIR_INFO)/$(THISAPP)
32 ###############################################################################
34 ###############################################################################
44 ###############################################################################
45 # Installation Details
46 ###############################################################################
47 IMGinst := /install/images/$(SNAME)-$(VERSION).2gb-ext2.$(MACHINE)-full-core$(CORE).img
48 IMGinsts := /install/images/$(SNAME)-$(VERSION).2gb-ext2-scon.$(MACHINE)-full-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
54 IMGroot := /install/images/rootfs
56 IMGvar := /install/images/varfs
59 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
60 rm -rf $(MNThdd) $(IMGinst) $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) && mkdir -p $(MNThdd)
62 # Create first 32 sectors of image
63 dd bs=1k if=/dev/zero of=$(IMGpart) count=16
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)
71 ifeq "$(MACHINE_TYPE)" "arm"
74 mkfs.ext2 -F $(IMGboot)
76 mkfs.ext2 -F $(IMGroot)
77 mkfs.ext2 -F $(IMGvar)
80 mount -o loop $(IMGroot) $(MNThdd)
83 mkdir $(MNThdd)/var/log
84 mount -o loop $(IMGboot) $(MNThdd)/boot
85 mount -o loop $(IMGvar) $(MNThdd)/var
88 tar -C $(MNThdd)/ -xvaf /install/cdrom/$(SNAME)-$(VERSION).tlz
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
92 -touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep
94 mount --bind /proc $(MNThdd)/proc
95 mount --bind /dev $(MNThdd)/dev
96 mount --bind /sys $(MNThdd)/sys
97 chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
98 sed -i -e "s|DEVICE1|UUID=$$(blkid -sUUID $(IMGboot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
99 ifeq "$(MACHINE_TYPE)" "arm"
100 # ARM flash images have a VFAT partition for /boot.
101 sed -i -e "s|ext2|vfat|" $(MNThdd)/etc/fstab
103 sed -i -e "s|DEVICE2|#DEVICE2|g" $(MNThdd)/etc/fstab
104 sed -i -e "s|DEVICE3|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
105 sed -i -e "s|DEVICE4|UUID=$$(blkid -sUUID $(IMGvar) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
106 sed -i -e "s|FSTYPE|ext2|g" $(MNThdd)/etc/fstab
108 ifneq "$(MACHINE_TYPE)" "arm"
109 sed -i -e "s|MOUNT|ro|g" $(MNThdd)/boot/grub/grub.conf
110 sed -i -e "s|KVER|$(KVER)|g" $(MNThdd)/boot/grub/grub.conf
111 sed -i -e "s|ROOT|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/boot/grub/grub.conf
112 ln -s grub.conf $(MNThdd)/boot/grub/menu.lst
114 # Copy grub files manually
115 cp -f $(MNThdd)/usr/share/grub/i386-pc/* $(MNThdd)/boot/grub/
118 # Setup symlink for partresize at first boot...
119 ln -sf ../init.d/partresize $(MNThdd)/etc/rc.d/rcsysinit.d/S25partresize
120 # Setup symlink for fsresize at second boot...
121 ln -sf ../init.d/fsresize $(MNThdd)/etc/rc.d/rcsysinit.d/S26fsresize
124 umount $(MNThdd)/proc
127 umount $(MNThdd)/boot
131 # zerofree the ext2 images to get better compression
132 ifneq "$(MACHINE_TYPE)" "arm"
134 -fsck.ext2 -f -y $(IMGboot)
135 fsck.ext2 -f -y $(IMGboot)
138 -fsck.ext2 -f -y $(IMGroot)
139 fsck.ext2 -f -y $(IMGroot)
141 -fsck.ext2 -f -y $(IMGvar)
142 fsck.ext2 -f -y $(IMGvar)
145 cat $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) > $(IMGinst)
146 # Write Partition table
147 echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \
148 | sfdisk -D -uM -H 64 -S 32 $(IMGinst)
150 ifneq "$(MACHINE_TYPE)" "arm"
152 echo "device (hd0) $(IMGinst)" > /tmp/grubinst.tmp
153 echo "root (hd0,0)" >> /tmp/grubinst.tmp
154 echo "setup (hd0)" >> /tmp/grubinst.tmp
155 echo "quit" >> /tmp/grubinst.tmp
156 grub < /tmp/grubinst.tmp
157 rm -f /tmp/grubinst.tmp
163 # Now Build serialcon Version
165 mount -o loop $(IMGroot) $(MNThdd)
166 mount -o loop $(IMGboot) $(MNThdd)/boot
168 ifneq "$(MACHINE_TYPE)" "arm"
169 sed -i -e "s|splashimage|#splashimage|g" $(MNThdd)/boot/grub/grub.conf
170 sed -i -e "s|#serial|serial|g" $(MNThdd)/boot/grub/grub.conf
171 sed -i -e "s|#terminal|terminal|g" $(MNThdd)/boot/grub/grub.conf
172 sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" $(MNThdd)/boot/grub/grub.conf
175 sed -i -e "s|1:2345:respawn:|#1:2345:respawn:|g" $(MNThdd)/etc/inittab
176 sed -i -e "s|2:2345:respawn:|#2:2345:respawn:|g" $(MNThdd)/etc/inittab
177 sed -i -e "s|3:2345:respawn:|#3:2345:respawn:|g" $(MNThdd)/etc/inittab
178 sed -i -e "s|4:2345:respawn:|#4:2345:respawn:|g" $(MNThdd)/etc/inittab
179 sed -i -e "s|5:2345:respawn:|#5:2345:respawn:|g" $(MNThdd)/etc/inittab
180 sed -i -e "s|6:2345:respawn:|#6:2345:respawn:|g" $(MNThdd)/etc/inittab
181 sed -i -e "s|#7:2345:respawn:|7:2345:respawn:|g" $(MNThdd)/etc/inittab
183 umount $(MNThdd)/boot
186 # zerofree the ext3 images to get better compression
187 ifneq "$(MACHINE_TYPE)" "arm"
189 -fsck.ext2 -f -y $(IMGboot)
190 fsck.ext2 -f -y $(IMGboot)
193 -fsck.ext2 -f -y $(IMGroot)
194 fsck.ext2 -f -y $(IMGroot)
196 -fsck.ext2 -f -y $(IMGvar)
197 fsck.ext2 -f -y $(IMGvar)
200 cat $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) > $(IMGinsts)
201 rm -vf $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar)
202 # Write Partition table
203 echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \
204 | sfdisk -D -uM -H 64 -S 32 $(IMGinsts)
206 ifneq "$(MACHINE_TYPE)" "arm"
208 echo "device (hd0) $(IMGinsts)" > /tmp/grubinst.tmp
209 echo "root (hd0,0)" >> /tmp/grubinst.tmp
210 echo "setup (hd0)" >> /tmp/grubinst.tmp
211 echo "quit" >> /tmp/grubinst.tmp
212 grub < /tmp/grubinst.tmp
213 rm -f /tmp/grubinst.tmp
219 rm -rf $(MNThdd) $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar)