kernel: add kernel for Raspberry Pi.
[ipfire-2.x.git] / lfs / flash-images
CommitLineData
52ca8220
AF
1###############################################################################
2# #
3# IPFire.org - A linux based firewall #
920b610f 4# Copyright (C) 2007-2011 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###############################################################################
76b82775
AF
47IMGinst := /install/images/$(SNAME)-$(VERSION).2gb-ext2.$(MACHINE)-full-core$(CORE).img
48IMGinsts := /install/images/$(SNAME)-$(VERSION).2gb-ext2-scon.$(MACHINE)-full-core$(CORE).img
52ca8220
AF
49MNThdd := /install/harddisk
50IMGpart := /install/images/part_area
51IMGboot := /install/images/bootfs
52# don't change SIZEboot this without checking Image size
9831c245 53SIZEboot := 50
52ca8220 54IMGroot := /install/images/rootfs
76b82775 55SIZEroot := 1400
52ca8220 56IMGvar := /install/images/varfs
9831c245 57SIZEvar := 400
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
9831c245 66 dd bs=1K if=/dev/zero of=$(IMGboot) count=51184 # 50MB-16K
52ca8220
AF
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
71ifeq "$(MACHINE_TYPE)" "arm"
72 mkfs.vfat $(IMGboot)
73else
52ca8220 74 mkfs.ext2 -F $(IMGboot)
185f92e1 75endif
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
9831c245
AF
87 # Install MLO and uboot first
88ifeq "$(MACHINE_TYPE)" "arm"
89 cp -v /boot/MLO $(MNThdd)/boot/
90 cp -v /boot/u-boot.bin $(MNThdd)/boot/
91 sync
92 umount $(MNThdd)/boot
93 mount -o loop $(IMGboot) $(MNThdd)/boot
94endif
95
52ca8220 96 # Install IPFire
185f92e1 97 tar -C $(MNThdd)/ -xvaf /install/cdrom/$(SNAME)-$(VERSION).tlz
6fafd272
AF
98 echo "LANGUAGE=en" >> $(MNThdd)/var/ipfire/main/settings
99 echo "HOSTNAME=$(SNAME)" >> $(MNThdd)/var/ipfire/main/settings
100 echo "THEME=ipfire" >> $(MNThdd)/var/ipfire/main/settings
185f92e1 101 -touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep
52ca8220
AF
102 mkdir $(MNThdd)/proc
103 mount --bind /proc $(MNThdd)/proc
104 mount --bind /dev $(MNThdd)/dev
105 mount --bind /sys $(MNThdd)/sys
106 chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
3cbeb8c7 107 sed -i -e "s|DEVICE1|UUID=$$(blkid -sUUID $(IMGboot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
185f92e1
MT
108ifeq "$(MACHINE_TYPE)" "arm"
109 # ARM flash images have a VFAT partition for /boot.
110 sed -i -e "s|ext2|vfat|" $(MNThdd)/etc/fstab
111endif
52ca8220 112 sed -i -e "s|DEVICE2|#DEVICE2|g" $(MNThdd)/etc/fstab
3cbeb8c7
AF
113 sed -i -e "s|DEVICE3|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
114 sed -i -e "s|DEVICE4|UUID=$$(blkid -sUUID $(IMGvar) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
52ca8220 115 sed -i -e "s|FSTYPE|ext2|g" $(MNThdd)/etc/fstab
52ca8220 116
185f92e1
MT
117ifneq "$(MACHINE_TYPE)" "arm"
118 sed -i -e "s|MOUNT|ro|g" $(MNThdd)/boot/grub/grub.conf
119 sed -i -e "s|KVER|$(KVER)|g" $(MNThdd)/boot/grub/grub.conf
120 sed -i -e "s|ROOT|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/boot/grub/grub.conf
121 ln -s grub.conf $(MNThdd)/boot/grub/menu.lst
122
edc2be70
AF
123 # Copy grub files manually
124 cp -f $(MNThdd)/usr/share/grub/i386-pc/* $(MNThdd)/boot/grub/
125endif
126
a6d0d790
AF
127 # Setup symlink for partresize at first boot...
128 ln -sf ../init.d/partresize $(MNThdd)/etc/rc.d/rcsysinit.d/S25partresize
129 # Setup symlink for fsresize at second boot...
130 ln -sf ../init.d/fsresize $(MNThdd)/etc/rc.d/rcsysinit.d/S26fsresize
131
52ca8220
AF
132 # Unmount
133 umount $(MNThdd)/proc
134 umount $(MNThdd)/dev
135 umount $(MNThdd)/sys
136 umount $(MNThdd)/boot
137 umount $(MNThdd)/var
138 umount $(MNThdd)
139
a6d0d790 140 # zerofree the ext2 images to get better compression
185f92e1 141ifneq "$(MACHINE_TYPE)" "arm"
dfc4bc56 142 zerofree $(IMGboot)
a6d0d790
AF
143 -fsck.ext2 -f -y $(IMGboot)
144 fsck.ext2 -f -y $(IMGboot)
185f92e1 145endif
dfc4bc56 146 zerofree $(IMGroot)
a6d0d790
AF
147 -fsck.ext2 -f -y $(IMGroot)
148 fsck.ext2 -f -y $(IMGroot)
dfc4bc56 149 zerofree $(IMGvar)
a6d0d790
AF
150 -fsck.ext2 -f -y $(IMGvar)
151 fsck.ext2 -f -y $(IMGvar)
dfc4bc56 152
52ca8220
AF
153 # Cat to an image
154 cat $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) > $(IMGinst)
9831c245 155
52ca8220 156 # Write Partition table
9831c245 157ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
158 echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \
159 | sfdisk -D -uM -H 64 -S 32 $(IMGinst)
9831c245
AF
160else
161 echo -e ",$(SIZEboot),c,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \
162 | sfdisk -D -uM -H 64 -S 32 $(IMGinst)
163endif
52ca8220 164
185f92e1 165ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
166 # Install grub
167 echo "device (hd0) $(IMGinst)" > /tmp/grubinst.tmp
168 echo "root (hd0,0)" >> /tmp/grubinst.tmp
169 echo "setup (hd0)" >> /tmp/grubinst.tmp
170 echo "quit" >> /tmp/grubinst.tmp
171 grub < /tmp/grubinst.tmp
172 rm -f /tmp/grubinst.tmp
185f92e1 173endif
52ca8220
AF
174
175 # Compress Image
176 gzip -f9 $(IMGinst)
177
178 # Now Build serialcon Version
179 # Mount Images
180 mount -o loop $(IMGroot) $(MNThdd)
181 mount -o loop $(IMGboot) $(MNThdd)/boot
182
185f92e1 183ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
184 sed -i -e "s|splashimage|#splashimage|g" $(MNThdd)/boot/grub/grub.conf
185 sed -i -e "s|#serial|serial|g" $(MNThdd)/boot/grub/grub.conf
186 sed -i -e "s|#terminal|terminal|g" $(MNThdd)/boot/grub/grub.conf
185f92e1 187 sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" $(MNThdd)/boot/grub/grub.conf
9007007b
AF
188else
189 sed -i -e "s| console=tty1 | console=ttyAMA0,115200n8 |g" $(MNThdd)/boot/cmdline.txt
185f92e1 190endif
52ca8220 191
3e962cfa
CS
192 sed -i -e "s|1:2345:respawn:|#1:2345:respawn:|g" $(MNThdd)/etc/inittab
193 sed -i -e "s|2:2345:respawn:|#2:2345:respawn:|g" $(MNThdd)/etc/inittab
194 sed -i -e "s|3:2345:respawn:|#3:2345:respawn:|g" $(MNThdd)/etc/inittab
195 sed -i -e "s|4:2345:respawn:|#4:2345:respawn:|g" $(MNThdd)/etc/inittab
196 sed -i -e "s|5:2345:respawn:|#5:2345:respawn:|g" $(MNThdd)/etc/inittab
197 sed -i -e "s|6:2345:respawn:|#6:2345:respawn:|g" $(MNThdd)/etc/inittab
52ca8220
AF
198 sed -i -e "s|#7:2345:respawn:|7:2345:respawn:|g" $(MNThdd)/etc/inittab
199
200 umount $(MNThdd)/boot
201 umount $(MNThdd)
202
dfc4bc56 203 # zerofree the ext3 images to get better compression
185f92e1 204ifneq "$(MACHINE_TYPE)" "arm"
dfc4bc56 205 zerofree $(IMGboot)
a6d0d790
AF
206 -fsck.ext2 -f -y $(IMGboot)
207 fsck.ext2 -f -y $(IMGboot)
185f92e1 208endif
dfc4bc56 209 zerofree $(IMGroot)
a6d0d790
AF
210 -fsck.ext2 -f -y $(IMGroot)
211 fsck.ext2 -f -y $(IMGroot)
dfc4bc56 212 zerofree $(IMGvar)
a6d0d790
AF
213 -fsck.ext2 -f -y $(IMGvar)
214 fsck.ext2 -f -y $(IMGvar)
dfc4bc56 215
52ca8220
AF
216 # Cat to an image
217 cat $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) > $(IMGinsts)
218 rm -vf $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar)
9831c245 219
52ca8220 220 # Write Partition table
9831c245 221ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
222 echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \
223 | sfdisk -D -uM -H 64 -S 32 $(IMGinsts)
9831c245
AF
224else
225 echo -e ",$(SIZEboot),c,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \
226 | sfdisk -D -uM -H 64 -S 32 $(IMGinsts)
227endif
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
242 rm -rf $(MNThdd) $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar)