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