I tried to decompress one of the .apk
files from my buildsystem using gzip, xz, zstd, bsdtar, and tar, but none of these can recognize the format. Does anyone know what compression is applied and how to manually decompress an OpenWrt build-system generated .apk file?
Try decompression tools as a first effort. libmagic file can teach you.
https://wiki.alpinelinux.org/wiki/Apk_spec
% file shonenjump-0.8.0-r1.apk
shonenjump-0.8.0-r1.apk: data
And
% gzip -l shonenjump-0.8.0-r1.apk
gzip: shonenjump-0.8.0-r1.apk: not in gzip format
Yet from the link you posted
This is a set of commands to partially build a package. DO NOT DO THIS , it's mainly an example to see how this all fits together. Use the official build tools to build packages.
tar -c .PKGNIFO .pre-install | abuild-tar --cut | gzip -9 > $controldir/control.tar.gz
cd $pkgdir; tar -c * | abuild-tar --hash | gzip -9 > $controldir/data.tar.gz
cat $controldir/control.tar.gz $controldir/data.tar.gz > mypackage-1.0-r0.apk
So should be just two gz files catted together. I am not sure how to break them apart for decompression.
Magic is ADBd
:
# curl -s 'https://downloads.openwrt.org/snapshots/packages/x86_64/packages/acme-4.0.0.apk' | dd bs=1 count=4 status=none | hexdump -C
00000000 41 44 42 64 |ADBd|
Does not exactly match magic from "adb.h" in apk-tools
:
But does match this file:
So probably a DEFLATE-compressed ADB file.
(Contrarily ADB.
might indicate uncompressed and ADBc
might indicate zstd-compressed.)
For decompression, I would try apk-tools
.
EDIT: manpage for apk extract
is here:
EDIT2: Cannot figure out why "apk" was chosen as the project name when there is already another package format (android packages) with the same name.. Near impossible to google for apk commands.
EDIT3: Oh, I see they also use the YAML file format in some of their tools, so they are clearly just insane.
Note that Alpine .APK has been there since at least 2005, well before Android was initially launched...
Makes sense then, thanks! I'll direct my frustrations towards android next time hah