|
|
#1 | |
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,139
Karma: 5328985
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI|K4|K3-3G|DXG|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
Checking for required libs. Exporting Binaries "easily"
well I did The following works OOTB on a touch ( I think?) feedback gratefully accepted... It needs a few fixups for the 3 as the dated busybox doesn't swallow colon substrings REF: http://landley.net/mantis/mantis-2924.html For the Touch and Paperwhite (and the 3 and 4 with the right files and linkages) Code:
#!/bin/bash
FAILS=""
MAINEXPORTDIR="/mnt/us/export"
TESTUSRLIB="/usr/lib/"
TESTLIB="/lib/"
BASEUS="/mnt/base-us/"
# fail on missing victim
if [ -z ${@} ]
then
echo "hmm I need a victim... usage: filechecker <binary_file>"
exit 1
fi
# fail on missing victim
if [ ! -e ${@} ]
then
echo "hmm I cannot find: ${@} - you sure? check the file exists."
exit 1
fi
FILES=$(readelf -d ${@} |awk -F\[ ' /Shared library/ {print $2}' | cut -d"]" -f1)
BINARY=$(basename ${@})
EXPORTDIR="${MAINEXPORTDIR}""/""${BINARY}"
mkdir -p $EXPORTDIR/bin
mkdir -p $EXPORTDIR/lib
cd $EXPORTDIR
# copy the binary we are interested in
cp -f ${@} "${EXPORTDIR}/bin/${BINARY}"
echo "copying ${@} to ${EXPORTDIR}/bin/${BINARY}"
LIBCOUNT=$(ls -al /lib/* | wc -l)
USRLIBCOUNT=$(ls -al /usr/lib/* | wc -l)
TOTCOUNT=$(ls -Ra1d /* | wc -l)
echo "Searching ${USRLIBCOUNT} user libs, ${LIBCOUNT} libs, ${TOTCOUNT} extended dirs"
for file in $FILES
do echo
MATCH=0
echo $file
#LOOSERESULTS=$(find / -iname '*'"$file"'*')
FASTLIBRESULTS=$(find /lib -iname '*'"$file"'*')
for result in $FASTLIBRESULTS
do
if [[ "${result:0:5}" == $TESTLIB ]]; then
echo "kindle supported at $result"
# dont copy the native stuff
MATCH=1
break
fi
done
if [ "$MATCH" == "1" ]; then
echo "/lib support detected"
continue
fi
FASTUSRLIBRESULTS=$(find /usr/lib -iname '*'"$file"'*')
for result in $FASTUSRLIBRESULTS
do
if [[ "${result:0:9}" == $TESTUSRLIB ]]; then
echo "kindle supported at $result"
# dont copy the native stuff
MATCH=1
break
fi
done
if [ "$MATCH" == "1" ]; then
echo "/usr/lib support detected"
continue
fi
EXACTRESULTS=$(find / -iname '*'"$file")
for result in $EXACTRESULTS
do
if [[ "${result:0:13}" == $BASEUS || "${result}" == $EXPORTDIR/lib/${file} ]] ; then
# dont bother with duplicates or exports
continue
fi
echo "non native result "${result}
cp -f ${result} $EXPORTDIR/lib/${file}
# just copy the first non-native instance for now...
MATCH=1
break
#fi
done
# we got this far
if [ "$MATCH" == "0" ]; then
FAIL="$FAIL""${file} "
fi
done
#remove empty lib dir
if [[ "$(ls -1 $EXPORTDIR/lib | wc -l)" == "0" ]] ; then
rmdir $EXPORTDIR/lib
fi
#remove empty bin dir if we really screwed up (on an old version.)
if [[ "$(ls -1 $EXPORTDIR/bin | wc -l)" == "0" ]] ; then
rmdir $EXPORTDIR/bin
fi
#report failures
if [ "$FAIL" != "" ]; then
echo "Failure of some files: $FAIL"
echo "Failed files that have no source for export are: $FAIL" >> $EXPORTDIR/failure.log
echo "Your binary wont work without them, please attempt to locate a copy of them and put them on your device then export again" >> $EXPORTDIR/failure.log
else
touch $EXPORTDIR/export.log
echo "Export complete at $EXPORTDIR ensure you run $BINARY like: cd $EXPORTDIR/bin; LD_LIBRARY_PATH=../lib:\$LD_LIBRARY_PATH ./$BINARY" | tee $EXPORTDIR/export.log
fi
Quote:
Everyone likes a good bash improvement thread. feel free to pick holes.
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set Last edited by twobob; 12-20-2012 at 12:23 PM. |
|
|
|
|
|
|
#2 |
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,139
Karma: 5328985
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI|K4|K3-3G|DXG|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
notes: I use bash rather than ash for this. (bash is available for the 3 and the 5)
if you get /mnt/us/bin/filechecker: line 42: syntax error: Bad substitution you need to check your bash is being correctly referenced. ah c'mon everyone likes bashing other peoples rubbishy scripting Chip in!it should be methodised at the very least. : ) No? : D ISSUES FOR THE 3: The sub-string substitution needs reworking for the really ancient busy box on the 3. I am enclosing egrep full version to facilitate this rewrite. The ancient busybox find does not support iname Either: I have enclosed a binary build of find that should do that job. invoke it directly to bypass busybox like /mnt/us/wherever/find /location/to/search -iname '*'"$file"'*' OR: change the ln -s link, or add an alias, or something to get it referencing find and bash. worst case. overwrite them. not recommended.
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set Last edited by twobob; 12-20-2012 at 07:16 AM. |
|
|
|
|
Enthusiast
|
|
|
|
#3 |
|
Just a Noob
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 128
Karma: 155592
Join Date: Aug 2011
Device: Kindle 3
|
@twobob
Awesome work, mate. |
|
|
|
|
|
#4 |
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,139
Karma: 5328985
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI|K4|K3-3G|DXG|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
Working on the 3 version now
Spoiler:
Done see below
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set Last edited by twobob; 12-20-2012 at 05:49 AM. |
|
|
|
|
|
#5 | |
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,139
Karma: 5328985
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI|K4|K3-3G|DXG|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
Confirmed as working on the 3...
okay... using the files from post two. (bash and find are the biggies)
no changes in the code. on a 3 (let's give it a tough one) [root@kindle root]# filechecker /mnt/us/usr/bin/matchbox-desktop Quote:
so yeah. just update your old versions of things in a safe way. over-ride, not overwrite (although I overwrote my various find and egrep calls with the bins just to see if it would blow the device up and it seems fine) but really just invoke it by path or something. but - at a pinch - you can just overwrite /bin/bash and /usr/bin/find WARNING!! They are symbolic links that point to busybox RENAME THEM TO name.old (like /bin/bah.old) before you attempt to replace them or you will overwrite your busybox... : ) Nice
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set Last edited by twobob; 12-20-2012 at 12:56 PM. |
|
|
|
|
|
|
#6 | ||
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,139
Karma: 5328985
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI|K4|K3-3G|DXG|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
debian extraction for dummies.
so.. and why did I want this?
on kindle 5: first mount debian [root@kindle bin]# mount -o loop=/dev/loop/debian,noatime -t ext3 /mnt/base-us/debian.ext3 /mnt/debian (just mount the ext3 file, not even chroot - that's all that is required) Let's extract something - err.. debian's wget! [root@kindle root]# filechecker /mnt/debian/usr/bin/wget Quote:
[root@kindle bin] # cd /mnt/us/export/wget/bin; LD_LIBRARY_PATH=../lib:$LD_LIBRARY_PATH ./wget --help Quote:
debian. pwned.NOTE: THIS IS NOT A MAGIC BULLET. all manner of shared files may be missing. This only identifies the libs... But it's a start.
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set Last edited by twobob; 12-20-2012 at 07:56 AM. |
||
|
|
|
|
|
#7 | |||
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,139
Karma: 5328985
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI|K4|K3-3G|DXG|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
Lets do one more and see what might go wrong.
I will do debians file (apt-get install file inside debian if you don't have it) (mount the ext.3 if it isn't already) [root@kindle bin]# mount -o loop=/dev/loop/debian,noatime -t ext3 /mnt/base-us/debian.ext3 /mnt/debian okay good to go [root@kindle bin]# filechecker /mnt/debian/usr/bin/file Quote:
[root@kindle bin]# cd /mnt/us/export/file/bin; LD_LIBRARY_PATH=../lib:$LD_LIBRARY_PATH ./file ./file Quote:
let's just hack the resources on to the root (they are tiny) [root@kindle bin]# mntroot rw [root@kindle bin]# mkdir -p /usr/share/misc/magic/ [root@kindle bin]# cp /mnt/debian/usr/share/misc/magic.mgc /usr/share/misc/magic.mgc [root@kindle bin]# mntroot ro and test it again [root@kindle bin]# cd /mnt/us/export/file/bin; LD_LIBRARY_PATH=../lib:$LD_LIBRARY_PATH ./file ./file Quote:
not too tricky all in. no doubt there will be cases where walking the required resource tree would be nice. parse a strace log maybe? : D sed would have been a better solution for accessing the resources on the FAT drive. patching the file binary to accept the new location Anyways - hope this helps other forgetful developers. HOW DO I MAKE INSTALL??? on my system (where my PATH includes /mnt/us/usr/bin and /mnt/us/usr/lib by default) to do a "make install" I would just [root@kindle bin]# cp -r /mnt/us/export/file/* /mnt/us/usr/ where file is the name of the exported application. You could do something similar
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set Last edited by twobob; 12-20-2012 at 01:31 PM. |
|||
|
|
|
|
|
#8 |
|
Embedded Cheerleader
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,118
Karma: 3854695
Join Date: Feb 2012
Device: Intel 4004
|
Reads like a generally useful tool for anyone that wants to "extended-purpose" a Kindle.
Nice job.
__________________
"Hack is just a four letter word." - - With apologies to B. Dylan |
|
|
|
|
|
#9 | |
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 91
Karma: 380902
Join Date: Jan 2013
Location: West Gardiner, Maine
Device: Touch (5.3.2.1)
|
Quote:
This whole business of exporting sure looks fun to me. |
|
|
|
|
|
|
#10 |
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,139
Karma: 5328985
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI|K4|K3-3G|DXG|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
there are plenty of options...
probably the easiest/most flexible is: add Code:
if [ -e "/mnt/us/.bashrc" ]; then
. /mnt/us/.bashrc
fi
simply stuff your additions in the FAT .bashrc (that you then create) I do that generally. I would add that this is not a completely bullet-proof solution to exporting. just a best-start tool to save some time. There may be resources that are missed, even libs from time to time seem to be missed. But in the main it does the job I need.
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set Last edited by twobob; 03-11-2013 at 09:50 PM. |
|
|
|
|
|
#11 |
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 91
Karma: 380902
Join Date: Jan 2013
Location: West Gardiner, Maine
Device: Touch (5.3.2.1)
|
Thanks! I know everyone has a personal setup, would you be willing to post your /mnt/us/.bashrc as a starting point? Do you just adjust path and libraries? Do you have any cool functions in there? Anyone else reading have anything to add?
|
|
|
|
|
|
#12 |
|
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,139
Karma: 5328985
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI|K4|K3-3G|DXG|Ematic E6+E8|Rooted Nook Touch|NO K2!!
|
pretty certain I have posted it around and about before.
With the forthcoming advent of kual-system I will refrain from giving system advice until I can be certain what that will ultimately bring. In essence include user libs and bins would be the first application of such a file as-is right now. Something along the lines of: export LD_LIBRARY_PATH=\ /mnt/us/usr/lib/arm-linux-gnueabi:\ /mnt/us/lib:\ /mnt/us/usr/lib:\ /usr/lib:\ /lib export PATH=/mnt/us/usr/local/bin:\ /mnt/us/usr/bin:\ /mnt/us/usr/games:\ /mnt/us/bin:\ /mnt/us/usr/sbin:\ /mnt/us/sbin:\ /usr/local/bin:\ /usr/bin:\ /bin:\ /usr/sbin:\ /sbin Obviously that is total overkill but you get the picture.
__________________
Audiophile and electron bully. My tunes (for free) soundcloud.com/twobob. DONATE TO KUAL BY CLICKING THIS SIMPLE LINK Kung-Fu. Hard work over time to accomplish skill. A painter can have kung-fu... The musician can have kung-fu, or the poet who paints pictures with words and makes emperors weep. This, too, is kung-fu. Formless, nameless, the true master dwells within. Only you can free him. The album I'm headlining on at the moment: s.beatport.com/OCp9dT - FREE: 2012 Award winning set Last edited by twobob; 03-12-2013 at 01:25 AM. |
|
|
|
|
|
#13 |
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 91
Karma: 380902
Join Date: Jan 2013
Location: West Gardiner, Maine
Device: Touch (5.3.2.1)
|
Thank you for making it so easy for me, I appreciate your time!
|
|
|
|
|
|
#14 | |
|
Embedded Cheerleader
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,118
Karma: 3854695
Join Date: Feb 2012
Device: Intel 4004
|
Quote:
As twobob wrote, there is an active project underway to bring system resources into the USB storage extensions/* tree. When that happens, nearly all of those paths will change (and a lot of the support work disappear). In fact, there is a whole lot of things "in progress" to extend "KUAL support" - We (twobob and I) have not given up answering questions, just been otherwise busy.
__________________
"Hack is just a four letter word." - - With apologies to B. Dylan |
|
|
|
|
![]() |
| Tags |
| bash, export, k5 tools, kindle, kindle tools, tools |
| Thread Tools | Search this Thread |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Feature Request: configurable space setting for "Insert blank line" in "Look & Feel" | therealjoeblow | Calibre | 15 | 07-25-2011 03:14 PM |
| "White Spaces Are Required"...PLEASE HELP! | UntreedReads | ePub | 12 | 07-22-2010 03:47 PM |
| Checking in public library books and "Borrowed" status | Lucybelle | Sony Reader | 2 | 03-24-2010 01:42 AM |