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