@@ -1956,14 +1956,22 @@ def link_pg_config():
1956
1956
packages .extend (['mysql80-server' , 'mysql80-client' ])
1957
1957
1958
1958
if 'pgsql' in features :
1959
- # Install the latest postgresql-client and postgresql-server.
1960
- _ , output = execute ("pkg search postgresql | grep -E 'postgresql[0-9]+-client' | tail -n 1 | "
1961
- "cut -d ' ' -f 1 | cut -d '-' -f 1-2" , capture = True )
1962
- postgresql_client = output .strip ()
1963
- _ , output = execute ("pkg search postgresql | grep -E 'postgresql[0-9]+-server' | tail -n 1 | "
1964
- "cut -d ' ' -f 1 | cut -d '-' -f 1-2" , capture = True )
1965
- postgresql_server = output .strip ()
1966
- packages .extend ([postgresql_client , postgresql_server ])
1959
+ # Install the latest postgresql-client and postgresql-server,
1960
+ # unless any postgresql-client or postgresql-server version is already installed.
1961
+ for i in ['client' , 'server' ]:
1962
+ # Check if already installed.
1963
+ _ , output = execute ('pkg info' , capture = True )
1964
+ m = re .search (f'postgresql[0-9]+-{ i } ' , output )
1965
+ if m is None :
1966
+ # If not, go ahead and install.
1967
+ _ , output = execute ('pkg search postgresql' , capture = True )
1968
+ found = re .findall (f'postgresql[0-9]+-{ i } ' , output )
1969
+ if len (found ) == 0 :
1970
+ print (f'No postgresql[0-9]+-{ i } found?' )
1971
+ sys .exit (1 )
1972
+ # There may be more matches. Results are sorted by pkg.
1973
+ # Choose the last from the list which should be the latest version.
1974
+ packages .append (found [- 1 ])
1967
1975
1968
1976
if 'gssapi' in features :
1969
1977
packages .extend (['krb5-devel' ])
0 commit comments