2009-01-02 07:40:21 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
msg() {
|
|
|
|
echo "==>" $@
|
|
|
|
}
|
|
|
|
|
|
|
|
die() {
|
|
|
|
echo $@
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2009-01-02 12:04:35 +00:00
|
|
|
unapk() {
|
|
|
|
local dest="$1"
|
|
|
|
shift
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
tar -C "$dest" -zxf "$1"
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
rm -f "$dest/.PKGINFO"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
APKS=../aports/core/*/
|
2009-01-02 07:40:21 +00:00
|
|
|
|
|
|
|
image=$PWD/image
|
|
|
|
dest=$PWD/test.gz
|
|
|
|
init=init
|
|
|
|
|
|
|
|
|
|
|
|
kernel=$1
|
|
|
|
# if no kernel specified, then guess...
|
|
|
|
if [ -z "$kernel" ]; then
|
|
|
|
kernel=$(ls /lib/modules 2>/dev/null | tail -n 1)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d /lib/modules/$kernel ]; then
|
|
|
|
die "modules dir /lib/modules/$kernel was not found"
|
|
|
|
fi
|
2009-01-02 12:04:35 +00:00
|
|
|
msg "mkinitram Using kernel $kernel"
|
2009-01-02 07:40:21 +00:00
|
|
|
|
|
|
|
# create empty image dir
|
|
|
|
|
|
|
|
rm -rf "$image"
|
2009-01-02 09:23:32 +00:00
|
|
|
mkdir -p "$image/dev" "$image/etc/rcS.d"
|
2009-01-02 07:40:21 +00:00
|
|
|
|
|
|
|
# unpack busybox and deps
|
2009-01-02 12:04:35 +00:00
|
|
|
unapk $image $APKS/uclibc-[0-9]*.apk \
|
|
|
|
$APKS/busybox-[0-9]*.apk \
|
|
|
|
$APKS/alpine-baselayout-[0-9]*.apk \
|
|
|
|
$APKS/apk-tools-[0-9]*.apk
|
|
|
|
|
2009-01-02 09:23:32 +00:00
|
|
|
ln -sf /bin/busybox $image/init
|
|
|
|
|
|
|
|
# create misc devs and enable boot scripts
|
|
|
|
mknod $image/dev/null c 2 2
|
|
|
|
ln -s ../init.d/mdev $image/etc/rcS.d/S10mdev
|
|
|
|
ln -s ../init.d/hwdrivers $image/etc/rcS.d/S30hwdrivers
|
|
|
|
ln -s ../init.d/modutils $image/etc/rcS.d/S40modutils
|
2009-01-02 12:04:35 +00:00
|
|
|
ln -s ../init.d/modloop $image/etc/rcS.d/S50modloop
|
|
|
|
ln -s ../init.d/hwdrivers $image/etc/rcS.d/S60hwdrivers
|
|
|
|
|
|
|
|
mkdir $image/.modloop
|
2009-01-02 09:23:32 +00:00
|
|
|
|
|
|
|
# load those extra drivers
|
2009-01-02 12:04:35 +00:00
|
|
|
for i in ide-cd usb-storage ide-disk loop; do
|
2009-01-02 09:23:32 +00:00
|
|
|
echo $i >> $image/etc/modules
|
|
|
|
done
|
|
|
|
|
2009-01-02 07:40:21 +00:00
|
|
|
|
|
|
|
# copy kernel modules
|
|
|
|
kmods=$image/lib/modules/$kernel
|
2009-01-02 12:04:35 +00:00
|
|
|
mkdir -p $kmods/kernel/drivers $kmods/kernel/fs
|
2009-01-02 07:40:21 +00:00
|
|
|
|
2009-01-02 16:00:27 +00:00
|
|
|
for i in acpi ata block ide scsi cdrom usb message hid; do
|
2009-01-02 07:40:21 +00:00
|
|
|
cp -LpR /lib/modules/$kernel/kernel/drivers/$i $kmods/kernel/drivers/
|
|
|
|
done
|
|
|
|
|
2009-01-02 12:04:35 +00:00
|
|
|
for i in isofs vfat nls ext2 cramfs '*.ko'; do
|
|
|
|
cp -LpR /lib/modules/$kernel/kernel/fs/$i $kmods/kernel/fs/
|
2009-01-02 07:40:21 +00:00
|
|
|
done
|
2009-01-02 12:04:35 +00:00
|
|
|
cp -LpR /lib/modules/$kernel/kernel/lib $kmods/kernel/
|
2009-01-02 07:40:21 +00:00
|
|
|
|
|
|
|
depmod $kernel -b $image
|
|
|
|
|
|
|
|
|
|
|
|
# generate the image
|
|
|
|
cd $image
|
|
|
|
find . | cpio -o -H newc | gzip -9 > $dest
|