aboutsummaryrefslogtreecommitdiff
path: root/mkrootfs.sh
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2019-12-10 02:11:23 +0300
committerCem Keylan <cem@ckyln.com>2019-12-10 02:11:23 +0300
commitceaafd986586ff12e93c82ac33e4b7140ce81104 (patch)
tree2a9754a42596cfedd94a592304f58fe9797f7a6a /mkrootfs.sh
downloadmkrootfs-ceaafd986586ff12e93c82ac33e4b7140ce81104.tar.gz
initial commit
Diffstat (limited to 'mkrootfs.sh')
-rwxr-xr-xmkrootfs.sh82
1 files changed, 82 insertions, 0 deletions
diff --git a/mkrootfs.sh b/mkrootfs.sh
new file mode 100755
index 0000000..dff0d14
--- /dev/null
+++ b/mkrootfs.sh
@@ -0,0 +1,82 @@
+#!/bin/sh -e
+# Bootstrapper for Carbs Linux
+# See LICENSE file for copyright and license details
+
+
+# Functions
+out() { printf "%s\\n" "$@" ;}
+msg() { printf "\033[1;35m=>\033[m $1\\n" ;}
+error() { msg "\033[1;31mERROR: \033[m$1" ;} >&2
+die() { error "$1"; exit 1 ;}
+ask() { printf "\033[1;33m== $1 ==\\n(y/N) "; read ans; case "$ans" in [Yy]*) return 0 ;; *) return 1 ;; esac ;}
+
+
+# If there is no config file, we copy config.def
+# to config. After we make sure config file is
+# in place, we source the contents
+! [ -e config ] && cp config.def config
+. "$PWD/config"
+
+# Check whether absolutely required variables are set.
+[ -n "$PKGS" ] || die "You must set PKGS variable to continue the bootstrapper"
+[ -n "$MNTDIR" ] || die "You must specify fakeroot location \"MNTDIR\" in order to continue the bootstrapper"
+
+
+# Print variables from the configuration file
+out \
+"Here are the configuration values:" \
+"" \
+"MNTDIR = $MNTDIR" \
+"" \
+"Build Options" \
+"CFLAGS = $CFLAGS" \
+"CXXFLAGS = $CXXFLAGS" \
+"MAKEFLAGS = $MAKEFLAGS" \
+"" \
+"Repository and package options" \
+"" \
+"REPO = $REPO" \
+"REPOSITORY PATH = $REPO_PATH" \
+"PKGS = $PKGS"
+
+
+# Check if there is no NOWELCOME variable set in
+# the configuration file. If there is such variable
+# set in the configuration, the bootstrapper will
+# start immediately
+if [ -z "$NOCONFIRM" ]; then
+ ask "Do you want to start the bootstrapper?" || die "User exited"
+else
+ msg "NOCONFIRM variable exists, starting without asking."
+fi
+
+
+# Script starts here
+
+msg "Starting Script..."
+
+msg "Setting KISS_ROOT to $MNTDIR"
+export KISS_ROOT="$MNTDIR"
+
+# Check whether REPO and REPO_PATH variables exist
+if [ -n "$REPO" ]; then
+ # Remove if /tmp/repo already exists
+ rm -rf /tmp/repo
+ git clone --depth 1 "$REPO" /tmp/repo
+ export KISS_PATH="${REPO_PATH:-/tmp/repo/core}"
+else
+ msg "REPO variable does not exist, current repository
+will be copied directly to the root filesystem"
+fi
+
+msg "Starting build from the PKGS variable"
+
+# Word Splitting is intentional here, as we are
+# passing package names seperately
+# shellcheck disable=SC2086
+kiss b $PKGS
+msg "Package build complete, starting package installation"
+kiss i $PKGS
+msg "Installation Complete, starting custombuild procedure if there is one"
+custombuild
+msg "Done!"