Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
Hi, On Fri, May 29, 2015 at 6:04 PM, Michael Biebl mbi...@gmail.com wrote: I we assume, autconf-archive is installed, the resulting patch would look like the attached diff. For convenience sake, we could also ship a copy of /usr/share/aclocal/ax_normalize_path.m4 in our m4/ directory. Yep... indeed autoconf-archive is the way to go. I tested your patch with some configure options and confirmed it works as expected. I also checked that it doesn't break distcheck or anything, so I think it's good to go... I'll resend it here including the embedded autoconf-archive file in a format that's ready for git am. Cheers, Filipe ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
On 05/30/2015 08:50 AM, Mike Gilbert wrote: On Fri, May 29, 2015 at 8:05 PM, Daniel Mack dan...@zonque.org wrote: Make sure the variable set via --with-rootprefix= does not contain a trailing slash, so man pages can use entities like rootprefix;/lib without ending up having double slashes. --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 92654a6..55b73de 100644 --- a/configure.ac +++ b/configure.ac @@ -1396,7 +1396,8 @@ AC_ARG_WITH([zshcompletiondir], AC_ARG_WITH([rootprefix], AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]), -[], [with_rootprefix=${ac_default_prefix}]) +[with_rootprefix=`echo ${withval} | sed -e s,/*$,,`], +[with_rootprefix=${ac_default_prefix}]) Why do you pipe it through sed when a simple shell parameter expansion would do? with_rootprefix=${withval%/} Isn't that's a bash'ism which we try to avoid at other places? FWIW, we use sed to strip off trailing dashes from $host for EFI_ARCH. Also, that one only replaces one trailing slash, not all of them. Anyway, Michael's AX_NORMALIZE_PATH approach seems to do the right thing, so let's go for that. Thanks, Daniel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
On Fri, May 29, 2015 at 8:05 PM, Daniel Mack dan...@zonque.org wrote: Make sure the variable set via --with-rootprefix= does not contain a trailing slash, so man pages can use entities like rootprefix;/lib without ending up having double slashes. --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 92654a6..55b73de 100644 --- a/configure.ac +++ b/configure.ac @@ -1396,7 +1396,8 @@ AC_ARG_WITH([zshcompletiondir], AC_ARG_WITH([rootprefix], AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]), -[], [with_rootprefix=${ac_default_prefix}]) +[with_rootprefix=`echo ${withval} | sed -e s,/*$,,`], +[with_rootprefix=${ac_default_prefix}]) Why do you pipe it through sed when a simple shell parameter expansion would do? with_rootprefix=${withval%/} ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
On 05/30/2015 12:42 PM, Daniel Mack wrote: On 05/30/2015 12:31 PM, Christian Seiler wrote: Speaking of: using 'echo' for shell scripting is problematic, because while bash, busybox's sh, mksh, pdksh and zsh don't interpret escape sequences (\n, \0oo, ...) by default when using echo and invoked as /bin/sh, dash and ash do. (Note that e.g. dash ist default on Debian, so it's not like this is something theoretical.) Also, when invoked as their proper name (not as /bin/sh), only bash and busybox's shell do not interpret escape sequences by default with echo. (In short: it's a mess.) It's a mess indeed. Now we only need a POSIX compliant way to strip _all_ trailing dashes from a string, then we can get rid of that one occurrence of 'sed' in configure.ac :) Define once: # (local variables in functions are a bashism, don't use them, but # name global variable in such a way that it won't clash with # anything else) strip_trailing_slashes() { _strip_trailing_slashes_value=$1 while [[ ${_strip_trailing_slashes_value} != ${_strip_trailing_slashes_value%/} ]] ; do _strip_trailing_slashes_value=${_strip_trailing_slashes_value%/} done printf '%s\n' ${_strip_trailing_slashes_value} } Later: VAR=$(strip_trailing_slashes $VAR) (Or, alternatively, repeat the loop each time, you're using M4 anyway, so you could AC_DEFUN the whole thing.) It's up to you to decide what you find more appealing. Christian ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
On 05/30/2015 10:28 AM, Daniel Mack wrote: On 05/30/2015 08:50 AM, Mike Gilbert wrote: On Fri, May 29, 2015 at 8:05 PM, Daniel Mack dan...@zonque.org wrote: Make sure the variable set via --with-rootprefix= does not contain a trailing slash, so man pages can use entities like rootprefix;/lib without ending up having double slashes. --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 92654a6..55b73de 100644 --- a/configure.ac +++ b/configure.ac @@ -1396,7 +1396,8 @@ AC_ARG_WITH([zshcompletiondir], AC_ARG_WITH([rootprefix], AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]), -[], [with_rootprefix=${ac_default_prefix}]) +[with_rootprefix=`echo ${withval} | sed -e s,/*$,,`], +[with_rootprefix=${ac_default_prefix}]) Why do you pipe it through sed when a simple shell parameter expansion would do? with_rootprefix=${withval%/} Isn't that's a bash'ism which we try to avoid at other places? FWIW, we use sed to strip off trailing dashes from $host for EFI_ARCH. Also, that one only replaces one trailing slash, not all of them. No, it's not a bashism, it's indeed POSIX. See: http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02 For example: V=aXbXc printf '%s\n' ${V#*X} printf '%s\n' ${V##*X} printf '%s\n' ${V%X*} printf '%s\n' ${V%%X*} When using either one of bash, dash, ash, busybox's shell, mksh, pdksh and zsh as /bin/sh, it all produces the same output: bXc c aXb a The following are bashisms, however: - ${variable/pattern/subst} - ${!variable_variable} Speaking of: using 'echo' for shell scripting is problematic, because while bash, busybox's sh, mksh, pdksh and zsh don't interpret escape sequences (\n, \0oo, ...) by default when using echo and invoked as /bin/sh, dash and ash do. (Note that e.g. dash ist default on Debian, so it's not like this is something theoretical.) Also, when invoked as their proper name (not as /bin/sh), only bash and busybox's shell do not interpret escape sequences by default with echo. (In short: it's a mess.) POSIX itself is ambivalent: http://pubs.opengroup.org/onlinepubs/009695399/utilities/echo.html | or if any of the operands contain a backslash ( '\' ) character, the | results are implementation-defined. But it does recommend the behavior that ash and dash currently show and NOT bash's behavior: | The following character sequences shall be recognized on | XSI-conformant systems within any of the arguments: | [ list of escape sequences ] The only portable way (not only to other UNIX systems, but also to Linux systems with other shells) of printing things without interpreting escape sequences is to use printf: printf '%s\n' $variable This is the same as ALL POSIX-compliant shells. See also: http://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo Christian ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
2015-05-30 2:24 GMT+02:00 Daniel Mack dan...@zonque.org: Fine for me, just go ahead if you have an implementation in mind :) I was lazy and just copied ftp://ftp.tu-clausthal.de/pub/mirror/gnu/www/software/ac-archive/normpath.html The resulting diff would look something like diff --git a/configure.ac b/configure.ac index 92654a6..815c8af 100644 --- a/configure.ac +++ b/configure.ac @@ -1397,11 +1397,13 @@ AC_ARG_WITH([zshcompletiondir], AC_ARG_WITH([rootprefix], AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]), [], [with_rootprefix=${ac_default_prefix}]) +adl_NORMALIZE_PATH([with_rootprefix]) AC_ARG_WITH([rootlibdir], AS_HELP_STRING([--with-rootlibdir=DIR], [Root directory for libraries necessary for boot]), [], [with_rootlibdir=${libdir}]) +adl_NORMALIZE_PATH([with_rootlibdir]) AC_ARG_WITH([pamlibdir], AS_HELP_STRING([--with-pamlibdir=DIR], [Directory for PAM modules]), diff --git a/m4/normpath.m4 b/m4/normpath.m4 new file mode 100644 index 000..5b29488 --- /dev/null +++ b/m4/normpath.m4 @@ -0,0 +1,15 @@ +AC_DEFUN([adl_NORMALIZE_PATH], +[case :[$]$1: in +# change empty paths to '.' + ::) $1='.' ;; +# strip trailing slashes + :*[[\\/]]:) $1=`echo [$]$1 | sed 's,[[\\/]]*[$],,'` ;; + :*:) ;; +esac +# squeze repeated slashes +case ifelse($2,,[$]$1,$2) in +# if the path contains any backslashes, turn slashes into backslashes + *\\*) $1=`echo [$]$1 | sed 's,\(.\)[[\\/]][[\\/]]*,\1,g'` ;; +# if the path contains slashes, also turn backslashes into slashes + *) $1=`echo [$]$1 | sed 's,\(.\)[[\\/]][[\\/]]*,\1/,g'` ;; +esac]) This would need to be extended all remaining dirs. -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
On Fri, May 29, 2015 at 5:21 PM, Michael Biebl mbi...@gmail.com wrote: autoconf already strips trailing slashes for all default directory variables [1]. How does it handle --prefix=/ though? Does it turn it into an empty string? I think we should do the same for *all* our custom --with-$foo-dir variables, not just rootlibdir. Agreed. I think we can go ahead with patch #2 (man: replace hard-coded /usr/lib) since it works for both the --with-rootprefix=/usr (default) case and the --with-rootprefix= (empty) case used by Debian. Cheers, Filipe ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
2015-05-30 2:53 GMT+02:00 Michael Biebl mbi...@gmail.com: 2015-05-30 2:50 GMT+02:00 Michael Biebl mbi...@gmail.com: 2015-05-30 2:24 GMT+02:00 Daniel Mack dan...@zonque.org: Fine for me, just go ahead if you have an implementation in mind :) I was lazy and just copied ftp://ftp.tu-clausthal.de/pub/mirror/gnu/www/software/ac-archive/normpath.html Oh, I just noticed there is a sort-of official macro for that, already provided in Debian as /usr/share/aclocal/ax_normalize_path.m4 It's shipped as part of autoconf-archive. I we assume, autconf-archive is installed, the resulting patch would look like the attached diff. For convenience sake, we could also ship a copy of /usr/share/aclocal/ax_normalize_path.m4 in our m4/ directory. Michael -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? diff --git a/configure.ac b/configure.ac index 92654a6..78d52e4 100644 --- a/configure.ac +++ b/configure.ac @@ -1370,16 +1370,19 @@ AC_ARG_WITH([dbuspolicydir], AS_HELP_STRING([--with-dbuspolicydir=DIR], [D-Bus policy directory]), [], [with_dbuspolicydir=${sysconfdir}/dbus-1/system.d]) +AX_NORMALIZE_PATH([with_dbuspolicydir]) AC_ARG_WITH([dbussessionservicedir], AS_HELP_STRING([--with-dbussessionservicedir=DIR], [D-Bus session service directory]), [], [with_dbussessionservicedir=${datadir}/dbus-1/services]) +AX_NORMALIZE_PATH([with_dbussessionservicedir]) AC_ARG_WITH([dbussystemservicedir], AS_HELP_STRING([--with-dbussystemservicedir=DIR], [D-Bus system service directory]), [], [with_dbussystemservicedir=${datadir}/dbus-1/system-services]) +AX_NORMALIZE_PATH([with_dbussystemservicedir]) AC_ARG_WITH([bashcompletiondir], AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]), @@ -1389,29 +1392,35 @@ AC_ARG_WITH([bashcompletiondir], ] , [ with_bashcompletiondir=${datadir}/bash-completion/completions ])]) +AX_NORMALIZE_PATH([with_bashcompletiondir]) AC_ARG_WITH([zshcompletiondir], AS_HELP_STRING([--with-zshcompletiondir=DIR], [Zsh completions directory]), [], [with_zshcompletiondir=${datadir}/zsh/site-functions]) +AX_NORMALIZE_PATH([with_zshcompletiondir]) AC_ARG_WITH([rootprefix], AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]), [], [with_rootprefix=${ac_default_prefix}]) +AX_NORMALIZE_PATH([with_rootprefix]) AC_ARG_WITH([rootlibdir], AS_HELP_STRING([--with-rootlibdir=DIR], [Root directory for libraries necessary for boot]), [], [with_rootlibdir=${libdir}]) +AX_NORMALIZE_PATH([with_rootlibdir]) AC_ARG_WITH([pamlibdir], AS_HELP_STRING([--with-pamlibdir=DIR], [Directory for PAM modules]), [], [with_pamlibdir=${with_rootlibdir}/security]) +AX_NORMALIZE_PATH([with_pamlibdir]) AC_ARG_WITH([pamconfdir], AS_HELP_STRING([--with-pamconfdir=DIR], [Directory for PAM configuration]), [], [with_pamconfdir=${sysconfdir}/pam.d]) +AX_NORMALIZE_PATH([with_pamconfdir]) AC_ARG_ENABLE([split-usr], AS_HELP_STRING([--enable-split-usr], [Assume that /bin, /sbin aren\'t symlinks into /usr]), ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
2015-05-30 2:05 GMT+02:00 Daniel Mack dan...@zonque.org: Make sure the variable set via --with-rootprefix= does not contain a trailing slash, so man pages can use entities like rootprefix;/lib without ending up having double slashes. --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 92654a6..55b73de 100644 --- a/configure.ac +++ b/configure.ac @@ -1396,7 +1396,8 @@ AC_ARG_WITH([zshcompletiondir], AC_ARG_WITH([rootprefix], AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]), -[], [with_rootprefix=${ac_default_prefix}]) +[with_rootprefix=`echo ${withval} | sed -e s,/*$,,`], +[with_rootprefix=${ac_default_prefix}]) AC_ARG_WITH([rootlibdir], AS_HELP_STRING([--with-rootlibdir=DIR], [Root directory for libraries necessary for boot]), autoconf already strips trailing slashes for all default directory variables [1]. I think we should do the same for *all* our custom --with-$foo-dir variables, not just rootlibdir. Maybe provide a custom macro for that and apply that to --with-html-dir=PATHpath to installed docs --with-efi-libdir=PATH Path to EFI lib directory --with-efi-ldsdir=PATH Path to EFI lds directory --with-efi-includedir=PATH --with-dbuspolicydir=DIR --with-dbussessionservicedir=DIR --with-dbussystemservicedir=DIR --with-bashcompletiondir=DIR --with-zshcompletiondir=DIR --with-rootprefix=DIR rootfs directory prefix for config files and kernel --with-rootlibdir=DIR Root directory for libraries necessary for boot --with-pamlibdir=DIRDirectory for PAM modules --with-pamconfdir=DIR Directory for PAM configuration WDYT? [1] http://comments.gmane.org/gmane.comp.sysutils.autoconf.bugs/5747 -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
2015-05-30 2:50 GMT+02:00 Michael Biebl mbi...@gmail.com: 2015-05-30 2:24 GMT+02:00 Daniel Mack dan...@zonque.org: Fine for me, just go ahead if you have an implementation in mind :) I was lazy and just copied ftp://ftp.tu-clausthal.de/pub/mirror/gnu/www/software/ac-archive/normpath.html Oh, I just noticed there is a sort-of official macro for that, already provided in Debian as /usr/share/aclocal/ax_normalize_path.m4 It's shipped as part of autoconf-archive. -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
Make sure the variable set via --with-rootprefix= does not contain a trailing slash, so man pages can use entities like rootprefix;/lib without ending up having double slashes. --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 92654a6..55b73de 100644 --- a/configure.ac +++ b/configure.ac @@ -1396,7 +1396,8 @@ AC_ARG_WITH([zshcompletiondir], AC_ARG_WITH([rootprefix], AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]), -[], [with_rootprefix=${ac_default_prefix}]) +[with_rootprefix=`echo ${withval} | sed -e s,/*$,,`], +[with_rootprefix=${ac_default_prefix}]) AC_ARG_WITH([rootlibdir], AS_HELP_STRING([--with-rootlibdir=DIR], [Root directory for libraries necessary for boot]), -- 2.4.0 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
2015-05-30 2:30 GMT+02:00 Filipe Brandenburger filbran...@google.com: On Fri, May 29, 2015 at 5:21 PM, Michael Biebl mbi...@gmail.com wrote: autoconf already strips trailing slashes for all default directory variables [1]. How does it handle --prefix=/ though? Does it turn it into an empty string? Hm, no, apparently it doesn't. It only strips the trailing '/' when you use something like --prefix=/usr/ -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth? ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH 1/2] configure.ac: strip off trailing slashed from $rootprefix
On 05/30/2015 02:21 AM, Michael Biebl wrote: 2015-05-30 2:05 GMT+02:00 Daniel Mack dan...@zonque.org: Make sure the variable set via --with-rootprefix= does not contain a trailing slash, so man pages can use entities like rootprefix;/lib without ending up having double slashes. --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 92654a6..55b73de 100644 --- a/configure.ac +++ b/configure.ac @@ -1396,7 +1396,8 @@ AC_ARG_WITH([zshcompletiondir], AC_ARG_WITH([rootprefix], AS_HELP_STRING([--with-rootprefix=DIR], [rootfs directory prefix for config files and kernel modules]), -[], [with_rootprefix=${ac_default_prefix}]) +[with_rootprefix=`echo ${withval} | sed -e s,/*$,,`], +[with_rootprefix=${ac_default_prefix}]) AC_ARG_WITH([rootlibdir], AS_HELP_STRING([--with-rootlibdir=DIR], [Root directory for libraries necessary for boot]), autoconf already strips trailing slashes for all default directory variables [1]. I think we should do the same for *all* our custom --with-$foo-dir variables, not just rootlibdir. Maybe provide a custom macro for that and apply that to --with-html-dir=PATHpath to installed docs --with-efi-libdir=PATH Path to EFI lib directory --with-efi-ldsdir=PATH Path to EFI lds directory --with-efi-includedir=PATH --with-dbuspolicydir=DIR --with-dbussessionservicedir=DIR --with-dbussystemservicedir=DIR --with-bashcompletiondir=DIR --with-zshcompletiondir=DIR --with-rootprefix=DIR rootfs directory prefix for config files and kernel --with-rootlibdir=DIR Root directory for libraries necessary for boot --with-pamlibdir=DIRDirectory for PAM modules --with-pamconfdir=DIR Directory for PAM configuration WDYT? Fine for me, just go ahead if you have an implementation in mind :) Thanks, Daniel ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel