Optware / Optware-ng

279 stars 52 forks source link

Optware-ng on android armv7 #6

Closed armando-basile closed 9 years ago

armando-basile commented 9 years ago

Hi, i installed old optware on my android box AmLogic s812 but i saw that optware-ng have more updated packages, so i would like to install it on my android box. Could it's possible ?

thanks Armando

alllexx88 commented 9 years ago

Hi, it should be possible, running this command

wget -O - http://optware-ng.zyxmon.org/buildroot-armeabi/buildroot-armeabi-bootstrap.sh | sh

as root should work, as long as /opt is writable and you have wget, tar with gzip and echo commands. These should be there, but anyway it's better to install busybox on your box if it's not already installed, since some post install scripts may require some additional commands

Regards,

armando-basile commented 9 years ago

Hi Alex, seems that installation done, i saw help message if i do: /opt/bin/ipkg

but if i try to /opt/bin/ipkg update i receive root@s806:/opt/bin # /opt/bin/ipkg update
mkdtemp: No such file or directory

alllexx88 commented 9 years ago

Hmm, looks like mkdtemp() function errors out, since there's no /tmp directory on your device, which is expected to be on UNIX, but probably usually isn't there in android. Can you try this?

mkdir -p /sdcard/tmp
/opt/bin/ipkg update  --tmp-dir=/sdcard/tmp
armando-basile commented 9 years ago

i solved fixing temp folder i installed /opt under /data, so i launch a script at boot to reset environment:

#!/system/bin/sh
mount -o rw,remount rootfs /
ln -s /data/opt /opt
mkdir -p /tmp
ln -s /data/opt/tmp /tmp
mkdir -p /bin
ln -s /system/bin/sh /bin/sh
mount -o ro,remount /
armando-basile commented 9 years ago

i installed and configured minidlna and transmission without init.d scripts but adding into start.sh script launch:

#!/system/bin/sh

# remount filesystem
mount -o rw,remount rootfs /
ln -s /data/opt /opt
mkdir -p /tmp
ln -s /data/opt/tmp /tmp
mkdir -p /bin
ln -s /system/bin/sh /bin/sh
mount -o ro,remount /
sleep 2

export PATH=$PATH:/data/opt/sbin:/data/opt/bin:/data/opt:/bin:/system/bin
export TMPDIR=/data/opt/tmp

# transmission daemon
rm -rf /opt/var/run/transmission-daemon.pid
/data/opt/bin/transmission-daemon -g /data/opt/etc/transmission-daemon -e /data/opt/var/log/transmission-daemon.log --log-error

# minidlna server
rm -rf /data/opt/var/minidlna/minidlna.pid
(/data/opt/sbin/minidlnad -f /data/opt/etc/minidlna.conf -P /data/opt/var/minidlna/minidlna.pid -d >/opt/etc/minidlna/minidlna.log) &

i would like also to configure dropbear to use ssh, so i installed and ssh root@android_ip show me login + password request but i don't know which is root password. I think that should create /opt/etc/passwd file ???

alllexx88 commented 9 years ago

I'm glad minidlna and transmission are working for you. As for dropbear, it's using system authentication (passwords hashes are usually in /etc/shadow), so if you don't know root's password and can't change it, you can try public key authentication. Look at this OpenWrt guide (skip the Disable password login part), just use /opt/etc/dropbear instead of /etc/dropbear. Haven't tested it myself, but I think it should work

UPD: after some googling, I see that android doesn't use password authentication, so there's no /etc/shadow, /etc/passwd etc. structure. I guess, your only option is to use public key authentication. The other option would be to patch dropbear to use a different authentication scheme, but I'm not interested in doing this (though I would accept pull requests with a patched version, say, dropbear-android package).

alllexx88 commented 9 years ago

BTW, you might also want to either mount RAM disk on /tmp or clean up /data/opt/tmp on boot, since it can often contain garbage that some user programs 'forgot' to clean

armando-basile commented 9 years ago

other little issue: with some installed packages i saw always: link failed No such file or directory at the end of opkg install. Parsing control.tar.gz into package i saw that problem is command

/opt/bin/update-alternatives --install /opt/bin/bzip2 bzip2 /opt/bin/bzip2-bzip2 80

that return this message. I already created folder /opt/var/lib/alternatives, should create some other folder ?

i have problems only on few packages, it show if i try to upgrade:

root@s806:/ # /opt/bin/ipkg upgrade                                            
Configuring bzip2
link failed No such file or directory
postinst script returned status 255
ERROR: bzip2.postinst returned 255
Configuring ncurses
link failed No such file or directory
postinst script returned status 255
ERROR: ncurses.postinst returned 255
Configuring psmisc
link failed No such file or directory
link failed No such file or directory
postinst script returned status 255
ERROR: psmisc.postinst returned 255
Nothing to be done
Successfully terminated.

this is my /opt tree https://gist.github.com/armando-basile/6c77128f8b1c7ad9fbba#file-android_opt_tree_optware-ng-txt

alllexx88 commented 9 years ago

I can't reproduce this. You can use strace to tackle that down:

/opt/bin/ipkg update
/opt/bin/ipkg install strace
/opt/bin/strace /opt/bin/update-alternatives --install /opt/bin/bzip2 bzip2 /opt/bin/bzip2-bzip2 80 2>&1 | grep "No such file or directory"

This should show all failed attempts to access a file/dir, e.g.

/opt/bin/strace /opt/bin/update-alternatives --install /opt/bin/bzip2 bzip2 /opt/bin/bzip2-bzip2 80 2>&1 | grep "No such file or directory"
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/sse2/libcrypt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/i686/sse2", 0xffb76808) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/libcrypt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/i686", 0xffb76808)     = -1 ENOENT (No such file or directory)
open("/lib/tls/sse2/libcrypt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/sse2", 0xffb76808)     = -1 ENOENT (No such file or directory)
open("/lib/tls/libcrypt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls", 0xffb76808)          = -1 ENOENT (No such file or directory)
open("/lib/i686/sse2/libcrypt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/i686/sse2", 0xffb76808)    = -1 ENOENT (No such file or directory)
open("/lib/i686/libcrypt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/i686", 0xffb76808)         = -1 ENOENT (No such file or directory)
open("/lib/sse2/libcrypt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/sse2", 0xffb76808)         = -1 ENOENT (No such file or directory)
stat64("/sbin/sed", 0xffb75900)         = -1 ENOENT (No such file or directory)
stat64("/sbin/mv", 0xffb759e0)          = -1 ENOENT (No such file or directory)
stat64("/sbin/echo", 0xffb75e00)        = -1 ENOENT (No such file or directory)
stat64("/sbin/ln", 0xffb75b60)          = -1 ENOENT (No such file or directory)

Or use

/opt/bin/strace /opt/bin/update-alternatives --install /opt/bin/bzip2 bzip2 /opt/bin/bzip2-bzip2 80 &> log.txt

To save all strace output to log.txt, and then grep through it.

armando-basile commented 9 years ago

https://gist.github.com/armando-basile/d1157cfff8032cf3911e#file-strace-log

i also saw that ipkg use mkdtemp that require to create temporary file under /tmp also if i set TMPDIR and --tmp-dir

TMPDIR=/data/opt/tmp /opt/bin/strace /opt/bin/ipkg update --tmp-dir=/data/opt/tmp
...
...
mkdir("/tmp/ipkg.G3afna", 0700)         = -1 EROFS (Read-only file system)
write(2, "mkdtemp", 7mkdtemp)                  = 7
write(2, ": ", 2: )                       = 2
write(2, "Read-only file system", 21Read-only file system)   = 21
write(2, "\n", 1
)                       = 1
write(1, "An error ocurred, return value: "..., 35An error ocurred, return value: 1.
) = 35
rmdir("/data/opt/tmp/ipkg-YA8tqg")      = 0
exit(1)                                 = ?
armando-basile commented 9 years ago

BINGOOOO :) seems that problem is ln -sf (-f = --force) parameter into update-alternatives script. I edited update-alternative and changed from ln -sf to ln -s and it work :)

only problem is that if link already exists you need to rm -rf

alllexx88 commented 9 years ago

LOL, I managed to reproduce the problem using Genymotion, nailed it down and wrote almost the same thing (regarding ln) like 13h ago, but forgot to press 'Comment' :smile: Anyway, thanks for your continuous effort to get Optware-ng to work with android! ipkg using /tmp even despite setting temp dir to something different is probably a bug, but it's OK, since you're REALLY advised to have writable /tmp to run anything UNIX. I've patched update-alternatives to not use -f ln flag, commit and binaries coming soon

alllexx88 commented 9 years ago

Closing this issue for now until new problems arise

alllexx88 commented 9 years ago

@armando-basile this might be interesting for you: 11a91d3743a3588d53b2b6b0ca4e5fdb21dc19b3 I've built a dropbear version (dropbear-android package) that supports Android Mode and allows password or public key logins on android. See /opt/etc/init.d/S51dropbear. If you want to add an OpenSSH public key, add it to /opt/etc/dropbear/authorized_keys (don't forget to chmod 600 on it). Tested with Genymotion

alllexx88 commented 9 years ago

@armando-basile and anyone with similar issues: [ARMv7/Intel][Root][Busybox][init.d]Optware-ng: install pre-compiled native packages topic on xda-developers may be of interest