From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mediacenter.hi.pengutronix.de ([2001:6f8:1178:2::65]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1RxQUo-0002iZ-OX for ptxdist@pengutronix.de; Tue, 14 Feb 2012 23:05:10 +0100 Received: from mol by mediacenter.hi.pengutronix.de with local (Exim 4.72) (envelope-from ) id 1RxQUo-0001y4-NV for ptxdist@pengutronix.de; Tue, 14 Feb 2012 23:05:10 +0100 Date: Tue, 14 Feb 2012 23:05:10 +0100 From: Michael Olbrich Message-ID: <20120214220510.GQ25569@pengutronix.de> References: <1329252947-118-1-git-send-email-bernhard@bwalle.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1329252947-118-1-git-send-email-bernhard@bwalle.de> Subject: Re: [ptxdist] [PATCH] ptxdist: Check for GNU readlink Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de On Tue, Feb 14, 2012 at 09:55:47PM +0100, Bernhard Walle wrote: > ptxdist heavily uses "readlink -f" which only works with GNU readlink. > So add the usual check here. > > However, because "readlink -f" is also used before the symlinks in the > ptxdist directory is added to the PATH, that "readlink -f" call is > replaced by a bash-only implementation. This one is copied from > http://mailman.archlinux.org/pipermail/pacman-dev/2009-February/008130.html. > > Tested on Mac OS 10.7. > > Signed-off-by: Bernhard Walle > --- > Makefile.in | 1 + > bin/ptxdist | 25 ++++++++++++++++++++++++- > configure.ac | 1 + > 3 files changed, 26 insertions(+), 1 deletions(-) > > diff --git a/Makefile.in b/Makefile.in > index e8544d1..2181608 100644 > --- a/Makefile.in > +++ b/Makefile.in > @@ -55,6 +55,7 @@ environment: > @ln -sf @PYTHON@ "$(abs_srcdir)/bin/python" > @ln -sf @SED@ "$(abs_srcdir)/bin/sed" > @ln -sf @TAR@ "$(abs_srcdir)/bin/tar" > + @ln -sf @READLINK@ "$(abs_srcdir)/bin/readlink" > @echo " done" > > clean: > diff --git a/bin/ptxdist b/bin/ptxdist > index eb3366a..9355b1f 100755 > --- a/bin/ptxdist > +++ b/bin/ptxdist > @@ -1843,6 +1843,29 @@ EOF > ################ setup stuff only ################################ > ################################################################## > > +# > +# bash implementation of realpath / readlink -f > +# arg1 - filename > +realpath() > +{ > + local fname oldfname > + hmmm, scary. > + fname=${1%/} # strips trailing '/' > + while [ -L "$fname" ]; do we prefer "${fname}" in ptxdist. Please change this everywhere. > + oldfname="$fname" > + fname="$(command ls -l $fname)" fname="$(command ls -l "${fname}")" > + fname="${fname#*\> }" hmmm, "${fname#*\ -> }" is better? Or is the output different for other 'ls' implementations? Another idea: Is the problem that "readlink -f" does not work or does "readlink" not exist at all? Any readlink implementations should work here for fname="$(readlink "${fname}")". > + if [ "$fname" = . ] ; then > + fname="$(dirname $oldfname)" > + elif echo $fname | grep -vq '^/' - ; then elif [ "${fname}" -eq "${fname#/}" ]; then > + fname="$(dirname $oldfname)/$fname" fname="$(dirname "${oldfname}")/${fname}" > + fi > + done > + pushd $(dirname $fname) > /dev/null ( cd "$(dirname "${fname}")" > + fname=$(pwd -P)/$(basename $fname) ) Michael > + popd > /dev/null > + echo $fname > +} > > # > # figure out PTXDIST_TOPDIR > @@ -1859,7 +1882,7 @@ EOF > setup_topdir() { > local ptxdist topdir > > - ptxdist="$(readlink -f "${0}")" && > + ptxdist="$(realpath "${0}")" && > topdir="$(cd "$(dirname "${ptxdist}")"/.. && pwd)" || return > > # > diff --git a/configure.ac b/configure.ac > index 00c2521..497441c 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -152,6 +152,7 @@ GNU_COREUTILS(md5sum) > GNU_COREUTILS(mkdir) > GNU_COREUTILS(install) > GNU_COREUTILS(stat) > +GNU_COREUTILS(readlink) > > dnl Check for egrep > AC_PROG_EGREP > -- > 1.7.9 > > > -- > ptxdist mailing list > ptxdist@pengutronix.de > -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -- ptxdist mailing list ptxdist@pengutronix.de