6 # --- T2-COPYRIGHT-NOTE-BEGIN ---
7 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
9 # T2 SDE: package/.../mkinitrd/mkinitrd.sh
10 # Copyright (C) 2005 - 2006 The T2 SDE Project
12 # More information can be found in the files COPYING and README.
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; version 2 of the License. A copy of the
17 # GNU General Public License can be found in the file COPYING.
18 # --- T2-COPYRIGHT-NOTE-END ---
22 if [ $UID != 0 ]; then
23 echo "Non root - exiting ..."
29 [0-9]*) kernelver="$1" ;;
30 -R) root="$2" ; shift ;;
31 *) echo "Usage: mkinitrd [ -R root ] [ kernelver ]"
37 [ "$root" ] || root=""
38 [ "$kernelver" ] || kernelver=`uname -r`
39 [ "$moddir" ] || moddir="${root}/lib/modules/$kernelver"
41 echo "Kernel: $kernelver, module dir: $moddir"
43 if [ ! -d $moddir ]; then
44 echo "Module dir $moddir does not exist!"
49 [ -f "${root}/boot/System.map-$kernelver" ] && sysmap="${root}/boot/System.map-$kernelver"
51 if [ -z "$sysmap" ]; then
52 echo "System.map_$kernelver not found!"
56 echo "System.map: $sysmap"
59 #for x in cpio gzip ; do
60 # if ! which $x >/dev/null ; then
61 # echo "$x not found!"
68 # create basic structure
70 rm -rf $tmpdir >/dev/null
72 echo "Create dirtree ..."
74 mkdir -p $tmpdir/{dev,bin,sbin,proc,sys,lib/modules,lib/udev,etc/hotplug.d/default}
75 mknod $tmpdir/dev/console c 5 1
77 # copy the basic / rootfs kernel modules
79 echo "Copying kernel modules ..."
82 find $moddir/kernel -type f | grep \
83 -e reiserfs -e reiser4 -e ext2 -e ext3 -e /jfs -e /xfs \
84 -e isofs -e udf -e /unionfs -e ntfs -e fat -e dm-mod \
85 -e /ide/ -e /ata/ -e /scsi/ -e /message/ \
86 -e hci -e usb-storage -e sbp2 \
87 -e drivers/net/ -e '/ipv6\.' -e usbhid |
90 for x in $fn `modinfo $fn | grep depends |
91 cut -d : -f 2- | sed -e 's/ //g' -e 's/,/ /g' `
93 # expand to full name if it was a depend
95 x=`find $moddir/kernel -name "$x.*o"`
102 mkdir -p `dirname $tmpdir/$xt`
103 cp $x $tmpdir/$xt 2>/dev/null
110 /sbin/depmod -ae -b $tmpdir -F $sysmap $kernelver
112 echo "Injecting programs and configuration ..."
116 cp -ar ${root}/etc/udev $tmpdir/etc/
117 # in theory all, but fat and currently only cdrom_id is needed ...
118 #cp -ar ${root}/lib/udev/cdrom_id $tmpdir/lib/udev/
122 for x in ${root}/sbin/{hotplug,udevd,modprobe,insmod}
125 file $x | grep -q "dynamically linked" &&
126 echo "Warning: $x is dynamically linked!"
130 x=${root}/sbin/insmod.old
132 echo "Warning: Skipped optional file $x!"
134 file $x | grep -q "dynamically linked" &&
135 echo "Warning: $x is dynamically linked!"
137 ln -s insmod.old $tmpdir/sbin/modprobe.old
140 ln -s /sbin/udev $tmpdir/etc/hotplug.d/default/10-udev.hotplug
141 cp ${root}/bin/bash $tmpdir/bin/sh
143 # static, tiny embutils and friends
145 #cp ${root}/usr/embutils/{mount,umount,rm,mv,mkdir,ln,ls,switch_root,sleep,losetup,chmod,cat,sed,mknod} \
147 ln -s mv $tmpdir/bin/cp
149 cp ${root}/sbin/init $tmpdir/init
151 # Custom ACPI DSDT table
152 if test -f "${root}/boot/DSDT.aml"; then
153 echo "Adding local DSDT file: $dsdt"
154 cp ${root}/boot/DSDT.aml $tmpdir/DSDT.aml
157 # create the cpio image
161 find . | cpio -o -H newc | gzip -c9 > ${root}/boot/initrd-$kernelver.img
164 # display the resulting image
166 du -sh ${root}/boot/initrd-$kernelver.img