diff options
author | Cem Keylan <cem@ckyln.com> | 2019-12-10 02:11:23 +0300 |
---|---|---|
committer | Cem Keylan <cem@ckyln.com> | 2019-12-10 02:11:23 +0300 |
commit | ceaafd986586ff12e93c82ac33e4b7140ce81104 (patch) | |
tree | 2a9754a42596cfedd94a592304f58fe9797f7a6a | |
download | mkrootfs-ceaafd986586ff12e93c82ac33e4b7140ce81104.tar.gz |
initial commit
-rw-r--r-- | LICENSE | 21 | ||||
-rw-r--r-- | README | 10 | ||||
-rw-r--r-- | config.def | 44 | ||||
-rwxr-xr-x | mkrootfs.sh | 82 |
4 files changed, 157 insertions, 0 deletions
@@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 Cem Keylan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. @@ -0,0 +1,10 @@ +carbs base +========== + +Tool for generating the rootfs tarball +You should execute the programs on the +base directory, they also provide instructions. + +Currently, this bootstrapper is not in a +functional state. Do not use it if your +intention is not to troubleshoot the program. diff --git a/config.def b/config.def new file mode 100644 index 0000000..44ba757 --- /dev/null +++ b/config.def @@ -0,0 +1,44 @@ +# +# Configuration file for Carbs bootstrapper +# + +# Root directory +# This is where the rootfs will be installed. +MNTDIR="/mnt" + +# List of packages to be installed +# Most of those are already dependencies +# of each other but it is not a bad idea +# to put them to the list anyway. +PKGS="baselayout kiss musl gcc mandoc make gzip xz zlib bzip2 binutils bison curl git perl linux-headers m4 flex busybox pkgconf rsync libressl libelf" + +# Build flags +# It is a good idea to not use flags like "native" +# If you plan on using the tarball on another computer +# due to architechtural differences. +CFLAGS="-march=x86-64 -mtune=generic -pipe -Os" +CXXFLAGS="-march=x86-64 -mtune=generic -pipe -Os" +MAKEFLAGS="-j$(nproc)" + +# Repository +# This repository will be cloned to /tmp/repo on the +# host, and /var/db/kiss/repo on the target system. +REPO="git://git.carbslinux.org/repository" +HOST_REPO_PATH="/tmp/repo/core" + +export MNTDIR PKGS CFLAGS CXXFLAGS REPO HOST_REPO_PATH MAKEFLAGS + +postinstall() { + # You can preferably add some custom + # commands if you want a postinstall + # procedure. This runs right after kiss + # install is complete + + # Currently default function is 'true' + # because there is nothing else to be done, + # but you can safely remove it if you will + # be adding some post-installation commands + true +} + +# vim:filetype=sh 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!" |