[Postgres-xl-developers] fix postgres-xl build on FreeBSD

Jov amutu at amutu.com
Tue Dec 16 19:15:28 PST 2014


hi Pavan,
   Thanks for your review,but it seams the patch which you have commit is
imcomplete.When use pgxc_ctl,it generate bash scripts from bash template to
run,so the bash template should be change to use '#!/usr/bin/env bash'
too.This  changes in my original v2 patch,I think you miss it? I make a v3
patch for the additional change:
diff --git a/contrib/pgxc_ctl/pgxc_ctl.bash b/contrib/pgxc_ctl/pgxc_ctl.bash
index 6cf5b95..6353e2e 100755
--- a/contrib/pgxc_ctl/pgxc_ctl.bash
+++ b/contrib/pgxc_ctl/pgxc_ctl.bash
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # TODO
 # * Backup configuration file (at update, too) to some remote site for
pgxc_ctl HA feature too.
@@ -258,7 +258,7 @@ progname=$0
 function create_config_file_template
 {
  cat > $configFile <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
 #==========================================================================================================================
 #
 # Configuration Section
@@ -709,7 +709,7 @@ function create_config_file
  # The configuration file is just a copy of the above configuraiton
section.   If you modify the above,
  # you should reflect it to the below too.
  cat > $configFile <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
 # The context will be supplied finally...
 EOF
 }
diff --git a/contrib/pgxc_ctl/pgxc_ctl_bash.c
b/contrib/pgxc_ctl/pgxc_ctl_bash.c
index 6799704..3784e3a 100644
--- a/contrib/pgxc_ctl/pgxc_ctl_bash.c
+++ b/contrib/pgxc_ctl/pgxc_ctl_bash.c
@@ -31,7 +31,7 @@
  */

 char *pgxc_ctl_bash_script[] = {
-"#!/bin/bash",
+"#!/usr/bin/env bash",
 "# Common variables
######################################################################",
 "xc_prompt='PGXC$ '",
 "interactive=n",
@@ -353,7 +353,7 @@ NULL
  * work directory with 'prepare config' command.
  */
 char *pgxc_ctl_conf_prototype[] = {
-"#!/bin/bash",
+"#!/usr/bin/env bash",
 "#",
 "# Postgres-XC Configuration file for pgxc_ctl utility. ",
 "#",
@@ -681,7 +681,7 @@ NULL
 };

 char *pgxc_ctl_conf_prototype_minimal[] = {
-"#!/bin/bash",
+"#!/usr/bin/env bash",
 "#",
 "# Postgres-XC Configuration file for pgxc_ctl utility. ",
 "#",
diff --git a/contrib/pgxc_ctl/pgxc_ctl_bash.org b/contrib/pgxc_ctl/
pgxc_ctl_bash.org
index f1c142d..23ba57d 100755
--- a/contrib/pgxc_ctl/pgxc_ctl_bash.org
+++ b/contrib/pgxc_ctl/pgxc_ctl_bash.org
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # TODO
 # * Backup configuration file (at update, too) to some remote site for
pgxc_ctl HA feature too.
@@ -307,7 +307,7 @@ logfile=none
 function create_config_file_template
 {
  cat > $configFile <<EOF
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # TODO
 # * Backup configuration file (at update, too) to some remote site for
pgxc_ctl HA feature too.
diff --git a/contrib/pgxc_ctl/pgxc_ctl_bash_2
b/contrib/pgxc_ctl/pgxc_ctl_bash_2
index 21839ea..afbccaf 100755
--- a/contrib/pgxc_ctl/pgxc_ctl_bash_2
+++ b/contrib/pgxc_ctl/pgxc_ctl_bash_2
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 # Common variables
######################################################################
 xc_prompt='PGXC$ '
 interactive=n
diff --git a/contrib/pgxc_ctl/pgxc_ctl_conf_part
b/contrib/pgxc_ctl/pgxc_ctl_conf_part
index 9640dc9..a1a4052 100755
--- a/contrib/pgxc_ctl/pgxc_ctl_conf_part
+++ b/contrib/pgxc_ctl/pgxc_ctl_conf_part
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Postgres-XC Configuration file for pgxc_ctl utility.
 #
diff --git a/contrib/pgxc_ctl/signature.h b/contrib/pgxc_ctl/signature.h
index 4268c99..fc28d0e 100644
--- a/contrib/pgxc_ctl/signature.h
+++ b/contrib/pgxc_ctl/signature.h
@@ -11,5 +11,5 @@
 #ifndef SIGNATURE_H
 #define SIGNATURE_H
 /* Signature file to identify the make */
-#define signature "140731_1647_N"
+#define signature "141217_1051_N"
 #endif /* SIGNATURE_H */


Jov
blog: http:amutu.com/blog <http://amutu.com/blog>

2014-12-15 19:27 GMT+08:00 Pavan Deolasee <pavan.deolasee at gmail.com>:
>
>
>
> On Sat, Dec 13, 2014 at 8:53 AM, Jov <amutu at amutu.com> wrote:
>>
>> the pgxc_ctl heavily use the bash array type,which is not support by
>> /bin/sh
>>
>> ➜  pgxc_ctl  /bin/sh ./pgxc_ctl.conf
>>> ./pgxc_ctl.conf: 125: Syntax error: word unexpected (expecting ")")
>>> ➜  pgxc_ctl  sed -n '125p' ./pgxc_ctl.conf
>>> gtmProxyNames=(gtm_pxy1 gtm_pxy2 gtm_pxy3 gtm_pxy4) # No used if it is
>>> not configured
>>> ➜  ~  sh ./git/postgres-xl/contrib/pgxc_ctl/pgxc_ctl.bash
>>> ./git/postgres-xl/contrib/pgxc_ctl/pgxc_ctl.bash: 127: Syntax error:
>>> word unexpected (expecting ")")
>>> ➜  ~  sed -n '127p'  ./git/postgres-xl/contrib/pgxc_ctl/pgxc_ctl.bash
>>> gtmProxyNames=(gtm_pxy1 gtm_pxy2 gtm_pxy3 gtm_pxy4) # No used if it is
>>> not configured
>>
>>
>>
> TBH I'm not sure if those bash scripts are really used by pgxc_ctl after
> its 'C' version was checked in. If not, we should probably clean that up to
> avoid confusion. For now, I will go with your patch and we can revisit it
> in future.
>
>
>
>> I know bash is not default /bin/sh on freebsd and debian(newer debian use
>> dash),but if we change to /bin/sh, the shell script should be rewrite and
>> test,it's a lot of work.
>>
>> I make a patch to check if the bash available and emit error when running
>> pgxc_ctl.
>> I use "command -v" to check the bash,wile it is portable because
>> "command" is a builtin command in FreeBSD /bin/sh and XSI sh  (type can
>> also be used,but it seems type is not posix portable:
>> http://compgroups.net/comp.unix.shell/-type-builtin-in-posix-only-shell/503234
>> )
>>
>
> Ok. That works for now.
>
> Thanks,
> Pavan
>
>
> --
> Pavan Deolasee
> http://www.linkedin.com/in/pavandeolasee
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.postgres-xl.org/private.cgi/postgres-xl-developers-postgres-xl.org/attachments/20141217/8b64fe22/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fb_fix_pgxc_ctl_v3.patch
Type: application/octet-stream
Size: 3420 bytes
Desc: not available
URL: <http://lists.postgres-xl.org/private.cgi/postgres-xl-developers-postgres-xl.org/attachments/20141217/8b64fe22/attachment.obj>


More information about the Postgres-xl-developers mailing list