]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - lfs/xen-image
Forward Firewall: Fix 80,81,83 (Forum)
[people/teissler/ipfire-2.x.git] / lfs / xen-image
CommitLineData
bada0832
AF
1###############################################################################
2# #
3# IPFire.org - A linux based firewall #
fdecb907 4# Copyright (C) 2007-2012 IPFire Team <info@ipfire.org> #
bada0832
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 = xen-image
30TARGET = $(DIR_INFO)/$(THISAPP)
31
500f7b48 32KVER2 = `grep "^VER " $(DIR_SRC)/lfs/linux2 | sed "s| ||g" | cut -d"=" -f2`
fdecb907 33
bada0832
AF
34###############################################################################
35# Top-level Rules
36###############################################################################
37
38install : $(TARGET)
39
40check :
41
42download :
43
44md5 :
45
46###############################################################################
47# Installation Details
48###############################################################################
3c937429 49IMGinst := /install/images/$(SNAME)-$(VERSION).xen.$(MACHINE)-full-core$(CORE).tar.bz2
bada0832
AF
50MNThdd := /install/harddisk
51
7f8044b6
AF
52IMGboot := /install/images/$(SNAME)/$(SNAME)-boot.img
53IMGswap := /install/images/$(SNAME)/$(SNAME)-swap.img
54IMGroot := /install/images/$(SNAME)/$(SNAME)-root.img
55IMGvar := /install/images/$(SNAME)/$(SNAME)-var.img
56
57SIZEboot := 30
bada0832 58SIZEswap := 512
7f8044b6 59SIZEroot := 512
fbeee892 60SIZEvar := 950
bada0832
AF
61
62$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
63 rm -rf $(MNThdd) $(IMGinst) $(IMGroot) && mkdir -p $(MNThdd)
aa730400 64 mkdir -p /install/images/$(SNAME) # /boot
bada0832 65
7f8044b6
AF
66 #Create bootimage
67 dd bs=1M if=/dev/zero of=$(IMGboot) count=$(SIZEboot)
831a579e 68 mkfs.ext2 -F $(IMGboot)
7f8044b6 69
bada0832
AF
70 #Create swapimage
71 dd bs=1M if=/dev/zero of=$(IMGswap) count=$(SIZEswap)
72 mkswap $(IMGswap)
73
74 #Create rootimage
75 dd bs=1M if=/dev/zero of=$(IMGroot) count=$(SIZEroot)
76 mkfs.ext3 -F $(IMGroot)
77
7f8044b6
AF
78 #Create varimage
79 dd bs=1M if=/dev/zero of=$(IMGvar) count=$(SIZEvar)
80 mkfs.ext3 -F $(IMGvar)
81
9df6d70f
AF
82 # Mount Images
83 mount -o loop $(IMGroot) $(MNThdd)
bada0832
AF
84 mkdir $(MNThdd)/boot
85 mkdir $(MNThdd)/var
86 mkdir $(MNThdd)/var/log
7f8044b6
AF
87 mount -o loop $(IMGboot) $(MNThdd)/boot
88 mount -o loop $(IMGvar) $(MNThdd)/var
bada0832
AF
89
90 # Install IPFire without kernel modules
dbf157bb 91 tar -C $(MNThdd)/ -xvf /install/cdrom/$(SNAME)-$(VERSION).tlz --lzma \
bada0832
AF
92 --exclude=lib/modules* --exclude=boot*
93
500f7b48
AF
94 #Install legacy Xen Kernel
95 tar -C $(MNThdd)/opt/pakfire/tmp -xvf /install/packages/linux-xen-$(KVER2)-*.ipfire
96 chroot $(MNThdd) /opt/pakfire/tmp/install.sh
97 rm -rf $(MNThdd)/opt/pakfire/tmp/*
98
99 #Install pae Kernel
100 tar -C $(MNThdd)/opt/pakfire/tmp -xvf /install/packages/linux-pae-$(KVER)-*.ipfire
bada0832
AF
101 chroot $(MNThdd) /opt/pakfire/tmp/install.sh
102 rm -rf $(MNThdd)/opt/pakfire/tmp/*
103
f98761dc
AF
104 #Create grub menuentry for pygrub
105 mkdir $(MNThdd)/boot/grub
7f8044b6
AF
106 echo "timeout 10" > $(MNThdd)/boot/grub/grub.conf
107 echo "default 0" >> $(MNThdd)/boot/grub/grub.conf
500f7b48
AF
108 echo "title IPFire (legacy XEN-Kernel)" >> $(MNThdd)/boot/grub/grub.conf
109 echo " kernel /vmlinuz-$(KVER2)-ipfire-xen root=/dev/xvda3 rootdelay=10 panic=10 console=xvc0 ro" \
f98761dc 110 >> $(MNThdd)/boot/grub/grub.conf
500f7b48 111 echo " initrd /ipfirerd-$(KVER2)-xen.img" >> $(MNThdd)/boot/grub/grub.conf
aa730400 112 echo "# savedefault 0" >> $(MNThdd)/boot/grub/grub.conf
500f7b48
AF
113 echo "title IPFire (PAE-Kernel)" >> $(MNThdd)/boot/grub/grub.conf
114 echo " kernel /vmlinuz-$(KVER)-ipfire-pae root=/dev/xvda3 rootdelay=10 panic=10 console=xvc0 ro" \
115 >> $(MNThdd)/boot/grub/grub.conf
116 echo " initrd /ipfirerd-$(KVER)-xen.img" >> $(MNThdd)/boot/grub/grub.conf
117 echo "# savedefault 1" >> $(MNThdd)/boot/grub/grub.conf
aa730400 118
f98761dc
AF
119 ln -s grub.conf $(MNThdd)/boot/grub/menu.lst
120
121 #Copy the meta-info of linux-xen package
122 cp -f /install/packages/meta-linux-xen $(MNThdd)/opt/pakfire/db/installed
123 cp -f /install/packages/meta-linux-xen $(MNThdd)/opt/pakfire/db/meta
500f7b48
AF
124 cp -f /install/packages/meta-linux-pae $(MNThdd)/opt/pakfire/db/installed
125 cp -f /install/packages/meta-linux-pae $(MNThdd)/opt/pakfire/db/meta
f98761dc 126
bada0832
AF
127 #Set default configuration
128 echo "LANGUAGE=en" >> $(MNThdd)/var/ipfire/main/settings
129 echo "HOSTNAME=$(SNAME)" >> $(MNThdd)/var/ipfire/main/settings
130 echo "THEME=ipfire" >> $(MNThdd)/var/ipfire/main/settings
500f7b48 131 touch $(MNThdd)/lib/modules/$(KVER2)-ipfire-xen/modules.dep
bada0832
AF
132 mkdir $(MNThdd)/proc
133 mount --bind /proc $(MNThdd)/proc
134 mount --bind /dev $(MNThdd)/dev
135 mount --bind /sys $(MNThdd)/sys
136 chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
7f8044b6
AF
137 sed -i -e "s|DEVICE1|/dev/xvda1|g" $(MNThdd)/etc/fstab
138 sed -i -e "s|DEVICE2|/dev/xvda2|g" $(MNThdd)/etc/fstab
139 sed -i -e "s|DEVICE3|/dev/xvda3|g" $(MNThdd)/etc/fstab
140 sed -i -e "s|DEVICE4|/dev/xvda4|g" $(MNThdd)/etc/fstab
bada0832
AF
141
142 sed -i -e "s|FSTYPE|ext3|g" $(MNThdd)/etc/fstab
bada0832 143
500f7b48
AF
144 chroot $(MNThdd) /sbin/dracut --force --verbose /boot/ipfirerd-$(KVER2)-xen.img $(KVER2)-ipfire-xen
145 chroot $(MNThdd) /sbin/dracut --force --verbose /boot/ipfirerd-$(KVER)-pae.img $(KVER)-ipfire-pae
bada0832 146
bada0832
AF
147 #Remove root / fstab check
148 rm -rf $(MNThdd)/etc/rc.d/rcsysinit.d/S19checkfstab
ad5b4390
AF
149 #Remove console init
150 rm -rf $(MNThdd)/etc/rc.d/rcsysinit.d/S70console
bada0832 151
9df6d70f
AF
152 #Add xvc0 to securetty
153 echo xvc0 >> $(MNThdd)/etc/securetty
154
7f8044b6 155 #Add getty for xvc0
fbeee892
AF
156 echo "#Enable login for XEN" >> $(MNThdd)/etc/inittab
157 echo "8:2345:respawn:/sbin/agetty xvc0 9600" >> $(MNThdd)/etc/inittab
7f8044b6 158
9df6d70f
AF
159 #Disable some initskripts
160 echo "#!/bin/sh" > $(MNThdd)/etc/rc.d/init.d/setclock
161 echo "#!/bin/sh" > $(MNThdd)/etc/rc.d/init.d/keymap
162
5cb1128d 163 #Remove autoload of acpi modules
9df6d70f
AF
164 sed -i -e "s|^ac|#ac|g" $(MNThdd)/etc/sysconfig/modules
165 sed -i -e "s|^battery|#battery|g" $(MNThdd)/etc/sysconfig/modules
166 sed -i -e "s|^button|#button|g" $(MNThdd)/etc/sysconfig/modules
167 sed -i -e "s|^fan|#fan|g" $(MNThdd)/etc/sysconfig/modules
5cb1128d
AF
168 sed -i -e "s|^processor|#processor|g" $(MNThdd)/etc/sysconfig/modules
169 sed -i -e "s|^thermal|#thermal|g" $(MNThdd)/etc/sysconfig/modules
170 sed -i -e "s|^video|#video|g" $(MNThdd)/etc/sysconfig/modules
171
a8c02fc3
AF
172 # Copy readme and config
173 cp $(DIR_SRC)/config/xen-image/* \
174 /install/images/$(SNAME)
175
bada0832
AF
176 # Unmount
177 umount $(MNThdd)/proc
178 umount $(MNThdd)/dev
179 umount $(MNThdd)/sys
7f8044b6
AF
180 umount $(MNThdd)/var
181 umount $(MNThdd)/boot
bada0832
AF
182 umount $(MNThdd)
183
dfc4bc56
AF
184 # Zerofree ext3 images to get better compression
185 zerofree $(IMGboot)
186 zerofree $(IMGroot)
187 zerofree $(IMGvar)
188
bada0832
AF
189 # Compress Image
190 cd /install/images/ && tar -cvjf $(IMGinst) $(SNAME)
191
192 rm -rf $(MNThdd) /install/images/$(SNAME)