SpazeDog / mounts2sd

Android SD-Ext Script+App
GNU General Public License v3.0
76 stars 27 forks source link

export: /sys/class/gpio/export: bad variable name #6

Closed Daneel87 closed 11 years ago

Daneel87 commented 11 years ago

don't know what is exactly the export which is causing troubles.

dbergloev commented 11 years ago

I am going to have a bit more information than this.

Daneel87 commented 11 years ago

latest beta, no line number, nothing works because script stops before doing anything, I had the error trying to run the script manually, but if I'm not wrong I first saw that in the logcat too

dbergloev commented 11 years ago

That is strange. If export does not work properly, then this is a shell issue. The ROM is likely to use dash (Never supports anything). I will have a go at this to day, and see if I can find out a way around this issue.

What ROM are you using?

Daneel87 commented 11 years ago

it is a stock ROM from a china phone with spreadtrum sc6820a, I just added init.d support I think it is a ROM issue too, but i'd like to use this script on this phone. I'll help for what is possible to me

dbergloev commented 11 years ago

Okay, well since you did try to manually execute the script, I assume that you know how to enter an ADB shell. I also assume that you know some basic commands? The first thing that I will need, is for you to track down the shell that your device is using. Enter the below commands in the shell.

which sh

On most custom devices, this is linked to mksh which in turn is linked to busybox. I need to know where yours link to, and then I will need you to extract that binary from your device. If I can get it myself, it will make it so much easier to debug this issue on one of my own devices.

Daneel87 commented 11 years ago

sh command is a binary located in /system/bin

here I uploaded it

https://copy.com/98PtG2ie0zTr

dbergloev commented 11 years ago

So your device is using a real sh binary? Then this is even more strange, as sh should have no problems with export. Well, I will try this on one of my devices and see if I can re-produce this.

Daneel87 commented 11 years ago

from what I can understand, the issue is that the script tries to export a variable called /sys/class/gpio/export, so the problem is not the export command, which doesn't accept / even on desktop shell, but the variable names itself.

That's where I stop, I didn't studied all the script, not enough time, so I don't know why it is trying to export that variable

dbergloev commented 11 years ago

He he, I am an idiot. Your right, of cause. The first thing that the script does, is extracting all environment variables from the init.rc files on the device and assigning them to it's own environment. The reason is, that on some devices, these variables are not yet assigned when init.d is executed, and some of these includes library information that some binaries need in order to work.

The way I locate these in the init.rc files, is by extracting all the export lines from the files. But I did of cause NOT make the script look for lines STARTING with export, but just lines INCLUDING the word. And I guess that one of your init.rc files has a line where /sys/class/gpio/export is included, and thereby the word export.

I will get this fixed right away and provide you with a new version that should work on your device.

dbergloev commented 11 years ago

I have uploaded a new Beta. You can download it here. Just update the app, go to the settings, remove the script and install it again (I have not updated the version number, so script update will not be possible).

Daneel87 commented 11 years ago

thanks :+1: , I will try that later or tomorrow, I need to eat something now :smiley:

dbergloev commented 11 years ago

Yes, that is an important part if life.

Hope that it will work for you without further issues :)

Daneel87 commented 11 years ago

whell, there's another issue, the app cannot locate busybox, even if it's installed, and previous version didn't complain about that

dbergloev commented 11 years ago

Hmm, Try deleting the app data in Android Settings. Maybe a reset of the app will do, because I did not make changes in the app.

Daneel87 commented 11 years ago

I notice now that the version I was using was 3.0.2-beta, since the one you linked i named beta_5 I think that wasnot the latest one. However, I tried restoring and completely wiping the phone, and still it doesn't see busybox, maybe you changed something after 3.0.2-beta.

Tell me what's the check you do to find busybox, maybe I can fix my ROM

dbergloev commented 11 years ago

By default, it extract an internal busybox version into /data/local/busybox and then adds /data/local to the $PATH environment variable. I then check for busybox using busybox test true and test the result code $? which should match 0. Then if the internal busybox for some reason is not compatible with the device, it will just use whatever other busybox binary is located in one of the $PATH folders. I never make a direct call to a specific location.

I also made sure to test the app and script on my own device before uploading it to you, so I don't get it. It is working fine here.

EDIT:

I did change the busybox version since last official beta release it seams. But if that is not working, it should just automatically use your ROM's binary instead. Try testing the internal busybox.

/data/local/busybox --list
Daneel87 commented 11 years ago

permission issue, the busybox you copy into /data/local is not executable

and even adding execute permissions, that command returns nothing and the apps keeps complaining about busybox not existing

I also tried copying system's busybox into /data/local but the result is the same

dbergloev commented 11 years ago

If that version does not have execute permissions, then it should just use the one from the system. This makes no sense.

I will compile a new version for you that does not copy the internal busybox to /data by default. Just to see if that will work, in which case I will have to find another way to handle the switch between the internal and the system version. I thought the $PATH would handle this automatically, but this can not be trusted it would seam.

I need to step out for a couple of hours, will have this for you first thing when I get back.

Daneel87 commented 11 years ago

I thank you but I have to leave this phone since it is a friend's and now he needs it, I don't know when I'll be able to test it again

I hope all this will be helpful to someone else and not a loss of time.

dbergloev commented 11 years ago

That's okay. At least we found some issues with the script which got fixed (Hopefully there is no more). And I got aware of the other issue. And since there has not been many changes to the app, the issue should be easy enough to find if I compare my whole source with the older one.

Thanks so far for your patient and help