]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - lfs/xen-image
Xen Image now use pygrub to load ramdisk and kernel inside of the image
[people/pmueller/ipfire-2.x.git] / lfs / xen-image
CommitLineData
bada0832
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 = xen-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).xen.$(MACHINE)-$(ED)-core$(CORE).tar.bz2
48MNThdd := /install/harddisk
49
50IMGroot := /install/images/$(SNAME)/$(SNAME).img
51IMGswap := /install/images/$(SNAME)/swap.img
52SIZEroot := 1024
53SIZEswap := 512
54
55$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
56 rm -rf $(MNThdd) $(IMGinst) $(IMGroot) && mkdir -p $(MNThdd)
aa730400 57 mkdir -p /install/images/$(SNAME) # /boot
bada0832
AF
58
59 #Create swapimage
60 dd bs=1M if=/dev/zero of=$(IMGswap) count=$(SIZEswap)
61 mkswap $(IMGswap)
62
63 #Create rootimage
64 dd bs=1M if=/dev/zero of=$(IMGroot) count=$(SIZEroot)
65 mkfs.ext3 -F $(IMGroot)
66
9df6d70f
AF
67 # Mount Images
68 mount -o loop $(IMGroot) $(MNThdd)
bada0832
AF
69 mkdir $(MNThdd)/boot
70 mkdir $(MNThdd)/var
71 mkdir $(MNThdd)/var/log
72
73 # Install IPFire without kernel modules
74 tar -C $(MNThdd)/ -xvjf /install/cdrom/$(SNAME)-$(VERSION).tbz2 \
75 --exclude=lib/modules* --exclude=boot*
76
77 #Install Xen Kernel
78 tar -C $(MNThdd)/opt/pakfire/tmp -xvf /install/packages/linux-xen-$(KVER)-*.ipfire
79 chroot $(MNThdd) /opt/pakfire/tmp/install.sh
80 rm -rf $(MNThdd)/opt/pakfire/tmp/*
81
f98761dc
AF
82 #Create grub menuentry for pygrub
83 mkdir $(MNThdd)/boot/grub
d876f9c3
AF
84 echo "default 1" > $(MNThdd)/boot/grub/grub.conf
85 echo "title IPFire (XEN-Kernel)" >> $(MNThdd)/boot/grub/grub.conf
86 echo " kernel /vmlinuz-$(KVER)-ipfire-xen root=/dev/xvda1 rootdelay=10 panic=10 console=xvc0 ro" \
f98761dc
AF
87 >> $(MNThdd)/boot/grub/grub.conf
88 echo " initrd /ipfirerd-$(KVER)-xen.img" >> $(MNThdd)/boot/grub/grub.conf
aa730400
AF
89 echo "# savedefault 0" >> $(MNThdd)/boot/grub/grub.conf
90
f98761dc
AF
91 ln -s grub.conf $(MNThdd)/boot/grub/menu.lst
92
93 #Copy the meta-info of linux-xen package
94 cp -f /install/packages/meta-linux-xen $(MNThdd)/opt/pakfire/db/installed
95 cp -f /install/packages/meta-linux-xen $(MNThdd)/opt/pakfire/db/meta
96
bada0832
AF
97 #Set default configuration
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
101 touch $(MNThdd)/lib/modules/$(KVER)-ipfire-xen/modules.dep
102 mv $(MNThdd)/bin/uname.bak $(MNThdd)/bin/uname
103 mkdir $(MNThdd)/proc
104 mount --bind /proc $(MNThdd)/proc
105 mount --bind /dev $(MNThdd)/dev
106 mount --bind /sys $(MNThdd)/sys
107 chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
108 sed -i -e "s|DEVICE1|#boot-disabled|g" $(MNThdd)/etc/fstab
109 sed -i -e "s|DEVICE2|/dev/xvdb1|g" $(MNThdd)/etc/fstab
110 sed -i -e "s|DEVICE3|/dev/xvda1|g" $(MNThdd)/etc/fstab
111 sed -i -e "s|DEVICE4|#var-disabled|g" $(MNThdd)/etc/fstab
112
113 sed -i -e "s|FSTYPE|ext3|g" $(MNThdd)/etc/fstab
114 cp -f $(MNThdd)/etc/mkinitcpio.conf $(MNThdd)/etc/mkinitcpio.conf.org
115 sed -i -e "s| autodetect | |g" $(MNThdd)/etc/mkinitcpio.conf
116
3c4d4ed0
AF
117 #Remove reiser4 because it is not work with xen-kernel
118 sed -i -e "s|reiser4 | |g" $(MNThdd)/etc/mkinitcpio.conf
bada0832
AF
119
120 chroot $(MNThdd) /sbin/mkinitcpio -g /boot/ipfirerd-$(KVER)-xen.img -k $(KVER)-ipfire-xen
121 cp -f $(MNThdd)/etc/mkinitcpio.conf.org $(MNThdd)/etc/mkinitcpio.conf
122
f98761dc 123
bada0832
AF
124 # Create a script for rebuild-initrd and setup
125 echo "#!/bin/bash" > $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
126 echo "/usr/local/sbin/setup /dev/null INSTALL" >> $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
127 echo "rm -f /etc/rc.d/rcsysinit.d/S75firstsetup \\" >> $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
128 echo "&& /sbin/reboot" >> $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
129 chmod +x $(MNThdd)/etc/rc.d/rcsysinit.d/S75firstsetup
130
131 #Remove root / fstab check
132 rm -rf $(MNThdd)/etc/rc.d/rcsysinit.d/S19checkfstab
133
9df6d70f
AF
134 #Add xvc0 to securetty
135 echo xvc0 >> $(MNThdd)/etc/securetty
136
137 #Disable some initskripts
138 echo "#!/bin/sh" > $(MNThdd)/etc/rc.d/init.d/setclock
139 echo "#!/bin/sh" > $(MNThdd)/etc/rc.d/init.d/keymap
140
5cb1128d 141 #Remove autoload of acpi modules
9df6d70f
AF
142 sed -i -e "s|^ac|#ac|g" $(MNThdd)/etc/sysconfig/modules
143 sed -i -e "s|^battery|#battery|g" $(MNThdd)/etc/sysconfig/modules
144 sed -i -e "s|^button|#button|g" $(MNThdd)/etc/sysconfig/modules
145 sed -i -e "s|^fan|#fan|g" $(MNThdd)/etc/sysconfig/modules
5cb1128d
AF
146 sed -i -e "s|^processor|#processor|g" $(MNThdd)/etc/sysconfig/modules
147 sed -i -e "s|^thermal|#thermal|g" $(MNThdd)/etc/sysconfig/modules
148 sed -i -e "s|^video|#video|g" $(MNThdd)/etc/sysconfig/modules
149
9df6d70f
AF
150 #Change pakfire trunk
151 sed -i -e "s|$(VERSION)|$(VERSION)-xen|g" \
152 $(MNThdd)/opt/pakfire/etc/pakfire.conf
153
bada0832 154 #Copy initramdisk, kernel and config
aa730400
AF
155 #cp -f $(MNThdd)/boot/ipfirerd-$(KVER)-xen.img \
156 # /install/images/$(SNAME)/boot
157 #cp -f $(MNThdd)/boot/vmlinuz-$(KVER)-ipfire-xen \
158 # /install/images/$(SNAME)/boot
bada0832
AF
159 cp $(DIR_SRC)/config/xen-image/* \
160 /install/images/$(SNAME)
161 sed -i -e "s|KVER|$(KVER)|g" /install/images/$(SNAME)/ipfire.cfg
162
163 # Unmount
164 umount $(MNThdd)/proc
165 umount $(MNThdd)/dev
166 umount $(MNThdd)/sys
167 umount $(MNThdd)
168
169 # Compress Image
170 cd /install/images/ && tar -cvjf $(IMGinst) $(SNAME)
171
172 rm -rf $(MNThdd) /install/images/$(SNAME)