From 7921216ba4aa5274b0863f24d329f426d83e06ec Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Fri, 2 Jan 2009 07:40:21 +0000
Subject: [PATCH] added scripts to make alpine bootable

those should probably go to a separate package but I put them here for now
---
 init      |  3 +++
 mkinitram | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 mkiso     | 38 +++++++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+)
 create mode 100755 init
 create mode 100644 mkinitram
 create mode 100644 mkiso

diff --git a/init b/init
new file mode 100755
index 000000000000..70ad286ec8ef
--- /dev/null
+++ b/init
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sh
diff --git a/mkinitram b/mkinitram
new file mode 100644
index 000000000000..af40603635f2
--- /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
diff --git a/mkiso b/mkiso
new file mode 100644
index 000000000000..8b25c260e20d
--- /dev/null
+++ b/mkiso
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+tmp=$PWD/tmp
+aports=$PWD/../aports
+target=alpine-test.iso
+
+rm -r $tmp
+mkdir -p $tmp/apks $tmp/isolinux
+cp /usr/share/syslinux/isolinux.* $tmp/isolinux
+cat >$tmp/isolinux/isolinux.cfg <<EOF
+timeout 300
+prompt 1
+default test
+
+label test
+	kernel /boot/vmlinuz
+	append initrd=/test.gz init=/sbin/init
+EOF
+
+
+cp $aports/core/*/*.apk $tmp/apks
+tar -C $tmp -zxf $aports/core/linux-grsec/linux-grsec-[0-9]*.apk
+rm -f $tmp/.PKGINFO
+
+sh mkinitram
+
+cp test.gz $tmp/ 
+
+genisoimage -o $target -l -J -R \
+	-b isolinux/isolinux.bin \
+	-c isolinux/boot.cat	\
+	-no-emul-boot		\
+	-boot-load-size 4	\
+	-boot-info-table	\
+	-quiet			\
+	$tmp
+
+
-- 
GitLab