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

Jov amutu at amutu.com
Fri Dec 12 19:23:38 PST 2014


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


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
)

diff --git a/contrib/pgxc_ctl/pgxc_ctl.c b/contrib/pgxc_ctl/pgxc_ctl.c
index 1bb567b..2d03358 100644
--- a/contrib/pgxc_ctl/pgxc_ctl.c
+++ b/contrib/pgxc_ctl/pgxc_ctl.c
@@ -440,6 +440,12 @@ int main(int argc, char *argv[])
                {0, 0, 0, 0}
        };

+       int is_bash_exist = system("command -v bash");
+       if ( is_bash_exist != 0 ) {
+               fprintf(stderr, "bash can not be find,make sure bash is
installed and in the PATH\n$
+               exit(2);
+       }
+
        strcpy(progname, argv[0]);
        init_var_hash();

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

2014-12-12 16:19 GMT+08:00 Jov <amutu at amutu.com>:
>
> I don't think all the shell scripts which pgxc_ctl depend is posix shell
> confirmed .I will test and feedback.
> 2014年12月12日 3:35 PM于 "Pavan Deolasee" <pavan.deolasee at gmail.com>写道:
>
>
>>
>> On Thu, Dec 11, 2014 at 1:31 PM, Jov <amutu at amutu.com> wrote:
>>>
>>> I will put the patch to pgxl,but the review progress is slow.there is no
>>> feedback from Mason Sharp for the first patch by now.
>>>
>>
>> Hi Jov,
>>
>> Sorry for the delay. I looked at your patch to fix FreeBSD issues. The
>> patch looks good except this change.
>>
>> diff --git a/contrib/pgxc_ctl/make_signature
>> b/contrib/pgxc_ctl/make_signature
>> index 04020f3..bdc3d42 100755
>> --- a/contrib/pgxc_ctl/make_signature
>> +++ b/contrib/pgxc_ctl/make_signature
>> @@ -1,4 +1,4 @@
>> -#!/bin/bash
>> +#!/usr/bin/env bash
>>  #--------------------------------------------------------------------
>>  #
>>  # make_signature
>>
>> IMHO its better to just revert to "sh" shell instead of using "bash".
>> From what I understand, bash may not even be installed on some FreeBSD
>> systems. So I'm proposing to use !/bin/sh since the same is used for couple
>> of other scripts that PostgreSQL uses and seem to work on all platforms
>> without any complaints. Can you please verify on FreeBSD and let us know?
>>
>> 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/20141213/ac7dc96c/attachment.htm>


More information about the Postgres-xl-developers mailing list