summaryrefslogtreecommitdiffstats
path: root/mkinitram
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-01-02 07:40:21 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-01-02 07:40:21 +0000
commit7921216ba4aa5274b0863f24d329f426d83e06ec (patch)
tree1e1b9d188fda102b33d663b6e9a8f1b19f6d50b8 /mkinitram
parentbbcaa47c848e0dbb8316310e86f2da2bfaef0aa8 (diff)
downloadabuild-7921216ba4aa5274b0863f24d329f426d83e06ec.tar.bz2
abuild-7921216ba4aa5274b0863f24d329f426d83e06ec.tar.xz
added scripts to make alpine bootable
those should probably go to a separate package but I put them here for now
Diffstat (limited to 'mkinitram')
-rw-r--r--mkinitram60
1 files changed, 60 insertions, 0 deletions
diff --git a/mkinitram b/mkinitram
new file mode 100644
index 0000000..af40603
--- /dev/null
+++ b/mkinitram
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+msg() {
+ echo "==>" $@
+}
+
+die() {
+ echo $@
+ exit 1
+}
+
+APKS=tmp/apks
+
+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
+msg "Using kernel $kernel"
+
+# create empty image dir
+
+rm -rf "$image"
+mkdir -p "$image"
+
+# unpack busybox and deps
+tar -C $image -zxf $APKS/uclibc-[0-9]*.apk
+tar -C $image -zxf $APKS/busybox-[0-9]*.apk
+tar -C $image -zxf $APKS/alpine-baselayout-[0-9]*.apk
+tar -C $image -zxf $APKS/apk-tools-[0-9]*.apk
+rm -f $image/.PKGINFO
+cp $init $image
+
+# copy kernel modules
+kmods=$image/lib/modules/$kernel
+mkdir -p $kmods/kernel/drivers
+
+for i in ata block ide ieee1394 scsi cdrom usb message; do
+ cp -LpR /lib/modules/$kernel/kernel/drivers/$i $kmods/kernel/drivers/
+done
+
+for i in fs lib; do
+ cp -LpR /lib/modules/$kernel/kernel/$i $kmods/kernel/
+done
+
+depmod $kernel -b $image
+
+
+# generate the image
+cd $image
+find . | cpio -o -H newc | gzip -9 > $dest