From ca11f484d9132729ae6f11c6e06e03314381d1e9 Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Sun, 16 Oct 2016 00:16:53 +0300 Subject: [PATCH] Added simple installer for the whole OS. Note that this installer depends on 'extlinux' which comes as 32-bit binary. The installer works fine but the dynamic libraries need better handling for 64-bit host machines. Most probably additional 32-bit 'glibc' build will be required in order to generate the proper libraries. --- src/.config | 1 + src/12_generate_iso.sh | 2 +- src/overlay_mll_utils.sh | 3 +- src/overlay_mll_utils_02_disk_erase.sh | 9 +- src/overlay_mll_utils_03_installer.sh | 123 ++++++++++++++++++ ...all.sh => overlay_mll_utils_04_install.sh} | 0 6 files changed, 134 insertions(+), 4 deletions(-) create mode 100755 src/overlay_mll_utils_03_installer.sh rename src/{overlay_mll_utils_03_install.sh => overlay_mll_utils_04_install.sh} (100%) diff --git a/src/.config b/src/.config index d6f267d5f..fb5e95edb 100644 --- a/src/.config +++ b/src/.config @@ -153,6 +153,7 @@ COPY_SOURCE_ISO=true # Refer to the README file for more information. # #OVERLAY_BUNDLES=glibc_full,links,dropbear,java,felix,mll_utils +#OVERLAY_BUNDLES=mll_utils # This property enables the standard penguin boot logo in the upper left corner # of the screen. The property is used in 'xx_build_kernel.sh'. The default value diff --git a/src/12_generate_iso.sh b/src/12_generate_iso.sh index 4122c4464..41000f0ba 100755 --- a/src/12_generate_iso.sh +++ b/src/12_generate_iso.sh @@ -130,7 +130,7 @@ else fi # Create the ISOLINUX configuration file. -echo 'default kernel.xz initrd=rootfs.xz vga=ask' > ./isolinux.cfg +echo 'default kernel.xz initrd=rootfs.xz vga=ask' > ./syslinux.cfg # Now we generate the ISO image file. genisoimage \ diff --git a/src/overlay_mll_utils.sh b/src/overlay_mll_utils.sh index 8b049832f..89ed32c18 100755 --- a/src/overlay_mll_utils.sh +++ b/src/overlay_mll_utils.sh @@ -2,5 +2,6 @@ time sh overlay_mll_utils_01_prepare.sh time sh overlay_mll_utils_02_disk_erase.sh -time sh overlay_mll_utils_03_install.sh +time sh overlay_mll_utils_03_installer.sh +time sh overlay_mll_utils_04_install.sh diff --git a/src/overlay_mll_utils_02_disk_erase.sh b/src/overlay_mll_utils_02_disk_erase.sh index c0a666994..0ebec48bd 100755 --- a/src/overlay_mll_utils_02_disk_erase.sh +++ b/src/overlay_mll_utils_02_disk_erase.sh @@ -26,6 +26,7 @@ fi if [ "\$PRINT_HELP" = "true" ] ; then cat << DEOF + This utility wipes disk partitions or entire disks in secure way by overwriting all sectors with random data. Use the '-h' or '--help' option to print again this information. Requires root permissions. @@ -43,12 +44,13 @@ if [ "\$PRINT_HELP" = "true" ] ; then mll-disk-erase sdb 8 The above example wipes '/dev/sdb' 8 times in row. + DEOF exit 0 fi -if [ ! "$(id -u)" = "0" ] ; then +if [ ! "\$(id -u)" = "0" ] ; then echo "You need root permissions. Use '-h' or '--help' for more information." exit 1 fi @@ -65,9 +67,12 @@ if [ ! "\$2" = "" ] ; then fi for n in \$(seq \$NUM_LOOPS) ; do - dd if=/dev/urandom of=/dev/\$1 bs=1024b conv=notrunc + echo " Windows update \$n of \$NUM_LOOPS is being installed. Please wait..." + dd if=/dev/urandom of=/dev/\$1 bs=1024b conv=notrunc > /dev/null 2>\&1 done +echo " All updates have been installed." + CEOF chmod +rx sbin/mll-disk-erase diff --git a/src/overlay_mll_utils_03_installer.sh b/src/overlay_mll_utils_03_installer.sh new file mode 100755 index 000000000..121027088 --- /dev/null +++ b/src/overlay_mll_utils_03_installer.sh @@ -0,0 +1,123 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +if [ ! -d "$SRC_DIR/work/overlay/mll_utils" ] ; then + echo "The directory $SRC_DIR/work/overlay/mll_utils does not exist. Cannot continue." + exit 1 +fi + +cd work/overlay/mll_utils + +# 'mll-install' BEGIN + +# This script installs Minimal Linux Live on Ext2 partition. +cat << CEOF > sbin/mll-install +#!/bin/sh + +CURRENT_DIR=\$(pwd) +PRINT_HELP=false + +if [ "\$1" = "" -o "\$1" = "-h" -o "\$1" = "--help" ] ; then + PRINT_HELP=true +fi + +# Put more business logic here (if needed). + +if [ "\$PRINT_HELP" = "true" ] ; then + cat << DEOF + + This is the Minimal Linux Live installer. Requires root permissions. + + Usage: mll-install DEVICE + + DEVICE The device where Minmal Linux Live will be installed. Specify only + the name, e.g. 'sda'. The installer will automatically convert this + to '/dev/sda' and will exit with warning message if the device does + not exist. + + mll-install sdb + + The above example installs Minimal Linux Live on '/dev/sdb'. + +DEOF + + exit 0 +fi + +if [ ! "\$(id -u)" = "0" ] ; then + echo "You need root permissions. Use '-h' or '--help' for more information." + exit 1 +fi + +if [ ! -e /dev/\$1 ] ; then + echo "Device '/dev/\$1' does not exist. Use '-h' or '--help' for more information." + exit 1 +fi + +cat << DEOF + + Minimal Linux Live will be installed on device '/dev/\$1'. The device will be + formatted with Ext2 and all previous data will be lost. Press 'Ctrl + C' to + exit or any other key to continue. + +DEOF + +read -n1 -s + +umount /dev/\$1 2>/dev/null +sleep 1 +mkfs.ext2 /dev/\$1 +mkdir /tmp/mnt/inst +mount /dev/\$1 /tmp/mnt/inst +sleep 1 +cd /tmp/mnt/device +cp -r kernel.xz rootfs.xz syslinux.cfg src minimal /tmp/mnt/inst 2>/dev/null +cd /tmp/mnt/inst +/sbin/extlinux --install . +cd .. +umount /dev/\$1 +sleep 1 +rmdir /tmp/mnt/inst + +cat << DEOF + + Installation is now complete. Device '/dev/\$1' should be bootable now. Check + the above output for any errors. You need to remove the ISO image and restart + the system. Let us hope the installation process worked!!! :) + +DEOF + +cd \$CURRENT_DIR + +CEOF + +chmod +rx sbin/mll-install + +# 'mll-install' END + +if [ ! -d "$SRC_DIR/work/syslinux" ] ; then +echo "The installer depends on Syslinux which is missing. Cannot continue." + exit 1 +fi; + +cd $SRC_DIR/work/syslinux +cd $(ls -d syslinux-*) + +cp bios/extlinux/extlinux \ + $SRC_DIR/work/overlay/mll_utils/sbin + +# Big mama hack - find workaround and remove it!!! +# Both syslinux and extlinux are 32-bit executables which require 32-bit libs. +mkdir -p $SRC_DIR/work/overlay/mll_utils/lib +mkdir -p $SRC_DIR/work/overlay/mll_utils/usr/lib +cp /lib/ld-linux.so.2 \ + $SRC_DIR/work/overlay/mll_utils/lib +cp /lib/i386-linux-gnu/libc.so.6 \ + $SRC_DIR/work/overlay/mll_utils/usr/lib +# Big mama hack - end. + +echo "Minimal Linux Live installer has been generated." + +cd $SRC_DIR + diff --git a/src/overlay_mll_utils_03_install.sh b/src/overlay_mll_utils_04_install.sh similarity index 100% rename from src/overlay_mll_utils_03_install.sh rename to src/overlay_mll_utils_04_install.sh