summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorosm0sis <osm0sis@outlook.com>2019-02-07 13:00:42 -0400
committerosm0sis <osm0sis@outlook.com>2019-02-07 13:00:42 -0400
commit82e7c0345b5dd962afe02a088cb5b950b9a8b9a6 (patch)
tree65704887e06484decdcf1365acefb707bda51bf7
parenta1f20c0d53a09b69a6cd769b6fc9a78f6a27246a (diff)
AK2: add support for uncompressed cpio ramdisks
ramdisk_compression=cpio or =none to force
-rwxr-xr-xtools/ak2-core.sh26
1 files changed, 19 insertions, 7 deletions
diff --git a/tools/ak2-core.sh b/tools/ak2-core.sh
index dffedaf..fcf8074 100755
--- a/tools/ak2-core.sh
+++ b/tools/ak2-core.sh
@@ -113,13 +113,19 @@ unpack_ramdisk() {
' B Z h'*) compext="bz2"; unpackcmd="bzip2";;
' stx ! L can') compext="lz4-l"; unpackcmd="$bin/lz4";;
' etx ! L can'|' eot " M can') compext="lz4"; unpackcmd="$bin/lz4";;
+ ' 0 7 0 7') compext=""; unpackcmd="cat";;
+ '') ui_print " "; ui_print "Ramdisk not found in image. Aborting..."; exit 1;;
*) ui_print " "; ui_print "Unknown ramdisk compression. Aborting..."; exit 1;;
esac;
- mv -f $split_img/boot.img-ramdisk.gz $split_img/boot.img-ramdisk.cpio.$compext;
+ if [ "$compext" ]; then
+ compext=.$compext;
+ unpackcmd="$unpackcmd -dc";
+ fi;
+ mv -f $split_img/boot.img-ramdisk.gz $split_img/boot.img-ramdisk.cpio$compext;
mkdir -p $ramdisk;
chmod 755 $ramdisk;
cd $ramdisk;
- $unpackcmd -dc $split_img/boot.img-ramdisk.cpio.$compext | EXTRACT_UNSAFE_SYMLINKS=1 cpio -i -d;
+ $unpackcmd $split_img/boot.img-ramdisk.cpio$compext | EXTRACT_UNSAFE_SYMLINKS=1 cpio -i -d;
if [ $? != 0 -o -z "$(ls $ramdisk)" ]; then
ui_print " "; ui_print "Unpacking ramdisk failed. Aborting..."; exit 1;
fi;
@@ -134,7 +140,8 @@ dump_boot() {
repack_ramdisk() {
local compext repackcmd;
case $ramdisk_compression in
- auto|"") compext=`echo $split_img/*-ramdisk.cpio.* | rev | cut -d. -f1 | rev`;;
+ auto|"") compext=`echo $split_img/*-ramdisk.cpio* | rev | cut -d. -f1 | rev`; test "$compext" == "cpio" && compext="";;
+ none|cpio) compext="";;
*) compext=$ramdisk_compression;;
esac;
case $compext in
@@ -145,20 +152,25 @@ repack_ramdisk() {
bz2) repackcmd="bzip2";;
lz4-l) repackcmd="$bin/lz4 -l";;
lz4) repackcmd="$bin/lz4";;
+ "") repackcmd="cat";;
esac;
+ if [ "$compext" ]; then
+ compext=.$compext;
+ repackcmd="$repackcmd -9c";
+ fi;
if [ -f "$bin/mkbootfs" ]; then
- $bin/mkbootfs $ramdisk | $repackcmd -9c > /tmp/anykernel/ramdisk-new.cpio.$compext;
+ $bin/mkbootfs $ramdisk | $repackcmd > /tmp/anykernel/ramdisk-new.cpio$compext;
else
cd $ramdisk;
- find . | cpio -H newc -o | $repackcmd -9c > /tmp/anykernel/ramdisk-new.cpio.$compext;
+ find . | cpio -H newc -o | $repackcmd > /tmp/anykernel/ramdisk-new.cpio$compext;
fi;
if [ $? != 0 ]; then
ui_print " "; ui_print "Repacking ramdisk failed. Aborting..."; exit 1;
fi;
cd /tmp/anykernel;
if [ -f "$bin/mkmtkhdr" ]; then
- $bin/mkmtkhdr --rootfs ramdisk-new.cpio.$compext;
- mv -f ramdisk-new.cpio.$compext-mtk ramdisk-new.cpio.$compext;
+ $bin/mkmtkhdr --rootfs ramdisk-new.cpio$compext;
+ mv -f ramdisk-new.cpio.$compext-mtk ramdisk-new.cpio$compext;
fi;
}
flash_dtbo() {