]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - lfs/flash-images
Update translations.
[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
68# / : 600MB
69S_BOOT := $(shell echo $$(( 131072 - $(S_OFFSET) )))
70S_ROOT := 1228800
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/
9831c245
AF
105 sync
106 umount $(MNThdd)/boot
107 mount -o loop $(IMGboot) $(MNThdd)/boot
108endif
109
52ca8220 110 # Install IPFire
185f92e1 111 tar -C $(MNThdd)/ -xvaf /install/cdrom/$(SNAME)-$(VERSION).tlz
6fafd272
AF
112 echo "LANGUAGE=en" >> $(MNThdd)/var/ipfire/main/settings
113 echo "HOSTNAME=$(SNAME)" >> $(MNThdd)/var/ipfire/main/settings
114 echo "THEME=ipfire" >> $(MNThdd)/var/ipfire/main/settings
185f92e1 115 -touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep
52ca8220
AF
116 mkdir $(MNThdd)/proc
117 mount --bind /proc $(MNThdd)/proc
118 mount --bind /dev $(MNThdd)/dev
119 mount --bind /sys $(MNThdd)/sys
120 chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
3cbeb8c7 121 sed -i -e "s|DEVICE1|UUID=$$(blkid -sUUID $(IMGboot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
8a5ef45f 122ifeq "$(PART_TYPE)" "c"
185f92e1
MT
123 # ARM flash images have a VFAT partition for /boot.
124 sed -i -e "s|ext2|vfat|" $(MNThdd)/etc/fstab
125endif
52ca8220 126 sed -i -e "s|DEVICE2|#DEVICE2|g" $(MNThdd)/etc/fstab
3cbeb8c7 127 sed -i -e "s|DEVICE3|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
3e011c27
AF
128 sed -i -e "s|DEVICE4|#DEVICE4|g" $(MNThdd)/etc/fstab
129 sed -i -e "s|FSTYPE|ext4|g" $(MNThdd)/etc/fstab
52ca8220 130
185f92e1
MT
131ifneq "$(MACHINE_TYPE)" "arm"
132 sed -i -e "s|MOUNT|ro|g" $(MNThdd)/boot/grub/grub.conf
133 sed -i -e "s|KVER|$(KVER)|g" $(MNThdd)/boot/grub/grub.conf
134 sed -i -e "s|ROOT|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/boot/grub/grub.conf
135 ln -s grub.conf $(MNThdd)/boot/grub/menu.lst
136
edc2be70 137 # Copy grub files manually
919eb671 138 cp -f $(MNThdd)/usr/lib/grub/i386-pc/* $(MNThdd)/boot/grub/
edc2be70
AF
139endif
140
a6d0d790
AF
141 # Setup symlink for partresize at first boot...
142 ln -sf ../init.d/partresize $(MNThdd)/etc/rc.d/rcsysinit.d/S25partresize
143 # Setup symlink for fsresize at second boot...
3e011c27 144 ln -sf ../init.d/fsresize $(MNThdd)/etc/rc.d/rcsysinit.d/S42fsresize
a6d0d790 145
52ca8220
AF
146 # Unmount
147 umount $(MNThdd)/proc
148 umount $(MNThdd)/dev
149 umount $(MNThdd)/sys
150 umount $(MNThdd)/boot
52ca8220
AF
151 umount $(MNThdd)
152
a6d0d790 153 # zerofree the ext2 images to get better compression
8a5ef45f 154ifneq "$(PART_TYPE)" "c"
dfc4bc56 155 zerofree $(IMGboot)
a6d0d790
AF
156 -fsck.ext2 -f -y $(IMGboot)
157 fsck.ext2 -f -y $(IMGboot)
185f92e1 158endif
dfc4bc56 159 zerofree $(IMGroot)
3e011c27
AF
160 -fsck.ext4 -f -y $(IMGroot)
161 fsck.ext4 -f -y $(IMGroot)
dfc4bc56 162
52ca8220 163 # Cat to an image
3e011c27 164 cat $(IMGpart) $(IMGboot) $(IMGroot) > $(IMGinst)
9831c245 165
52ca8220 166 # Write Partition table
8a5ef45f
SS
167 echo -e "$(S_OFFSET),$(S_BOOT),$(PART_TYPE),*\n,0,0\n$$(( $(S_BOOT) + $(S_OFFSET) )),$(S_ROOT),L\n,0,0\n" \
168 | sfdisk -D -uS -H 64 -S 32 $(IMGinst)
52ca8220 169
185f92e1 170ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
171 # Install grub
172 echo "device (hd0) $(IMGinst)" > /tmp/grubinst.tmp
173 echo "root (hd0,0)" >> /tmp/grubinst.tmp
174 echo "setup (hd0)" >> /tmp/grubinst.tmp
175 echo "quit" >> /tmp/grubinst.tmp
176 grub < /tmp/grubinst.tmp
177 rm -f /tmp/grubinst.tmp
185f92e1 178endif
52ca8220
AF
179
180 # Compress Image
181 gzip -f9 $(IMGinst)
182
183 # Now Build serialcon Version
184 # Mount Images
185 mount -o loop $(IMGroot) $(MNThdd)
186 mount -o loop $(IMGboot) $(MNThdd)/boot
187
185f92e1 188ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
189 sed -i -e "s|splashimage|#splashimage|g" $(MNThdd)/boot/grub/grub.conf
190 sed -i -e "s|#serial|serial|g" $(MNThdd)/boot/grub/grub.conf
191 sed -i -e "s|#terminal|terminal|g" $(MNThdd)/boot/grub/grub.conf
185f92e1 192 sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" $(MNThdd)/boot/grub/grub.conf
9007007b
AF
193else
194 sed -i -e "s| console=tty1 | console=ttyAMA0,115200n8 |g" $(MNThdd)/boot/cmdline.txt
7284262a 195 sed -i -e "s| console=tty1 | console=ttyO2,115200n8 |g" $(MNThdd)/boot/boot.script
3e011c27 196 cd $(MNThdd)/boot && ./convert_bootscript
185f92e1 197endif
52ca8220 198
3e962cfa
CS
199 sed -i -e "s|1:2345:respawn:|#1:2345:respawn:|g" $(MNThdd)/etc/inittab
200 sed -i -e "s|2:2345:respawn:|#2:2345:respawn:|g" $(MNThdd)/etc/inittab
201 sed -i -e "s|3:2345:respawn:|#3:2345:respawn:|g" $(MNThdd)/etc/inittab
202 sed -i -e "s|4:2345:respawn:|#4:2345:respawn:|g" $(MNThdd)/etc/inittab
203 sed -i -e "s|5:2345:respawn:|#5:2345:respawn:|g" $(MNThdd)/etc/inittab
204 sed -i -e "s|6:2345:respawn:|#6:2345:respawn:|g" $(MNThdd)/etc/inittab
52ca8220
AF
205 sed -i -e "s|#7:2345:respawn:|7:2345:respawn:|g" $(MNThdd)/etc/inittab
206
207 umount $(MNThdd)/boot
208 umount $(MNThdd)
209
dfc4bc56 210 # zerofree the ext3 images to get better compression
8a5ef45f 211ifneq "$(PART_TYPE)" "c"
dfc4bc56 212 zerofree $(IMGboot)
a6d0d790
AF
213 -fsck.ext2 -f -y $(IMGboot)
214 fsck.ext2 -f -y $(IMGboot)
185f92e1 215endif
dfc4bc56 216 zerofree $(IMGroot)
3e011c27
AF
217 -fsck.ext4 -f -y $(IMGroot)
218 fsck.ext4 -f -y $(IMGroot)
dfc4bc56 219
52ca8220 220 # Cat to an image
3e011c27
AF
221 cat $(IMGpart) $(IMGboot) $(IMGroot) > $(IMGinsts)
222 rm -vf $(IMGpart) $(IMGboot) $(IMGroot)
9831c245 223
52ca8220 224 # Write Partition table
8a5ef45f
SS
225 echo -e "$(S_OFFSET),$(S_BOOT),$(PART_TYPE),*\n,0,0\n$$(( $(S_BOOT) + $(S_OFFSET) )),$(S_ROOT),L\n,0,0\n" \
226 | sfdisk -D -uS -H 64 -S 32 $(IMGinsts)
52ca8220 227
185f92e1 228ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
229 # Install grub
230 echo "device (hd0) $(IMGinsts)" > /tmp/grubinst.tmp
231 echo "root (hd0,0)" >> /tmp/grubinst.tmp
232 echo "setup (hd0)" >> /tmp/grubinst.tmp
233 echo "quit" >> /tmp/grubinst.tmp
234 grub < /tmp/grubinst.tmp
235 rm -f /tmp/grubinst.tmp
185f92e1 236endif
52ca8220
AF
237
238 # Compress Image
239 gzip -f9 $(IMGinsts)
240
3e011c27 241 rm -rf $(MNThdd) $(IMGpart) $(IMGboot) $(IMGroot)