lots of progress, still WIP

This commit is contained in:
ThatGeekyWeeb 2021-09-05 02:42:18 -04:00
parent 243e700bd6
commit af6bc5d5ba
4 changed files with 57 additions and 5 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
./chroot/*
./bin/*

39
base.sh
View File

@ -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

13
bscripts/ex Normal file
View File

@ -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

7
bscripts/kati Normal file
View File

@ -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"