Commit 5be335cc authored by Natanael Copa's avatar Natanael Copa

initramfs-init: extract apkovl

also link mkiso to use the makefile
parent e81ebe19
......@@ -80,7 +80,7 @@ INITFS_MODDIR := $(INITFS_DIR)/lib/modules/$(KERNEL)
INITFS_MODDIRSTAMP := $(DESTDIR)/stamp.initfs.modules
INITFS_APKS := $(UCLIBC_APK) $(BUSYBOX_APK)
INITFS_RAWBASEFILES := etc/mdev.conf etc/passwd etc/group etc/fstab
INITFS_RAWBASEFILES := etc/mdev.conf etc/passwd etc/group etc/fstab etc/modules
INITFS_BASEFILES := $(addprefix $(INITFS_DIR)/, $(INITFS_RAWBASEFILES))
$(INITFS_DIRSTAMP): $(INITFS_APKS)
......@@ -88,8 +88,7 @@ $(INITFS_DIRSTAMP): $(INITFS_APKS)
@rm -rf $(INITFS_DIR)
@mkdir -p $(addprefix $(INITFS_DIR)/, \
dev proc sys sbin bin .modloop lib/modules \
media/cdrom media/floppy media/usb \
newroot/proc newroot/sys)
media/cdrom media/floppy media/usb newroot)
@for apk in $(INITFS_APKS) ; do \
tar -C $(INITFS_DIR) -xzf $$apk ; \
done
......@@ -158,7 +157,7 @@ $(ISOLINUX_CFG):
@echo "default linux" >>$(ISOLINUX_CFG)
@echo "label linux" >>$(ISOLINUX_CFG)
@echo " kernel /boot/vmlinuz" >>$(ISOLINUX_CFG)
@echo " append initrd=/boot/initramfs.gz alpine_dev=cdrom quiet" >>$(ISOLINUX_CFG)
@echo " append initrd=/boot/initramfs.gz alpine_dev=cdrom modules=floppy quiet" >>$(ISOLINUX_CFG)
ISO_KERNEL := $(ISO_DIR)/boot/vmlinuz
ISO_APKS := $(ISO_DIR)/apks
......
#!/bin/ash
#!/bin/sh
VERSION=1.9.1-pre0
NEWROOT=/newroot
......@@ -36,6 +36,22 @@ scan_drivers() {
fi
}
find_ovl() {
local mnt="$1"
local ovl
local lines
# look for apkovl's on mounted media
ovl=$( ls -1 "$mnt"/*.apkovl.tar.gz* 2>/dev/null ) || return 1
lines=$(echo "$ovl" | wc -l)
if [ $lines -gt 1 ] ; then
echo "ERROR: More than one apkovl file was found on $(basename $mnt). None will be read." >&2
return 1
fi
echo "$ovl"
}
# gotta start from somewhere :)
echo "Starting Alpine $VERSION"
......@@ -74,9 +90,16 @@ mount -t devpts -o gid=5,mode=0620,noexec,nosuid devpts /dev/pts
mount -t tmpfs -o nodev,nosuid,noexec shm /dev/shm
eend $RC
/bin/sh
# load available drivers to get access to modloop media
ebegin "Loading boot drivers"
[ "$MODULES" ] && modprobe $MODULES 2> /dev/null
if [ -f /etc/modules ] ; then
sed 's/\#.*//g' < /etc/modules |
while read module args; do
modprobe -q $module $args
done
fi
scan_drivers
scan_drivers
eend 0
......@@ -110,11 +133,27 @@ ebegin "Loading hardware drivers"
scan_drivers
eend 0
# look for apkovl
for i in usb floppy cdrom; do
mount /media/$i 2>/dev/null || continue
ovl=$(find_ovl /media/$i)
[ -f "$ovl" ] && break
umount /media/$i 2>/dev/null
done
if [ -f "$ovl" ]; then
ebegin "Loading user settings from $ovl"
tar -C $NEWROOT -zxf "$ovl"
eend $?
umount /media/$i 2>/dev/null
pkgs=$(sed 's/\#.*//' $NEWROOT/etc/lbu/packages.list 2>/dev/null)
fi
# install new root
ebegin "Installing packages to root filesystem"
mount -t tmpfs -o size=50M tmpfs $NEWROOT
apk create --root /newroot
apk add --root /newroot --repository /media/cdrom/apks --quiet --progress
apk add --root /newroot --repository /media/cdrom/apks --quiet --progress $pkgs
eend $?
# switch over to new root
......@@ -125,4 +164,11 @@ cat /proc/mounts | while read DEV DIR TYPE OPTS ; do
fi
done
sync
exec /bin/busybox switch_root $NEWROOT /sbin/init $KOPT_init_args || exec /bin/busybox sh
if [ -x $NEWROOT/sbin/init ]; then
exec /bin/busybox switch_root $NEWROOT /sbin/init $KOPT_init_args
fi
echo "initramfs emergency recovery shell launched"
exec /bin/busybox sh
reboot
#!/bin/sh
tmp=$PWD/tmp
aports=$PWD/../aports
target=alpine-test.iso
initramfs=test.gz
modloop=modloop.cmg
unapk() {
local dest="$1"
shift
while [ $# -gt 0 ]; do
tar -C "$dest" -zxf "$1"
shift
done
rm -f "$dest/.PKGINFO"
}
link_or_copy() {
ln -f "$1" "$2" 2>/dev/null || cp "$1" "$2"
}
rm -r $tmp
mkdir -p $tmp/apks $tmp/isolinux
cp /usr/share/syslinux/isolinux.* $tmp/isolinux
cat >$tmp/isolinux/isolinux.cfg <<EOF
timeout 20
prompt 1
default test
label test
kernel /boot/vmlinuz
append initrd=/boot/test.gz alpine_dev=cdrom quiet
EOF
#cp $aports/core/*/*.apk $tmp/apks
unapk $tmp $aports/core/linux-grsec/linux-grsec-[0-9]*.apk
# only build initram if its missing or script is newer than target
if [ ! -f "$initramfs" ] || [ mkinitram -nt "$initramfs" ]; then
sh mkinitram
fi
if [ ! -f "$modloop" ] || [ mkmodloop -nt "$modloop" ]; then
sh mkmodloop
fi
mkdir -p $tmp/boot/
link_or_copy test.gz $tmp/boot/
link_or_copy modloop.cmg $tmp/boot/
echo "==> Creating ISO image"
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
make -f alpine.mk
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment