[Android Software/Hacking General [Developers Only]] osm0sis:
My remaining "engineering" (read: hacky :p) build scripts, for completion sake (zipsigner jar can be found in my Complete Shell Script Zip thread):

~/aik-winbuild.sh:

# yeah you know

# aik-winbuild.sh
#
# osm0sis @ xda-developers
#
# requires (in addition to the default basic Cygwin x86 packages):
# cpio, lzop, git, wget, make, gcc-core, gcc-g++, bison, flex, libssl-devel, libSDL2-devel

AIK="/cygdrive/c/Users/chris/Documents/Projects/Android Image Kitchen";
WINTOOLS="$AIK/android_win_tools";

listdep() {
local i;
cd "$WINTOOLS";
for i in *; do
diff /bin/$i $i 2>/dev/null;
done;
}

updatedep() {
local i;
cd "$WINTOOLS";
for i in $(listdep | awk '{ print $5 }'); do
cp -fv /bin/$i "$WINTOOLS/";
done;
}

init() {
local i;
cd $HOME;
echo -e "\nRemoving repos ...";
rm -rf mkbootimg pxa-mkbootimg elftool unpackelf mboot uboot* mkmtkhdr dhtbsign futility blobtools rkflashtool lokitool lz4* bootimg-info;
echo -e "\nCreating repos ...";
for i in mkbootimg pxa-mkbootimg elftool unpackelf mboot mkmtkhdr dhtbsign futility bootimg-info; do
echo "--- Initializing $i";
git clone https://github.com/osm0sis/$i;
done;
echo "--- Initializing uboot"
git clone https://source.denx.de/u-boot/u-boot.git uboot;
echo "--- Initializing blobtools"
git clone https://github.com/AndroidRoot/BlobTools blobtools;
echo "--- Initializing rkflashtool"
git clone https://github.com/linux-rockchip/rkflashtool rkflashtool;
echo "--- Initializing lokitool"
git clone https://github.com/djrbliss/loki lokitool;
echo "--- Initializing lz4";
git clone https://github.com/lz4/lz4;
}

update() {
local i curtag dir;
echo -e "\nUpdating repos ...";

## genericlist + futility blobtools rkflashtool lokitool
genericlist="mkbootimg pxa-mkbootimg elftool unpackelf mboot mkmtkhdr dhtbsign bootimg-info";
for i in $genericlist futility blobtools rkflashtool lokitool; do
cd $HOME/$i;
git checkout master >/dev/null 2>&1;
echo -n "--- $i: ";
git pull origin;
done;

## uboot update
cd $HOME/uboot*;
git fetch --tags >/dev/null;
curtag=$(git tag | grep -vE 'rc' | tail -n 1);
dir="uboot-$(echo $curtag | cut -c 2-)";
echo -n "--- uboot: ";
if [ "$dir" != "$(basename $PWD)" -o "$FORCE" ]; then
echo "Checking out $curtag";
git reset -- . >/dev/null;
git clean -df >/dev/null;
git checkout -- .;
git checkout -f $curtag 2>&1 | tail -n 1;
# work around breakage on older make versions
sed -i 's/undefine MK_ARCH/override MK_ARCH =/' Makefile;
# undo broken former non-POSIX Cygwin/Windows changes
sed -i 's/HOSTCFLAGS\t+= -ansi/HOSTCFLAGS += $(CSTD_FLAG)/' Makefile;
# neuter setlocalversion to give us only the proper revision
sed -i "s/printf '\%s' -dirty/printf '\%s'/" scripts/setlocalversion;
# fix missing Cygwin, macOS and NDK includes/defines
sed -i 's;# include <byteswap.h>;# include <byteswap.h>\n#elif defined(__CYGWIN__)\n# include <linux/types.h>\n# include <linux/byteorder/swab.h>;' include/compiler.h;
sed -i 's|#ifdef __FreeBSD__|#ifdef __ANDROID__\ntypedef unsigned short ushort;\n#endif\n#ifdef __FreeBSD__|' include/compiler.h;
sed -i 's|#include <asm/posix_types.h>|#include <asm/posix_types.h>\n\n#ifndef __kernel_ulong_t\ntypedef long __kernel_long_t;\ntypedef unsigned long __kernel_ulong_t;\n#endif\n\n#ifndef __kernel_daddr_t\ntypedef int __kernel_daddr_t;\n#endif\n\n#ifndef __kernel_ino_t\ntypedef __kernel_ulong_t __kernel_ino_t;\n#endif|' include/linux/posix_types.h;
sed -i 's|malloc.h|stdlib.h|' lib/rsa/rsa-sign.c;
# work around missing macOS clock_gettime and CLOCK_MONOTONIC
wget --no-check-certificate -O tools/timing_mach.c https://raw.githubusercontent.com/ChisholmKyle/PosixMachTiming/master/src/timing_mach.c;
wget --no-check-certificate -O tools/timing_mach.h https://raw.githubusercontent.com/ChisholmKyle/PosixMachTiming/master/src/timing_mach.h;
sed -i 's|#include <version.h>|#include <version.h>\n\n#include "timing_mach.c"|' tools/image-host.c;
cd ..;
mv uboot* $dir;
else
echo "Already up to date.";
fi;

## lz4
cd $HOME/lz4*;
git fetch --tags >/dev/null;
curtag=$(git describe --tags `git rev-list --tags --max-count=1`);
dir="lz4-$(echo $curtag | cut -c 2-)";
echo -n "--- lz4: ";
if [ "$dir" != "$(basename $PWD)" -o "$FORCE" ]; then
echo "Checking out $curtag";
git reset -- . >/dev/null;
git clean -df >/dev/null;
git checkout -- .;
git checkout -f $curtag 2>&1 | tail -n 1;
cd ..;
mv lz4* $dir;
else
echo "Already up to date.";
fi;

## uboot config
cd $HOME/uboot*;
echo -e "\nConfiguring uboot ...";
make sandbox_defconfig;
# disable unneeded options to avoid build errors and reduce binary size
sed -i 's|^CONFIG_CMD_NET=y|# CONFIG_CMD_NET is not set|' .config;
sed -i 's|^CONFIG_CMD_LOADS=y|# CONFIG_CMD_LOADS is not set|' .config;
sed -i 's|^CONFIG_EFI_LOADER=y|# CONFIG_EFI_LOADER is not set|' .config;
sed -i 's|^CONFIG_NETCONSOLE=y|# CONFIG_NETCONSOLE is not set|' .config;
sed -i 's|^CONFIG_TOOLS_MKEFICAPSULE=y|# CONFIG_TOOLS_MKEFICAPSULE is not set|' .config;
sed -i 's|^CONFIG_VIDEO_LOGO=y|# CONFIG_VIDEO_LOGO is not set|' .config;
}

build() {
local i;
for i in mkbootimg pxa-mkbootimg elftool unpackelf mboot mkmtkhdr dhtbsign futility; do
cd $HOME/$i;
git checkout master;
make clean;
make all;
mv -fv *.exe "$WINTOOLS/";
done;
rm -f "$WINTOOLS"/pxa*-dtbTool.exe;

cd $HOME/uboot*;
make clean;
make HOSTCC="gcc -Wno-char-subscripts -ffunction-sections -O3 -Wl,-s" tools-only;
mv -fv tools/dumpimage.exe "$WINTOOLS/";
mv -fv tools/mkimage.exe "$WINTOOLS/";

cd $HOME/blobtools;
git checkout master;
make clean;
make CFLAGS="-I. -Ishared -Wall -ggdb -ffunction-sections -O3" LDFLAGS="-Wl,--gc-sections,-s";
mv -fv *.exe "$WINTOOLS/";

cd $HOME/rkflashtool;
git checkout master;
make clean
make CFLAGS="-ffunction-sections -O3" LDFLAGS="-Wl,--gc-sections,-s" rkcrc;
mv -fv *.exe "$WINTOOLS/";

cd $HOME/lokitool;
git checkout master;
make clean;
make CC=gcc CC_STRIP=strip CFLAGS="-ffunction-sections -O3" LDFLAGS="-Wl,--gc-sections,-s";
mv -fv *.exe "$WINTOOLS/";

cd $HOME/lz4*/programs;
make clean;
CC="gcc -ffunction-sections -Wl,--gc-sections,-s" make VERBOSE=1 lz4;
mv -fv *.exe "$WINTOOLS/";
}

case $1 in
listdep|updatedep|init|update|build) $1;;
help|"") echo "aik-winbuild.sh listdep, updatedep, init, update, build";;
esac;

Compares Cygwin's system binaries/libraries against those included in AIK to list the differences and update as necessary, and forces fresh builds of the binaries compiled from source (necessary whenever the Cygwin libraries are updated to avoid compatibility issues).

~/aik-bundle.sh:

#!/bin/bash
# this right here

# aik-bundle.sh
#
# osm0sis @ xda-developers
#
# requires (in addition to the default basic Ubuntu WSL packages):
# zip, default-jre

bold() { echo -e "\033[1m"$@"\033[0m"; }

reset() {
bold "--- Removing AIK packages build environment ...";
rm -rfv Android-Image-Kitchen AIK-mobile AIK-Linux zipsigner-*.jar AIK-Linux-*-ALL.tar.gz AIK-mobile-*-ALL*.zip UPDATE-AIK.Mobile.Installer.*-ALL-signed.zip;

}

init() {
local i zipsigner;
reset;

bold "--- Initializing AIK packages build environment ...";
bold "- Cloning Android-Image-Kitchen git repository ...";
git clone -b master https://github.com/osm0sis/Android-Image-Kitchen;

bold "- Cloning AIK-mobile git repository ...";
git clone -b AIK-mobile https://github.com/osm0sis/Android-Image-Kitchen AIK-mobile;

bold "- Cloning AIK-Linux git repository ...";
git clone -b AIK-Linux https://github.com/osm0sis/Android-Image-Kitchen AIK-Linux;

bold "- Extracting binary assets from AIK-mobile installer latest release zip ...";
cd AIK-mobile;
unzip -n "$(find $HOME/projects/AIK\ Archive/UPDATE-AIK.Mobile.Installer.v*-signed.zip | tail -n1)";
cd binarch;
tar -xzvf xz.tar.gz && rm -f xz.tar.gz;
for i in arm arm64 x86 x86_64 mips mips64; do
tar -xJvf $i.tar.xz && rm -f $i.tar.xz;
done;

bold "- Extracting binary assets from AIK-Linux latest release zip ...";
cd $HOME;
tar -xzv --skip-old-files -f "$(find $HOME/projects/AIK\ Archive/AIK-Linux-v*-ALL.tar.gz | tail -n1)";

bold "- Downloading zipsigner ...";
zipsigner=$(wget -qO- https://github.com/opengapps/opengapps/tree/master/scripts/zipsigner-resources | grep -o 'opengapps/.*jar' | cut -d\" -f1 | sed 's/blob/raw/');
wget -O $HOME/$(basename $zipsigner) https://github.com/$zipsigner;
}

main() {
local zipflag stdout tarflag tag i;

zipflag=-q;
stdout=/dev/null;
tag=WIP;

until [ ! "$1" ]; do
case $1 in
help) echo "aik-bundle.sh reset, init, [verbose] [tag]"; exit 1;;
reset|init) $1; return;;
verbose) stdout=/dev/stdout; tarflag=v; unset zipflag; shift;;
*) tag=$1; shift;;
esac;
done;

bold "--- Bundling ...";
rm -f AIK-Linux-*-ALL.tar.gz AIK-mobile-*-ALL*.zip UPDATE-AIK.Mobile.Installer.*-ALL-signed.zip AIK-mobile/binarch/*.tar.* 2>/dev/null;
bold "- Packing \"AIK-Linux-$tag-ALL.tar.gz\" ...";
tar -cz$tarflag --exclude .git --owner=1000 --group=1000 -f AIK-Linux-$tag-ALL.tar.gz AIK-Linux;

bold "- Packing \"AIK-mobile-$tag-ALL.zip\" ...";
cd AIK-mobile/binarch;
for i in arm arm64 x86 x86_64 mips mips64; do
tar -cJ$tarflag --exclude xz --owner=0 --group=0 -f $i.tar.xz $i;
done;
tar -cz$tarflag --owner=0 --group=0 -f xz.tar.gz */xz;
cd ..;
zip -9 -x ".git" "binarch/arm/*" "binarch/arm64/*" "binarch/x86/*" "binarch/x86_64/*" "binarch/mips/*" "binarch/mips64/*" -r $zipflag $HOME/AIK-mobile-$tag-ALL.zip *;
rm -f binarch/*.tar.*;
cd $HOME;

if [ "$tag" != "WIP" ]; then
bold "- Signing as \"UPDATE-AIK.Mobile.Installer.$tag-ALL-signed.zip\" ...";
java -jar zipsigner-*.jar AIK-mobile-$tag-ALL.zip AIK-mobile-$tag-ALL-signed.zip;
mv -f AIK-mobile-$tag-ALL-signed.zip UPDATE-AIK.Mobile.Installer.$tag-ALL-signed.zip 2>/dev/null;
rm -f AIK-mobile-*-ALL.zip /tmp/signAPK*.tmp 2>/dev/null;
fi;
}

cd $HOME;
main "$@";
exit 0;

Packages AIK-Linux and AIK-mobile releases.

~/build/aik-lnxbuild.sh (Deprecated by switch to WSL2):

#!/bin/bash

# aik-lnxbuild.sh (Deprecated by switch to WSL2)
#
# osm0sis @ xda-developers
#
# requires (in addition to the default basic Ubuntu Server packages):
# make, gcc-core, bison, flex, libssl-dev, libSDL2-dev, libuuid-dev, libgnutls-dev

home=/home/osm0sis/build;
xtools="$home/x-tools";
build="$home/AIK-build";

mkimage_dumpimage() {
local cflags curtag dir ldflags libarch libs savedpath;
case $1 in
update)
cd libcrypto_static;
git checkout master > /dev/null 2>&1;
echo -n "--- libcrypto_static: ";
git pull origin;
cd ..;
cd uboot* 2>/dev/null;
git fetch --tags > /dev/null;
curtag=$(git tag | grep -vE 'rc' | tail -n 1);
dir="uboot-$(echo $curtag | cut -c 2-)";
echo -n "--- mkimage/dumpimage: ";
if [ "$dir" != "$(basename $PWD)" -o "$force" ]; then
echo "Checking out $curtag";
git reset -- . > /dev/null;
git clean -df > /dev/null;
git checkout -- .;
git checkout -f $curtag 2>&1 | tail -n 1;
# work around breakage on older make versions
sed -i 's/undefine MK_ARCH/override MK_ARCH =/' Makefile;
# undo broken former non-POSIX Cygwin/Windows changes
sed -i 's/HOSTCFLAGS\t+= -ansi/HOSTCFLAGS += $(CSTD_FLAG)/' Makefile;
# neuter setlocalversion to give us only the proper revision
sed -i "s/printf '\%s' -dirty/printf '\%s'/" scripts/setlocalversion;
# fix missing Cygwin, macOS and NDK includes/defines
sed -i 's;# include <byteswap.h>;# include <byteswap.h>\n#elif defined(__CYGWIN__)\n# include <linux/types.h>\n# include <linux/byteorder/swab.h>;' include/compiler.h;
sed -i 's|#ifdef __FreeBSD__|#ifdef __ANDROID__\n# include <linux/byteorder/swab.h>\ntypedef unsigned long ulong;\n#endif\n#ifdef __FreeBSD__|' include/compiler.h;
sed -i 's|#include <asm/posix_types.h>|#include <asm/posix_types.h>\n\n#ifndef __kernel_ulong_t\ntypedef long __kernel_long_t;\ntypedef unsigned long __kernel_ulong_t;\n#endif\n\n#ifndef __kernel_daddr_t\ntypedef int __kernel_daddr_t;\n#endif\n\n#ifndef __kernel_ino_t\ntypedef __kernel_ulong_t __kernel_ino_t;\n#endif|' include/linux/posix_types.h;
sed -i 's|malloc.h|stdlib.h|' lib/rsa/rsa-sign.c;
# work around missing macOS clock_gettime and CLOCK_MONOTONIC
wget --no-check-certificate -O tools/timing_mach.c https://raw.githubusercontent.com/ChisholmKyle/PosixMachTiming/master/src/timing_mach.c;
wget --no-check-certificate -O tools/timing_mach.h https://raw.githubusercontent.com/ChisholmKyle/PosixMachTiming/master/src/timing_mach.h;
sed -i 's|#include <version.h>|#include <version.h>\n\n#include "timing_mach.c"|' tools/image-host.c;
cd ..;
mv uboot* $dir;
else
echo "Already up-to-date.";
fi;
return;
;;
config)
cd uboot* 2>/dev/null;
echo "--- Configuring mkimage/dumpimage";
make sandbox_defconfig;
# disable unneeded options to avoid build errors and reduce binary size
sed -i 's|^CONFIG_CMD_NET=y|# CONFIG_CMD_NET is not set|' .config;
sed -i 's|^CONFIG_CMD_LOADS=y|# CONFIG_CMD_LOADS is not set|' .config;
sed -i 's|^CONFIG_EFI_LOADER=y|# CONFIG_EFI_LOADER is not set|' .config;
sed -i 's|^CONFIG_NETCONSOLE=y|# CONFIG_NETCONSOLE is not set|' .config;
return;
;;
esac;

cd uboot* 2>/dev/null;
savedpath="$PATH";
export PATH="$(dirname $CROSS_COMPILE):$PATH";
cflags="-ffunction-sections -O3 -static";
ldflags="-Wl,--gc-sections,-s,-static";
# use prebuilt NDK libraries
case $output in
*arm) libarch=armeabi;;
*arm64) libarch=arm64-v8a;;
*) libarch=$(basename $output);;
esac;
libs="$home/libcrypto_static/obj/local/$libarch";
make $ARGS CROSS_BUILD_TOOLS=y HOSTCC="gcc -Wno-char-subscripts" CC="$(basename $CROSS_COMPILE)gcc $cflags $ldflags -I../libcrypto_static/include -I../libcrypto_static/crypto -L$libs" tools-only;
mv -f tools/mkimage "$build/$output/mkimage";
mv -f tools/dumpimage "$build/$output/dumpimage";
make $args clean;
export PATH="$savedpath";
return;
}

clean() {
if [ ! "$noclean" ]; then
echo -e "\nCleaning ...";
for i in uboot*; do
cd "$home/"$i;
for dep in */.deps/*; do [ -e $dep ] && echo "# dummy" > $dep; done;
for dep in .deps/*; do [ -e $dep ] && echo "# dummy" > $dep; done;
make clean > /dev/null 2>&1;
done;
fi;
cd $home;
return;
}

cleanall() {
if [ ! "$noclean" ]; then
clean;
rm -rf "$build";
fi;
return;
}

init() {
cd "$home";
echo -e "\nRemoving repos ...";
rm -rf uboot* libcrypto_static;
echo -e "\nCreating repos ...";
echo "--- Initializing uboot (silent) (and ssl support)"
git clone http://git.denx.de/u-boot.git uboot;
git clone https://github.com/osm0sis/libcrypto_static;
action="update ";
main $action;
return;
}

main() {
case $1 in
update*) cleanall; echo -e "\nUpdating repos ...";;
config*) clean;;
*) cleanall;;
esac;
for output in mobile/arm mobile/x86 mobile/mips mobile/arm64 mobile/x86_64 mobile/mips64; do
queue="mkimage_dumpimage";
case $1 in
update|config) ;;
*) echo -e "\nBuilding for $output ...";
mkdir -p "$build/$output";
case $output in
*arm) arch=arm-linux-androideabi;;
*x86) arch=i686-linux-android;;
*mips) arch=mipsel-linux-android;;
*arm64) arch=aarch64-linux-android;;
mobile/x86_64) arch=x86_64-linux-android;;
*mips64) arch=mips64el-linux-android;;
esac;
export CROSS_COMPILE=$(echo "$xtools"/$arch* | rev | cut -d\ -f1 | rev)/bin/$arch-;
;;
esac;
for i in $queue; do
case $1 in
update|config) ;;
*) echo "--- $action${i/_//}";;
esac;
cd "$home";
$i $1;
done;
case $1 in
update|config) return;;
*) unset CROSS_COMPILE;;
esac;
done;
echo -e "\nDone!";
return;
}

cd "$home";
args=--silent;
until [ ! $1 ]; do
case $1 in
verbose) unset args;;
noclean) noclean=1;;
force) force=1;;
update|config) action="$1 ";;
clean*|init) $1; exit 0;;
help) echo "clean, cleanall, init, [force] update, config, verbose, noclean, or without args"; exit 1;;
*) echo "aik-lnxbuild: invalid option -- '$*'"; exit 1;;
esac;
shift;
done;
main $action;
exit 0;

The Linux stripped-down old aik-build.sh for building only mkimage/dumpimage cross-compiled with the NDK, since this currently can't be done with the U-Boot sources as they are on Cygwin.

The rest of my Linux ~/build directory is set up as follows:

~/build/android-ndk-r10e.

~/build/libcrypto_static from my GitHub repo.

~/build/x-tools with the NDK standalone CC's in the 6 architectures.

And lastly, for those interested, I keep the Diffusion Installer Backend separate from my repos and push backend-only updates in centrally using the following script.

~/diff-bundle.sh:

#!/bin/bash
# and now

# diff-bundle.sh
#
# osm0sis @ xda-developers
#
# requires (in addition to the default basic Ubuntu WSL packages):
# unzip, zip, default-jre

MAGISK=$HOME/magisk-modules;

bold() { echo -e "\033[1m"$@"\033[0m"; }

reset() {
local i;
bold "--- Removing manual Diffusion modules ...";
# busybox-ndk is removed by bbox-bundle.sh
# mtd-ndk is removed by mtd-build.sh
# nano-ndk is removed by nano-build.sh
# zipsigner is removed by zip-build.sh
rm -rfv $HOME/Diffusion zipsigner-*.jar;
for i in adb Adreno Fla**** Nexus; do
rm -rfv UPDATE-$i*.zip $MAGISK/UPDATE-$i*;
done;
rmdir $MAGISK 2>/dev/null;
}

init() {
local zipsigner;
reset;
bold "--- Initializing manual Diffusion modules ...";
bold "- Cloning installer git repositories ...";
mkdir -p $MAGISK;
git clone https://github.com/Magisk-Modules-Repo/adb-ndk $MAGISK/UPDATE-adb.Installer.v1.0.41;
git clone https://github.com/Magisk-Modules-Repo/adreno-dev $MAGISK/UPDATE-Adreno.Systemless.Installer;
# busybox-ndk is initialized by bbox-bundle.sh
# mtd-ndk is initialized by mtd-build.sh
# nano-ndk is initialized by nano-build.sh
git clone https://github.com/Magisk-Modules-Repo/nexusmedia $MAGISK/UPDATE-Nexus.Media.Installer;
# zipsigner is initialized by zip-build.sh

bold "- Unpacking Fla**** installer latest release zip ...";
unzip "$HOME/projects/Misc Flashable+Scripts"/UPDATE-Fla****.Installer.v*-signed.zip -d $MAGISK/$(basename "$(echo "$HOME/projects/Misc Flashable+Scripts"/UPDATE-Fla****.Installer.v*-signed.zip)" -signed.zip);
rm -f $MAGISK/UPDATE-Fla****.Installer.v*/META-INF/* 2>/dev/null;

# AIK-mobile is initialized by aik-bundle.sh

bold "- Copying out Diffusion Backend common files ...";
mkdir -p $HOME/Diffusion;
cp -fprv $MAGISK/UPDATE-adb*/META-INF $MAGISK/UPDATE-adb*/customize.sh $HOME/Diffusion;
chmod -R 755 $HOME/Diffusion;
chmod 644 $HOME/Diffusion/META-INF/com/google/android/updater-script;

bold "- Downloading zipsigner ...";
zipsigner="opengapps/opengapps/raw/master/scripts/zipsigner-resources/zipsigner-2.2.jar";
wget -O $HOME/$(basename $zipsigner) https://github.com/$zipsigner;
}

main() {
local zipflag stdout copy iterate pack sign i mod name modcode newmodcode;

zipflag=-q;
stdout=/dev/null;
copy=1;
iterate=1;
pack=1;
sign=1;

until [ ! "$1" ]; do
case $1 in
help) echo "diff-bundle.sh reset, init, [verbose] [nocopy] [noiterate] [nopack] [nosign]"; exit 1;;
reset|init) $1; return;;
verbose) stdout=/dev/stdout; unset zipflag; shift;;
nocopy) unset copy; shift;;
noiterate) unset iterate; shift;;
nopack) unset pack; shift;;
nosign) unset sign; shift;;
*) echo "unknown option: $1"; exit 1;;
esac;
done;

rm -f UPDATE-*.zip 2>/dev/null;

if [ "$copy" ]; then
bold "--- Copying new Diffusion Backend files ...";
# AIK-mobile is a special case; update its Diffusion Backend only
for i in $HOME/AIK-mobile/. $MAGISK/UPDATE-*/diffusion_config.sh; do
cp -fpr $HOME/Diffusion/* $(dirname $i)/;
done;
fi;

for i in $MAGISK/UPDATE-*/diffusion_config.sh; do
mod=$(dirname $i);
name=$(basename $mod);

bold "\n--- Updating \"$name\" ...";
# Fla**** is a special case; do not iterate its module versionCode
case $name in
*Fla*****) ;;
*)
if [ "$iterate" ]; then
modcode=$(grep -o "^versionCode=.*$" $mod/module.prop | cut -d= -f2);
newmodcode="$((modcode + 1))";
bold "- Changing Magisk module version code ($modcode -> $newmodcode) ...";
sed -i -e "s/versionCode=.*/versionCode=$newmodcode/" $mod/module.prop;
sed -i -e "s/versionCode\".*/versionCode\": \"$newmodcode\",/" $mod/update.json;
fi;
;;
esac;

if [ "$pack" ]; then
bold "- Packing \"$name.zip\" ...";
cd $mod;
zip -9 -x .git -x .github -x update.json -r $zipflag $HOME/$name.zip *;
cd $HOME;

if [ "$sign" ]; then
bold "- Signing as \"$name-signed.zip\" ...";
java -jar zipsigner-*.jar $name.zip $name-signed.zip;
rm -f $name.zip /tmp/signAPK*.tmp 2>/dev/null;
fi;
fi;
done;
}

cd $HOME;
main "$@";
exit 0;

Bonus, I now keep my scripts backed up from WSL2 and Cygwin to my Windows Documents folder so that Windows File History will pick them up, so I won't lose my WIP if my SSD ever decides to die again. :mad:

~/sync-sh-it.sh:

#!/bin/bash

# Sync .sh It!
#
# osm0sis @ xda-developers
#
# Keep WSL2 and Cygwin up-to-date with Windows File History backed-up Documents copies

bold() { echo -e "\033[1m"$@"\033[0m"; }

linuxdir=~;
cygwindir=/mnt/c/Cygwin/home/chris;
regtestdir=/mnt/c/Uploads/bootimg-tools/regtester;

linuxfiles=(`find $linuxdir/*.sh`);
cygwinfiles=(`find $cygwindir/*.sh`);

destdir="/mnt/c/Users/Chris/Documents/Projects/Misc Flashable+Scripts";

# main scripts are separated in WSL2 Ubuntu and Cygwin homedirs

bold "\n*** ~ -> Projects";
rsync -utv "${linuxfiles[@]}" "${cygwinfiles[@]}" "$destdir" | head -n -2;

bold "\n*** ~ <- Projects"
bold " - WSL2"
rsync -utv "${linuxfiles[@]/$linuxdir/$destdir}" $linuxdir | head -n -2;
bold " - Cygwin"
rsync -utv "${cygwinfiles[@]/$cygwindir/$destdir}" $cygwindir | head -n -2;

# aik-regtest.sh is symlinked in ~/uploads/bootimg-tools/regtester for WSL2 Ubuntu and Cygwin

bold "\n*** ~/uploads/bootimg-tools/regtester -> Projects"
rsync -utv "$regtestdir/aik-regtest.sh" "$destdir" | head -n -2;

bold "\n*** ~/uploads/bootimg-tools/regtester <- Projects"
rsync -utv "$destdir/aik-regtest.sh" "$regtestdir" | head -n -2;