yashsingh1/xdaforums huggingface dataset:
[Android Software Development] xdav20:
Using AIK couldn't be easier to unpack and repack both boot and recovery images. Thank you for the great tool.

I have already spent many hours without finding any leads to what I would like to achieve.

After unpacking a recovery image I can drop any executable applets/binaries to the /sbin folder and after repacking and reflashing it see them listed in /sbin folder/partition. So far so good. However, from the terminal I cannot execute anything that I added, obviously because of file permission not being 0750 for instance. I know I can manually fix this problem. Then I used another image extractor, being curious, and noticed a file called cpiolist.txt was created by the process. In this file I added something like the following example:

file sbin/binary-test initrd/sbin\binary-test 0750

After repacking and reflashing the recovery I can execute it but not before executing the following command first:

ln -s /sbin /system/bin

How can I set the file permission of binary-test, for instance, by AIK and fix the symbolic link without the need to use ln command every time in recovery?

If not possible, how can I fix the ln issue in cpiolist.txt?

I see lines like this as well...

slink sbin/awk busybox 0750

I thought, one trick would be to add binary-test to the busybox (surrogate) and let the process that is unpacking and placing the busybox's applets to /sbin, during bootup, take care of binary-test too. But until a month ago I didn't know anything about Linux, hence my technical shortcomings.

I would appreciate a sound advise in what I described in above please. Thank you.
[Android Software Development] osm0sis:
[MENTION=7065547]yan_saputra[/MENTION] the how-to you're looking for has definitely already been written. I suggest you search a bit more.

[MENTION=8589922]xdav20[/MENTION] AIK's mkbootfs should be setting everything to 750 in /sbin, but you're better off with AIK-Linux using ./unpackimg.sh --sudo since that will unpack/repack with the ownership/permissions exactly as originally, and you have full control over the same of any file/directory added.

If elevating AIK in Windows doesn't work I'll be looking into alternatives similar to that cpiolist.txt producing version of cpio, but maybe add them as part of the filenames instead to keep it more intuitive and self-contained.
[Android Software Development] yan_saputra:
Previous thanks for the response [MENTION=4544860]osm0sis[/MENTION]... i have previously read the tread from the screenshot you have ever posted ... but i am confused to enter the command in fx ... can you make unpack repack video tutorial on fx without using pc? Sorry for being so newbie. And my pc & laptop his broken. And my pc & laptop his broken.
[Android Software Development] osm0sis:
Read the captions. https://m.imgur.com/a/q9H6T
[Android Software Development] xdav20:
Thank you [MENTION=4544860]osm0sis[/MENTION]. I will look into the Linux version next.

To be honest, I was, secretly, hoping my question would turn into a feature request and it did. Only because a good tool maker, like yourself, can see the shortcomings when presented by a question. Thank you for your optimistic way of thinking.
[Android Software Development] osm0sis:
Oh it was definitely on the to-do, since I've already updated my AIK v3.0 WIP to ditch mkbootfs on every other platform. ;)
[Android Software Development] xdav20:
Brilliant. This feature wil allow other developers to integrate their tools to TWRP without the need to recompile from the source. I am neither a Linux developer nor Android but I have strong programming background. My 48 hours non-stop coding days is over now. Thank you again.
[Android Software Development] osm0sis:
I can't reproduce this on my side, even with the boot.img you supplied, which suggests that the AIK directories aren't set up correctly for you, so I'd suggest removing them and unzipping the package again.

Unfortunately unpacking and repacking as administrator isn't the magic fix I was hoping for either, so I'll have to look into one of those custom cpio options to get rid of mkbootfs on Windows.
[Android Software Development] xdav20:
Feedback

[MENTION=4544860]osm0sis[/MENTION], I did another test with AIK Windows version and you were correct about AIK's mkbootfs settings that everthing in /sbin folder was set to 0750. I stand corrected.

However, my second issue still unsolved. How to add a symbolic link for every executable is added to /sbin folder? This issue also shared with boot images as well.

In Recovery's terminal, I can't even execute the binary I added by its path, example:

/sbin/binary-test [flags]

unless I execute...

ln -s /sbin /system/bin

I'm guessing the AIK Linux version has this shortcoming as well. I mean, unable to create symbolic links for the newly added files in /sbin.

What I have observed between your AIK and the Image Extractor (MTK Extractor v2.6.3) program, I mentioned in my previous post, both Win versions, the version of AIK /sbin directory contains mainly the symbolic links, whereas the MTK Image Extractor contains the physical file.

I then noticed the cpiolist.txt was in very specific alphabetical order. If I placed my file in the wrong place and tried to repack, depending the situation, I had to restart from scratch again, process aborted.

I applied two different slink formats to the binary file without a success. There are other binary applets in /sbin folder (i.e. bu) that can be executed in recovery's terminal, without any prior intervention, but there is no slink commands specified for them in the generated cpiolist.txt file.

I concluded, I'm missing the mechanism to grant the binary applet a shell executable, I'm referring to Owner:Group (i.e. root:Shell). For now, I'm very happy I can include any applets with recovery and just run an ln command before I can use them. With your AIK everything is easy on a Windows machine. I hope you can find a solution to this, I'm willing to test the Windows version if you need testers. I have LG V20 H990DS phone. Thank you for your time reading this post.

Edit -01

I just discovered, if I add binaries to the system's /sbin (boot image) then from Android Terminal I can access them by its path unlike in TWRP that I reported.

Example:

/sbin/binary-test [flags]
[Android Software Development] btb55:
Thanks for AIK, I've used the Linux version to unpack the Kernel on my Samsung TAB A 10.1 (2016) T580, and after making mods and changes repack and flash so far so good, tablet boots. My first ever attempt to unpack and mod a kernel.

One issue I'm having, not specifically related to AIK, but some knowledgeable contributors here who may give me advice, I've searched far and wide and drawn a blank. I can't make the kernel permissive. I've carefully manually applied all the patches from GIThub that patch the Samsung enforcing kernel, after which I get menuconfig options to disable enforcing. I've searched all the files in the kernel Security/Selinux folders and I'm as sure as I can be that it should be possible to set permissive. Does anyone know any other method that Samsung use to force Selinux to enforcing?

Edited to add: I found my error, kernel now booting permissive. I'd missed a line of code.
[Android Software Development] almoniplo:
I downloaded Galaxy S5 (G900H) firmware from sammobile and a kernel with a matching build number from Samsung Open Source website.

After extrating the partitions from the firmware's tar.md5 and unpacking the boot.img using AIK, I replaced the boot.img-zImage with a kernel that I compiled.

I used the correct toolchain (arm-eabi-4.6), but for some reason when trying to repack the boot.img with AIK I get this error:

By the way, my Galaxy S5 model is G900H and not the regular G900F, is that relevant?

Is there any way you can help me repack the boot.img with my kernel?

Thanks!
[Android Software Development] ashyx:
Is your kernel a similar size to the original?
[Android Software Development] crazyut:
Works on bootloader unlocked, rooted devices:

Freedom Mobile LG-M470 (Canada)

T-mobile LG G Pad 8.0 X LG-V521 (US)

T-mobile LG G5 LG-H830 (US)

Known Working Devices

[/QUOTE]
[Android Software Development] osm0sis:
Development update

A little update on my progress.

Again, knowing what I know now, I dug back into the issue, and it turns out literally the only problem with cpio on Windows is ownership; since Windows doesn't have root they all become the internal userid, so on a repack using cpio you'd get uid:gid of like 195232:195232 and thus a non-booting ramdisk. Running as Administrator unfortunately doesn't make a difference.

Since the permissions actually, miraculously come out (perfectly!) intact, I've opted to take a much simpler approach than writing my own cpio tool, which is to have the cpio we already have make everything root:root on repack, which should be fine in 99% of cases. New files end up as 755 permissions, which is also acceptable. For full control there's still always AIK-Linux and the forthcoming AIK-mobile with my new method. :good:

The only trick to that is for --------- (000) permissioned files/directories (like .subackup) there's no way to traverse the directory without Administrator privileges to get the filelist for the cpio repack... BUT after a LOT of hunting and dead ends because most elevated command solutions in Windows can't pipe output, I came across a pretty legit, self-contained "sudo" for Windows! :D

No x86 compile available (of course, another hurdle.. :rolleyes:;)) so I installed Go 1.9.2, and built my own with some added stripping and ran it through UPX for further size reduction. :cowboy::victory:
[Android Software Development] osm0sis:
There's been some interest expressed in directions for how to run Flashlt and AIK-mobile from the command prompt while booted to recovery. This is complicated a little bit by my recent addition of a "|&" co-process pipe (to fix filenames with spaces once-and-for-all) which is m/ksh only and not available in busybox ash that recovery uses, the other issue being if we're AVB v1 re-signing we need access to dalvikvm to execute BootSignature_Android.jar. Well, here we go.. ;)

umount /system;
umount /system_root;
umount /system;
mount -o ro -t auto /system;
slot=$(getprop ro.boot.slot_suffix 2>/dev/null);
test ! "$slot" && slot=$(grep -o 'androidboot.slot_suffix=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
if [ ! "$slot" ]; then
slot=$(getprop ro.boot.slot 2>/dev/null);
test ! "$slot" && slot=$(grep -o 'androidboot.slot=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
test "$slot" && slot=_$slot;
fi;
test ! "$slot" -o ! -e "/dev/block/bootdevice/by-name/system$slot" && unset slot;
if [ -f "/system/system/bin/dalvikvm" ]; then
umount /system;
umount /system;
mkdir /system_root;
mount -o ro -t auto /dev/block/bootdevice/by-name/system$slot /system_root;
mount -o bind /system_root/system /system;
fi;
savedpath="$LD_LIBRARY_PATH";
savedpre="$LD_PRELOAD";
unset LD_LIBRARY_PATH;
unset LD_PRELOAD;

cd /data/local/Fla****;
./dumpit.sh;
mv *.img ../AIK-mobile/;

cd /data/local/AIK-mobile;
./unpackimg.sh;
./repackimg.sh;
mv image-new.img ../Fla****/boot-new.img;
./cleanup.sh;
rm *.img;

cd /data/local/Fla****;
./fla****.sh;
rm boot-new.img;

umount /system;
if [ -d "/system_root" ]; then
umount /system_root;
fi;
umount /system;
test "$savedpath" && export LD_LIBRARY_PATH="$savedpath";
test "$savedpre" && export LD_PRELOAD="$savedpre";

As you can see I threw in some example usage of Fla**** and AIK-mobile. This should cover Pixel devices (/system/system and A/B slot devices).

Don't be daunted, on a non-Pixel device it boils down to just the following (and you don't even really need to bother with the saved LD_ stuff, just the unset is needed for dalvikvm to run):

mount -o ro -t auto /system;
savedpath="$LD_LIBRARY_PATH";
savedpre="$LD_PRELOAD";
unset LD_LIBRARY_PATH;
unset LD_PRELOAD;

[I]<Fla**** and/or AIK-mobile commands>[/I]

umount /system;
test "$savedpath" && export LD_LIBRARY_PATH="$savedpath";
test "$savedpre" && export LD_PRELOAD="$savedpre";

Not so bad, right? Alright, have fun! :)

Edit (01/13/2018)

: Updated with potential support for Pixel 2 devices' different slot prop setup.

Edit (08/20/2018)

: Small tweaks now that I actually have an A/B device (OP6) to test on.

Edit (01/16/2020)

: The above method is no longer sufficient for AVBv1 signed images on Android 10 systems due to them requiring dalvikvm to work. It's still doable but there's a lot more work involved (e.g. mounting all the APEX files for libc to work), so that'll just have to be a known caveat for now.
[Android Software Development] shuini:
Can init.qcom.power.rc custom voltage it? How to define it?

Thank you
[Android Software Development] DodoGTA:
Why would you want to do that? :eek:
[Android Software Development] jahidinbedod:
I want to change the default language of china to english bro
[Android Software Development] DodoGTA:
By default, TWRP uses English (unless one modifies the TWRP source code)
[Android Software Development] martyfender:
I agree, I believe the default language is English. Also there is a tab in settings to change the language.

Also, I don't believe you stated your TWRP version.
[Android Software Development] ian97:
Sir osm0sis, permission to include this tool for my project..
[Android Software Development] CStadler:
I think he would want to know what the project is or what your trying to make
[Android Software Development] ian97:
oreo contexts converter
[Android Software Development] osm0sis:
Replied via PM, but for general knowledge: yes absolutely, as long as you provide credit to me for the use, @ mention me and link to this thread.

Good luck with your project! :)
[Android Software Development] DR64XDA:
Hi osm0sys,

Just like to confirm your suite works with these Mediatek 32 bit arm devices (minor brand :))

Auchan QiLive Q5S55IN4G (Android 5.1.1, SoC Mediatek mt6735m)

Auchan QiLive Q7S55IN4G (Android 6.0.1, SoC Mediatek mt6735).

I have used the AIK mobile version straightly on these devices and flashed the repacked imgs without issues at rebooting.

Just wondered if AIK mobile could be available on Magisk Repo for getting updates notifications?

Your updater already handles systemless installing for magisk, maybe just need to add the proper repo template.

Many thanks for your great work, really useful ( am tricking TWRP C sources :) and got a working version my stock kernels having no sources).
[Android Software Development] osm0sis:
No, because it would require moving the AIK-mobile branch from my GitHub account over to Magisk-Module-Repos, and I really don't want to do that.

It's not really a Magisk module anyway, only the helper script is, and uninstalling the helper module doesn't uninstall AIK, so adding it to the Magisk repo would only muddy the waters further.
[Android Software Development] DodoGTA:
Why don't you want to do that?

And, can you make it a full Magisk module?
[Android Software Development] Vagelis1608:
There is no point in him doing that because the only thing that he "modifies" in the /system partition is the helper script.

Everything else is in /data/local/AIK-mobile
[Android Software Development] DR64XDA:
Ok I see your points .. The AIK contents under /data/media are not uninstalled automatically from the script - and you are likely right in this choice - and more important you don't 'want your developments to be bounded under a repo you don't own. That's totally understandable, mine was just a curiosity so don't worry.

By the way, AIK worked for the devices I mentioned, so if you like to increase your supported device list :)
[Android Software Development] osm0sis:
Exactly. Couldn't have said it better, thanks for understanding what I was driving at. I'll check out adding those devices to the list. :)
[Android Software Development] jahidinbedod:
hi dude

how to display or edit author name in header twrp?

where the location of the file must be edited

help me
[Android Software Development] yan_saputra:
Hiii [MENTION=4544860]osm0sis[/MENTION] & Friends ... Please cross check where is My mistake in this screenshot ??? Why NOT FULL WORKED Bro ??? (Unpackimg.sh & Repackimg.sh using Terminal Emulator.apk (I do NOT Change it at all, still Normal) and always back to FastBoot Mode, include in Restart RECOVERY always in FastBoot ... Except I flash with Official TWRP App.apk to be able to open again TWRP Normal with TWRP Mat Recovery back default, while until this moment I still can NOT change the look of BACKGROUND Mat Recovery as desired ... Only be in 1 Theme Mat Recovery Default only ... ???

Please Solution and Full Tutorial Video Complete Bro ... Thanks in advance ... ?

https://www.dropbox.com/s/ew7nci94csm1tzy/Screenshot_20171130-154630.png?dl=0

https://www.dropbox.com/s/e366e58iuw4frrd/Screenshot_20171130-155028.png?dl=0

(Device : Asus, Intel x86_32-bit, ZF2, ZE551ML, Z00A, 4 Gigs Ram, Root Method Super User V2.8.2, Custom ROM RR V5.8.5 Nightly Build in 20171128 with Security Patch 20171106 & TWRP Official V3.1.1-0 from Official TWRP App.apk, Kernel Default V3.10.72, SELinux Default Enforcing, UPDATE-AIK.Mobile.Installer.v2.9-ALL-signed.zip, BusyBox V61 - 1.27.2, Xposed Installer V88.2, Xposed .apk V3.1.4, Root Explorer & Terminal Emulator).
[Android Software Development] osm0sis:
I think I understand you're trying to replace the TWRP splash screen or something? There are lots of tutorials around.

My guess is mkbootfs ****ing things up on repack for your device, per usual, and if so it'll be fixed for good in v3.0. Try AIK-Linux with ./unpackimg.sh --sudo in the meantime.

General note for everyone, since a number of these questions have popped up lately: I make the tools, but this thread is not for endless how-to questions, especially not for TWRP theming.

I know how to unpack things but that doesn't mean I know all the ins and outs of TWRP's themes, and there are better places to ask.

I'm sure a bit more searching in the correct places would find these types of questions already answered, possibly with step-by-step instructions and maybe even video tutorials, but again, this is not that place.

Questions of this nature will go unanswered here because honestly I don't know the answer for x device's bootsplash, y device's SELinux state, or z's TWRP theme, and this thread is for development.

Thanks for your cooperation.
[Android Software Development] osm0sis:
I need a Pixel tester (i.e. last year's) rooted with SuperSU to try an unpack/repack with no changes in AIK v3.0 beta on a Windows PC. Any volunteers?
[Android Software Development] Alxoom33:
Problem is that the TWRP 3.2.0 img and zip files do not work for the Pixel 2 XL. They freeze at the stock splash screen as soon as they are booted. So I'm not sure how to test at this time until we have a working TWRP 3.2.0 recovery. Currently only TWRP Beta 2, v. 3.1.1 is working for our device.
[Android Software Development] osm0sis:
Recovery doesn't really matter for the testing purposes here. Make sure you have a working recovery for now, just for the safety. Like I said, I'm more interested in how a repack of a rooted boot.img dump works using AIK v3.0 Beta for Windows at the moment.
[Android Software Development] ingbrzy:
Hi [MENTION=4544860]osm0sis[/MENTION]

Is there a way how to rm dm-verify from dtb at OREO with AIK..?

Thank you
[Android Software Development] osm0sis:
If you search xda there are dtb tools available that you may use after AIK unpacks the boot.img. You may first need to hex edit the zImage to get the dtb from the end however.
[Android Software Development] osm0sis:
[MENTION=5868929]hsbadr[/MENTION], I've been chipping away at the script changes necessary using my girlfriend's MacBook Pro (:p), but have hit a real snag with this macOS distro'd file binary failing to use the detection in my androidbootimg.magic file (symptom being that it reports "Android" instead of "AOSP"), this results in all sorts of detections failing.

I'm starting to think that file has been enough of a headache with broken versions on all platforms that I need to always include my own builds. While I still work on my Windows -> Darwin cross-compiler toolchains would you be able to compile a Darwin file binary at tag FILE5_32 and upload it for me so I can continue working on the script? :cowboy:

https://github.com/file/file/tree/FILE5_32
[Android Software Development] ipdev:
Will this work with Apple's APFS file system?

(Only ask since I did a fresh install of high Sierra this weekend and it converted my initial os extended (case sensitive journaled) to APFS case sensitive.)
[Android Software Development] osm0sis:
Umm, good question. I have no idea what that is haha.

Follow that post I quoted and try his semi-functional unofficial "AIK-Unix" and see.
[Android Software Development] martyfender:
"Definition of: APFS
[Android Software Development] osm0sis:
Development update

Well as long as APFS is ext-like enough that cpio can unpack/repack as root with permissions and UID:GID (# value at least) intact, then we should be in business on all Intel Macs. If not I can always add a workaround to have it repack as 0:0 like I do now for Windows in v3.0.

I found file being the broken v5.31 wasn't the only issue with out-of-the-box macOS (i.e. without Homebrew/MacPorts addons), readlink, cpio, dd and tail are also weird and missing important features. xz and lzop are also missing. Good news is I found a mirror of prebuilt MacPorts distro packages and was able to grab any I couldn't work around natively from there:

http://pcbsd.mirror.garr.it/mirrors/macports-packages/

Saves me from cross-compiling file to Darwin also, since they have v5.32 there, and really macOS and Cygwin are the only package distros I know still stuck on the broken v5.31, so I'll just include a workaround to substitute functions and point to those required binaries for Darwin only in AIK-Linux (and I continue to leave Cygwin's at v5.25 until they get around to updating to v5.32). :good:

I also found macOS is currently shipping with an old version (7) of the JDK and AVBv1 signing would fail, so I've made it use the JRE java instead so it's relatively painless to resolve by updating to the latest JRE (8).

Some more testing aside the script changes are done and now I just need to get my cross-compile toolchain working so I can update the binaries. :)

I wonder if I can also coax [MENTION=4120742]munjeni[/MENTION] into making i686 and x86_64 Darwin builds of his excellent SIN unpacking tool, so all platforms can have the complete set..? :D
[Android Software Development] Wolfcity:
[MENTION=4544860]osm0sis[/MENTION]; What's the best way to uninstall the android version of AIK? Just delete the folder?

For me it's easier to handle the windows version so I don't need the mobile version anymore.
[Android Software Development] osm0sis:
su -c "/data/local/AIK-mobile/bin/aik --uninstall"

should do the trick.
[Android Software Development] z31s1g:
Nexus 7 2013 can be added to the list of devices confirmed working. Thanks again for this useful tool!
[Android Software Development] DarkFantasy6:
Lg optimus 4x HD can be added, because i tested it :) Repacked a kernel for 4.3 :P
[Android Software Development] NSDCars5:
Just wanted to tell you that it works on the Micromax A27. Thanks for this wonderful tool, now I have init.d in my ROM!
[Android Software Development] hkfriends:
hi there

it is strange to my Pantech A880S kernel image...

Splitting image to "/split_img/" . . .

BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.hardware=qcom user_debug=31 maxcpus=2 msm_rtb.filter=0x3F ehci-hcd.park=3 loglevel=0

BOARD_KERNEL_BASE 00000000

BOARD_PAGE_SIZE 2048

BOARD_RAMDISK_ADDR 02000000

Unpacking ramdisk to "/ramdisk/" . . .

Compression used: gzip

4704 blocks

Done!

Everything looks ok, but when I using fastboot to boot it (my device has been unloacked bootloader)

>fastboot boot image-new.img

downloading 'boot.img'...

OKAY [ 0.301s]

booting...

FAILED (remote: dtb not found)

finished. total time: 0.316s

It is not success, my boot.img is attached here

anyone know who to extract kernel and dtb ?