diff options
-rw-r--r-- | include/inject.sh | 43 | ||||
-rw-r--r-- | include/lib.sh | 11 | ||||
-rwxr-xr-x | mk | 23 |
3 files changed, 38 insertions, 39 deletions
diff --git a/include/inject.sh b/include/inject.sh index e5282861..0886adc8 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -282,19 +282,18 @@ extract_tbfw() { chkvars TBFW_size # size in bytes, matching TBFW's flash IC x_ mkdir -p tmp - x_ rm -f tmp/tb.bin - find "$appdir" -type f -name "TBT.bin" > "tmp/tb.txt" || \ - $err "extract_tbfw $_dest: Can't extract TBT.bin - $dontflash" - while read -r f; do - [ -f "$f" ] || continue - [ -L "$f" ] && continue - x_ cp "$f" "tmp/tb.bin" - break - done < "tmp/tb.txt" + + x_ rm -f tmp/tb.bin && fx_ copy_tbfw "$appdir" -type f -name "TBT.bin" + x_ dd if=/dev/null of=tmp/tb.bin bs=1 seek=$TBFW_size x_ cp "tmp/tb.bin" "$_dest" } +copy_tbfw() +{ + [ -f "$1" ] && [ ! -L "$1" ] && x_ cp "$1" "tmp/tb.bin" && return 1; : +} + extract_fspm() { copy_fsp M; : @@ -419,16 +418,10 @@ patch_release_roms() hashfile="$_hashes" && break; : done - x_ mkdir -p "tmp" && [ -L "tmp/rom.list" ] && \ - $err "'$archive' -> tmp/rom.list is a symlink - $dontflash" - - find "$tmpromdir" -maxdepth 1 -type f -name "*.rom" > "tmp/rom.list" \ - || $err "'$archive' -> Can't make tmp/rom.list - $dontflash" + x_ mkdir -p "tmp" if readkconfig; then - while read -r _xrom ; do - process_release_rom "$_xrom" || break - done < "tmp/rom.list" + fx_ prep_rom "$tmpromdir" -maxdepth 1 -type f -name "*.rom" [ "$nukemode" != "nuke" ] || \ printf "Make sure you inserted vendor files: %s\n" \ "$vguide" > "$tmpromdir/README.md" || : @@ -462,7 +455,7 @@ patch_release_roms() "$archive" || $err "'$archive' -> Can't overwrite - $dontflash"; : } -process_release_rom() +prep_rom() { _xrom="$1" _xromname="${1##*/}" @@ -578,13 +571,7 @@ modify_mac() [ "$new_mac" != "restore" ] && x_ make -C util/nvmutil && \ x_ "$nvm" tmp/gbe setmac "$new_mac" - find "$tmpromdir" -maxdepth 1 -type f -name "*.rom" > "tmp/rom.list" \ - || $err "'$archive' -> Can't make tmp/rom.list - $dontflash" - - while read -r _xrom; do - e "$_xrom" f && xchanged="y" && x_ \ - "$ifdtool" $ifdprefix -i GbE:tmp/gbe "$_xrom" -O "$_xrom" - done < "tmp/rom.list" + fx_ newmac "$tmpromdir" -maxdepth 1 -type f -name "*.rom" printf "\nGbE NVM written to '%s':\n" "$archive" x_ "$nvm" tmp/gbe dump | grep -v "bytes read from file" || : @@ -593,3 +580,9 @@ modify_mac() printf "\nDefault GbE file '%s' written, unmodified.\n" \ "${CONFIG_GBE_BIN_PATH##*../}"; : } + +newmac() +{ + e "$1" f && xchanged="y" && x_ \ + "$ifdtool" $ifdprefix -i GbE:tmp/gbe "$1" -O "$1"; : +} diff --git a/include/lib.sh b/include/lib.sh index bef2a16f..507a37c1 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -128,6 +128,17 @@ setvars() printf "%s\n" "${_setvars% }" } +fx_() +{ + fd="`mktemp`" + xx="$1" && shift 1 + find "$@" | sort > "$fd" || $err "!find $(echo "$@") > \"$fd\"" + while read -r fx; do + "$xx" "$fx" || break; : + done < "$fd" + x_ rm -f "$fd" +} + x_() { [ $# -lt 1 ] || "$@" || $err "Unhandled error for: $(echo "$@")"; : @@ -278,20 +278,9 @@ check_project_hashes() [ ! -f "$XBMK_CACHE/hash/$project$tree" ] || \ read -r old_pjhash < "$XBMK_CACHE/hash/$project$tree" - x_ rm -f "$xbmktmp/project.list" "$xbmktmp/project.hash" \ - "$xbmktmp/project.tmp" - x_ touch "$xbmktmp/project.tmp" "$xbmktmp/project.hash" - - for rmchk in "$datadir" "$configdir/$tree" "$mdir"; do - [ ! -d "$rmchk" ] || find "$rmchk" -type f -not -path \ - "*/.git*/*" >> "$xbmktmp/project.tmp" || $err "!fh $rmchk" - done - sort "$xbmktmp/project.tmp" > "$xbmktmp/project.list" || $err "!pj srt" - - while read -r rmchk; do - [ ! -f "$rmchk" ] || x_ sha512sum "$rmchk" | awk \ - '{print $1}' >> "$xbmktmp/project.hash" || $err "!h $rmchk" - done < "$xbmktmp/project.list" + x_ rm -f "$xbmktmp/project.hash" + fx_ create_project_hash "$datadir" "$configdir/$tree" "$mdir" \ + -type f -not -path "*/.git*/*" pjhash="$(sha512sum "$xbmktmp/project.hash" | awk '{print $1}')" || : [ "$pjhash" != "$old_pjhash" ] && badhash="y" @@ -304,6 +293,12 @@ check_project_hashes() "elf/$project/$tree" "elf/$project/$target"; : } +create_project_hash() +{ + [ ! -f "$1" ] || x_ sha512sum "$1" | awk \ + '{print $1}' >> "$xbmktmp/project.hash" || $err "!h $1"; : +} + check_cross_compiler() { xgccargs="UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS" |