Add /init script to the stage3 disk.
authorRichard W.M. Jones <rjones@redhat.com>
Sat, 6 Aug 2016 06:51:10 +0000 (07:51 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Sat, 6 Aug 2016 07:57:10 +0000 (08:57 +0100)
Makefile
init.sh [new file with mode: 0755]

index 96da1ca..2cc075c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -237,6 +237,7 @@ stage3: stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux \
        stage3-chroot/etc/fedora-release \
        stage3-chroot/lib64/libc.so.6 \
        stage3-chroot/bin/bash \
        stage3-chroot/etc/fedora-release \
        stage3-chroot/lib64/libc.so.6 \
        stage3-chroot/bin/bash \
+       stage3-chroot/init \
        stage3-disk.img
 
 stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux:
        stage3-disk.img
 
 stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux:
@@ -251,11 +252,13 @@ stage3-kernel/linux-$(KERNEL_VERSION)/vmlinux:
        git fetch riscv && \
        git checkout -f linux-4.1.y-riscv && \
        make mrproper && \
        git fetch riscv && \
        git checkout -f linux-4.1.y-riscv && \
        make mrproper && \
-       make ARCH=riscv defconfig && \
-       make ARCH=riscv \
-           CONFIG_CROSS_COMPILE=riscv64-unknown-elf- \
-           CONFIG_CMDLINE="root=/dev/htifblk0 init=/bin/bash" \
-           vmlinux
+       make ARCH=riscv defconfig
+       echo CONFIG_CMDLINE=\"root=/dev/htifblk0 init=/init\" >> stage3-kernel/linux-$(KERNEL_VERSION)/.config
+       echo CONFIG_CROSS_COMPILE=riscv64-unknown-elf- >> stage3-kernel/linux-$(KERNEL_VERSION)/.config
+       cd stage3-kernel/linux-$(KERNEL_VERSION) && \
+       make ARCH=riscv olddefconfig
+       cd stage3-kernel/linux-$(KERNEL_VERSION) && \
+       make ARCH=riscv vmlinux
        ls -l $@
 
 # Build an original (x86-64) chroot using supermin.  We then aim to
        ls -l $@
 
 # Build an original (x86-64) chroot using supermin.  We then aim to
@@ -305,6 +308,10 @@ bash-$(BASH_VERSION).tar.gz:
        wget -O $@-t ftp://ftp.gnu.org/gnu/bash/bash-$(BASH_VERSION).tar.gz
        mv $@-t $@
 
        wget -O $@-t ftp://ftp.gnu.org/gnu/bash/bash-$(BASH_VERSION).tar.gz
        mv $@-t $@
 
+# Create an /init script.
+stage3-chroot/init: init.sh
+       install -m 0755 $^ $@
+
 # Create the stage3 disk image.
 # Note `-s +...' adds spare space to the disk image.
 stage3-disk.img: stage3-chroot
 # Create the stage3 disk image.
 # Note `-s +...' adds spare space to the disk image.
 stage3-disk.img: stage3-chroot
diff --git a/init.sh b/init.sh
new file mode 100755 (executable)
index 0000000..f619f30
--- /dev/null
+++ b/init.sh
@@ -0,0 +1,17 @@
+#!/bin/bash -
+# Init script installed in stage3 disk image.
+
+echo
+echo "Welcome to the Fedora/RISC-V stage3 disk image"
+echo "https://fedoraproject.org/wiki/Architectures/RISC-V"
+echo
+
+PS1='stage3:\w\$ '
+export PS1
+
+# Run bash.
+bash -i
+
+# Sync disks and shut down.
+sync
+poweroff