Commit f4c57f6e494fd628d is the wrong fix.

Tito farmatito at tiscali.it
Fri Mar 4 07:06:37 UTC 2011


On Friday 04 March 2011 03:41:56 Rob Landley wrote:
> Don't #ifdef ANDROID and hardwire in various random strings.  Make the
> string a config symbol with a sane default, and let people set it in
> their config.  (If you'd like to suggest a few in the help text, fine.
> But I don't find the fact that Busybox is getting more brittle with time
> to be a comforting trend.)
> 
> Rob

Hi,
this could be easily fixed without code changes:

1) substitute /system/bin/sh with a busybox build with only ash enabled

2) or mount bind it at boot time 
	if [ -e /system/xbin/busybox ] ; then
		mount --bind /system/xbin/sh /system/bin/sh;
	fi;

More in general to add a compatibility layer for real linux, scripts can be used,
but this is stuff for android forums ;-).

Ciao,
Tito

------------------------------------------------------------------------------------------------------------------------
#!/system/bin/sh
#
# (C) 2009 - 2010 farmatito at tiscali.it
#
SYSTEM_BUILD_PROP="/system/build.prop"
SD_PATH="/sd-ext";

# Modify the system - set rw
mount -o remount,rw /dev/mtdblock3 /system;
mount -o remount,rw /dev/rootfs /;

if [ `grep -c "^/dev/block/mmcblk0p2 $SD_PATH " /proc/mounts` -eq 1 ] ; then
	# Prepare dir and link for overriding system binaries
	mkdir /usr;
	chown root.root /usr;
	chmod 755 /usr;
	if [ ! -e $SD_PATH/bin ] ; then
		mkdir $SD_PATH/bin;
	fi;
	chown root.shell $SD_PATH/bin;
	chmod 755 $SD_PATH/bin;
	busybox ln -s $SD_PATH/bin /usr/bin;

	# Prepare dir for additional libs
	if [ ! -e $SD_PATH/lib ] ; then
		mkdir $SD_PATH/lib;
	fi;
	chown root.shell $SD_PATH/lib;
	chmod 755 $SD_PATH/lib;
	busybox ln -s $SD_PATH/lib /usr/lib;

	find $SD_PATH/lib/ -name *.so | while read line ; do
		name=`basename $line`;
		busybox ln -s $line /system/lib/$name;
	done;

	# Prepare fake home dir
	if [ ! -e $SD_PATH/home ] ; then
		mkdir $SD_PATH/home;
		chown root.root $SD_PATH/home;
		chmod 755 $SD_PATH/home;
	fi;
	busybox ln -s $SD_PATH/home /home;
	busybox ln -s /system/lib /lib	
	# Use ash as default shell
	if [ -e /usr/bin/busybox ] ; then
		mount --bind /usr/bin/sh /system/bin/sh;
	fi;

	# Setup fstab, mtab, passwd and group files
	if [ ! -e $SD_PATH/etc ] ; then
		mkdir $SD_PATH/etc;
	fi;
	chmod 644 $SD_PATH/etc;
	chown root.root $SD_PATH/etc;
	chown root.root $SD_PATH/etc/passwd;
	chown root.root $SD_PATH/etc/group;
	chown root.root $SD_PATH/etc/shadow;
	chown root.root $SD_PATH/etc/gshadow;
	chown root.root $SD_PATH/etc/fstab;
	chown root.root $SD_PATH/etc/shells;
	chown root.root $SD_PATH/etc/profile;
	chmod 644 $SD_PATH/etc/passwd;
	chmod 644 $SD_PATH/etc/group;
	chmod 600 $SD_PATH/etc/shadow;
	chmod 600 $SD_PATH/etc/gshadow;
	chmod 644 $SD_PATH/etc/shells;
	chmod 644 $SD_PATH/etc/profile;
	if [ ! -e /etc/fstab ] ; 	then
		busybox ln -s $SD_PATH/etc/fstab /etc/fstab;
	fi;
	chmod 644 $SD_PATH/etc/fstab;
	busybox ln -s $SD_PATH/etc/passwd  /etc/passwd;
	busybox ln -s $SD_PATH/etc/shadow  /etc/shadow;
	busybox ln -s $SD_PATH/etc/group   /etc/group;
	busybox ln -s $SD_PATH/etc/gshadow /etc/gshadow;
	busybox ln -s $SD_PATH/etc/shells  /etc/shells;
	busybox ln -s $SD_PATH/etc/profile /etc/profile;
	if [ ! -e /etc/mtab ] ; 	then
		busybox ln -s /proc/mounts /etc/mtab;
	fi;
fi;

# Fix scripts in /system/bin needed by busybox ash
for i in am ime input monkey pm svc;
do
	if [ `grep -c "#!/system/bin/sh" /system/bin/$i` -eq 0 ] ; 	then
		echo "#!/system/bin/sh" > /system/bin/$i.tmp;
		cat /system/bin/$i >> /system/bin/$i.tmp;
		mv /system/bin/$i.tmp /system/bin/$i;
		chown root.shell /system/bin/$i;
		chmod 755 /system/bin/$i;
	fi;
done;

# Setup resolv.conf, needed by ping
if [ `grep -c "208.67.222.222" /etc/resolv.conf` -eq 0 ] ; then
	echo "nameserver 208.67.222.222" > /etc/resolv.conf;
	echo "nameserver 208.67.220.220" >> /etc/resolv.conf;
	setprop net.dns1 208.67.222.222;
	setprop net.dns2 208.67.220.220;
fi;

# Device compatibility
for i in 0 1 2 3 4 5 6 7;
do
	busybox ln -s /dev/block/loop$i /dev/loop$i;
done;

# Clean up /system/etc/hosts file - paranoia
echo "127.0.0.1               localhost" > /system/etc/hosts

# Use our own host file as default
if [ -e /sd-ext/etc/hosts ] ; then
	mount --bind /sd-ext/etc/hosts /system/etc/hosts;
fi;

# Remount all ro 
mount -o remount,ro /dev/rootfs /;
mount -o remount,ro /dev/mtdblock3 /system;

exit 0;

------------------------------------------------------------------------------------------------------------------------
 


More information about the busybox mailing list