[hipl-dev] Re: [Merge] lp:~hipl-core/hipl/android-hipfw into lp:hipl

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-dev@xxxxxxxxxxxxx
  • Date: Wed, 24 Sep 2014 15:47:02 +0200

On Wed, Sep 24, 2014 at 01:26:09AM +0300, Juhani Toivonen wrote:
> On 24.09.2014, at 01:06, Juhani Toivonen <dmarc-noreply@xxxxxxxxxxxxx> wrote:
> >>> --- tools/prepare_android_toolchain.sh    2013-11-18 14:14:39 +0000
> >>> +++ tools/prepare_android_toolchain.sh    2014-09-23 12:13:08 +0000
> >>> @@ -1,14 +1,18 @@
> >>> # These are for the script's internals
> >>> +PATCHES_DIR=$(dirname $(readlink -f ${0}))/../patches/android
> >> 
> >> readlink is not a standard tool, but only part of GNU coreutils.
> >> But I don't think you really need it anyway.
> > 
> > It’s been on every Linux system I’ve ever used, including the Android 
> > phones. That was the first solution I found.
> > 
> > I figure $(dirname $(pwd)/${0})/ would do too..
> 
> I don’t think the new one is better. Now calling the script with its absolute 
> path makes it wrong. readlink handles this correctly too.
> 
> If readlink is not ok, what is the standard way for a script to find its own 
> absolute path?

I'm afraid it's not entirely trivial.

> Now that the patches are extracted to separate files, the script needs
> a way to find them. Relative paths go out the window right after the
> script changes directory, which it does many times before the patches
> are to be applied. I would also like to avoid having the script work
> only if called from under tools/.

Forget about it and use readlink.  We can worry about such problems when
actual problems arise.

Diego

Other related posts: