[Miscellaneous Android Development] surfer63:
No :mad:

Worked hours on it, but without success.

Now within TWK's install-apps.sh script you find in the top line

#!/system/bin/busybox sh

where it starts the busybox shell interpreter and later down in the script

/system/bin/busybox sh -c "/system/bin/pm install /system/twkdata/Betterterm.apk" >> /data/twk-install.log 2>&1 &

After extensive logging and logcat analysis I found that within my archos/busybox combination the busybox doesn't work at all with pm install.

Now what seemed to work in my script (my sh/archos combi):

#!/system/bin/sh
<snip>
for i in /system/HvdWdata/apkinstall/*.apk;
do
apkonly=`busybox basename $i`
echo "now installing $i" >> /data/boot-install.log
/system/bin/pm install $i /data/app/$apkonly >> /data/boot-install.log 2>&1 &
# as the command is started as a background command (ending &) to prevent
# the tablet from bricking when install failing, the for/next loop continues
# without waiting for command to finish, so build in a 20 second wait loop.
/system/bin/busybox sleep 20s
done

As such that worked BUT I now get the error: Error: Could not access the Package Manager. Is the system running?

Now the reason for this seems to be a bad performance of your (mine in this case) tablet. I have not been able to get around this.

I did find some work-around though. If you look for connectbot (org.connectbot) or QuickPic (com.alensw.PicFolder) you find that they install one or more libraries inside e.g. /data/data/org.connectbot/lib and /data/data/com.alensw.PicFolder/lib.

So what I did in the terminal is:

$ su
# tar -cvf /sdcard/com.alensw.PicFolder.tar /data/data/com.alensw.PicFolder

Now this creates a tar file on my sdcard which I copy into my /system/HvdWdata/data for installing (see below).

Note: Be careful not to copy your settings and/or cache (scanned music, scanned pictures, scanned videos, etc.).

To be absolutely sure you only have the libraries do something like:

$ su
# tar -cvf /sdcard/com.alensw.PicFolder.tar /data/data/com.alensw.PicFolder/lib

Try to read also more about sqlite3 and the databases in /data/data/<real apk name>/databases if you want more. In that case you need the first tar command. Some apks store their settings in the database, some in shared_prefs/preferences.xml.

My script has now been extended (following after the simple apkcopy and apkinstall part) with:

### Start copying data of apks to /data/data ###
# Some apps can be preconfgured by just copying their data back.
# Some apps install libraries in their /data/data/<real app name>/lib. These need to be "reinstalled"
/system/bin/busybox echo "`/system/bin/busybox date` Begin copying data..." >> /data/boot-install.log
ls /data/data_installed
case "$?" in
0)
echo "Nothing to do. file exists"
;;
*)
echo "file doesn't exist. Start installing"
# Use tar instead of tar.gz or .tgz. It's a compressed file system anyway so compressing doesn't help in
# conserving space and the extra step in uncompressing makes it slower.
for i in /system/HvdWdata/data/*.tar
do
tar -xvf $i -C / >> /data/boot-install.log 2>&1 &
# as the command is started as a background command (ending &) to prevent
# the tablet from bricking when install failing, the for/next loop continues
# without waiting for command to finish, so build in a 10 second wait loop.
/system/bin/busybox sleep 10s
done
busybox touch "/data/data_installed" ;
esac

Note that I also use the data option for zeam launcher to do some "preconfigure" things and that I use the com.android.providers.settings sqlite3 database to switch on wifi and "install from unknown sources" setting.

Note 2: This data copy option doesn't work for all "to be installed" applications. Don't know why yet :(

For complete reference see my attached script (also contains more info and variable substitution). I always write a lot of comments, both for myself as well as for others :D