diff options
Diffstat (limited to 'include/lib.sh')
-rw-r--r-- | include/lib.sh | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/include/lib.sh b/include/lib.sh index 2cd8c0d7..9a5faabb 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -7,8 +7,6 @@ export LC_COLLATE=C export LC_ALL=C _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0" -kbnotice="Insert a .gkb file from config/data/grub/keymap/ as keymap.gkb \ -if you want a custom keymap in GRUB; use cbfstool from elf/cbfstool." ifdtool="elf/ifdtool/default/ifdtool" cbfstool="elf/cbfstool/default/cbfstool" @@ -58,8 +56,7 @@ e() estr="[ -$es_t \"\$1\" ] || return 1" [ $# -gt 2 ] && estr="[ -$es_t \"\$1\" ] && return 1" && es2="missing" - eval "$estr" - printf "%s %s\n" "$1" "$es2" 1>&2 + eval "$estr"; printf "%s %s\n" "$1" "$es2" 1>&2 } install_packages() @@ -106,7 +103,8 @@ expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \ 1>/dev/null 2>/dev/null || export XBMK_THREADS=1 # user gave a non-integer x_() { - [ $# -lt 1 ] || $@ || $err "Unhandled non-zero exit: $@"; return 0 + [ $# -lt 1 ] || $@ || \ + $err "Unhandled non-zero exit: $(echo "$@")"; return 0 } [ -e ".git" ] || [ -f "version" ] || printf "unknown\n" > version || \ @@ -121,8 +119,7 @@ versiondate_="$versiondate" [ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \ --pretty='%ct' HEAD)" || versiondate="$versiondate_" for p in projectname version versiondate projectsite; do - chkvars "$p" - eval "x_ printf \"%s\\n\" \"\$$p\" > $p" + chkvars "$p"; eval "x_ printf \"%s\\n\" \"\$$p\" > $p" done relname="$projectname-$version" export LOCALVERSION="-$projectname-${version%%-*}" @@ -147,8 +144,7 @@ mkrom_tarball() printf "%s\n" "$versiondate" > "$1/versiondate" || $err "$1 !vdate" printf "%s\n" "$projectname" > "$1/projectname" || $err "$1 !pname" - mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz" - x_ rm -Rf "$1" + mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz"; x_ rm -Rf "$1"; : } mktarball() @@ -182,7 +178,7 @@ rmgit() singletree() { for targetfile in "config/${1}/"*/target.cfg; do - [ -e "$targetfile" ] && [ -f "$targetfile" ] && return 1 + [ -e "$targetfile" ] && [ -f "$targetfile" ] && return 1; : done; return 0 } @@ -208,13 +204,35 @@ download() vendor_checksum() { [ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1 - printf "Bad checksum for file: %s\n" "$2" 1>&2 - rm -f "$2" || : + printf "Bad checksum for file: %s\n" "$2" 1>&2; rm -f "$2" || :; : } cbfs() { + fRom="$1" # image to operate on + fAdd="$2" # file to add + fName="$3" # filename when added in CBFS + ccmd="add-payload" && [ $# -gt 3 ] && ccmd="add" - lzma="-c lzma" && [ $# -gt 3 ] && lzma="-t raw" - x_ "$cbfstool" "$1" $ccmd -f "$2" -n "$3" $lzma + lzma="-c lzma" && [ $# -gt 3 ] && [ $# -lt 5 ] && lzma="-t $4" + + # hack. TODO: do it better. this whole function is cursed + if [ $# -gt 4 ]; then + # add flat binary for U-Boot (u-boot.bin) on x86 + if [ "$5" = "0x1110000" ]; then + ccmd="add-flat-binary" + lzma="-c lzma -l 0x1110000 -e 0x1110000" + fi + fi + + "$cbfstool" "$fRom" $ccmd -f "$fAdd" -n "$fName" $lzma || \ + $err "CBFS fail: $fRom $ccmd -f '$fAdd' -n '$fName' $lzma"; : +} + +mk() +{ + mk_flag="$1" || $err "No argument given" + shift 1 && for mk_arg in $@; do + ./mk $mk_flag $mk_arg || $err "./mk $mk_flag $mk_arg"; : + done; : } |