I have installed busybox on my device, though have trouble in using tar. I issued this command but gets an error,
$ tar -xv stressapptest-1.0.4.tar
This is the usage help it gives,
BusyBox v1.19.4-Stericson (2012-02-20 19:30:32 CST) multi-call binary.
Usage: tar -[cxtZhmvO] [-X FILE] [-T FILE] [-f TARFILE] [-C DIR] [FILE]...
Create, extract, or list files from a tar file
Operation:
c Create
x Extract
t List
f Name of TARFILE ('-' for stdin/out)
C Change to DIR before operation
v Verbose
Z (De)compress using compress
O Extract to stdout
h Follow symlinks
m Don't restore mtime
exclude File to exclude
X File with names to exclude
T File with names to include
What combination should I use to extract the file(.tar)?
Thanks..
DKSL said:
I have installed busybox on my device, though have trouble in using tar. I issued this command but gets an error,
$ tar -xv stressapptest-1.0.4.tar
This is the usage help it gives,
BusyBox v1.19.4-Stericson (2012-02-20 19:30:32 CST) multi-call binary.
Usage: tar -[cxtZhmvO] [-X FILE] [-T FILE] [-f TARFILE] [-C DIR] [FILE]...
Create, extract, or list files from a tar file
Operation:
c Create
x Extract
t List
f Name of TARFILE ('-' for stdin/out)
C Change to DIR before operation
v Verbose
Z (De)compress using compress
O Extract to stdout
h Follow symlinks
m Don't restore mtime
exclude File to exclude
X File with names to exclude
T File with names to include
What combination should I use to extract the file(.tar)?
Thanks..
Click to expand...
Click to collapse
You didn't add the "f" switch to choose the filename so tar is trying to read from stdin. Change your command to:
tar -xvf stressapptest-1.0.4.tar
Similar problem I have:
Command:
tar -zcvf /storage/emulated/0/!Backup/backup_`date +%Y-%m-%d_%H-%M-%S`.tar.gz /storage/emulated/0/!Bac
kup/tmp
BusyBox v1.21.0-Stericson (2013-01-28 21:49:55 GMT) multi-call binary.
Usage: tar -[cxtZhmvO] [-X FILE] [-T FILE] [-f TARFILE] [-C DIR] [FILE]...
Create, extract, or list files from a tar file
====================================
I want to compress to gz.
Related
Since I tend to modify roms before flashing them to my phone, and sometimes want to do so away from a computer, I ended up writing this. It's an ash script that uses the openssl binary found on most custom roms, and infozip. The sdk test/platform/media/etc keys are included. Usage:
Usage: signapk (options) [command] (files)
commands:
sign FILE sign a .zip or .apk
sign FILE1 FILE2 create a signed copy of FILE1 as FILE2
cert FILE(s) print cert info on FILE's signer
certinfo FILE print detailed cert info on FILE's signer
cmp FILE compare signer of FILE with default/selected cert
cmp FILE1 FILE2 compare signer of FILE1 to signer of FILE2
options:
-k, --key FILE key to sign with
-c, --cert FILE cert to sign with
if -c or -k are not files then they are considered
aliases to builtins (ie -k testkey or -c platform)
-f, --force sign even if cert differs from original
-t, --tmp DIR use DIR for tempdir instead of '/cache'
-d, --debug output debugging
-V, --version print 'signapk v0.3.1'
exit codes:
1: read error (file 1) 2: read error (file 2)
3: write error 4: ssl error
5: zip write error 9: key error
8: sign: cert mismatch 10: cmp: cert mismatch
128: script error 255: user error
Installation:
unpack somewhere. If needed, edit the variables at the top of the script. By default it uses /cache/ for 4 small temporary files.
Faq:
* Why did you include a busybox and openssl? * Some roms don't include the openssl utility. Busybox's unzip refuses to deal with zipaligned apks on alot of roms, because it wasn't compiled with ENABLE_DESKTOP. Busybox's ash is missing things that the script needs, on some roms. The script will use whatever the rom provides, if these binaries are not present. Good luck.
* How do I change the cert? * see signapk --help for cert/key selection flags
* Can I use this in my MarketAppThingy? * Sure, and please let me know. If it's a paid MarketAppThingy, consider sending me a free copy.
Changelog:
release 3: cmp function, key selection, documented exit codes that make sense, and paranoia. Includes trimmed down busybox and openssl binaries. If these are present, script will reload itself to run in it's busybox ash interpreter to avoid broken busybox compiles, and can run without using anything provided by the rom. In theory this means no compatibility issues, but is limited to ARM devices.
release 2: Apparently it's valid to have ANYNAME.SF/ANYNAME.RSA or ANYNAME.DSA. signapk cert and certinfo now handles this. The sign function will blindly write to CERT.SF and CERT.RSA as this is the behavior of the standard SignApk.java. This may be fixed later.
If you don't wanna signup to download attachment, snag this from http://code.google.com/p/signapk/downloads/list
very, very useful. I'm testing this now Signing stuff was always way too complicated.
Cool. Can't wait for someone to make a market app that creates a simple ui to edit update.zips before flashing. Hint hint
I put the files in /system/signapk (new folder)
When i run the script I get the error below. The test file is an unsigned apk exported from eclipse.
Code:
# ./signapk sign /sdcard/unsigned.apk
./signapk sign /sdcard/unsigned.apk
Checksumming /mnt/sdcard/unsigned.apk:
res/layout/main.xml AndroidManifest.xml
resources.arsc res/drawable-hdpi/icon.png res/drawable-ldpi/icon.png res/drawable-mdpi/icon.png classes.dex
[COLOR="Red"]unable to write 'random state'
./signapk: line 132: ./signapk.zip: not found[/COLOR]
#
Any idea what needs changing to fix this?
update: When I used the full path it worked.
Code:
# /system/signapk/signapk sign /sdcard/unsigned.apk
/system/signapk/signapk sign /sdcard/unsigned.apk
Checksumming /mnt/sdcard/unsigned.apk:
res/layout/main.xml AndroidManifest.xml
resources.arsc res/drawable-hdpi/icon.png res/drawable-ldpi/icon.png res/drawable-mdpi/icon.png classes.dex
unable to write 'random state'
adding: META-INF/MANIFEST.MF (deflated 49%)
adding: META-INF/CERT.SF (deflated 48%)
adding: META-INF/CERT.RSA (deflated 33%)
# /system/signapk/signapk cert /sdcard/unsigned.apk
/system/signapk/signapk cert /sdcard/unsigned.apk
/sdcard/unsigned.apk 936EACBE07F201DF SDK Test Key
Was playing around with app inventor and came up with this:
edit: AppInventor does not generate java code and it cannot be worked on further in anything else (i.e eclipse)
I was really hoping I would atleast get the activity xml
Heya, the latest is at http://code.google.com/p/signapk/downloads/list and should fix the zip error. signapk-bb, signapk-zip, and signapk-openssl are static, trimmed down versions of utilities required by the script, and should be extracted to the same directory as the script. If they are not present it will try to use stuff in $PATH
Just throwing it (the obvious) out there that this could enable a new generation of morphs for /data apps
Copy apk,uninstall,morph, install
Hmmmm....
britoso said:
Just throwing it (the obvious) out there that this could enable a new generation of morphs for /data apps
Copy apk,uninstall,morph, install
Click to expand...
Click to collapse
How can i get this to work with a morph and to edit the updater-script?
Someone explain the commands with example...
Another noob question is .. it is for android or pc...
Edit:- Made my own mod here https://forum.xda-developers.com/t/...-apk-zip-within-android.3835975/post-81324327
below code works with latest(1.32.0) busybox
Bash:
#!/system/bin/sh
# depends unzip printf zip openssl
# put zip openssl busybox in PATH
# Usage:-
# Sign.sh key.pk8 key.x509.pem in.zip out.zip
ordie() {
if [ $? -ne 0 ]; then
IFS=" "
$BB printf "$1\n"
exit $2
fi
}
PKEY="$1"
CERT="$2"
ORIG="$3"
TARGET="$4"
BB=busybox
cat "$ORIG" > "$TARGET"; ordie "Cannot write to $TARGET" 3
$BB printf "Checksumming $ORIG:\n"
TMP=$HOME
TMPDIR="$TMP/sign-$$"
TMPPKEY="$TMPDIR/tmp.pkey"
mkdir -p "$TMPDIR/META-INF"; ordie "" 3
$BB printf "Manifest-Version: 1.0\r\nCreated-By: 1.0 (Android SignApk)\r\n\r\n" > "$TMPDIR/META-INF/MANIFEST.MF"
ZIPls=$($BB unzip -qql "$ORIG"); ordie "$ORIG: unzip error" 1
OLDIFS=$IFS
IFS=${IFS:2:2}
for i in $ZIPls; do
IFS=$OLDIFS
set -- $i
if [ "$#" -ge 3 ] && [ "$1" != "0" ]; then
file="${i:30}"
case "$file" in META-INF/MANIFEST.MF|META-INF/CERT.SF|META-INF/CERT.RSA) continue;; esac
$BB printf "$file "
hash=$($BB unzip -p "$ORIG" "$file" | openssl sha1 -binary | openssl base64); ordie "$ORIG: unzip error" 1
ret="Name: $file\r\nSHA1-Digest: $hash\r\n\r\n"
$BB printf "$ret" >> "$TMPDIR/META-INF/MANIFEST.MF"
hash=$($BB printf "$ret" | openssl sha1 -binary | openssl base64)
$BB printf "Name: $file\r\nSHA1-Digest: $hash\r\n\r\n" >> "$TMPDIR/META-INF/CERT.SF.temp"
fi
done
$BB printf "\n"
mfhash=$(cat "$TMPDIR/META-INF/MANIFEST.MF" | openssl sha1 -binary | openssl base64)
$BB printf "Signature-Version: 1.0\r\nCreated-By: 1.0 (Android SignApk)\r\nSHA1-Digest-Manifest: $mfhash\r\n\r\n" > "$TMPDIR/META-INF/CERT.SF"
cat "$TMPDIR/META-INF/CERT.SF.temp" >> "$TMPDIR/META-INF/CERT.SF"
openssl pkcs8 -inform DER -nocrypt -in "$PKEY" > "$TMPPKEY"; ordie "" 4
cat "$TMPDIR/META-INF/CERT.SF" | openssl smime -sign -inkey "$TMPPKEY" -signer "$CERT" -binary -outform DER -noattr > "$TMPDIR/META-INF/CERT.RSA"; ordie "" 4
cd "$TMPDIR"
zip "$TARGET" META-INF/MANIFEST.MF META-INF/CERT.SF META-INF/CERT.RSA; ordie "" 5
cd - > /dev/null
rm -r "$TMPDIR"
Disclaimer: Do only use this information if you know what you're doing!
PATH=$PATH:/home/markus/android/sdk/platform-tools
Get kernel from phone:
adb shell
su
dd if=/dev/block/mmcblk0p8 of=/sdcard/external_sd/stockboot.img
Exit adb shell
adb pull /sdcard/external_sd/stockboot.img
Separate the zImage from the ramdisk (see below for abootimg):
abootimg -x stockboot.img
unpacks the archive and copies contents to working directory:
gunzip -c initrd.img | cpio -i
Do your edits, e.g. default.prop, add:
debug.performance.tuning=1
video.accelerate.hw=1
windowsmgr.max_events_per_sec=150
--> move all files to new folder, cd into this folder:
repacks files from working directory into an archive (MAKE SURE NO OTHER FILES ARE IN THE WORKING DIRECTORY!!)
find . | cpio -o -H newc | gzip > ../myinitrd.img
New boot.img:
./mkbootimg --kernel zImage --ramdisk myinitrd.img --cmdline "console=null androidboot.hardware=qcom androidboot.emmc=true hw=6" -o myBuiltBoot.img --base 0x00400000 --pagesize 4096
You can also use abootimg to create your new .img file, it has an easier syntax as it exports the commandline to a .cfg file and you can use that while creating the package.
Push your new kernel.img to the phone:
adb push myBuiltBoot.img /sdcard/external_sd/myBuiltBoot.img
Write kernel to kernel-partition in phone:
adb shell
su
dd if=/sdcard/external_sd/myBuiltBoot.img of=/dev/block/mmcblk0p8
adb reboot
< pray >
Sources:
http://forums.androidcentral.com/lg...ense-back-up-your-phone-without-nandroid.html
http://forum.xda-developers.com/showthread.php?t=1227269
http://forum.xda-developers.com/showthread.php?t=1292557
Also quite handy: http://packages.debian.org/de/sid/abootimg
wouldnt just editing build.prop in /system without touching kernel do the same job? ^_^
Yep. I just wanted to describe the whole process of extracting and packing the needed files. The edit was just an example. And in fact, i made a typo, it's called default.prop.
Hi,
My Question is
How do i extract initramfs from a Kernel.bin file ?
the Galaxy S Advance uses Kernel.bin instead of a boot.img
I tried dsixda's kitchen, but it couldn't recognize the file format
I just want to replace a certain binary in the /sbin folder and repack the kernel.
Edit:this phone is kinda different,
it seems that the recovery and kernel partitions are the same
Figured it out
The zImage created after compilation process is actually the same, a kernel binary aka kernel.bin
I just had to rename the zImage to kernel.bin and add md5sum to the kernel.bin and pack it into a tarball to make it flashable via odin.
that can be done like this
Code:
md5sum -t kernel.bin >> kernel.bin
mv kernel.bin kernel.bin.md5
tar -cvf mykernel.tar kernel.bin.md5
As for packing the ramdisk into the kernel.bin
that can be done before compiling by editing the .config file or any config you gonna use
just have to add the path to the ramdisk at CONFIG_INITRAMFS_SOURCE="path to your ramdisk"
There's also a script to unpack the ramdisk from the kernel.bin, i'll attach it here
usage:
place the script at the same location of the kernel.bin
Code:
chmod +x unpack-initramfs.sh
bash unpack-initramfs.sh kernel.bin.md5
OR
/bin/sh unpack-initramfs.sh kernel.bin.md5
Hope this helped Others who were facing the same problem
how to repack it?
Easy peasy. Download the script attached and run as follows to create an Odin flashable tar
Code:
$ odintar image_1 image_2 image_3 ... image_X package.tar
You can also run the script with no arguments to get the usage information.
The output will be a package.tar.md5 which will contain all the image_XXX files you specified, and will also be Odin flashable.
Flash at your own risk, but I have tested this and it works. Just helps to automate tar flashable making
Instructions for use:
Download and remove .txt extension
Move/Copy to somewhere in your path (~/bin, /usr/local/bin, [for cygwin move it to C:/path/to/cygwinDirectory/bin] anywhere in your PATH)
Run to make tars
Profit.
Contents of script file:
Code:
#!/bin/bash
if [ "[email protected]"="" ]
then
echo "Usage: $0 image_1 image_2 ... image_X package.tar"
exit 0
fi
O=${#@}
((NUM = ${#@} - 1))
tar -H ustar -c ${@:1:$NUM} > ${@:$O}
md5sum -t ${@:$O} >> ${@:$O}
mv ${@:$O} ${@:$O}.md5
sdat2img for Android!
Most of us, have no pc for converting system.new.dat to system.img...
So, this is why i create this tool!
Code:
[B]Post 1[/B] → Introduction, installation, downloads
[B]Post 2[/B] → Changelog
[B]Post 3[/B] → How to use
sdat2img is a tool, that write on python language, to convert system.new.dat into system.img
This tool was only work on Windows and Linux
So i adapt it into android that can be runned in the Terminal
Requirements:
Custom Recovery
Around 30-50MB of free system
a Terminal
Installation:
Download the zip
Install via custom recovery
Reboot!
Uninstalling:
I should have the uninstaller, but it is gone somewere in my PC. So maybe later gonna add this.
Download links:
AndroidFileHost
Credits:
@xpirt for sdat2img.py
@7175 for python for android
XDA:DevDB Information
sdat2img for Android, Tool/Utility for the Android General
Contributors
RendyAK
Version Information
Status: Beta
Current Beta Version: 0.2
Created 2016-08-27
Last Updated 2016-08-27
Changelog:
0.2 BETA
Code:
[Fixed] Convert error
Old Changelog
Code:
[B]0.1 BETA[/B]
- Intial Release
How to use!
Well, this is pretty simple, haha.
Just like the @xpirt sdat2img.
Code:
Usage: sdat2img <system_transfer_list> <system_new_file> <system_img>
And wait for the process finish.
WARNING!
I SUGGEST YOU TO "cd" TO THE DIRECTORY OF system.new.dat FIRST!
How to extract the system.img?
Just simply enter this command
Dont forget to "cd" to the directory of system.img
Code:
mkdir system
mount -t ext4 -o loop system.img system
cp -rf system system2
And the output is on system2 folder.
Dont forget to press enter each command you type!
Reserved for some case.
Update!
0.2 BETA
Code:
[Fixed] Convert error
Incredible! Thank you so much for this, can't wait to try it out! :good:
RendyAK said:
Changelog:
0.2 BETA
Click to expand...
Click to collapse
After unpacking the file sdat2img-android-arm-0.2.zip, catalog python3.4.2 occupies 42.6 MB of valuable space on the system partition.
Could you just leave these components python that are needed?
Thanks.
ze7zez said:
After unpacking the file sdat2img-android-arm-0.2.zip, catalog python3.4.2 occupies 42.6 MB of valuable space on the system partition.
Could you just leave these components python that are needed?
Thanks.
Click to expand...
Click to collapse
I didnt know whats the python main file.
But it think for best result its need all of the python files.
On Android! Just what I was searching for. Thank you @RendyAK. This is awesome stuff.
hi @RendyAK
I have a cm12 system.new.dat. What will your program do to this
I floop the pig
Everything had worked fine till i tried to convert a dat file of over 4gb. It says
[email protected]:/ $ su
[email protected]:/ # cd /storage/sdcard1
system.transfer.list system.new.dat system.img <
Traceback (most recent call last):
File "/system/python3.4.2/sdat2img.py", line 99, in <module>
main(sys.argv)
File "/system/python3.4.2/sdat2img.py", line 78, in main
init_output_file_size(output_img, commands)
File "/system/python3.4.2/sdat2img.py", line 73, in init_output_file_size
output_file_obj.flush()
OSError: [Errno 27] File too large
1|[email protected]:/storage/sdcard1 #
adithbalan said:
Everything had worked fine till i tried to convert a dat file of over 4gb. It says
0_a1[email protected]:/ $ su
[email protected]:/ # cd /storage/sdcard1
system.transfer.list system.new.dat system.img <
Traceback (most recent call last):
File "/system/python3.4.2/sdat2img.py", line 99, in <module>
main(sys.argv)
File "/system/python3.4.2/sdat2img.py", line 78, in main
init_output_file_size(output_img, commands)
File "/system/python3.4.2/sdat2img.py", line 73, in init_output_file_size
output_file_obj.flush()
OSError: [Errno 27] File too large
1|[email protected]:/storage/sdcard1 #
Click to expand...
Click to collapse
Please make sure you have 4-8GB free on your sdcard.
PiggyFlooper said:
hi @RendyAK
I have a cm12 system.new.dat. What will your program do to this
I floop the pig
Click to expand...
Click to collapse
It just do the same with the xpirt's sdat2img.
Go to xpirt thread for more info
@RendyAK, can you give me a link to the python for android
When i write this command
mount -t ext4 -o loop system.img system
Then it shows device or resource busy
@RendyAK
Hi is there a way to uninstall this zip ?
Help me !
RendyAK said:
Well, this is pretty simple, haha.
Just like the @xpirt sdat2img.
Code:
Usage: sdat2img <system_transfer_list> <system_new_file> <system_img>
And wait for the process finish.
WARNING!
I SUGGEST YOU TO "cd" TO THE DIRECTORY OF system.new.dat FIRST!
How to extract the system.img?
Just simply enter this command
Dont forget to "cd" to the directory of system.img
Code:
mkdir system
mount -t ext4 -o loop system.img system
cp -rf system system2
And the output is on system2 folder.
Dont forget to press enter each command you type!
Click to expand...
Click to collapse
After I type and enter " Usage: sdat2img...." , terminal display this "
/system/bin/sh: syntax error: '< ' unexpected
"
Lordlight said:
After I type and enter " Usage: sdat2img...." , terminal display this "
/system/bin/sh: syntax error: '< ' unexpected
"
Click to expand...
Click to collapse
Don't type it literally. You supposed to replace stuff in brackets with your filenames. "Usage:" should be there too.
Thanks a lot !
Not_Sure said:
Don't type it literally. You supposed to replace stuff in brackets with your filenames. "Usage:" should be there too.
Click to expand...
Click to collapse
Could you please give me an example ?
It is better.
Binary sdat2img, no python