[Android Software Development] ace2nutzer:
Hmm, i can't get it to work with latest version.

The bad thing is that once i try to grab last_kmsg i get only a ghost log from previous (working) kernel.

I can reproduce the issue.

If i use my old backup of AIK-Linux it works.

With the new version, no way.

Of course using same kernel + ramdisk.

i do unpack and repack like always with --nosudo.

For instance here some snippets of code from the older working version:

bin/magic

#------------------------------------------------------------------------------
# Slimmed down magic file for archives only
#------------------------------------------------------------------------------
# $File: archive,v 1.108 2017/08/30 13:45:10 christos Exp $
# archive: file(1) magic for archive formats (see also "msdos" for self-
# extracting compressed archives)
#
# cpio, ar, arc, arj, hpack, lha/lharc, rar, squish, uc2, zip, zoo, etc.
# pre-POSIX "tar" archives are handled in the C code.
...

bin/androidbootimg.magic

#------------------------------------------------------------------------------
# Various Android OEM non-standard boot image related magic entries
# osm0sis @ xda-developers
#------------------------------------------------------------------------------

# ASUS Blob Signature
0 string -SIGNED-BY-SIGNBLOB- BLOB signing

# Barnes & Noble Nook Signature
64 string Green\x20Loader NOOK signing (loader)
64 string Green\x20Recovery NOOK signing (recovery)

# Google ChromeOS Signature
0 string CHROMEOS CHROMEOS signing

# Samsung/Spreadtrum DHTB Signature
0 string DHTB\x01\x00\x00 DHTB signing

# Sony SIN Packaging/Signature
0 string \x01\x00\x00\x00 SIN signing v1
0 string \x02\x00\x00\x00 SIN signing v2
0 string \x03SIN SIN signing v3

# Google Pixel/Nexus/AOSP Standard
# [test "x" as workaround to odd file/magic behavior not allowing search here]
0 string x
>0 search ANDROID! AOSP bootimg
>>36 string \x00\x00\x00\x02 \b, PXA variant (020)
>>36 string \x00\x00\x80\x02 \b, PXA variant (028)
>>36 string \x00\x00\x00\x03 \b, PXA variant (030)
>>1024 search LOKI\x01 \b, LOKI header (recovery)
>>1024 search LOKI\x00 \b, LOKI header (boot)
>>2048 search \x88\x16\x88\x58 \b, MTK headers
!:strength * 2

# DENX U-Boot
0 string \x27\x05\x19\x56 U-Boot bootimg

# Intel OS
0 string $OS$\x00\x00\x01 OS bootimg

# Rockchip KRNL
0 string KRNL KRNL bootimg

# Sony ELF
0 string \x7FELF ELF
>5 string \x01\x01\x61 bootimg
>18 string \x28 (ARM
>18 string \x03 (x86_
>18 string \x08 (MIPS
>4 string \x01 \b)
>4 string \x02 \b64)
>0 search \x88\x16\x88\x58 \b, MTK headers

# MediaTek MTK
# [for detection after boot image has already been split]
0 search \x88\x16\x88\x58 MTK header
>0 search KERNEL \b, kernel type
>0 search ROOTFS \b, rootfs type
>0 search RECOVERY \b, recovery type
!:strength / 15

# Qualcomm Device Tree
# [for detection after boot image has already been split]
0 string QCDT QCDT header
!:strength / 15

# Google Android Verified Boot Signature
# [for detection with the tail of the boot image]
0 search \x02\x01\x01\x30\x82 AVB signing v1 footer
>0 search /boot \b, boot type
>0 search /recovery \b, recovery type
!:strength / 15

# LG Bump
# [for detection with the tail of the boot image]
0 search \x41\xA9\xE4\x67\x74\x4D\x1D\x1B\xA4\x29\xF2\xEC\xEA\x65\x52\x79 Bump footer
!:strength / 15

# Samsung SEAndroid
# [for detection with the tail of the boot image]
# [test "x" as workaround to odd file/magic behavior not allowing search here]
0 string x
>0 search SEANDROIDENFORCE SEAndroid footer
!:strength / 15

unpackimg.sh

#!/bin/bash
# AIK-Linux/unpackimg: split image and unpack ramdisk
# osm0sis @ xda-developers

cleanup() { $aik/cleanup.sh >/dev/null; }
abort() { cd "$aik"; echo "Error!"; }

case $1 in
--help) echo "usage: unpackimg.sh [--nosudo] <file>"; exit 1;;
--nosudo) nosudo=1; shift;;
--sudo) shift;;
esac;
if [ ! "$nosudo" ]; then
sudo=sudo; sumsg=" (as root)";
fi;

case $(uname -s) in
Darwin|Macintosh)
plat="macos";
readlink() { perl -MCwd -e 'print Cwd::abs_path shift' "$2"; }
;;
*) plat="linux";;
esac;
arch=$plat/`uname -m`;

aik="${BASH_SOURCE:-$0}";
aik="$(dirname "$(readlink -f "$aik")")";
bin="$aik/bin";
rel=bin;
cur="$(readlink -f "$PWD")";

case $plat in
macos)
cpio="env DYLD_LIBRARY_PATH="$bin/$arch" "$bin/$arch/cpio"";
statarg="-f %Su";
dd() { DYLD_LIBRARY_PATH="$bin/$arch" "$bin/$arch/dd" "$@"; }
file() { DYLD_LIBRARY_PATH="$bin/$arch" "$bin/$arch/file" "$@"; }
lzma() { DYLD_LIBRARY_PATH="$bin/$arch" "$bin/$arch/xz" "$@"; }
lzop() { DYLD_LIBRARY_PATH="$bin/$arch" "$bin/$arch/lzop" "$@"; }
tail() { DYLD_LIBRARY_PATH="$bin/$arch" "$bin/$arch/tail" "$@"; }
xz() { DYLD_LIBRARY_PATH="$bin/$arch" "$bin/$arch/xz" "$@"; }
;;
linux)
cpio=cpio;
statarg="-c %U";
;;
esac;

cd "$aik";
chmod -R 755 "$bin" *.sh;
chmod 644 "$bin/magic" "$bin/androidbootimg.magic" "$bin/BootSignature.jar" "$bin/avb/"* "$bin/chromeos/"*;

test -f "$cur/$1" && img="$cur/$1" || img="$1";
if [ ! "$img" ]; then
while IFS= read -r line; do
case $line in
aboot.img|image-new.img|unlokied-new.img|unsigned-new.img) continue;;
esac;
img="$line";
break;
done < <(ls *.elf *.img *.sin 2>/dev/null);
fi;
img="$(readlink -f "$img")";
if [ ! -f "$img" ]; then
echo "No image file supplied.";
abort;
exit 1;
fi;

clear;
echo " ";
echo "Android Image Kitchen - UnpackImg Script";
echo "by osm0sis @ xda-developers";
echo " ";

file=$(basename "$img");
echo "Supplied image: $file";
echo " ";

if [ -d split_img -o -d ramdisk ]; then
if [ -d ramdisk ] && [ "$(stat $statarg ramdisk | head -n 1)" = "root" -o ! "$(find ramdisk 2>&1 | cpio -o >/dev/null 2>&1; echo $?)" -eq "0" ]; then
rmsumsg=" (as root)";
fi;
echo "Removing old work folders and files$rmsumsg...";
echo " ";
cleanup;
fi;

echo "Setting up work folders...";
echo " ";
mkdir split_img ramdisk;

imgtest="$(file -m $rel/androidbootimg.magic "$img" | cut -d: -f2-)";
if [ "$(echo $imgtest | awk '{ print $2 }' | cut -d, -f1)" = "signing" ]; then
echo $imgtest | awk '{ print $1 }' > "split_img/$file-sigtype";
sigtype=$(cat "split_img/$file-sigtype");
echo "Signature with \"$sigtype\" type detected, removing...";
echo " ";
case $sigtype in
BLOB)
cd split_img;
cp -f "$img" "$file";
"$bin/$arch/blobunpack" "$file" | tail -n+5 | cut -d" " -f2 | dd bs=1 count=3 > "$file-blobtype" 2>/dev/null;
mv -f "$file."* "$file";
cd ..;
;;
CHROMEOS) "$bin/$arch/futility" vbutil_kernel --get-vmlinuz "$img" --vmlinuz-out "split_img/$file";;
DHTB) dd bs=4096 skip=512 iflag=skip_bytes conv=notrunc if="$img" of="split_img/$file" 2>/dev/null;;
NOOK)
dd bs=1048576 count=1 conv=notrunc if="$img" of="split_img/$file-master_boot.key" 2>/dev/null;
dd bs=1048576 skip=1 conv=notrunc if="$img" of="split_img/$file" 2>/dev/null;
;;
SIN)
"$bin/$arch/kernel_dump" split_img "$img" >/dev/null;
mv -f "split_img/$file."* "split_img/$file";
rm -rf "split_img/$file-sigtype";
;;
esac;
img="$aik/split_img/$file";
fi;

imgtest="$(file -m $rel/androidbootimg.magic "$img" | cut -d: -f2-)";
if [ "$(echo $imgtest | awk '{ print $2 }' | cut -d, -f1)" = "bootimg" ]; then
test "$(echo $imgtest | awk '{ print $3 }')" = "PXA" && typesuffix=-PXA;
echo "$(echo $imgtest | awk '{ print $1 }')$typesuffix" > "split_img/$file-imgtype";
imgtype=$(cat "split_img/$file-imgtype");
else
cleanup;
echo "Unrecognized format.";
abort;
exit 1;
fi;
echo "Image type: $imgtype";
echo " ";

case $imgtype in
AOSP*|ELF|KRNL|U-Boot) ;;
*)
cleanup;
echo "Unsupported format.";
abort;
exit 1;
;;
esac;

if [ "$(echo $imgtest | awk '{ print $3 }')" = "LOKI" ]; then
echo $imgtest | awk '{ print $5 }' | cut -d\( -f2 | cut -d\) -f1 > "split_img/$file-lokitype";
lokitype=$(cat "split_img/$file-lokitype");
echo "Loki patch with \"$lokitype\" type detected, reverting...";
echo " ";
echo "Warning: A dump of your device's aboot.img is required to re-Loki!";
echo " ";
"$bin/$arch/loki_tool" unlok "$img" "split_img/$file" >/dev/null;
img="$file";
fi;

tailtest="$(tail -n50 "$img" 2>/dev/null | file -m $rel/androidbootimg.magic - | cut -d: -f2-)";
tailtype="$(echo $tailtest | awk '{ print $1 }')";
case $tailtype in
AVB)
echo "Signature with \"$tailtype\" type detected.";
echo " ";
echo $tailtype > "split_img/$file-sigtype";
echo $tailtest | awk '{ print $5 }' > "split_img/$file-avbtype";
;;
Bump|SEAndroid)
echo "Footer with \"$tailtype\" type detected.";
echo " ";
echo $tailtype > "split_img/$file-tailtype";
;;
esac;

echo 'Splitting image to "split_img/"...';
cd split_img;
case $imgtype in
AOSP) "$bin/$arch/unpackbootimg" -i "$img";;
AOSP-PXA) "$bin/$arch/pxa-unpackbootimg" -i "$img";;
ELF) "$bin/$arch/unpackelf" -i "$img";;
KRNL) dd bs=4096 skip=8 iflag=skip_bytes conv=notrunc if="$img" of="$file-ramdisk.cpio.gz" 2>&1 | tail -n+3 | cut -d" " -f1-2;;
U-Boot)
"$bin/$arch/dumpimage" -l "$img";
"$bin/$arch/dumpimage" -l "$img" > "$file-header";
grep "Name:" "$file-header" | cut -c15- > "$file-name";
grep "Type:" "$file-header" | cut -c15- | cut -d" " -f1 > "$file-arch";
grep "Type:" "$file-header" | cut -c15- | cut -d" " -f2 > "$file-os";
grep "Type:" "$file-header" | cut -c15- | cut -d" " -f3 | cut -d- -f1 > "$file-type";
grep "Type:" "$file-header" | cut -d\( -f2 | cut -d\) -f1 | cut -d" " -f1 | cut -d- -f1 > "$file-comp";
grep "Address:" "$file-header" | cut -c15- > "$file-addr";
grep "Point:" "$file-header" | cut -c15- > "$file-ep";
rm -rf "$file-header";
"$bin/$arch/dumpimage" -i "$img" -p 0 "$file-zImage";
if [ ! $? -eq "0" ]; then
cleanup;
abort;
exit 1;
fi;
if [ "$(cat "$file-type")" = "Multi" ]; then
"$bin/$arch/dumpimage" -i "$img" -p 1 "$file-ramdisk.cpio.gz";
else
touch "$file-ramdisk.cpio.gz";
fi;
;;
esac;
if [ ! $? -eq "0" ]; then
cleanup;
abort;
exit 1;
fi;

if [ "$imgtype" = "AOSP" ] && [ "$(cat "$file-hash")" = "unknown" ]; then
echo " ";
echo 'Warning: "unknown" hash type detected; assuming "sha1" type!';
echo "sha1" > "$file-hash";
fi;

if [ "$(file -m ../$rel/androidbootimg.magic *-zImage | cut -d: -f2 | awk '{ print $1 }')" = "MTK" ]; then
mtk=1;
echo " ";
echo "MTK header found in zImage, removing...";
dd bs=512 skip=1 conv=notrunc if="$file-zImage" of=tempzimg 2>/dev/null;
mv -f tempzimg "$file-zImage";
fi;
mtktest="$(file -m ../$rel/androidbootimg.magic *-ramdisk*.gz | cut -d: -f2-)";
mtktype=$(echo $mtktest | awk '{ print $3 }');
if [ "$(echo $mtktest | awk '{ print $1 }')" = "MTK" ]; then
if [ ! "$mtk" ]; then
echo " ";
echo "Warning: No MTK header found in zImage!";
mtk=1;
fi;
echo "MTK header found in \"$mtktype\" type ramdisk, removing...";
dd bs=512 skip=1 conv=notrunc if="$(ls *-ramdisk*.gz)" of=temprd 2>/dev/null;
mv -f temprd "$(ls *-ramdisk*.gz)";
else
if [ "$mtk" ]; then
if [ ! "$mtktype" ]; then
echo 'Warning: No MTK header found in ramdisk, assuming "rootfs" type!';
mtktype="rootfs";
fi;
fi;
fi;
test "$mtk" && echo $mtktype > "$file-mtktype";

if [ -f *-dtb ]; then
dtbtest="$(file -m ../$rel/androidbootimg.magic *-dtb | cut -d: -f2 | awk '{ print $1 }')";
if [ "$imgtype" = "ELF" ]; then
case $dtbtest in
QCDT|ELF) ;;
*) echo " ";
echo "Non-QC DTB found, packing zImage and appending...";
gzip --no-name -9 "$file-zImage";
mv -f "$file-zImage.gz" "$file-zImage";
cat "$file-dtb" >> "$file-zImage";
rm -f "$file-dtb";;
esac;
fi;
fi;

file -m ../$rel/magic *-ramdisk*.gz | cut -d: -f2 | awk '{ print $1 }' > "$file-ramdiskcomp";
ramdiskcomp=`cat *-ramdiskcomp`;
unpackcmd="$ramdiskcomp -dc";
compext=$ramdiskcomp;
case $ramdiskcomp in
gzip) unpackcmd="gzip -dcq"; compext=gz;;
lzop) compext=lzo;;
xz) ;;
lzma) ;;
bzip2) compext=bz2;;
lz4) unpackcmd="$bin/$arch/lz4 -dcq";;
empty) compext=empty;;
*) compext="";;
esac;
if [ "$compext" ]; then
compext=.$compext;
fi;
mv -f "$(ls *-ramdisk*.gz)" "$file-ramdisk.cpio$compext" 2>/dev/null;
cd ..;
if [ "$ramdiskcomp" = "data" ]; then
echo "Unrecognized format.";
abort;
exit 1;
fi;

echo " ";
if [ "$ramdiskcomp" = "empty" ]; then
echo "Warning: No ramdisk found to be unpacked!";
else
echo "Unpacking ramdisk$sumsg to \"ramdisk/\"...";
echo " ";
$sudo chown 0:0 ramdisk 2>/dev/null;
cd ramdisk;
echo "Compression used: $ramdiskcomp";
if [ ! "$compext" ]; then
echo "Unsupported format.";
abort;
exit 1;
fi;
$unpackcmd "../split_img/$file-ramdisk.cpio$compext" | $sudo $cpio -i -d --no-absolute-filenames;
if [ ! $? -eq "0" ]; then
test "$nosudo" && echo "Unpacking failed, try without --nosudo.";
abort;
exit 1;
fi;
cd ..;
fi;

echo " ";
echo "Done!";
exit 0;

repackimg.sh

#!/bin/bash
# AIK-Linux/repackimg: repack ramdisk and build image
# osm0sis @ xda-developers

abort() { cd "$aik"; echo "Error!"; }

case $1 in
--help) echo "usage: repackimg.sh [--original] [--level <0-9>] [--avbkey <name>]"; exit 1;
esac;

case $(uname -s) in
Darwin|Macintosh)
plat="macos";
readlink() { perl -MCwd -e 'print Cwd::abs_path shift' "$2"; }
;;
*) plat="linux";;
esac;
arch=$plat/`uname -m`;

aik="${BASH_SOURCE:-$0}";
aik="$(dirname "$(readlink -f "$aik")")";
bin="$aik/bin";
rel=bin;
cur="$(readlink -f "$PWD")";

case $plat in
macos)
cpio="env DYLD_LIBRARY_PATH="$bin/$arch" "$bin/$arch/cpio"";
statarg="-f %Su";
dd() { DYLD_LIBRARY_PATH="$bin/$arch" "$bin/$arch/dd" "$@"; }
java() { "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" "$@"; }
lzop() { DYLD_LIBRARY_PATH="$bin/$arch" "$bin/$arch/lzop" "$@"; }
xz() { DYLD_LIBRARY_PATH="$bin/$arch" "$bin/$arch/xz" "$@"; }
;;
linux)
cpio=cpio;
statarg="-c %U";
;;
esac;

cd "$aik";
chmod -R 755 "$bin" *.sh;
chmod 644 "$bin/magic" "$bin/androidbootimg.magic" "$bin/BootSignature.jar" "$bin/avb/"* "$bin/chromeos/"*;

ramdiskcomp=`cat split_img/*-ramdiskcomp 2>/dev/null`;
if [ -z "$(ls split_img/* 2>/dev/null)" -o -z "$(ls ramdisk/* 2>/dev/null)" -a ! "$ramdiskcomp" = "empty" ]; then
echo "No files found to be packed/built.";
abort;
exit 1;
fi;

clear;
echo " ";
echo "Android Image Kitchen - RepackImg Script";
echo "by osm0sis @ xda-developers";
echo " ";

if [ ! -z "$(ls *-new.* 2>/dev/null)" ]; then
echo "Warning: Overwriting existing files!";
echo " ";
fi;

if [ -d ramdisk ] && [ "$(stat $statarg ramdisk | head -n 1)" = "root" ]; then
sudo=sudo; sumsg=" (as root)";
else
cpioarg="-R 0:0";
fi;

rm -f "*-new.*";
while [ "$1" ]; do
case $1 in
--original) original=1;;
--level)
case $2 in
''|*[!0-9]*) ;;
*) level="-$2"; lvltxt=" - Level: $2"; shift;;
esac;
;;
--avbkey)
if [ "$2" ]; then
for keytest in "$2" "$cur/$2" "$aik/$2"; do
if [ ! -z "$(ls $keytest.pk8 2>/dev/null)" -a ! -z "$(ls $keytest.x509.* 2>/dev/null)" ]; then
avbkey="$keytest"; avbtxt=" - Key: $2"; shift; break;
fi;
done;
fi;
;;
esac;
shift;
done;

if [ "$original" ]; then
echo "Repacking with original ramdisk...";
elif [ "$ramdiskcomp" = "empty" ]; then
echo "Warning: Using empty ramdisk for repack!";
compext=empty;
touch ramdisk-new.cpio.$compext;
else
echo "Packing ramdisk$sumsg...";
echo " ";
test -z "$level" -a "$ramdiskcomp" = "xz" && level=-1;
echo "Using compression: $ramdiskcomp$lvltxt";
repackcmd="$ramdiskcomp $level";
compext=$ramdiskcomp;
case $ramdiskcomp in
gzip) compext=gz;;
lzop) compext=lzo;;
xz) repackcmd="xz $level -Ccrc32";;
lzma) repackcmd="xz $level -Flzma";;
bzip2) compext=bz2;;
lz4) repackcmd="$bin/$arch/lz4 $level -l";;
*) abort; exit 1;;
esac;
cd ramdisk;
$sudo find . | $sudo $cpio $cpioarg -H newc -o 2>/dev/null | $repackcmd > ../ramdisk-new.cpio.$compext;
if [ ! $? -eq "0" ]; then
abort;
exit 1;
fi;
cd ..;
fi;

echo " ";
echo "Getting build information...";
cd split_img;
imgtype=`cat *-imgtype`;
if [ "$imgtype" != "KRNL" ]; then
kernel=`ls *-zImage`; echo "kernel = $kernel";
kernel="split_img/$kernel";
fi;
if [ "$original" ]; then
ramdisk=`ls *-ramdisk.cpio*`; echo "ramdisk = $ramdisk";
ramdisk="split_img/$ramdisk";
else
ramdisk="ramdisk-new.cpio.$compext";
fi;
if [ "$imgtype" = "U-Boot" ]; then
name=`cat *-name`; echo "name = $name";
uarch=`cat *-arch`;
os=`cat *-os`;
type=`cat *-type`;
comp=`cat *-comp`; echo "type = $uarch $os $type ($comp)";
test "$comp" = "uncompressed" && comp=none;
addr=`cat *-addr`; echo "load_addr = $addr";
ep=`cat *-ep`; echo "entry_point = $ep";
elif [ "$imgtype" = "KRNL" ]; then
rsz=$(wc -c < "$aik/$ramdisk"); echo "ramdisk_size = $rsz";
else
if [ -f *-second ]; then
second=`ls *-second`; echo "second = $second";
second=(--second "split_img/$second");
fi;
if [ -f *-cmdline ]; then
cmdline=`cat *-cmdline`; echo "cmdline = $cmdline";
fi;
if [ -f *-board ]; then
board=`cat *-board`; echo "board = $board";
fi;
base=`cat *-base`; echo "base = $base";
pagesize=`cat *-pagesize`; echo "pagesize = $pagesize";
kerneloff=`cat *-kerneloff`; echo "kernel_offset = $kerneloff";
ramdiskoff=`cat *-ramdiskoff`; echo "ramdisk_offset = $ramdiskoff";
if [ -f *-secondoff ]; then
secondoff=`cat *-secondoff`; echo "second_offset = $secondoff";
fi;
if [ -f *-tagsoff ]; then
tagsoff=`cat *-tagsoff`; echo "tags_offset = $tagsoff";
fi;
if [ -f *-osversion ]; then
osver=`cat *-osversion`; echo "os_version = $osver";
fi;
if [ -f *-oslevel ]; then
oslvl=`cat *-oslevel`; echo "os_patch_level = $oslvl";
fi;
if [ -f *-hash ]; then
hash=`cat *-hash`; echo "hash = $hash";
hash="--hash $hash";
fi;
if [ -f *-dtb ]; then
dtb=`ls *-dtb`; echo "dtb = $dtb";
dtb=(--dt "split_img/$dtb");
fi;
if [ -f *-unknown ]; then
unknown=`cat *-unknown`; echo "unknown = $unknown";
fi;
fi;
cd ..;

if [ -f split_img/*-mtktype ]; then
mtktype=`cat split_img/*-mtktype`;
echo " ";
echo "Generating MTK headers...";
echo " ";
echo "Using ramdisk type: $mtktype";
"$bin/$arch/mkmtkhdr" --kernel "$kernel" --$mtktype "$ramdisk" >/dev/null;
if [ ! $? -eq "0" ]; then
abort;
exit 1;
fi;
mv -f "$(basename "$kernel")-mtk" kernel-new.mtk;
mv -f "$(basename "$ramdisk")-mtk" $mtktype-new.mtk;
kernel=kernel-new.mtk;
ramdisk=$mtktype-new.mtk;
fi;

if [ -f split_img/*-sigtype ]; then
outname=unsigned-new.img;
else
outname=image-new.img;
fi;

if [ "$imgtype" = "ELF" ]; then
imgtype=AOSP;
echo " ";
echo "Warning: ELF format detected; will be repacked using AOSP format!";
fi;

echo " ";
echo "Building image...";
echo " ";
echo "Using format: $imgtype";
echo " ";
case $imgtype in
AOSP) "$bin/$arch/mkbootimg" --kernel "$kernel" --ramdisk "$ramdisk" "${second[@]}" --cmdline "$cmdline" --board "$board" --base $base --pagesize $pagesize --kernel_offset $kerneloff --ramdisk_offset $ramdiskoff --second_offset "$secondoff" --tags_offset "$tagsoff" --os_version "$osver" --os_patch_level "$oslvl" $hash "${dtb[@]}" -o $outname;;
AOSP-PXA) "$bin/$arch/pxa-mkbootimg" --kernel "$kernel" --ramdisk "$ramdisk" "${second[@]}" --cmdline "$cmdline" --board "$board" --base $base --pagesize $pagesize --kernel_offset $kerneloff --ramdisk_offset $ramdiskoff --second_offset "$secondoff" --tags_offset "$tagsoff" --unknown $unknown "${dtb[@]}" -o $outname;;
KRNL) "$bin/$arch/rkcrc" -k "$ramdisk" $outname;;
U-Boot)
test "$type" == "Multi" && uramdisk=(:"$ramdisk");
"$bin/$arch/mkimage" -A $uarch -O $os -T $type -C $comp -a $addr -e $ep -n "$name" -d "$kernel""${uramdisk[@]}" $outname >/dev/null;
;;
*) echo " "; echo "Unsupported format."; abort; exit 1;;
esac;
if [ ! $? -eq "0" ]; then
abort;
exit 1;
fi;

if [ -f split_img/*-sigtype ]; then
sigtype=`cat split_img/*-sigtype`;
if [ -f split_img/*-avbtype ]; then
avbtype=`cat split_img/*-avbtype`;
fi;
if [ -f split_img/*-blobtype ]; then
blobtype=`cat split_img/*-blobtype`;
fi;
echo "Signing new image...";
echo " ";
echo "Using signature: $sigtype $avbtype$avbtxt$blobtype";
test ! "$avbkey" && avbkey="$rel/avb/verity";
echo " ";
case $sigtype in
AVB) java -jar "$bin/BootSignature.jar" /$avbtype unsigned-new.img "$avbkey.pk8" "$avbkey.x509."* image-new.img 2>/dev/null;;
BLOB)
awk 'BEGIN { printf "-SIGNED-BY-SIGNBLOB-\00\00\00\00\00\00\00\00" }' > image-new.img;
"$bin/$arch/blobpack" tempblob $blobtype unsigned-new.img >/dev/null;
cat tempblob >> image-new.img;
rm -rf tempblob;
;;
CHROMEOS) "$bin/$arch/futility" vbutil_kernel --pack image-new.img --keyblock $rel/chromeos/kernel.keyblock --signprivate $rel/chromeos/kernel_data_key.vbprivk --version 1 --vmlinuz unsigned-new.img --bootloader $rel/chromeos/empty --config $rel/chromeos/empty --arch arm --flags 0x1;;
DHTB)
"$bin/$arch/dhtbsign" -i unsigned-new.img -o image-new.img >/dev/null;
rm -rf split_img/*-tailtype 2>/dev/null;
;;
NOOK) cat split_img/*-master_boot.key unsigned-new.img > image-new.img;;
esac;
if [ ! $? -eq "0" ]; then
abort;
exit 1;
fi;
fi;

if [ -f split_img/*-lokitype ]; then
lokitype=`cat split_img/*-lokitype`;
echo "Loki patching new image...";
echo " ";
echo "Using type: $lokitype";
echo " ";
mv -f image-new.img unlokied-new.img;
if [ -f aboot.img ]; then
"$bin/$arch/loki_tool" patch $lokitype aboot.img unlokied-new.img image-new.img >/dev/null;
if [ ! $? -eq "0" ]; then
echo "Patching failed.";
abort;
exit 1;
fi;
else
echo "Device aboot.img required in script directory to find Loki patch offset.";
abort;
exit 1;
fi;
fi;

if [ -f split_img/*-tailtype ]; then
tailtype=`cat split_img/*-tailtype`;
echo "Appending footer...";
echo " ";
echo "Using type: $tailtype";
echo " ";
case $tailtype in
Bump) awk 'BEGIN { printf "\x41\xA9\xE4\x67\x74\x4D\x1D\x1B\xA4\x29\xF2\xEC\xEA\x65\x52\x79" }' >> image-new.img;;
SEAndroid) printf 'SEANDROIDENFORCE' >> image-new.img;;
esac;
fi;

echo "Done!";
exit 0;

I hope this helps. - If you need more informations, let me know.