Zwischencommit... ISO wird gebaut!
[ipfire-2.x.git] / lfs / initrd
1 ###############################################################################
2 # This file is part of the IPCop Firewall.                                    #
3 #                                                                             #
4 # IPCop is free software; you can redistribute it and/or modify               #
5 # it under the terms of the GNU General Public License as published by        #
6 # the Free Software Foundation; either version 2 of the License, or           #
7 # (at your option) any later version.                                         #
8 #                                                                             #
9 # IPCop is distributed in the hope that it will be useful,                    #
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
12 # GNU General Public License for more details.                                #
13 #                                                                             #
14 # You should have received a copy of the GNU General Public License           #
15 # along with IPCop; if not, write to the Free Software                        #
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA    #
17 #                                                                             #
18 # Makefiles are based on LFSMake, which is                                    #
19 # Copyright (C) 2002 Rod Roard <rod@sunsetsystems.com>                        #
20 #                                                                             #
21 ###############################################################################
22
23 ###############################################################################
24 # Definitions
25 ###############################################################################
26
27 include Config
28
29 VER = ipfire
30
31 THISAPP    = initrd
32 DIR_APP    = $(DIR_SRC)/$(THISAPP)
33 TARGET     = $(DIR_INFO)/$(THISAPP)
34
35 ###############################################################################
36 # Top-level Rules
37 ###############################################################################
38
39 install : $(TARGET)
40
41 check :
42
43 download :
44
45 md5 :
46
47 ###############################################################################
48 # Installation Details
49 ###############################################################################
50
51 $(TARGET) :
52         @$(PREBUILD)
53         rm -f /install/images/{cdinitrd,cdinitrd.gz,fdinitrd,fdinitrd.gz}
54
55         # Finish up initrd directory
56         -mkdir -p /install/initrd/{dev,etc,mnt,root,lib/modules/$(KVER)/kernel/drivers,cdrom,dev,harddisk,proc,tmp,usr/share/terminfo/l,var/run,sys} && \
57         cd /install/initrd && ln -sfn bin sbin
58         cd /install/initrd/etc && rm -f fstab
59         cp -aRf $(DIR_SRC)/config/install/* /install/initrd/etc/
60         mv -f /install/initrd/etc/fstab /install/initrd/etc/fstab.boot
61         cd /install/initrd/etc && ln -s /tmp/fstab fstab
62         rm -rf /install/initrd/etc{,/udev,/udev/rules.d}/.svn
63         rm -rf /install/initrd/usr/share/man
64         chmod 755 /install/initrd/etc/halt /install/initrd/etc/rc
65         cp -f /usr/share/terminfo/l/linux /install/initrd/usr/share/terminfo/l
66
67         # Extra modules
68         -mkdir -p /install/initrd/lib/modules/$(KVER)/kernel/drivers/scsi
69         cp -f /lib/modules/$(KVER)/kernel/drivers/scsi/{scsi_mod.ko,sd_mod.ko,sr_mod.ko} \
70                 /install/initrd/lib/modules/$(KVER)/kernel/drivers/scsi/
71
72         -mkdir -p /install/initrd/lib/modules/$(KVER)/kernel/drivers/usb/storage
73         cp -f /lib/modules/$(KVER)/kernel/drivers/usb/storage/*.ko \
74                 /install/initrd/lib/modules/$(KVER)/kernel/drivers/usb/storage/
75
76         -mkdir -p /install/initrd/lib/modules/$(KVER)/kernel/drivers/usb/host
77         cp -f /lib/modules/$(KVER)/kernel/drivers/usb/host/*.ko \
78                 /install/initrd/lib/modules/$(KVER)/kernel/drivers/usb/host
79
80         -mkdir -p /install/initrd/lib/modules/$(KVER)/kernel/drivers/usb/input
81         cp -f /lib/modules/$(KVER)/kernel/drivers/usb/input/usbhid.ko \
82                 /install/initrd/lib/modules/$(KVER)/kernel/drivers/usb/input
83
84         -mkdir -p /install/initrd/lib/modules/$(KVER)/kernel/drivers/usb/core
85         cp -f /lib/modules/$(KVER)/kernel/drivers/usb/core/*.ko \
86                 /install/initrd/lib/modules/$(KVER)/kernel/drivers/usb/core
87
88         # File system
89         -mkdir -p /install/initrd/lib/modules/$(KVER)/kernel/fs
90         cp -rf /lib/modules/$(KVER)/kernel/fs/* /install/initrd/lib/modules/$(KVER)/kernel/fs
91
92         cp -f /lib/modules/$(KVER)/modules.* /install/initrd/lib/modules/$(KVER)
93
94         cp /opt/$(MACHINE)-uClibc/lib/libgcc_s.so.1 /install/initrd/lib/
95
96         cd /install/initrd/lib/ && ln -sf libgcc_s.so.1 libgcc_s.so
97         
98         # Floppy initrd
99         -mkdir -p /install/{images,mnt}
100         rm -rf /install/mnt/*
101
102         cp -aR /install/initrd/* /install/mnt
103         # cp -a /install/misc/bin/* /install/mnt/bin
104
105         # make new dependencies
106         depmod -a -F /boot/System.map-$(KVER) $(KVER)
107         touch /install/mnt/FLOPPYBOOT
108
109         RAMDISK_SIZE=8192 && \
110             dd if=/dev/zero of=/install/images/fdinitrd bs=1k count=$${RAMDISK_SIZE}
111         for i in `seq 0 7`; do \
112             if (! losetup /dev/loop$${i} >/dev/null 2>&1 ); then \
113                 LOOPDEV="/dev/loop$${i}" \
114                 break; \
115             fi; \
116             done && \
117             losetup $$LOOPDEV /install/images/fdinitrd && \
118             mke2fs -m 0 -N 1024 $$LOOPDEV && \
119             mount -t ext2 $$LOOPDEV /install/mnt && \
120             rm -rf /install/mnt/lost+found && \
121             cp -aR /install/initrd/* /install/mnt/ && \
122             cd /install/mnt/ && find ./ -ls > $(DIR_INFO)/_build.fdinitrd && \
123             cd / && umount /install/mnt && \
124             losetup -d $$LOOPDEV
125         gzip -9 /install/images/fdinitrd
126
127         RAMDISK_SIZE=11264 && \
128             dd if=/dev/zero of=/install/images/cdinitrd bs=1k count=$${RAMDISK_SIZE}
129         for i in `seq 0 7`; do \
130             if (! losetup /dev/loop$${i} >/dev/null 2>&1 ); then \
131                 LOOPDEV="/dev/loop$${i}" \
132                 break; \
133             fi; \
134             done && \
135             losetup $$LOOPDEV /install/images/cdinitrd && \
136             mke2fs -m 0 -N 1024 $$LOOPDEV && \
137             mount -t ext2 $$LOOPDEV /install/mnt && \
138             rm -rf /install/mnt/lost+found && \
139             cp -aR /install/initrd/* /install/mnt/ && \
140             cd /install/mnt && tar xfz /install/images/drivers-$(VERSION).img && \
141             cd /install/mnt && tar xfz /install/images/scsidrv-$(VERSION).img && \
142             cd /install/mnt/ && find ./ -ls > $(DIR_INFO)/_build.cdinitrd && \
143             touch /install/mnt/CDROMBOOT && \
144             cd / && umount /install/mnt && \
145             losetup -d $$LOOPDEV
146         gzip -9 /install/images/cdinitrd
147
148         @$(POSTBUILD)