#!/bin/bash ROOT_DIR=$(readlink -f $(dirname $(readlink -f $0))/..) SELF=$(readlink -f $0) print_usage() { echo "Toolkit for creating systemd based initramfs images (osid)" echo "Usage: $(basename $SELF) [OPTIONS] CMD" echo "Options:" echo -e " --rebuild-all, -r \t force recreation of build env" echo -e " --rebuild-cpio \t force recreation of cpio base" echo -e " --rebuild-sqfs \t force recreation of sqfs base" echo -e " --help, -h \t print help" echo "Commands (CMD):" echo -e " clean \t clean build dir" echo -e " initramfs \t create only initramfs" echo -e " iso \t create iso" } rebuild_cpio=0 rebuild_sqfs=0 build_initramfs=0 build_iso=0 clean=0 if [ "x$1" = "x" ]; then print_usage exit 0 elif [ "x$(whoami)" != "xroot" ]; then echo "ERROR: You need root rights to run $SELF." echo " (required for creating dev files)" exit 1 fi while [ "x$1" != "x" ]; do arg=$1 if [ "x$arg" = "x--rebuild-all" -o "x$arg" = "x-r" ]; then rebuild_cpio=1 rebuild_sqfs=1 elif [ "x$arg" = "x--rebuild-cpio" ]; then rebuild_cpio=1 elif [ "x$arg" = "x--rebuild-sqfs" -o "x$arg" = "x-s" ]; then rebuild_sqfs=1 elif [ "x$arg" = "x--help" -o "x$arg" = "x-h" ]; then print_usage exit 0 elif [ "x$arg" = "xiso" ]; then build_initramfs=1 build_iso=1 elif [ "x$arg" = "xinitramfs" ]; then build_initramfs=1 elif [ "x$arg" = "xclean" ]; then clean=1 else echo "ERROR: Unkown argument ($arg)." print_usage exit 1 fi shift done if [ $rebuild_cpio -eq 1 ]; then rm -rf ${ROOT_DIR}/build/cpio-base fi if [ $rebuild_sqfs -eq 1 ]; then rm -rf ${ROOT_DIR}/build/sqfs-base fi if [ $clean -eq 1 ]; then rm -rf ${ROOT_DIR}/build fi if [ $build_initramfs -eq 1 ]; then ${ROOT_DIR}/inc/build.initramfs.sh && exit 0 fi if [ $build_iso -eq 1 ]; then ${ROOT_DIR}/inc/build.iso.sh fi exit 0