Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
inportb
Old
(Last edited by inportb; 25th May 2012 at 06:48 AM.)
#1  
Recognized Developer - OP
Thanks Meter 166
Posts: 433
Join Date: Dec 2008
Talking PengDroid: a healthy fusion of Debian and Android

Quote:
Notice: Now that PengDroid has been rolled into BotBrew, this installation method is now deprecated. You'd get all this, and a package manager GUI, by installing BotBrew "basil".
I love Debian, and I think it's nice to have a chroot environment full of useful tools. However, there's always a barrier keeping Android and Linux from talking to each other. This is why BotBrew is designed to not rely on a chroot system.

PengDroid is an experimental chimera of Android and Linux that gives you access to a chrooted Linux userland while preserving access to the Android system.

If this sounds dangerous, let me explain why this is safe. Have a look at the root directory of a Linux system and the root directory of an Android system; notice how they don't overlap much. This means that we could safely map some of the most useful Android directories into the Linux namespace; there's no need to modify the Android side. Let's see the code.

I made a prebuilt archive to demonstrate this method. In exchange for trying, you get a nice Debian chroot. What's not to love?!
  1. download pengdroid.tgz to your Android device
  2. unpack it to /data (or /sd-ext): tar zxvf path/to/pengdroid.tgz -C /data
  3. run it: /data/pengdroid/init

For a quick sanity check, run: getprop ro.product.model (whoa, Android inside Linux)
Then, for some more fun: apt-get
By default, no repositories are enabled.

Note: Before we start installing packages from Debian, we should actually install Debian. Wait, what? Right, PengDroid is so small because it packs just enough for us to use dpkg/apt; but many Debian packages assume that we have a complete setup. To bootstrap a minimal Debian installation, run /debian.sh (which makes the final installed size a whopping 58mb). If that's too much, keep reading.

Advanced Usage

Installing a minimal Debian gives us a fairly complete, but still small, *nix system. If we wanted to go even lighter, but still have a reasonably robust setup, we could run the alternative installer: /debian.sh apt -- which installs a complete dpkg/apt system.

It's a hassle to run /data/pengdroid/init all the time, but we could fix that by making a shortcut:
Code:
busybox mount -o remount,rw /system
echo '/data/pengdroid/init -- "$@"' > /system/bin/pengdroid
chmod 0755 /system/bin/pengdroid
Now, we could just prefix everything with pengdroid, like so: pengdroid python
Or, if we just want a shell: pengdroid
The Following 5 Users Say Thank You to inportb For This Useful Post: [ Click to Expand ]
 
BobbyBest
Old
#2  
Member
Thanks Meter 26
Posts: 94
Join Date: Jun 2009
Awesome! Although you can probably do better on the name assignment, this is another great step transforming Android into a real Unix Distribution
 
inportb
Old
#3  
Recognized Developer - OP
Thanks Meter 166
Posts: 433
Join Date: Dec 2008
Yeah, the name's awkward. But I figured I'd roll this into BotBrew some day, when we slim it down enough. It's already pretty tiny for a Linux distro, but it could be even smaller if all we want is a package manager.
The Following User Says Thank You to inportb For This Useful Post: [ Click to Expand ]
 
inportb
Old
(Last edited by inportb; 25th April 2012 at 03:31 AM.)
#4  
Recognized Developer - OP
Thanks Meter 166
Posts: 433
Join Date: Dec 2008
PengDroid is now on a diet. It installs to some 7.7mb, with a 3.5mb download size. This is good enough to support package management, and we're one command away from a minimally-functional Debian setup (instructions in OP).

/edit:
I just fixed a potential privilege escalation vulnerability in init.c, and added some new PATH-handling code. Instead of overriding the PATH, it now prepends to it. In addition, if PATH contains a double-colon ( :: ), it inserts its additions between the colons instead of prepending. To install the new init executable without reinstalling, do (outside of PengDroid):
Code:
wget http://dl.inportb.com/pengdroid.init
cp pengdroid.init /data/pengdroid/init
umount /data/pengdroid
rm pengdroid.init
/edit:
It seems that Debian Squeeze is a bit too old for our needs. Specifically, for reliable package management across many types of Android devices, we need multiarch support. So now, I'm tracking Debian Sid.
The Following 3 Users Say Thank You to inportb For This Useful Post: [ Click to Expand ]
 
mateorod
Old
#5  
Senior Member
Thanks Meter 2711
Posts: 1,729
Join Date: Nov 2011
Location: New Orleans
Excited to see the debian runit scripts and how they operate. I am too noob to know the difference between the Debian distros, but I have learned to trust you in such decisions.

How about adding the pengdroid symlinks to bbsh when it makes it to +1?

I'm sure it or something like it is already firmly in the testing phase. Sounds like SOP now that I write it. I just always forget and try to get a pengdroid shell between flashes.

Watch, he's gonna tell me an easier way I should know already...
 
Die_Panzerfaust
Old
#6  
Die_Panzerfaust's Avatar
Member
Thanks Meter 1
Posts: 42
Join Date: May 2012
Location: London
Sweet, Finally, Debian & Android rolled up together in a neat little package. Il test this out later,

& do you hail from West or South London by any Chance, where i come from "Peng" is a slang term for "Sexy" :P
 
inportb
Old
#7  
Recognized Developer - OP
Thanks Meter 166
Posts: 433
Join Date: Dec 2008
Oh snap, I lost track of this thread

You might have noticed a pengdroid.zip archive in my files. That's a self-extracting package for those who don't have a working tar utility. You could extract it using unzip, or just run the file like a program:
Code:
chmod 0755 pengdroid.zip
./pengdroid.zip
Quote:
Originally Posted by mateorod View Post
Excited to see the debian runit scripts and how they operate. I am too noob to know the difference between the Debian distros, but I have learned to trust you in such decisions.

How about adding the pengdroid symlinks to bbsh when it makes it to +1?

I'm sure it or something like it is already firmly in the testing phase. Sounds like SOP now that I write it. I just always forget and try to get a pengdroid shell between flashes.

Watch, he's gonna tell me an easier way I should know already...
We'll essentially be killing the existing sysvinit system and offering additional packages containing runit scripts. sysvinit is pretty good, but not enough to keep track of services.

I'd like to have [almost] perfect compatibility with the current BotBrew. BotBrew works by attaching its own filesystem (which conveniently lives under /botbrew) to the existing Android tree. Pengdroid turns this relationship on its head: it attaches crucial parts of the Android filesystem to the Debian tree, and then chroots into Debian. Technically, the chroot/reversal is not required, but it simplifies cleanup.

In BotBrew+1, /botbrew lives within the Debian filesystem tree already. After chrooting into Debian, we have automatic access to /botbrew as before. But what about direct access without chrooting? That's easy... just selectively attach the debian/botbrew directory the same way we've always been doing. So we'll need a couple of changes:
  1. bbsh needs to detect if it's called from within the chroot and handle that special case
  2. the init program (for starting the chroot) should add /botbrew/bin to the PATH

Multiarch is another fun thing to play with. Debian recently (officially) gained the ability to install libraries for multiple architectures at the same time. For example, this lets you have both i386 and amd64 software installed on your 64-bit system. In BotBrew, we'll take advantage of this to install both Debian packages and Android-native packages.

Why are we still planning to distribute the old stuff (repacked from Opkg) if we could get all of that and more from Debian? Simply put, these Android-native packages tend to be more efficient in terms of execution speed and space usage. But during the testing phase, I'd like to use Debian software primarily because we get those for free

Quote:
Originally Posted by Der_Panzerfaust View Post
Sweet, Finally, Debian & Android rolled up together in a neat little package. Il test this out later,

& do you hail from West or South London by any Chance, where i come from "Peng" is a slang term for "Sexy" :P
Just a coincidence, I assure you, since I'm on the other side of the great pond I thought this might be an appropriate name for a penguin cyborg, that's all.
 
Die_Panzerfaust
Old
#8  
Die_Panzerfaust's Avatar
Member
Thanks Meter 1
Posts: 42
Join Date: May 2012
Location: London
Roger that :)

Sent from my E15 using xda premium

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

report this ad
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

XDA University: Crafting Recovery-Flashable Packages

Those of us who use Linux on a day to day basis don’t think twice about sinking … more

Side-Swiping Multitasking with Kakudo

Recovering iPad users may still remember the multitasking function where you can swipe left or right to … more

Learn to Edit Graphics for your Development Work

The importance of good and appropriate graphics for your development work is undeniable. Be … more