Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 625368 - app-eselect/eselect-postgresql-2.1: canonicalise doesn't return path for nonexistent files
Summary: app-eselect/eselect-postgresql-2.1: canonicalise doesn't return path for none...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: PgSQL Bugs
URL:
Whiteboard:
Keywords:
: 627050 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-07-17 03:29 UTC by Anton Bolshakov
Modified: 2017-08-07 12:07 UTC (History)
1 user (show)

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


Attachments
pg_build.log (build.log,3.95 KB, text/x-log)
2017-07-17 03:41 UTC, Anton Bolshakov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Bolshakov 2017-07-17 03:29:16 UTC
I have just upgraded from 9.5 to 9.6 and facing an issue.

There are few broken symlinks left in the system which prevents other packages (dev-ruby/pg) to build. The symlinks are the following:

/usr/include/libpq -> postgresql-9.5/libpq
/usr/include/libpq-fe.h -> postgresql-9.5/libpq-fe.h
/usr/include/postgres_ext.h -> postgresql-9.5/postgres_ext.h
/usr/include/postgresql-9.6/postgresql-9.6 -> postgresql-9.6
/usr/include/pg_config_ext.h -> postgresql-9.5/pg_config_ext.h
/usr/include/pg_config_manual.h -> postgresql-9.5/pg_config_manual.h

/usr/bin/droplang -> ../lib64/postgresql-9.5/bin/droplang
/usr/bin/pg_config -> ../lib64/postgresql-9.5/bin/pg_config
/usr/bin/vacuumdb -> ../lib64/postgresql-9.5/bin/vacuumdb
/usr/bin/pg_restore -> ../lib64/postgresql-9.5/bin/pg_restore
/usr/bin/createdb -> ../lib64/postgresql-9.5/bin/createdb
/usr/bin/postgres -> ../lib64/postgresql-9.5/bin/postgres
/usr/bin/reindexdb -> ../lib64/postgresql-9.5/bin/reindexdb
/usr/bin/pg_test_timing -> ../lib64/postgresql-9.5/bin/pg_test_timing
/usr/bin/pg_standby -> ../lib64/postgresql-9.5/bin/pg_standby
/usr/bin/postmaster -> ../lib64/postgresql-9.5/bin/postgres
/usr/bin/clusterdb -> ../lib64/postgresql-9.5/bin/clusterdb
/usr/bin/pg_archivecleanup -> ../lib64/postgresql-9.5/bin/pg_archivecleanup
/usr/bin/pg_dump -> ../lib64/postgresql-9.5/bin/pg_dump
/usr/bin/vacuumlo -> ../lib64/postgresql-9.5/bin/vacuumlo
/usr/bin/ecpg -> ../lib64/postgresql-9.5/bin/ecpg
/usr/bin/createlang -> ../lib64/postgresql-9.5/bin/createlang
/usr/bin/dropdb -> ../lib64/postgresql-9.5/bin/dropdb
/usr/bin/pgbench -> ../lib64/postgresql-9.5/bin/pgbench
/usr/bin/pg_recvlogical -> ../lib64/postgresql-9.5/bin/pg_recvlogical
/usr/bin/pg_resetxlog -> ../lib64/postgresql-9.5/bin/pg_resetxlog
/usr/bin/pg_basebackup -> ../lib64/postgresql-9.5/bin/pg_basebackup
/usr/bin/pg_test_fsync -> ../lib64/postgresql-9.5/bin/pg_test_fsync
/usr/bin/dropuser -> ../lib64/postgresql-9.5/bin/dropuser
/usr/bin/pg_receivexlog -> ../lib64/postgresql-9.5/bin/pg_receivexlog
/usr/bin/initdb -> ../lib64/postgresql-9.5/bin/initdb
/usr/bin/createuser -> ../lib64/postgresql-9.5/bin/createuser
/usr/bin/pg_ctl -> ../lib64/postgresql-9.5/bin/pg_ctl
/usr/bin/psql -> ../lib64/postgresql-9.5/bin/psql
/usr/bin/pg_isready -> ../lib64/postgresql-9.5/bin/pg_isready
/usr/bin/pg_controldata -> ../lib64/postgresql-9.5/bin/pg_controldata
/usr/bin/pg_xlogdump -> ../lib64/postgresql-9.5/bin/pg_xlogdump
/usr/bin/pg_upgrade -> ../lib64/postgresql-9.5/bin/pg_upgrade
/usr/bin/pg_dumpall -> ../lib64/postgresql-9.5/bin/pg_dumpall                                                                             
/usr/bin/oid2name -> ../lib64/postgresql-9.5/bin/oid2name                                                                                 
/usr/bin/pg_rewind -> ../lib64/postgresql-9.5/bin/pg_rewind

The list may be not complete.

Please find a solution so that the upgrade would be smooth.

Thank you.

emerge --info 
Portage 2.3.6 (python 2.7.12-final-0, hardened/linux/amd64, gcc-5.4.0, glibc-2.23-r4, 4.8.17-pentoo-r2 x86_64)
=================================================================
System uname: Linux-4.8.17-pentoo-r2-x86_64-Intel-R-_Core-TM-_i5-3320M_CPU_@_2.60GHz-with-gentoo-2.3
KiB Mem:     7981072 total,   3058600 free
KiB Swap:    4194300 total,   4175600 free
Timestamp of repository gentoo: Sun, 16 Jul 2017 03:30:01 +0000
sh bash 4.3_p48-r1
ld GNU ld (Gentoo 2.28 p1.2) 2.28
app-shells/bash:          4.3_p48-r1::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.24.1-r2::gentoo
dev-lang/python:          2.7.12::gentoo, 3.4.5::gentoo
dev-util/cmake:           3.7.2::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.3::gentoo
sys-apps/openrc:          0.26.3::gentoo
sys-apps/sandbox:         2.10-r3::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.15-r2::gentoo
sys-devel/binutils:       2.28-r2::gentoo
sys-devel/gcc:            5.4.0-r3::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.4::gentoo (virtual/os-headers)
sys-libs/glibc:           2.23-r4::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

local-overlay
    location: /usr/local/portage
    masters: gentoo
    priority: 0

pentoo
    location: /data/pentoo/pentoo
    sync-type: git
    sync-uri: https://github.com/pentoo/pentoo-overlay
    masters: gentoo

steam-overlay
    location: /var/lib/layman/steam-overlay
    masters: gentoo
    priority: 50

ABI="amd64"
ABI_X86="64"
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA OPERA-12 NVIDIA-CUDA PUEL AdobeFlash-11.x Google-TOS dlj-1.1 google-chrome Oracle-BCLA-JavaSE Intel-SDP skype-4.0.0.7-copyright baudline"
ACCEPT_PROPERTIES="*"
ACCEPT_RESTRICT="*"
ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci"
ANDROID_HOME="/opt/android-sdk-update-manager"
ANDROID_SWT="/usr/share/swt-3.7/lib"
ANT_HOME="/usr/share/ant"
APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias"
ARCH="amd64"
AUTOCLEAN="yes"
BOOTSTRAP_USE="cxx unicode internal-glib python_targets_python3_4 python_targets_python2_7 multilib hardened pax_kernel pic xtpax -jit -orc"
CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CFLAGS_amd64="-m64"
CFLAGS_x32="-mx32"
CFLAGS_x86="-m32"
CHOST="x86_64-pc-linux-gnu"
CHOST_amd64="x86_64-pc-linux-gnu"
CHOST_x32="x86_64-pc-linux-gnux32"
CHOST_x86="i686-pc-linux-gnu"
CLEAN_DELAY="5"
COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
COLLISION_IGNORE="/lib/modules/* *.py[co] *$py.class */dropin.cache"
COLORFGBG="15;0"
COLORTERM="truecolor"
CONFIG_PROTECT="/etc /etc/stunnel/stunnel.conf /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"
CXXFLAGS="-march=native -O2 -pipe"
DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-MX0niADHJr,guid=a9f8b078409174a865da237d596c29c4"
DEFAULT_ABI="amd64"
DESKTOP_SESSION="/usr/share/xsessions/plasma"
DISPLAY=":0"
DISTDIR="/usr/portage/distfiles"
EDITOR="/usr/bin/mcedit"
ELIBC="glibc"
EMERGE_DEFAULT_OPTS=" --ask-enter-invalid --keep-going=y --binpkg-respect-use=y --tree --verbose --with-bdeps=y --autounmask=n --buildpkg-exclude "sys-kernel/compat-drivers sys-kernel/ax88179_178a x11-drivers/ati-drivers x11-drivers/nvidia-drivers sys-fs/zfs-kmod sys-kernel/spl                      sys-power/bbswitch pentoo/pentoo-installer x11-drivers/xf86-video-virtualbox app-emulation/virtualbox-guest-additions                     app-emulation/virtualbox-modules app-emulation/vmware-modules app-emulation/open-vm-tools-kmod sys-kernel/genkernel                       sys-kernel/pentoo-sources dev-python/twisted-web net-analyzer/metasploit sci-libs/lapack-reference x11-base/xorg-drivers app-admin/genmenu" --usepkg-exclude "sys-kernel/compat-drivers sys-kernel/ax88179_178a x11-drivers/ati-drivers x11-drivers/nvidia-drivers sys-fs/zfs-kmod sys-kernel/spl                   sys-power/bbswitch pentoo/pentoo-installer x11-drivers/xf86-video-virtualbox app-emulation/virtualbox-guest-additions                     app-emulation/virtualbox-modules app-emulation/vmware-modules app-emulation/open-vm-tools-kmod sys-kernel/genkernel                       sys-kernel/pentoo-sources dev-python/twisted-web net-analyzer/metasploit sci-libs/lapack-reference x11-base/xorg-drivers app-admin/genmenu""
EMERGE_WARNING_DELAY="10"
EPREFIX=""
EROOT="/"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FETCHCOMMAND="wget -t 3 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}""
FETCHCOMMAND_RSYNC="rsync -avP "${URI}" "${DISTDIR}/${FILE}""
FETCHCOMMAND_SFTP="bash -c "x=\${2#sftp://} ; host=\${x%%/*} ; port=\${host##*:} ; host=\${host%:*} ; [[ \${host} = \${port} ]] && port= ; eval \"declare -a ssh_opts=(\${3})\" ; exec sftp \${port:+-P \${port}} \"\${ssh_opts[@]}\" \"\${host}:/\${x#*/}\" \"\$1\"" sftp "${DISTDIR}/${FILE}" "${URI}" "${PORTAGE_SSH_OPTS}""
FETCHCOMMAND_SSH="bash -c "x=\${2#ssh://} ; host=\${x%%/*} ; port=\${host##*:} ; host=\${host%:*} ; [[ \${host} = \${port} ]] && port= ; exec rsync --rsh=\"ssh \${port:+-p\${port}} \${3}\" -avP \"\${host}:/\${x#*/}\" \"\$1\"" rsync "${DISTDIR}/${FILE}" "${URI}" "${PORTAGE_SSH_OPTS}""
FFLAGS="-O2 -pipe"
GCC_SPECS=""
GENTOO_MIRRORS="http://ftp.swin.edu.au/gentoo/"
Comment 1 Anton Bolshakov 2017-07-17 03:36:18 UTC
the workaround is to remove all broken links and run:
```eselect postgresql set 9.6```
Comment 2 Anton Bolshakov 2017-07-17 03:41:12 UTC
Created attachment 485246 [details]
pg_build.log

just an example
Comment 3 Anton Bolshakov 2017-07-17 04:38:51 UTC
(In reply to Anton Bolshakov from comment #1)
> the workaround is to remove all broken links and run:
> ```eselect postgresql set 9.6```

I forgot to say that this command does not work with existing broken links.
It just fails with no reason. It may be easier to fix this script instead.
It's your call.
Comment 4 MT 2017-07-17 08:11:53 UTC
Package dev-lang/php is also affected by broken symlinks left by PostgreSQL 9.5:

checking for PostgreSQL support for PDO... yes
checking for pg_config... not found
configure: error: Cannot find libpq.so. Please specify correct PostgreSQL installation path

!!! Please attach the following file when seeking support:
!!! /var/tmp/portage/dev-lang/php-7.0.21/work/sapis-build/embed/config.log
Comment 5 Aaron W. Swenson gentoo-dev 2017-07-17 11:29:40 UTC
dev-db/postgresql does indeed call `postgresql-config update` (AKA, eselect postgresql) after installation and removal.

The problem lies in the canoncalise() function used by the postgresql.eselect module.

canoncalise() is a wrapper function declared in path-manipulation.bash library around the readlink or realpath functions, but both readlink and realpath expect the link to point to a place that exists. Since the files have been removed, canoncalise either fails silently (readlink -f) or complains on stderr (realpath).

I'll work on a solution and probably get something pushed today.
Comment 6 Aaron W. Swenson gentoo-dev 2017-07-21 19:06:32 UTC
commit c18485e2c4819cdaff3242d3c46e26a77d2be6a8 (HEAD -> master, origin/master, origin/HEAD)
Author: Aaron W. Swenson <titanofold@gentoo.org>
Date:   Fri Jul 21 15:05:51 2017 -0400

    app-eselect/eselect-postgresql: Version Bump

    Add -m option to canonicalise() so that the path gets returned even if
    it doesn’t exist.

    Bug: 625368

    Package-Manager: Portage-2.3.6, Repoman-2.3.1
Comment 7 Aaron W. Swenson gentoo-dev 2017-07-21 19:13:31 UTC
You may be presented with another error or two regarding some link(s) already existing.

Just rm the links manually and then you should be good to go from here on out.
Comment 8 Anton Bolshakov 2017-07-21 22:50:20 UTC
Removing links manually is NOT a solution.
first of all, this is stupid. Second, the list of files is long so it has to be automated and documented somewhere (https://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Post-9.0_Migration?)
Comment 9 Aaron W. Swenson gentoo-dev 2017-07-22 10:36:26 UTC
(In reply to Anton Bolshakov from comment #8)
> Removing links manually is NOT a solution.
> first of all, this is stupid. Second, the list of files is long so it has to
> be automated and documented somewhere
> (https://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Post-9.0_Migration?)

First of all, the cause of the symptoms is fixed. Second, that guide you linked doesn't recommend uninstalling the old slot before you start the migration, which setting the new slot is step 3.

Here's a couple steps -- after you install eselect-postgresql-2.2 -- that will take care of the symptoms either entirely or leave a singular symlink that still needs to be removed manually (deal with it):

# ln -s /usr/share/postgresql-${slot_you_want_to_unset} /usr/share/postgresql
# postgresql-config set ${some_other_slot}

If you had to remove a link manually, you'll need to repeat these steps one more time.

The eselect module examines /usr/share/postgresql to determine which slot is active. Making the link manually will jump start the system.

If the steps work for you, feel free to document it. That's a wiki you linked. It's open to everyone to improve, including you. If you don't know something, ask. Don't just sit there snapping at the hand that's trying to help you.
Comment 10 Anton Bolshakov 2017-07-22 23:41:45 UTC
you mentioned that the package runs "postgresql-config update" at some point so it should run in the proper moment.

I did not uninstall the old slot manually and did mess with it.

The sequence of commands were the standard:
 emerge -DNua world
 emerge --depclean


This bug is about making that standard way smooth so it won't be broken links left and eselect would update links when it is necessary. 

An end user should not do it manually.

I will try to upgrade an anothing system and will re-open this bug if it is not fixed.

Thank you for your quick actions btw
Comment 11 Anton Bolshakov 2017-07-23 05:19:06 UTC
alright, good news. It is fixed, indeed. Thank you again!
Comment 12 Aaron W. Swenson gentoo-dev 2017-07-23 14:37:17 UTC
(In reply to Anton Bolshakov from comment #11)
> alright, good news. It is fixed, indeed. Thank you again!

Excellent! Thank you for detailing, testing, and giving me some feedback. It is always appreciated.
Comment 13 Aaron W. Swenson gentoo-dev 2017-08-07 11:08:58 UTC
*** Bug 627050 has been marked as a duplicate of this bug. ***
Comment 14 Anton Bolshakov 2017-08-07 12:07:22 UTC
Please stabilise app-eselect/eselect-postgresql-2.2 soonest to avoid further duplicates. It affects way too many people.