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 1S7RbD-0002yf-Uz for ptxdist@pengutronix.de; Tue, 13 Mar 2012 14:17:11 +0100 Received: from mol by mediacenter.hi.pengutronix.de with local (Exim 4.72) (envelope-from ) id 1S7RbD-0002Iv-Tw for ptxdist@pengutronix.de; Tue, 13 Mar 2012 14:17:11 +0100 Date: Tue, 13 Mar 2012 14:17:11 +0100 From: Michael Olbrich Message-ID: <20120313131711.GR29221@pengutronix.de> References: <20120313101643.GL29221@pengutronix.de> <1331638223-8889-1-git-send-email-bernhard@bwalle.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1331638223-8889-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, Mar 13, 2012 at 12:30:23PM +0100, bernhard@bwalle.de wrote: > From: Bernhard Walle > > 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 inspired from > http://mailman.archlinux.org/pipermail/pacman-dev/2009-February/008130.html. > > Tested on Mac OS 10.7. There were still some issues with some indirect links in directories with white-spaces, so I added some more quotation marks. But It's applied now. Michael > Signed-off-by: Bernhard Walle > --- > ===== Sorry, forget the first version. I forgot to commit. > > Makefile.in | 1 + > bin/ptxdist | 22 +++++++++++++++++++++- > configure.ac | 1 + > 3 files changed, 23 insertions(+), 1 deletion(-) > > diff --git a/Makefile.in b/Makefile.in > index e62a2d9..17a6ce6 100644 > --- a/Makefile.in > +++ b/Makefile.in > @@ -54,6 +54,7 @@ environment: > @ln -sf @GNU_stat@ "$(abs_srcdir)/bin/stat" > @ln -sf @GNU_mknod@ "$(abs_srcdir)/bin/mknod" > @ln -sf @GNU_tar@ "$(abs_srcdir)/bin/tar" > + @ln -sf @GNU_readlink@ "$(abs_srcdir)/bin/readlink" > @ln -sf @PYTHON@ "$(abs_srcdir)/bin/python" > @ln -sf @SED@ "$(abs_srcdir)/bin/sed" > @ln -sf @XARGS@ "$(abs_srcdir)/bin/xargs" > diff --git a/bin/ptxdist b/bin/ptxdist > index eb3366a..3cb8eed 100755 > --- a/bin/ptxdist > +++ b/bin/ptxdist > @@ -1843,6 +1843,26 @@ EOF > ################ setup stuff only ################################ > ################################################################## > > +# > +# bash implementation of realpath / readlink -f > +# arg1 - filename > +realpath() > +{ > + local fname oldfname > + > + fname=${1%/} # strips trailing '/' > + while [ -L "${fname}" ]; do > + oldfname="${fname}" > + fname="$(readlink ${fname})" > + if [ "$fname" = . ] ; then > + fname="$(dirname $oldfname)" > + elif [ "${fname}" = "${fname#/}" ]; then > + fname="$(dirname "${oldfname}")/${fname}" > + fi > + done > + > + (cd "$(dirname "${fname}")"; echo $(pwd -P)/$(basename "${fname}")) > +} > > # > # figure out PTXDIST_TOPDIR > @@ -1859,7 +1879,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 37a01ae..780bf28 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -155,6 +155,7 @@ GNU_TOOL(mkdir, coreutils) > GNU_TOOL(install, coreutils) > GNU_TOOL(stat, coreutils) > GNU_TOOL(mknod, coreutils) > +GNU_TOOL(readlink, coreutils) > GNU_TOOL(tar, tar) > > dnl Check for egrep > -- > 1.7.9.4 > > > -- > 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