FORUMS
Remove All Ads from XDA

[TRICK/CWM3/EDIFY] Output to recovery UI from shell script

11,416 posts
Thanks Meter: 88,052
 
By Chainfire, Moderator Emeritus / Senior Recognized Developer - Where is my shirt? on 5th April 2011, 02:14 PM
Post Reply Email Thread
15th May 2014, 09:51 PM |#21  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,102
 
Donate to Me
More
Quote:
Originally Posted by _that

Exactly! I learned a lot about the zip format while researching this.

Argh! I saw your original question in that thread but I never found the solution because there were so many pages in between...

I ended up with a hack that appears to resemble Chainfire's minsignapk, but I didn't need to write my own zipadjust. Basically I simply sign the zip normally with signapk, then I unpack and repack the whole archive using 7zip (bonus: slightly better compression), and then I run the whole-zip-signer on the archive.

Here is my SignWholeFile.jar - the source code is just too ugly to publish. Attachment 2745848 If you find that it works better than Chainfire's version, I'll clean the source and release it.

This is the script I use for signing:

Code:
#!/bin/sh
KEYDIR=~/android/aosp/build/target/product/security
SIGNAPK=~/android/aosp/prebuilts/sdk/tools/lib/signapk.jar
SIGNWHOLEFILE=~/android/src/signapk/SignWholeFile.jar

java -jar $SIGNAPK -w $KEYDIR/testkey.x509.pem $KEYDIR/testkey.pk8 "$1" "$1.signed.zip"
mv "$1" "$1.unsigned"
signedzip=$(readlink -f "$1.signed.zip")
[ -d /tmp/signapk2 ] && rm -rf /tmp/signapk2
mkdir /tmp/signapk2
pushd /tmp/signapk2
unzip $signedzip
rm $signedzip
7z a -r -mx=9 $signedzip *
#7z a -r $signedzip *
popd
mv "$1.signed.zip" "$1"
java -jar $SIGNWHOLEFILE $KEYDIR/testkey.x509.pem $KEYDIR/testkey.pk8 "$1" "$1"

Fantastic! Thanks a lot!

@TKruzze is working on converting his popular PA GApps packages over to shell script update-binary, and asked me to look into the signing issue again citing my old post there, so if Chainfire's doesn't do the trick then I'll point him this way.
 
 
17th May 2014, 12:13 PM |#22  
rlorange's Avatar
Senior Member
Flag Melbourne
Thanks Meter: 2,268
 
More
Quote:
Originally Posted by osm0sis

Nice! My misunderstanding then.

And ah yes, the old "1 and 8" issue with unzip. Might be resolved in the latest busybox 1.22.1 but I'm not 100% about that, and it'll be awhile before that makes it into recoveries.

I'd love to get hold of your zip signer if that'd be okay. I have Chainfire's solution, but I was still running into some verification problems (I think) from the MinSignApk whole file resigning.

I simply used zarchiver apk to zip the folder and unzip command works. Root explorer used to zip it up failed with 1,8 error. Hope this helps you all

Sent from my GT-I9505 using Tapatalk
17th May 2014, 05:15 PM |#23  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,102
 
Donate to Me
More
Quote:
Originally Posted by rlorange

I simply used zarchiver apk to zip the folder and unzip command works. Root explorer used to zip it up failed with 1,8 error. Hope this helps you all

We're talking about unzipping via script in recovery. Thanks for trying to help though.
17th May 2014, 11:01 PM |#24  
rlorange's Avatar
Senior Member
Flag Melbourne
Thanks Meter: 2,268
 
More
Quote:
Originally Posted by osm0sis

We're talking about unzipping via script in recovery. Thanks for trying to help though.

I know man I made my own mod using this and what I said stands just use chain fire zip replace with your own stuff zip with zarchiver from device it works when unzipping when you flash not with root explorer

Sent from my GT-I9505 using Tapatalk
17th May 2014, 11:10 PM |#25  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,102
 
Donate to Me
More
Quote:
Originally Posted by rlorange

I know man I made my own mod using this and what I said stands just use chain fire zip replace with your own stuff zip with zarchiver from device it works when unzipping when you flash not with root explorer

And zArchiver signs the zip so that it will pass zip verification when flashed in recovery? Because that's the key to what we've been discussing here, and it doesn't appear to support it.
18th May 2014, 12:56 AM |#26  
rlorange's Avatar
Senior Member
Flag Melbourne
Thanks Meter: 2,268
 
More
Quote:
Originally Posted by osm0sis

And zArchiver signs the zip so that it will pass zip verification when flashed in recovery? Because that's the key to what we've been discussing here, and it doesn't appear to support it.

The discussion I'm refering to is busybox uzip command not working because of 1,8 error I used my device to rezip and chainfures zip as a template and z archiver to zip up

Sent from my GT-I9505 using Tapatalk

---------- Post added at 10:56 AM ---------- Previous post was at 10:48 AM ----------

I found this thread and used the trick in a mod and encountered the problem. I was using root explorer to zip and replaced chainfires update-binary with my own script. But the unzip command didn't work. I zipped using zrachuver instead and stumbled on a solution. Luck I guess lol

Sent from my GT-I9505 using Tapatalk
The Following User Says Thank You to rlorange For This Useful Post: [ View ] Gift rlorange Ad-Free
18th May 2014, 02:43 AM |#27  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,102
 
Donate to Me
More
7zip works too, but once you sign the zip it breaks again.

That's where _that and Chainfire's whole zip signers should come into play.
The Following User Says Thank You to osm0sis For This Useful Post: [ View ]
Modding.MyMind
5th June 2014, 10:06 PM |#28  
Guest
Thanks Meter: 0
 
More
Not sure if this info is useful knowledge but I enjoy throwing my ten cents out anyways lol. Most of these custom recoveries (unless custom built and properly dealt with) don't support zip formats with more up to date encryptions. Such zips which are being created and used successfully in recoveries are based on some really old school encryptions which the recoveries currently support. I ran in to this issue last week with a zip I made on my linux distro and the encryption it put out gave the 1,8 error. Had to find a zip source which used an older encryption method. I'm actually surprised such recoveries haven't implemented this yet. It isn't hard to add. More in less, just a copy and paste lol.
6th June 2014, 12:26 AM |#29  
Recognized Developer / Recognized Contributor
Thanks Meter: 4,266
 
Donate to Me
More
Quote:
Originally Posted by Modding.MyMind

Most of these custom recoveries (unless custom built and properly dealt with) don't support zip formats with more up to date encryptions.

The problem has nothing at all to do with encryption - not even with compression algorithms. It's just the way how the file headers in the zip file are written, and the design decision in busybox to support only the easier variant unless support for the other is explicitly enabled.
The Following User Says Thank You to _that For This Useful Post: [ View ]
Modding.MyMind
6th June 2014, 12:51 AM |#30  
Guest
Thanks Meter: 0
 
More
Quote:
Originally Posted by _that

The problem has nothing at all to do with encryption - not even with compression algorithms. It's just the way how the file headers in the zip file are written, and the design decision in busybox to support only the easier variant unless support for the other is explicitly enabled.

Hmm, I stand corrected. Decided to take a look at the source this time. Was too lazy last time but figured it to be as earlier stated by me.

Sent from my C525c using Tapatalk
27th August 2014, 08:37 PM |#31  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,102
 
Donate to Me
More
Any ideas how to get the name of the zip update-binary is running from, via a .sh executed by the EDIFY?

It's dead easy with a pure shell script update-binary ($3) but I'm having trouble figuring it out when doing EDIFY.


Edit: Nevermind! Figured it out myself!

Very similar to the OUTFD, we can just pull it from the updater commandline (duh $3!) through ps, but we have to go wide to get the whole thing.

Full path:
Code:
ps -w | grep -v "grep" | grep -oE "update(.*)" | cut -d" " -f4
Just the zip name:
Code:
basename `ps -w | grep -v "grep" | grep -oE "update(.*)" | cut -d" " -f4`
The Following 3 Users Say Thank You to osm0sis For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes