Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 364237 - app-admin/eselect-postgresql contains bashisms
Summary: app-admin/eselect-postgresql contains bashisms
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: FreeBSD (show other bugs)
Hardware: All FreeBSD
: Normal normal with 1 vote (vote)
Assignee: Aaron W. Swenson
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-20 13:16 UTC by Dmitri Bogomolov
Modified: 2011-05-03 14:29 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch for postgresql.eselect (postgresql.eselect.patch,644 bytes, text/plain)
2011-04-21 12:33 UTC, Yuta SATOH
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitri Bogomolov 2011-04-20 13:16:19 UTC
/etc/eselect/postgresql/slots/8.4/base contains bash-style list:

postgres_symlinks="(
/usr/include/postgresql-8.4 /usr/include/postgresql
/usr/include/postgresql-8.4/libpq-fe.h /usr/include/libpq-fe.h
/usr/include/postgresql-8.4/pg_config_manual.h /usr/include/pg_config_manual.h
/usr/include/postgresql-8.4/libpq /usr/include/libpq
/usr/include/postgresql-8.4/postgres_ext.h /usr/include/postgres_ext.h
)

and maybe work incorrect on g/fbsd (openrc always print warnings).

/usr/share/eselect/modules/postgresql.eselect has "find -printf" expression which breaks eselect-postgresql

Reproducible: Always

Steps to Reproduce:
1. eselect postgresql list

Actual Results:  
Available PostgreSQL Slots
find: -printf: unknown option
!!! Warning: No slots available.

Expected Results:  
Available PostgreSQL installations
  8.4 <-* <-S                base-8.4.7-r2 server-8.4.7
Comment 1 Aaron W. Swenson gentoo-dev 2011-04-20 16:12:27 UTC
eselect modules are explicitly Bash scripts. Bash-style anything is permitted.

I'll figure out a solution to the find stuff.
Comment 2 Dmitri Bogomolov 2011-04-20 20:44:53 UTC
(In reply to comment #1)
> eselect modules are explicitly Bash scripts. Bash-style anything is permitted.
> 
> I'll figure out a solution to the find stuff.

OK for dev-db/postgresql-base: after rollback to app-admin/eselect-postgresql-0.4 I've been able to do `eselect postgresql set 8.4` on my g/fbsd-8.0.
Comment 3 Yuta SATOH 2011-04-21 12:33:24 UTC
Created attachment 270769 [details]
patch for postgresql.eselect

sample patch for postgresql.eselect

find of FreeBSD doesn't support printf. 
Additionally, I do not think that perhaps, there is a command that takes out only the file name. 
Therefore, the file name has been taken out by using gawk. 

FYI,
-E option
this is necessary so that regex operate appropriately.
Comment 4 Aaron W. Swenson gentoo-dev 2011-04-21 23:32:39 UTC
Or I can go the easy route and just use a system agnostic approach to the regex:

    -regex '.*postgresql-[0-9][0-9]*\.[0-9][0-9]*'

New version coming soon.
Comment 5 Aaron W. Swenson gentoo-dev 2011-04-22 10:56:49 UTC
  22 Apr 2011; Aaron W. Swenson <titanofold@gentoo.org>
  -eselect-postgresql-1.0.6.ebuild, -eselect-postgresql-1.0.7.ebuild,
  +eselect-postgresql-1.0.8.ebuild, metadata.xml:
  Fixes bug 364257 and bug 364237
Comment 6 Dmitri Bogomolov 2011-04-23 18:07:16 UTC
(In reply to comment #5)
>   22 Apr 2011; Aaron W. Swenson <titanofold@gentoo.org>
>   -eselect-postgresql-1.0.6.ebuild, -eselect-postgresql-1.0.7.ebuild,
>   +eselect-postgresql-1.0.8.ebuild, metadata.xml:
>   Fixes bug 364257 and bug 364237

This is not enough. Look:

# eix -Ic postgres
[I] app-admin/eselect-postgresql (1.0.8@04/23/11): Utility to select the default PostgreSQL slot
[I] dev-db/postgresql-base (8.4.8(8.4)@04/23/11): PostgreSQL libraries and clients
[I] dev-db/postgresql-server (8.4.8(8.4)@04/23/11): PostgreSQL server
Found 3 matches.
# eselect postgresql set 8.4
Setting 8.4 as the default installation...
        Removing old links...done.
        Generating new links...find: -xtype: unknown option
done.
Setting 8.4 as default was successful!
# psql -U postgres
bash: psql: command not found
# grep xtype /usr/share/eselect/modules/postgresql.eselect
                "-xtype f" "${B_PATH}/bin"
                        "-xtype f" "${B_PATH}/bin" "${curslot//.}"
Comment 7 sean dreilinger 2011-04-24 06:52:58 UTC
i couldn't get the eselect-postgresql-1.0.8 to work correctly until i modified the find command in  /usr/share/eselect/modules/postgresql.eselect - i had to specify the flavor of regex in the find command, and i also had to modify the regex (just like Yuta SATOH).

$ find --version
$ find (GNU findutils) 4.4.2

RCS file: RCS/postgresql.eselect,v
retrieving revision 1.1
diff -uBbw -r1.1 postgresql.eselect
--- postgresql.eselect  2011/04/24 03:53:13     1.1
+++ postgresql.eselect  2011/04/24 06:46:36
@@ -87,8 +93,8 @@
 ### Get Slots Function ###
 # Find all available slots in the preferred lib_dir() and return them.
 get_slots() {
-       echo $(find "${B_PATH}/$(lib_dir)" -maxdepth 1 -type d \
-               -regex '.*postgresql-[0-9][0-9]*\.[0-9][0-9]*' | \
+       echo $(find "${B_PATH}/$(lib_dir)/" -regextype posix-extended -maxdepth 1 -type d \
+               -regex '.*postgresql-([0-9]+\.[0-9]+)' | \
                sed -re 's#.*([0-9]+\.[0-9]+)$#\1#' | sort -n)
 }
Comment 8 Aaron W. Swenson gentoo-dev 2011-04-24 12:01:54 UTC
(In reply to comment #7)
> i couldn't get the eselect-postgresql-1.0.8 to work correctly until i modified
> the find command in  /usr/share/eselect/modules/postgresql.eselect - i had to
> specify the flavor of regex in the find command, and i also had to modify the
> regex (just like Yuta SATOH).
> 
> $ find --version
> $ find (GNU findutils) 4.4.2
> 
> RCS file: RCS/postgresql.eselect,v
> retrieving revision 1.1
> diff -uBbw -r1.1 postgresql.eselect
> --- postgresql.eselect  2011/04/24 03:53:13     1.1
> +++ postgresql.eselect  2011/04/24 06:46:36
> @@ -87,8 +93,8 @@
>  ### Get Slots Function ###
>  # Find all available slots in the preferred lib_dir() and return them.
>  get_slots() {
> -       echo $(find "${B_PATH}/$(lib_dir)" -maxdepth 1 -type d \
> -               -regex '.*postgresql-[0-9][0-9]*\.[0-9][0-9]*' | \
> +       echo $(find "${B_PATH}/$(lib_dir)/" -regextype posix-extended -maxdepth
> 1 -type d \
> +               -regex '.*postgresql-([0-9]+\.[0-9]+)' | \
>                 sed -re 's#.*([0-9]+\.[0-9]+)$#\1#' | sort -n)
>  }

The type of regular expression in use doesn't make a difference. Also, '-regextype' is not compatible with BSD.

atrus ~ 
# find /usr/lib -maxdepth 1 -regextype posix-egrep -regex '.*postgresql-[0-9][0-9]*\.[0-9][0-9]*'
/usr/lib/postgresql-8.2
/usr/lib/postgresql-8.3
/usr/lib/postgresql-8.4
/usr/lib/postgresql-9.0
/usr/lib/postgresql-9.1
atrus ~ 
# find /usr/lib -maxdepth 1 -regextype posix-awk -regex '.*postgresql-[0-9][0-9]*\.[0-9][0-9]*'
/usr/lib/postgresql-8.2
/usr/lib/postgresql-8.3
/usr/lib/postgresql-8.4
/usr/lib/postgresql-9.0
/usr/lib/postgresql-9.1
atrus ~ 
# find /usr/lib -maxdepth 1 -regextype posix-basic -regex '.*postgresql-[0-9][0-9]*\.[0-9][0-9]*'
/usr/lib/postgresql-8.2
/usr/lib/postgresql-8.3
/usr/lib/postgresql-8.4
/usr/lib/postgresql-9.0
/usr/lib/postgresql-9.1
atrus ~ 
# find /usr/lib -maxdepth 1 -regextype posix-extended -regex '.*postgresql-[0-9][0-9]*\.[0-9][0-9]*'
/usr/lib/postgresql-8.2
/usr/lib/postgresql-8.3
/usr/lib/postgresql-8.4
/usr/lib/postgresql-9.0
/usr/lib/postgresql-9.1
atrus ~ 
# find /usr/lib -maxdepth 1 -regextype emacs -regex '.*postgresql-[0-9][0-9]*\.[0-9][0-9]*'
/usr/lib/postgresql-8.2
/usr/lib/postgresql-8.3
/usr/lib/postgresql-8.4
/usr/lib/postgresql-9.0
/usr/lib/postgresql-9.1
Comment 9 Aaron W. Swenson gentoo-dev 2011-04-25 23:52:01 UTC
  25 Apr 2011; Aaron W. Swenson <titanofold@gentoo.org>
  -eselect-postgresql-1.0.8.ebuild, +eselect-postgresql-1.0.9.ebuild:
  Fix bug 364237 again
Comment 10 sean dreilinger 2011-04-26 05:18:59 UTC
eselect-postgresql-1.0.9 wouldn't work here until i added a trailing slash to the find path, perhaps this was the problem all along:

RCS file: RCS/postgresql.eselect,v
retrieving revision 1.2
diff -uBbw -r1.2 postgresql.eselect
--- postgresql.eselect  2011/04/26 05:02:36     1.2
+++ postgresql.eselect  2011/04/26 05:09:42
@@ -90,7 +90,7 @@
 ### Get Slots Function ###
 # Find all available slots in the preferred lib_dir() and return them.
 get_slots() {
-       echo $(find "${B_PATH}/$(lib_dir)" -maxdepth 1 -type d \
+       echo $(find "${B_PATH}/$(lib_dir)/" -maxdepth 1 -type d \
                -regex '.*postgresql-[0-9][0-9]*\.[0-9][0-9]*' | \
                sed -re 's#.*([0-9]+\.[0-9]+)$#\1#' | sort -n)
 }
Comment 11 Eric Grüttefien 2011-05-03 14:29:11 UTC
comment 10 works for me