flashimages: is dracut to create initrd.
[people/pmueller/ipfire-2.x.git] / lfs / flash-images
CommitLineData
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
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###############################################################################
47IMGinst := /install/images/$(SNAME)-$(VERSION).1gb-ext2.$(MACHINE)-$(ED)-core$(CORE).img
48IMGinsts := /install/images/$(SNAME)-$(VERSION).1gb-ext2-scon.$(MACHINE)-$(ED)-core$(CORE).img
49MNThdd := /install/harddisk
50IMGpart := /install/images/part_area
51IMGboot := /install/images/bootfs
52# don't change SIZEboot this without checking Image size
53SIZEboot := 20
54IMGroot := /install/images/rootfs
55SIZEroot := 500
56IMGvar := /install/images/varfs
cd0cfb61 57SIZEvar := 430
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
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
6fafd272 79 mkdir $(MNThdd)/var/log
52ca8220
AF
80 mount -o loop $(IMGboot) $(MNThdd)/boot
81 mount -o loop $(IMGvar) $(MNThdd)/var
82
83 # Install IPFire
dbf157bb 84 tar -C $(MNThdd)/ -xvf /install/cdrom/$(SNAME)-$(VERSION).tlz --lzma
6fafd272
AF
85 echo "LANGUAGE=en" >> $(MNThdd)/var/ipfire/main/settings
86 echo "HOSTNAME=$(SNAME)" >> $(MNThdd)/var/ipfire/main/settings
87 echo "THEME=ipfire" >> $(MNThdd)/var/ipfire/main/settings
52ca8220
AF
88 touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep
89 mv $(MNThdd)/bin/uname.bak $(MNThdd)/bin/uname
90 mkdir $(MNThdd)/proc
91 mount --bind /proc $(MNThdd)/proc
92 mount --bind /dev $(MNThdd)/dev
93 mount --bind /sys $(MNThdd)/sys
94 chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
95 sed -i -e "s|MOUNT|ro|g" $(MNThdd)/boot/grub/grub.conf
96 sed -i -e "s|KVER|$(KVER)|g" $(MNThdd)/boot/grub/grub.conf
97 sed -i -e "s|ROOT|/dev/sda3|g" $(MNThdd)/boot/grub/grub.conf
98 ln -s grub.conf $(MNThdd)/boot/grub/menu.lst
99 sed -i -e "s|DEVICE2|#DEVICE2|g" $(MNThdd)/etc/fstab
100 sed -i -e "s|DEVICE|/dev/sda|g" $(MNThdd)/etc/fstab
101 sed -i -e "s|FSTYPE|ext2|g" $(MNThdd)/etc/fstab
dafc8fbe 102 chroot $(MNThdd) /usr/local/bin/rebuild-initrd
52ca8220
AF
103
104 # Copy grub files manually
05ffd50f
AF
105 cp -f $(MNThdd)/usr/share/grub/i386-pc/* $(MNThdd)/boot/grub/
106 #chroot $(MNThdd) /usr/sbin/grub-set-default 0
52ca8220
AF
107
108 # Create a script for rebuild-initrd and setup
6fafd272
AF
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 echo "&& /sbin/reboot" >> $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
115
52ca8220 116 chmod +x $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
6fafd272 117
52ca8220
AF
118 # Unmount
119 umount $(MNThdd)/proc
120 umount $(MNThdd)/dev
121 umount $(MNThdd)/sys
122 umount $(MNThdd)/boot
123 umount $(MNThdd)/var
124 umount $(MNThdd)
125
dfc4bc56
AF
126 # zerofree the ext3 images to get better compression
127 zerofree $(IMGboot)
128 zerofree $(IMGroot)
129 zerofree $(IMGvar)
130
52ca8220
AF
131 # Cat to an image
132 cat $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) > $(IMGinst)
133 # Write Partition table
134 echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \
135 | sfdisk -D -uM -H 64 -S 32 $(IMGinst)
136
137 # Install grub
138 echo "device (hd0) $(IMGinst)" > /tmp/grubinst.tmp
139 echo "root (hd0,0)" >> /tmp/grubinst.tmp
140 echo "setup (hd0)" >> /tmp/grubinst.tmp
141 echo "quit" >> /tmp/grubinst.tmp
142 grub < /tmp/grubinst.tmp
143 rm -f /tmp/grubinst.tmp
144
145 # Compress Image
146 gzip -f9 $(IMGinst)
147
148 # Now Build serialcon Version
149 # Mount Images
150 mount -o loop $(IMGroot) $(MNThdd)
151 mount -o loop $(IMGboot) $(MNThdd)/boot
152
153 sed -i -e "s|splashimage|#splashimage|g" $(MNThdd)/boot/grub/grub.conf
154 sed -i -e "s|#serial|serial|g" $(MNThdd)/boot/grub/grub.conf
155 sed -i -e "s|#terminal|terminal|g" $(MNThdd)/boot/grub/grub.conf
156 sed -i -e "s| panic=10 | console=ttyS0,38400n8 panic=10 |g" $(MNThdd)/boot/grub/grub.conf
157
3e962cfa
CS
158 sed -i -e "s|1:2345:respawn:|#1:2345:respawn:|g" $(MNThdd)/etc/inittab
159 sed -i -e "s|2:2345:respawn:|#2:2345:respawn:|g" $(MNThdd)/etc/inittab
160 sed -i -e "s|3:2345:respawn:|#3:2345:respawn:|g" $(MNThdd)/etc/inittab
161 sed -i -e "s|4:2345:respawn:|#4:2345:respawn:|g" $(MNThdd)/etc/inittab
162 sed -i -e "s|5:2345:respawn:|#5:2345:respawn:|g" $(MNThdd)/etc/inittab
163 sed -i -e "s|6:2345:respawn:|#6:2345:respawn:|g" $(MNThdd)/etc/inittab
52ca8220
AF
164 sed -i -e "s|#7:2345:respawn:|7:2345:respawn:|g" $(MNThdd)/etc/inittab
165
166 umount $(MNThdd)/boot
167 umount $(MNThdd)
168
dfc4bc56
AF
169 # zerofree the ext3 images to get better compression
170 zerofree $(IMGboot)
171 zerofree $(IMGroot)
172 zerofree $(IMGvar)
173
52ca8220
AF
174 # Cat to an image
175 cat $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar) > $(IMGinsts)
176 rm -vf $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar)
177 # Write Partition table
178 echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,$(SIZEvar),L\n" \
179 | sfdisk -D -uM -H 64 -S 32 $(IMGinsts)
180
181 # Install grub
182 echo "device (hd0) $(IMGinsts)" > /tmp/grubinst.tmp
183 echo "root (hd0,0)" >> /tmp/grubinst.tmp
184 echo "setup (hd0)" >> /tmp/grubinst.tmp
185 echo "quit" >> /tmp/grubinst.tmp
186 grub < /tmp/grubinst.tmp
187 rm -f /tmp/grubinst.tmp
188
189 # Compress Image
190 gzip -f9 $(IMGinsts)
191
192 rm -rf $(MNThdd) $(IMGpart) $(IMGboot) $(IMGroot) $(IMGvar)
3e962cfa 193