mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH 1/2] Makefile.in: Create symlink for xargs
@ 2012-03-12 19:56 Bernhard Walle
  2012-03-12 19:56 ` [ptxdist] [PATCH 2/2] ptxdist: Check for GNU readlink Bernhard Walle
  2012-03-13  9:42 ` [ptxdist] [PATCH 1/2] Makefile.in: Create symlink for xargs Michael Olbrich
  0 siblings, 2 replies; 12+ messages in thread
From: Bernhard Walle @ 2012-03-12 19:56 UTC (permalink / raw)
  To: ptxdist

We check for a xargs binary that supports the '-r' flag, so put the
usual symlink into the bin directory once we have found a proper
implementation.

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
---
 Makefile.in |    1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile.in b/Makefile.in
index b976a3f..e62a2d9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -56,6 +56,7 @@ environment:
 	@ln -sf @GNU_tar@ "$(abs_srcdir)/bin/tar"
 	@ln -sf @PYTHON@ "$(abs_srcdir)/bin/python"
 	@ln -sf @SED@ "$(abs_srcdir)/bin/sed"
+	@ln -sf @XARGS@ "$(abs_srcdir)/bin/xargs"
 	@echo " done"
 
 clean:
-- 
1.7.9.2


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ptxdist] [PATCH 2/2] ptxdist: Check for GNU readlink
  2012-03-12 19:56 [ptxdist] [PATCH 1/2] Makefile.in: Create symlink for xargs Bernhard Walle
@ 2012-03-12 19:56 ` Bernhard Walle
  2012-03-13 10:16   ` Michael Olbrich
  2012-03-13  9:42 ` [ptxdist] [PATCH 1/2] Makefile.in: Create symlink for xargs Michael Olbrich
  1 sibling, 1 reply; 12+ messages in thread
From: Bernhard Walle @ 2012-03-12 19:56 UTC (permalink / raw)
  To: ptxdist

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.

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
---
 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..7636187 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.2


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ptxdist] [PATCH 1/2] Makefile.in: Create symlink for xargs
  2012-03-12 19:56 [ptxdist] [PATCH 1/2] Makefile.in: Create symlink for xargs Bernhard Walle
  2012-03-12 19:56 ` [ptxdist] [PATCH 2/2] ptxdist: Check for GNU readlink Bernhard Walle
@ 2012-03-13  9:42 ` Michael Olbrich
  1 sibling, 0 replies; 12+ messages in thread
From: Michael Olbrich @ 2012-03-13  9:42 UTC (permalink / raw)
  To: ptxdist

On Mon, Mar 12, 2012 at 08:56:32PM +0100, Bernhard Walle wrote:
> We check for a xargs binary that supports the '-r' flag, so put the
> usual symlink into the bin directory once we have found a proper
> implementation.

Applied.

Michael

> Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
> ---
>  Makefile.in |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Makefile.in b/Makefile.in
> index b976a3f..e62a2d9 100644
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -56,6 +56,7 @@ environment:
>  	@ln -sf @GNU_tar@ "$(abs_srcdir)/bin/tar"
>  	@ln -sf @PYTHON@ "$(abs_srcdir)/bin/python"
>  	@ln -sf @SED@ "$(abs_srcdir)/bin/sed"
> +	@ln -sf @XARGS@ "$(abs_srcdir)/bin/xargs"
>  	@echo " done"
>  
>  clean:
> -- 
> 1.7.9.2
> 
> 
> -- 
> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ptxdist] [PATCH 2/2] ptxdist: Check for GNU readlink
  2012-03-12 19:56 ` [ptxdist] [PATCH 2/2] ptxdist: Check for GNU readlink Bernhard Walle
@ 2012-03-13 10:16   ` Michael Olbrich
  2012-03-13 11:23     ` [ptxdist] [PATCH] " bernhard
  2012-03-13 11:30     ` bernhard
  0 siblings, 2 replies; 12+ messages in thread
From: Michael Olbrich @ 2012-03-13 10:16 UTC (permalink / raw)
  To: ptxdist

On Mon, Mar 12, 2012 at 08:56:33PM +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 inspired from
> http://mailman.archlinux.org/pipermail/pacman-dev/2009-February/008130.html.
> 
> Tested on Mac OS 10.7.
> 
> Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
> ---
>  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..7636187 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}))

	(cd "$(dirname "${fname}")"; echo $(pwd -P)/$(basename "${fname}"))

just to make sure. I need to test this some more, but I think the rest is
ok now.

Michael

> +}
>  
>  #
>  # 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.2
> 
> 
> -- 
> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ptxdist] [PATCH] ptxdist: Check for GNU readlink
  2012-03-13 10:16   ` Michael Olbrich
@ 2012-03-13 11:23     ` bernhard
  2012-03-13 11:30     ` bernhard
  1 sibling, 0 replies; 12+ messages in thread
From: bernhard @ 2012-03-13 11:23 UTC (permalink / raw)
  To: ptxdist; +Cc: Bernhard Walle

From: Bernhard Walle <bernhard@bwalle.de>

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.

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
---
 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..7636187 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ptxdist] [PATCH] ptxdist: Check for GNU readlink
  2012-03-13 10:16   ` Michael Olbrich
  2012-03-13 11:23     ` [ptxdist] [PATCH] " bernhard
@ 2012-03-13 11:30     ` bernhard
  2012-03-13 13:17       ` Michael Olbrich
  1 sibling, 1 reply; 12+ messages in thread
From: bernhard @ 2012-03-13 11:30 UTC (permalink / raw)
  To: ptxdist; +Cc: Bernhard Walle

From: Bernhard Walle <bernhard@bwalle.de>

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.

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
---
===== 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ptxdist] [PATCH] ptxdist: Check for GNU readlink
  2012-03-13 11:30     ` bernhard
@ 2012-03-13 13:17       ` Michael Olbrich
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Olbrich @ 2012-03-13 13:17 UTC (permalink / raw)
  To: ptxdist

On Tue, Mar 13, 2012 at 12:30:23PM +0100, bernhard@bwalle.de wrote:
> From: Bernhard Walle <bernhard@bwalle.de>
> 
> 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 <bernhard@bwalle.de>
> ---
> ===== 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ptxdist] [PATCH] ptxdist: Check for GNU readlink
  2012-03-13 10:14     ` Michael Olbrich
@ 2012-03-13 11:32       ` Bernhard Walle
  0 siblings, 0 replies; 12+ messages in thread
From: Bernhard Walle @ 2012-03-13 11:32 UTC (permalink / raw)
  To: ptxdist

* Michael Olbrich <m.olbrich@pengutronix.de> [2012-03-13 11:14]:
> 
> Not the 'local', the whole function. Getting all corner-cases right for
> something like this is not trivial.

Ah, ok. Indeed. That's why I started using something from the
Internet[tm] and that's also why I only replaced that initial
"readlink -f" call to find the ptxdist directory by the Bash
implementation. The rest should still be (g)readlink -f.

The alternative would be a Perl one-liner or Python. But that would be
add additional requirements.

Regards,
Bernhard

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ptxdist] [PATCH] ptxdist: Check for GNU readlink
  2012-03-12 19:56   ` Bernhard Walle
@ 2012-03-13 10:14     ` Michael Olbrich
  2012-03-13 11:32       ` Bernhard Walle
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Olbrich @ 2012-03-13 10:14 UTC (permalink / raw)
  To: ptxdist

On Mon, Mar 12, 2012 at 08:56:17PM +0100, Bernhard Walle wrote:
> Hi Michael,
> 
> thanks again for the review.
> 
> * Michael Olbrich <m.olbrich@pengutronix.de> [2012-02-14 23:05]:
> > > +# bash implementation of realpath / readlink -f
> > > +#   arg1 - filename
> > > +realpath()
> > > +{
> > > +	local fname oldfname
> > > +
> > 
> > hmmm, scary.
> 
> What's wrong about 'local'?

Not the 'local', the whole function. Getting all corner-cases right for
something like this is not trivial.

> > 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}")".
> 
> You're right. Even Apple adds a working readlink implementation. :)
> 
> > > +		if [ "$fname" = . ] ; then
> > > +			fname="$(dirname $oldfname)"
> > > +		elif echo $fname | grep -vq '^/' - ; then
> > 
> > 		elif [ "${fname}" -eq "${fname#/}" ]; then
> 
> -eq is only for numeric comparison, so it should be '=', right?

Right.

> 
> > 	( cd "$(dirname "${fname}")"
> > 
> > > +	fname=$(pwd -P)/$(basename $fname)
> > 
> > 	)
> 
> Assigning a variable in a subshell has no effect on the outer shell, has
> it? But echo'ing directly here works.

True. We want to echo anyways.

> A reworked version will follow.

Michael

-- 
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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ptxdist] [PATCH] ptxdist: Check for GNU readlink
  2012-02-14 22:05 ` Michael Olbrich
@ 2012-03-12 19:56   ` Bernhard Walle
  2012-03-13 10:14     ` Michael Olbrich
  0 siblings, 1 reply; 12+ messages in thread
From: Bernhard Walle @ 2012-03-12 19:56 UTC (permalink / raw)
  To: ptxdist

Hi Michael,

thanks again for the review.

* Michael Olbrich <m.olbrich@pengutronix.de> [2012-02-14 23:05]:
> > +# bash implementation of realpath / readlink -f
> > +#   arg1 - filename
> > +realpath()
> > +{
> > +	local fname oldfname
> > +
> 
> hmmm, scary.

What's wrong about 'local'?

> 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}")".

You're right. Even Apple adds a working readlink implementation. :)

> > +		if [ "$fname" = . ] ; then
> > +			fname="$(dirname $oldfname)"
> > +		elif echo $fname | grep -vq '^/' - ; then
> 
> 		elif [ "${fname}" -eq "${fname#/}" ]; then

-eq is only for numeric comparison, so it should be '=', right?

> 	( cd "$(dirname "${fname}")"
> 
> > +	fname=$(pwd -P)/$(basename $fname)
> 
> 	)

Assigning a variable in a subshell has no effect on the outer shell, has
it? But echo'ing directly here works.

A reworked version will follow.



Regards,
Bernhard

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [ptxdist] [PATCH] ptxdist: Check for GNU readlink
  2012-02-14 20:55 [ptxdist] [PATCH] ptxdist: Check for GNU readlink Bernhard Walle
@ 2012-02-14 22:05 ` Michael Olbrich
  2012-03-12 19:56   ` Bernhard Walle
  0 siblings, 1 reply; 12+ messages in thread
From: Michael Olbrich @ 2012-02-14 22:05 UTC (permalink / raw)
  To: ptxdist

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 <bernhard@bwalle.de>
> ---
>  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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [ptxdist] [PATCH] ptxdist: Check for GNU readlink
@ 2012-02-14 20:55 Bernhard Walle
  2012-02-14 22:05 ` Michael Olbrich
  0 siblings, 1 reply; 12+ messages in thread
From: Bernhard Walle @ 2012-02-14 20:55 UTC (permalink / raw)
  To: ptxdist

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 <bernhard@bwalle.de>
---
 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
+
+	fname=${1%/} # strips trailing '/'
+	while [ -L "$fname" ]; do
+		oldfname="$fname"
+		fname="$(command ls -l $fname)"
+		fname="${fname#*\> }"
+		if [ "$fname" = . ] ; then
+			fname="$(dirname $oldfname)"
+		elif echo $fname | grep -vq '^/' - ; then
+			fname="$(dirname $oldfname)/$fname"
+		fi
+	done
+	pushd $(dirname $fname) > /dev/null
+	fname=$(pwd -P)/$(basename $fname)
+	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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-03-13 13:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-12 19:56 [ptxdist] [PATCH 1/2] Makefile.in: Create symlink for xargs Bernhard Walle
2012-03-12 19:56 ` [ptxdist] [PATCH 2/2] ptxdist: Check for GNU readlink Bernhard Walle
2012-03-13 10:16   ` Michael Olbrich
2012-03-13 11:23     ` [ptxdist] [PATCH] " bernhard
2012-03-13 11:30     ` bernhard
2012-03-13 13:17       ` Michael Olbrich
2012-03-13  9:42 ` [ptxdist] [PATCH 1/2] Makefile.in: Create symlink for xargs Michael Olbrich
  -- strict thread matches above, loose matches on Subject: below --
2012-02-14 20:55 [ptxdist] [PATCH] ptxdist: Check for GNU readlink Bernhard Walle
2012-02-14 22:05 ` Michael Olbrich
2012-03-12 19:56   ` Bernhard Walle
2012-03-13 10:14     ` Michael Olbrich
2012-03-13 11:32       ` Bernhard Walle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox