From af6bc5d5ba163487773ae5b7c9aecae89a32a988 Mon Sep 17 00:00:00 2001 From: ThatGeekyWeeb Date: Sun, 5 Sep 2021 02:42:18 -0400 Subject: [PATCH] lots of progress, still WIP --- .gitignore | 3 ++- base.sh | 39 +++++++++++++++++++++++++++++++++++---- bscripts/ex | 13 +++++++++++++ bscripts/kati | 7 +++++++ 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 bscripts/ex create mode 100644 bscripts/kati diff --git a/.gitignore b/.gitignore index 6a42434..a26b646 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -./chroot/* \ No newline at end of file +./chroot/* +./bin/* diff --git a/base.sh b/base.sh index 49c7b92..ff3b736 100644 --- a/base.sh +++ b/base.sh @@ -6,20 +6,51 @@ has() { alias*|"") return 1 esac } -has go || { echo "The golang compiler is required on the host system..."; exit 1;} +has go || { echo "golang compiler is required on the host system..."; exit 1;} # needed for kati has curl || { echo "curl is required on the host systtem"; exit 1;} # for downloading sources has bsdtar || { echo "bsdtar is required on the host system"; exit 1;} # for extracting sources -rm chroot/builddir -rf 2>/dev/null +has mkdir || { echo "basic coreutils are required..."; exit 1;} +mkdir ./chroot ./bin 2>/dev/null +rm chroot/* bin/* -rf 2>/dev/null # clean chroot and bin before starting mkdir -p chroot/builddir; bdir="$(realpath chroot/builddir)" +cd chroot; org=$(realpath ${PWD}/../) IFS=""; while read -r p; do # no need for EOF check case "$p" in "#"*) ;; # ignore lines with comments - *) org=${PWD}; url="${p##*- }" + *) url="${p##*- }" echo "Downloading/Extracting ${p%% -*} ..." cd ${bdir}; curl -L "$url" --progress-bar | bsdtar -xf -;; esac -done < ./sources # read from sources and download +done < ${org}/sources # read from sources and download cd ${org} +for i in bin etc lib dev usr; do # create some base folders + mkdir -p "${org}/chroot/${i}" +done +# ./loc read func +loc(){ + while read -r p || [ -n "$p" ]; do + case "$p" in # basically grep for $1 + *"${1}"*) printf '%s\n' "${p##*- }" + esac + done < ${org}/loc +} +for i in ${org}/bscripts/*; do # loop over all build scripts + . ${i} # source build script + [ "$pkg" = "ex" ] && continue # DO NOT ATTEMPT TO READ EXAMPLE SCRIPT + IFS=" "; for dep in ${hbinrequires}; do # loop over all host bin deps + has $dep || { echo "$i is required on the hostsystem"; exit 1;} + done + cd ${dir}; ${cmd} + [ -e "${out}" ] && { + chmod +x "${out}" # mark as excutable + cp "${out}" "${org}/bin/" # copy to nG's local bin/ + export PATH="${org}/bin:$PATH" # set PATH to contain local bin/ + # also make sure local bin/ is first in PATH + :;} || { + echo "$out NOT FOUND... CANNOT CONTINUE; BUILD MUST HAVE FAILED" + exit 1 + } +done diff --git a/bscripts/ex b/bscripts/ex new file mode 100644 index 0000000..a8f5896 --- /dev/null +++ b/bscripts/ex @@ -0,0 +1,13 @@ +# example bscript for nG +# MUST start with a shebang for /bin/sh +# --- +#!/bin/sh +pkg=ex # name of pkg; MUST be equal to $0 +dir="$bdir/$(loc $pkg)" # pulls in and sets the location of build folder +hbinrequires="" # required binaries on the host system +gbinrequires="" # required binaries within nG's local bin/ +cbinrequires="" # required binaries within chroot/bin +cmd='' # equal to the literal process required to build $pkg +out="$dir/<>" # equal to outputed binary +static="" # MUST be set if $out is not static +# if $static is set $pkg MUST be recompiled from within chroot diff --git a/bscripts/kati b/bscripts/kati new file mode 100644 index 0000000..b968321 --- /dev/null +++ b/bscripts/kati @@ -0,0 +1,7 @@ +#!/bin/sh +pkg=kati +dir="$bdir/$(loc $pkg)" +hbinrequires="go" +cmd='go build -o kati github.com/google/kati/golang/cmd/kati' +out="$dir/kati" +static="1"