Optware / Optware-ng

279 stars 52 forks source link

setup environment on Android 6 (CyanogenMod 13) #57

Closed armando-basile closed 8 years ago

armando-basile commented 8 years ago

Hi, i trying to setup optware-ng on my android 6. first of all i installed busybox:

# mount -o remount,rw /
# mount -o remount,rw /system
# mount -o remount,rw /data
# mkdir /data/opt
# chmod 777 /data/opt
# ln -s /data/opt /opt
# mkdir -p /data/opt/tmp
# chmod 777 /data/opt/tmp
# ln -s /data/opt/tmp /tmp
# cd /opt
# curl -o busybox https://busybox.net/downloads/binaries/1.21.1/busybox-armv7l
# cp busybox /data/local/busybox
# chmod 755 /data/local/busybox

--- if not exists /system/xbin ---
# /data/local/busybox mkdir /system/xbin
# cd /data/local
# ./busybox cp /data/local/busybox /system/xbin
# cd /system/xbin
# chmod 755 busybox
# ./busybox --install -s /system/xbin
# rm /data/local/busybox

after i install static ipkg following buildroot-armeabihf-bootstrap.sh steps:

# cd /opt
# wget -O ipkg-static_0.99.163-3_arm.ipk http://optware-ng.zyxmon.org/buildroot-armeabihf/ipkg-static_0.99.163-3_arm.ipk
# tar -xvzf ipkg-static_0.99.163-3_arm.ipk ./data.tar.gz
# tar -C / -xzvf data.tar.gz
# echo "src/gz alllexx http://optware-ng.zyxmon.org/buildroot-armeabihf" > /opt/etc/ipkg.conf 
# echo "dest /opt/ /" >> /opt/etc/ipkg.conf
# PATH=$PATH:/opt/bin:/opt/sbin
# TMPDIR=/data/opt/tmp
# /opt/bin/ipkg update

but i receive an error from ipkg:

Downloading http://optware-ng.zyxmon.org/buildroot-armeabihf/Packages.gz
An error ocurred, return value: 1.
Collected errors:
ipkg_download: ERROR: Command failed with return value 127: `wget    -q -P /data/opt/tmp/ipkg-VO20AJ http://optware-ng.zyxmon.org/buildroot-armeabihf/Packages.gz'

this is strace ipkg update response

i saw that if i try:

# wget -P /data/opt/tmp/ipkg-qUiDHM http://optware-ng.zyxmon.org/buildroot-armeabihf/Packages.gz

wget don't save file, but if i use -O option, it do that:

# wget -O Packages.gz -P /data/opt/tmp/ipkg-qUiDHM http://optware-ng.zyxmon.org/buildroot-armeabihf/Packages.gz

seems that temporary random folder was created but with another name.

could you help me

alllexx88 commented 8 years ago

Looks like a weird android wget behaviour. Could you try to create wget ling to /data/local/busybox and change PATH to use this wget?:

mkdir -p /data/local/xbin
ln -s ../busybox /data/local/xbin/wget
export PATH=/data/local/xbin:$PATH

?

armando-basile commented 8 years ago

https://gist.github.com/armando-basile/a6a16bb897f17aadb1ac#file-stacktrace i saw that now if i try to download using wget in a folder already exists, work fine, es using /data/opt/tmp that i already have:

wget -P /data/opt/tmp http://optware-ng.zyxmon.org/buildroot-armeabihf/Packages.gz

if wget need to create a subfolder into, there is the problem

wget -P /data/opt/tmp/ipkg-qUiDHM http://optware-ng.zyxmon.org/buildroot-armeabihf/Packages.gz
armando-basile commented 8 years ago

i tryed also on another android device always with Android 6 and have the same problem. Could be an idea to split in ipkg mkdir command and after wget using already created folder ?

alllexx88 commented 8 years ago

That's normal wget behaviour. That temp dir should've been created by ipkg beforehand, and judging from your ipkg strace, it is (attempted to be) created:

mkdir("/data/local/tmp/ipkg-5L9LTZ", 0700) = 0

But later on wget complains that the dir doesn't exist:

unlink("/data/local/tmp/ipkg-5L9LTZ/Packages.gz") = -1 ENOENT (No such file or directory)

So either mkdir syscal doesn't work properly, or something happens between these calls that removes the dir (given that wget works as you've described).

armando-basile commented 8 years ago

Oh i tryed also on Android 5.1 and also here there is problem :( the only Android where it's work is 4.x

could we try a workaround ?

armando-basile commented 8 years ago

BINGOOO

optware-ng on Android require also:

# mkdir /bin
# ln -s /system/bin/sh /bin/sh

to work

armando-basile commented 8 years ago

:) ok, tested with success on android 5 and also 6. This is my start.sh boot script :

#!/system/bin/sh
mount -o remount,rw rootfs /
ln -s /data/opt /opt
ln -s /data/opt/tmp /tmp
chmod 777 /data/opt/tmp
rm -rf /data/opt/tmp/*
mkdir /bin
ln -s /system/bin/sh /bin/sh
mount -o remount,ro /

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

# openssh server
rm -rf /data/opt/var/run/dropbear.pid
/data/opt/sbin/dropbear -A -N root -U 0 -G 0 -C <password> -p 22

# 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) &

# update dtdns
(/data/opt/bin/udtdns >/dev/null) &

# update date
(ntpd -q -p 1.it.pool.ntp.org) &

# pyLoad
/opt/etc/init.d/S98Pyload start &

# start samba server
/opt/etc/init.d/S08samba start &