0

Usual shar archives fail to extact in adb shell due to problems with lock directory and temporary files for HERE documents. Zip archives are also not an option.

How do I make an archive that can be easily extracted to /data/local/tmp/ out of the box on unrooted Android without busybox?

Vi0
  • 1,665
  • 7
  • 23
  • 43

1 Answers1

1

You can install busybox pretty easily on an unrooted Android phone. Steps:

  • Grab the file busybox-android from the eponymous github project.
  • Get it onto your device via scp, adb push, Android File Transfer, etc. Put it somewhere public that you'll have access to from a Terminal Emulator session. Just call it busybox.
  • Start a Terminal Emulator session. Make a directory ~/bin and copy the busybox file from the public place you put it to that new directory.
    • Since the cp command is not available in a Terminal Emulator session (!) do it this way: cat $PATH_TO_BUSYBOX/busybox > ~/bin/busybox
  • Now cd ~/bin and create a symbolic link: ln -s busybox tar.

So now create a tarball using tar czv $FILENAME $ROOT_OF_FILES_TO_ARCHIVE, kick it over to your device, and extract using tar xzv $FILENAME.

tar is also available by default to ssh sessions served by SSHDroid (because SSHDroid provides busybox). You might need to register it? Don't remember if that stuff works on the free version.

intuited
  • 817
  • 2
  • 11
  • 24
  • Is there a tool to create self-extracting archives for Android, to be able to unwrap complex structure (e.g. Valgrind) in /data/local/tmp/ in one move, without preparation step? – Vi0 Mar 11 '15 at 21:10
  • If there is, it would likely use the POSIX toolkit provided by busybox. – intuited Mar 12 '15 at 06:31
  • It can be shellscript+busybox+datafile bundled in one file. – Vi0 Mar 12 '15 at 10:41
  • Hmm. How would you extract the busybox from the bundle without the POSIX toolkit? – intuited Mar 12 '15 at 14:27
  • The bundle can start with #!/system/bin/sh, which will somehow extract busybox from it, then call busybox tar -xf. – Vi0 Mar 12 '15 at 21:59
  • Well, yes. But the "somehow" is really the crux of the issue. I did just notice that dd is available, so that would be one way. Maybe you should ask another question to see if somebody has found such a program or is writing one. – intuited Mar 13 '15 at 21:48
  • There's also an app that installs busybox on an unrooted phone. Though I guess by "out of the box" you mean "with no applications installed". – intuited Mar 13 '15 at 21:54