]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - lfs/flash-images
core78: Add OpenVPN changes.
[people/teissler/ipfire-2.x.git] / lfs / flash-images
CommitLineData
52ca8220
AF
1###############################################################################
2# #
3# IPFire.org - A linux based firewall #
919eb671 4# Copyright (C) 2007-2012 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
25include Config
26
27VER = ipfire
28
29THISAPP = flash-image
30TARGET = $(DIR_INFO)/$(THISAPP)
31
32###############################################################################
33# Top-level Rules
34###############################################################################
35
36install : $(TARGET)
37
38check :
39
40download :
41
42md5 :
43
44###############################################################################
45# Installation Details
46###############################################################################
3e011c27
AF
47IMGinst := /install/images/$(SNAME)-$(VERSION).1gb-ext4.$(MACHINE)-full-core$(CORE).img
48IMGinsts := /install/images/$(SNAME)-$(VERSION).1gb-ext4-scon.$(MACHINE)-full-core$(CORE).img
52ca8220
AF
49MNThdd := /install/harddisk
50IMGpart := /install/images/part_area
51IMGboot := /install/images/bootfs
52ca8220 52IMGroot := /install/images/rootfs
8a5ef45f
SS
53
54# All sizes in blocks
55ifeq "$(MACHINE_TYPE)" "arm"
56 S_OFFSET = 8192
57
58 # FAT32
59 PART_TYPE = c
60else
61 S_OFFSET = 32
62
63 # Logical
64 PART_TYPE = L
65endif
66
67# /boot: 64MB - OFFSET
72cdb517 68# / : 700MB
8a5ef45f 69S_BOOT := $(shell echo $$(( 131072 - $(S_OFFSET) )))
72cdb517 70S_ROOT := 1433600
52ca8220
AF
71
72$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
3e011c27 73 rm -rf $(MNThdd) $(IMGinst) $(IMGpart) $(IMGboot) $(IMGroot) && mkdir -p $(MNThdd)
52ca8220
AF
74
75 # Create first 32 sectors of image
8a5ef45f 76 dd if=/dev/zero of=$(IMGpart) bs=512 count=$(S_OFFSET)
52ca8220
AF
77
78 # Create images for filesystems
8a5ef45f
SS
79 dd if=/dev/zero of=$(IMGboot) bs=512 count=$(S_BOOT)
80 dd if=/dev/zero of=$(IMGroot) bs=512 count=$(S_ROOT)
52ca8220
AF
81
82 # Format them
8a5ef45f 83ifeq "$(PART_TYPE)" "c"
185f92e1
MT
84 mkfs.vfat $(IMGboot)
85else
52ca8220 86 mkfs.ext2 -F $(IMGboot)
185f92e1 87endif
3e011c27 88 mkfs.ext4 -O ^has_journal,extent -F $(IMGroot)
52ca8220 89
e9b5c815
AF
90 # Most systems that use Flashimages has no RTC at boot
91 # so the interval check should disables
92 tune2fs -i0 $(IMGroot)
93
52ca8220
AF
94 # Mount Images
95 mount -o loop $(IMGroot) $(MNThdd)
96 mkdir $(MNThdd)/boot
97 mkdir $(MNThdd)/var
6fafd272 98 mkdir $(MNThdd)/var/log
52ca8220 99 mount -o loop $(IMGboot) $(MNThdd)/boot
52ca8220 100
9831c245
AF
101 # Install MLO and uboot first
102ifeq "$(MACHINE_TYPE)" "arm"
103 cp -v /boot/MLO $(MNThdd)/boot/
7284262a 104 cp -v /boot/u-boot.img $(MNThdd)/boot/
906d293b 105 cp -v /boot/zImage-ipfire-multi $(MNThdd)/boot/
9831c245
AF
106 sync
107 umount $(MNThdd)/boot
108 mount -o loop $(IMGboot) $(MNThdd)/boot
109endif
110
52ca8220 111 # Install IPFire
185f92e1 112 tar -C $(MNThdd)/ -xvaf /install/cdrom/$(SNAME)-$(VERSION).tlz
6fafd272
AF
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
185f92e1 116 -touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep
52ca8220
AF
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"
3cbeb8c7 122 sed -i -e "s|DEVICE1|UUID=$$(blkid -sUUID $(IMGboot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
8a5ef45f 123ifeq "$(PART_TYPE)" "c"
185f92e1
MT
124 # ARM flash images have a VFAT partition for /boot.
125 sed -i -e "s|ext2|vfat|" $(MNThdd)/etc/fstab
126endif
52ca8220 127 sed -i -e "s|DEVICE2|#DEVICE2|g" $(MNThdd)/etc/fstab
3cbeb8c7 128 sed -i -e "s|DEVICE3|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
3e011c27
AF
129 sed -i -e "s|DEVICE4|#DEVICE4|g" $(MNThdd)/etc/fstab
130 sed -i -e "s|FSTYPE|ext4|g" $(MNThdd)/etc/fstab
52ca8220 131
185f92e1
MT
132ifneq "$(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
edc2be70 138 # Copy grub files manually
919eb671 139 cp -f $(MNThdd)/usr/lib/grub/i386-pc/* $(MNThdd)/boot/grub/
edc2be70
AF
140endif
141
a6d0d790
AF
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...
3e011c27 145 ln -sf ../init.d/fsresize $(MNThdd)/etc/rc.d/rcsysinit.d/S42fsresize
a6d0d790 146
52ca8220
AF
147 # Unmount
148 umount $(MNThdd)/proc
149 umount $(MNThdd)/dev
150 umount $(MNThdd)/sys
151 umount $(MNThdd)/boot
52ca8220
AF
152 umount $(MNThdd)
153
a6d0d790 154 # zerofree the ext2 images to get better compression
8a5ef45f 155ifneq "$(PART_TYPE)" "c"
dfc4bc56 156 zerofree $(IMGboot)
a6d0d790
AF
157 -fsck.ext2 -f -y $(IMGboot)
158 fsck.ext2 -f -y $(IMGboot)
185f92e1 159endif
dfc4bc56 160 zerofree $(IMGroot)
3e011c27
AF
161 -fsck.ext4 -f -y $(IMGroot)
162 fsck.ext4 -f -y $(IMGroot)
dfc4bc56 163
52ca8220 164 # Cat to an image
3e011c27 165 cat $(IMGpart) $(IMGboot) $(IMGroot) > $(IMGinst)
9831c245 166
52ca8220 167 # Write Partition table
8a5ef45f
SS
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)
52ca8220 170
185f92e1 171ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
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
185f92e1 179endif
52ca8220
AF
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
185f92e1 189ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
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
185f92e1 193 sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" $(MNThdd)/boot/grub/grub.conf
9007007b
AF
194else
195 sed -i -e "s| console=tty1 | console=ttyAMA0,115200n8 |g" $(MNThdd)/boot/cmdline.txt
7284262a 196 sed -i -e "s| console=tty1 | console=ttyO2,115200n8 |g" $(MNThdd)/boot/boot.script
3e011c27 197 cd $(MNThdd)/boot && ./convert_bootscript
185f92e1 198endif
52ca8220 199
3e962cfa
CS
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
52ca8220
AF
206 sed -i -e "s|#7:2345:respawn:|7:2345:respawn:|g" $(MNThdd)/etc/inittab
207
208 umount $(MNThdd)/boot
209 umount $(MNThdd)
210
dfc4bc56 211 # zerofree the ext3 images to get better compression
8a5ef45f 212ifneq "$(PART_TYPE)" "c"
dfc4bc56 213 zerofree $(IMGboot)
a6d0d790
AF
214 -fsck.ext2 -f -y $(IMGboot)
215 fsck.ext2 -f -y $(IMGboot)
185f92e1 216endif
dfc4bc56 217 zerofree $(IMGroot)
3e011c27
AF
218 -fsck.ext4 -f -y $(IMGroot)
219 fsck.ext4 -f -y $(IMGroot)
dfc4bc56 220
52ca8220 221 # Cat to an image
3e011c27
AF
222 cat $(IMGpart) $(IMGboot) $(IMGroot) > $(IMGinsts)
223 rm -vf $(IMGpart) $(IMGboot) $(IMGroot)
9831c245 224
52ca8220 225 # Write Partition table
8a5ef45f
SS
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)
52ca8220 228
185f92e1 229ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
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
185f92e1 237endif
52ca8220
AF
238
239 # Compress Image
240 gzip -f9 $(IMGinsts)
241
3e011c27 242 rm -rf $(MNThdd) $(IMGpart) $(IMGboot) $(IMGroot)