• XDA Forums have been migrated to XenForo. We are aware of several issues including missing threads, logins not working, and more. To discuss, use this thread.

[2015/03/07] BotBrew: *nix tools for Android

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,808
0
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
Darn it. This looks like exactly the same problem I'm seeing on my G1. I can coerce an installation using the command line, but even then, it's kinda shaky. As I noted in the other thread, there's no way to change the logging level, but I'll put that into BotBrew+1, which is due soon for a prerelease. I'll let you know when that's ready!
.
Heres some motivation... im going to be doing a few linux oriented xdatv episodes soon because Samsung has asked us to step up our production 2.5x our current number of XDATV episodes this month... anyway.. http, ssh, and ftp will come in handy. Id like to feature your app.
 

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,808
0
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
I tried to run the bootstrap but for some reason it had not extracted the /data/botbrew tar.gz or the control tar.gz

I think I fixed it..
Code:
#! /system/bin/sh
export TARGET=/data
PREFIX=/botbrew
BUSYBOX="${TARGET}${PREFIX}/bin/busybox"
CACHEDIR="/data/data/com.inportb.botbrew/cache/bootstrap"
root_rw() {
	"${BUSYBOX}" mount -o remount,rw /
}
root_ro() {
	"${BUSYBOX}" mount -o remount,ro /
}
botbrew_clean() {
	root_rw
	"${BUSYBOX}" umount -l /botbrew/run > /dev/null 2>&1 || true
	"${BUSYBOX}" umount -l /botbrew > /dev/null 2>&1 || true
	"${BUSYBOX}" rm -rf /botbrew > /dev/null 2>&1 || true
	root_ro
}
botbrew_link() {
	if ! [ -e "${PREFIX}" ]; then
		root_rw
		ln -s "${TARGET}${PREFIX}" "${PREFIX}" || true
		root_ro
	fi
}
botbrew_unlink() {
	if [ -L "${PREFIX}" ]; then
		root_rw
		rm "${PREFIX}" || true
		root_ro
	fi
}
botbrew_clobber() {
	if [ -e /system/lib/opkg/info ]; then
		echo
		echo "Removing your old BotBrew setup:"
		"${BUSYBOX}" mount -o remount,rw /system
		echo "Running prerm scripts..."
		for item in /system/lib/opkg/info/*.prerm; do
			"${item}" remove || true
		done
		echo "Running postrm scripts..."
		for item in /system/lib/opkg/info/*.postrm; do
			"${item}" remove || true
		done
		echo "Removing files..."
		for item in `cat /system/lib/opkg/info/*.list`; do
			case "${item}" in
				*/);;
				*)
					if [ -e "${item}" ]; then
						rm "${item}" || true
					fi
					;;
			esac
		done
		echo "Removing directories..."
		for item in `cat /system/lib/opkg/info/*.list`; do
			case "${item}" in
				*/)
					if [ -e "${item}" ]; then
						rmdir "${item}" || true
					fi
					;;
			esac
		done
		echo "Wrapping up..."
		rm -r /data/vtmp || true
		rm -r /system/libexec || true
		rm -r /system/etc/opkg || true
		rm -r /system/lib/opkg || true
		rm -r /system/share || true
		echo "Done; moving on!"
	fi
}
echo
echo Temporarily installing busybox...
mkdir "${TARGET}${PREFIX}" || true
mkdir "${TARGET}${PREFIX}/bin" || true
mkdir "${TARGET}${PREFIX}/lib" || true
cp "${CACHEDIR}/busybox" "${BUSYBOX}"
cp "${CACHEDIR}/libbusybox.so.1.19.4" "${TARGET}${PREFIX}/lib/libbusybox.so.1.19.4"
chmod 0755 "${BUSYBOX}"
export PATH="${TARGET}${PREFIX}/bin:${TARGET}${PREFIX}/libexec/busybox:${PATH}"
export LD_LIBRARY_PATH="${TARGET}${PREFIX}/lib:${LD_LIBRARY_PATH}"
"${BUSYBOX}" mkdir -p "${TARGET}${PREFIX}/libexec/busybox"
"${BUSYBOX}" ln -s "${BUSYBOX}" "${TARGET}${PREFIX}/libexec/busybox/chmod"
"${BUSYBOX}" ln -s "${BUSYBOX}" "${TARGET}${PREFIX}/libexec/busybox/cp"
"${BUSYBOX}" ln -s "${BUSYBOX}" "${TARGET}${PREFIX}/libexec/busybox/grep"
"${BUSYBOX}" ln -s "${BUSYBOX}" "${TARGET}${PREFIX}/libexec/busybox/mkdir"
"${BUSYBOX}" ln -s "${BUSYBOX}" "${TARGET}${PREFIX}/libexec/busybox/mv"
"${BUSYBOX}" ln -s "${BUSYBOX}" "${TARGET}${PREFIX}/libexec/busybox/rm"
"${BUSYBOX}" ln -s "${BUSYBOX}" "${TARGET}${PREFIX}/libexec/busybox/rmdir"
"${BUSYBOX}" ln -s "${BUSYBOX}" "${TARGET}${PREFIX}/libexec/busybox/tar"
echo
echo Unpacking...
"${BUSYBOX}" mkdir -p "${TARGET}${PREFIX}/tmp" "${TARGET}${PREFIX}/run/tmp" "${TARGET}${PREFIX}/var/tmp/opkg/tmp"
cd "${TARGET}${PREFIX}/var/tmp/opkg/tmp"
botbrew_clobber
botbrew_clean
"${BUSYBOX}" tar -zxf "${CACHEDIR}/control.tar.gz"
cat control
echo
echo Installing...
botbrew_link
if [ -f preinst ]; then ./preinst bootstrap; fi
"${BUSYBOX}" tar -zxvf "${CACHEDIR}/data.tar.gz"
if [ $? -gt 0 ]; then
	echo
	echo 'ERROR: BotBrew was unable to extract the bootstrap package. Please report this problem.'
	exit 1
fi
"${BUSYBOX}" cp -a ".${PREFIX}" "${TARGET}/"
echo
echo Configuring...
if [ -f postinst ]; then ./postinst bootstrap; fi
echo
echo Finishing...
"${BUSYBOX}" rm -rf * "${CACHEDIR}/control.tar.gz" "${CACHEDIR}/data.tar.gz" "${TARGET}${PREFIX}/var/tmp/opkg/archives/"*
opkg update
if [ $? -gt 0 ]; then
	echo
	echo 'WARNING: BotBrew was not able to update its package cache over the Internet. For normal operation, BotBrew needs superuser privileges, as well as the ability to download feeds and packages over the Internet.'
	echo
	echo 'To complete the setup, please make sure that BotBrew has superuser privileges and we are connected to the Internet, and then tap the refresh button and install the package:'
	echo '	botbrew-core'
	echo
	echo 'To do this using the command line, run as superuser:'
	echo '	opkg update'
	echo '	opkg install botbrew-core'
	botbrew_unlink
	exit 1
fi
opkg install botbrew-core
if [ $? -gt 0 ]; then
	echo
	echo 'WARNING: BotBrew was not able to install core packages. For normal operation, BotBrew needs superuser privileges, as well as the ability to download feeds and packages over the Internet.'
	echo
	echo 'To complete the setup, please make sure that BotBrew has superuser privileges and we are connected to the Internet, and then tap the refresh button and install the package:'
	echo '	botbrew-core'
	echo
	echo 'To do this using the command line, run as superuser:'
	echo '	opkg update'
	echo '	opkg install botbrew-core'
	botbrew_unlink
	exit 1
fi
botbrew_unlink
"${TARGET}${PREFIX}/init.sh"
The two lines I added were:
#! /system/bin/sh
CACHEDIR="/data/data/com.inportb.botbrew/cache/bootstrap"

It collected some errors though..
Code:
 * extract_archive: Cannot create symlink from ./system/bin/botbrew to '/data/botbrew/bin/botbrew': Read-only file system.
 * extract_archive: Cannot create symlink from ./system/bin/bbsh to '/data/botbrew/bin/bbsh': Read-only file system.
 * extract_archive: Cannot create symlink from ./system/bin/ldimport to '/data/botbrew/bin/ldimport': Read-only file system.
 * extract_archive: Cannot create symlink from ./system/lib/libbusybox.so.1.19.4 to '/botbrew/lib/libbusybox.so.1.19.4': Read-only file system.
 * opkg_conf_deinit: Couldn't unlink /botbrew/tmp/opkg.lock: No such file or directory.
 
  • Like
Reactions: mateorod

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,808
0
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
Also, the /system folder was not mounted RW..

I came up with some mega-ultra-script-fu for this..

Code:
mount -o remount,rw -t `mount|grep system |awk -F " " '{ print $3 }'`  `mount|grep system |awk -F " " '{ print $1 }'` `mount|grep system |awk -F " " '{ print $2 }'`
It makes a Mount -rw command out of whatever is already mounted by using the mount command :).... it came up as busy on my system which I'm not sure what I've got going on right now.. i'm sure it's alot though.


Still a problem with the actual "botbrew" command not installing properly.. opkg works everything seems to work fine, just not botbrew itself, and when I get into botbrew manually, it throws an error
Code:
[email protected]:/data/botbrew/bin $ ./botbrew
link_image[1936]:  2842 could not load needed library 'libbusybox.so.1.19.4' for 'busybox' (load_library[1091]: Library 'libbusybox.so.1.19.4' not found)CANNOT LINK EXECUTABLE
this error does not happen when running as root.

At this point I can opkg install files, but not install from the GUI package manager.
 
Last edited:
  • Like
Reactions: inportb

worldindo1

New member
Dec 8, 2011
179
68
0
Darn it. This looks like exactly the same problem I'm seeing on my G1. I can coerce an installation using the command line, but even then, it's kinda shaky. As I noted in the other thread, there's no way to change the logging level, but I'll put that into BotBrew+1, which is due soon for a prerelease. I'll let you know when that's ready!



With the current version of BotBrew, no. This is because emmc is a FAT partition (like sdcard), which is unsuitable for *nix-like systems. For the next major release, I'm entertaining the idea of automatically supporting loop-mounted disk images, which should work just fine on pretty much any filesystem. I'm looking forward to a prerelease soon.
The really great thing is I didn't have to question a single word in that. I most certainly look forward to being able to use eMMC as a viable storage option for my *nix tools. Any idea on what kind of size it will take up? Or possibly a partitioner in the setup that allows us to choose a size (like Ubuntu)? I'll be camping out waiting for the next big release. Can't wait to dig into BotBrew a bit more.
 
  • Like
Reactions: inportb

inportb

Retired Recognized Developer
Dec 29, 2008
438
194
0
inportb.com
Any idea on what kind of size it will take up? Or possibly a partitioner in the setup that allows us to choose a size (like Ubuntu)?
I've learned that we can't really assume that the base Android system would give us anything useful, since every ROM is different. So most likely, we'd bootstrap with a fixed 100MB image, then install tools within BotBrew that let us resize the image as needed.
 

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,808
0
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
I've learned that we can't really assume that the base Android system would give us anything useful, since every ROM is different. So most likely, we'd bootstrap with a fixed 100MB image, then install tools within BotBrew that let us resize the image as needed.
Not necessarily...

Code:
 /local/bin:$PATH
[email protected]:/ $ df
Filesystem             Size   Used   Free   Blksize
/dev                   347M    32K   347M   4096
/mnt/asec              347M     0K   347M   4096
/mnt/obb               347M     0K   347M   4096
/system                643M   295M   347M   4096
/data                   13G     3G     9G   4096
/cache                 425M     7M   418M   4096
/factory                19M     8M    11M   4096
/mnt/sdcard             13G     3G     9G   4096
/botbrew                13G     3G     9G   4096
/botbrew/run           347M     0K   347M   4096
[email protected]:/ $
If you deploy a version of busybox and use that to get the df command, you can grep, then awk it and make some sort of interperater.
 
  • Like
Reactions: inportb

inportb

Retired Recognized Developer
Dec 29, 2008
438
194
0
inportb.com
If you deploy a version of busybox and use that to get the df command, you can grep, then awk it and make some sort of interperater.
This is exactly how the base installation satisfies its own dependencies (until you install coreutils, etc). Then to grow the image a bit, all you need to do is dd some more bytes into the file, resize2fs, and fsck. Alternatively, we could ship a small (8MB) base installation, have it create a bigger image, and copy its contents over.
 

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,808
0
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
This is exactly how the base installation satisfies its own dependencies (until you install coreutils, etc). Then to grow the image a bit, all you need to do is dd some more bytes into the file, resize2fs, and fsck. Alternatively, we could ship a small (8MB) base installation, have it create a bigger image, and copy its contents over.
That sounds like a great idea. You'd be surprised how quickly modern devices can read if=/dev/zero of=myfileOrdevice bs=4096. On my nook tablet it was 12 Gigs in 2 Minutes for my Ubuntu Recovery to wipe the /sdcard/ partition.
 
  • Like
Reactions: inportb

viulian

Inactive Recognized Developer
Apr 6, 2011
419
410
0
hex.ro
Hello!

I did not know this project exists - I've been tipped off about this project by fellow member mateorod. Congratulations inportb :) very well structured and clean project.

I'm also working with cross-compiling, for now I have gcc, lighttpd, php-5.4.2 with curl and openssl as well as mysql statically linked. I took a different approach - building one package at a time to serve different needs.

Good luck, I've subscribed here so I can keep track of the progress.
 
  • Like
Reactions: inportb

inportb

Retired Recognized Developer
Dec 29, 2008
438
194
0
inportb.com
Thanks for all the support, folks! I know I haven't been posting a lot, but here's a little screenshot to show that a working pre-release is imminent. There's still a lot of work to do, but I'd like to at least support installing/upgrading/removing packages. The reason for the delay is that dpkg+apt is substantially more complex than opkg, and there was a lot of planning involved. Anyway:


Package maintainers: you might have noticed that opk's are very similar to deb's. Tools for building deb's are widely available, and could be used in much the same way as opkg-utils. You could continue to host repos via your favorite file host (i.e. Dropbox) if you want. The difference is that debs have some more control fields (to support a more powerful package management experience), and some of them may be interpreted differently. I'll keep you posted. Thanks for using this project!
 

tiger2wander

New member
Feb 6, 2009
337
210
0
Hà Nội
Forgot to give you guys that there are already a set of command lines bundled inside app which allow us to write, compile android app to .apk directly on android.

https://play.google.com/store/apps/details?id=com.spartacusrex.spartacuside

It will be great if we have all: javac, java, dex, dx inside BotBrew to able to build and package .apk like that.

If you want a GUI editor with many advanced features like: autocomplete, code refactor, document for Android dev much like you are done with Eclipse, give a look for this app: https://play.google.com/store/apps/details?id=com.aide.ui

Good cross fingers.
 

mateorod

Inactive Recognized Developer
Nov 16, 2011
1,981
3,503
0
New Orleans
www.gigmasters.com
Forgot to give you guys that there are already a set of command lines bundled inside app which allow us to write, compile android app to .apk directly on android.

https://play.google.com/store/apps/details?id=com.spartacusrex.spartacuside

It will be great if we have all: javac, java, dex, dx inside BotBrew to able to build and package .apk like that.

If you want a GUI editor with many advanced features like: autocomplete, code refactor, document for Android dev much like you are done with Eclipse, give a look for this app: https://play.google.com/store/apps/details?id=com.aide.ui

Good cross fingers.
I've tried both of those apps, having more success with the AIDE than Terminal IDE, although the fault has a fine chance of being just mine.

Have you tried the javavm package in Botbrew? I use it with the baksmali binaries, although the Nook Color somewhat chugs through the smali.jar operations...
 

tiger2wander

New member
Feb 6, 2009
337
210
0
Hà Nội
Not tried javavm yet because of I've just update new ROM. Will be try soon.

For me, both AIDE and Terminal IDE work well. To get started with Terminal IDE you should have a look at builder.sh and run.sh inside system/src/demo* directories. I love this one because of I can run my App without install/update .apk package.
 

inportb

Retired Recognized Developer
Dec 29, 2008
438
194
0
inportb.com
Alright, here's a very rough build that is able to bootstrap the base system and do some basic package management. Services do not work yet, but they're coming soon! This app may be used in parallel with the current-stable BotBrew release, without conflict.

Source: https://github.com/jyio/botbrew-gui
Issues: https://github.com/jyio/botbrew-gui/issues

Thanks for the help testing this thing! If you have bugs to report or features to request, feel free to post here or (if you have a GitHub account) open issues directly.

Quick Start

Warning: If you're using this in parallel with the stable BotBrew, you'd find that some packages are available through both apps. Please do not try to install the same thing in both apps, because they would let you, and bad things might happen.

Notice: If you bootstrap to a FAT filesystem (such as the one on your SD card), everything will be installed to a loop-mounted disk image. Disk image support is very basic. The image is 100MB; if you want to resize it, you must do so manually.
Let's assume that you bootstrapped to /data/botbrew-basil. The bootstrap process helps you prepare BotBrew for some common usage patterns. In case you want to do it manually, just keep reading.

Running Commands

For convenience, you could just install the botbrew-wrapper package. This gives you a botbrew2 command, just like the old-style botbrew command. Run it without arguments to start a shell, or prefix your commands with it.

If you like doing things the long way, you could do without the botbrew2 wrapper. For one-shot jobs, you may simply prefix your commands:
Code:
/data/botbrew-basil/init -- command goes here
If you want a shell so you don't need to prefix everything:
Code:
/data/botbrew-basil/init
first command
second command
...
Installing Debian

Before you could install Debian, you must enable a Debian repository. Just install repository-emdebian.

There are currently two "flavors" available to you:
  1. Install botbrew-debian-apt for a robust installation of apt/dpkg. This does not include things like grep and findutils, which some packages need; keep that in mind when you see these errors, and install the required packages.
  2. For full Debian support, also install botbrew-debian-minimal afterwards.

Removing BotBrew

To remove everything other than the app, first exit the system from the preferences window, then:
Code:
rm -r /data/botbrew-basil
Enjoy!
 
Last edited:
Our Apps
Get our official app! (coming soon)
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone