In postgresql-7.2.1-r1 (yes, I unmasked this), pkg_preinst() adds the postgres user with a /bin/true shell. Later on, pkg_config() uses su - postgres -c ... to configure the package. Since the shell is /bin/true, nothing (useful) happens. Similar comments apply to the startup script, /etc/init.d/postgresql. Short-Term Workaround: Give postgres user a real shell (/bin/sh). Long-Term Solution: Use setuidguid from daemontools instead of su, i.e. in pkg_config(): setuidgid postgres /usr/bin/initdb --pgdata /var/lib/postgresql/data # /space/gentoo/cvsroot/gentoo-x86/dev-db/postgresql/postgresql-7.2.1.ebuild,v 1.2 2002/06/17 04:05:39 rphillips Exp
The init script is probably ok, I think I had a old init script from an older version of postgresql. I am testing now. Also... pkg_preinst() tests for the non-existence of the user and group postgresql, and then tries to add the user and group postgres. This causes it to fail if the postgres user already exists.
OK, the init script problem is due to files/7.2.1/postgresql not existing. I copied files/7.2/postgresql to files/7.2.1/postgresql and the init script works fine. It uses start-stop-daemon. There is still the issue of setting up the initial database in pkg_config(): I have verified that daemontools setuidgid works fine for this. You do not need to run daemontools' svscan for this to work. Also, changing the test in pkg_preinst() to look for the postgres user/group instead of postgresql fixes that problem. If you want, I'll churn out a patch.
andy: does the new postgres ebuild fix this problem?
I don't see how. It still uses /bin/true for the shell for the postgres user and then uses su - postgres -c "/usr/bin/initdb --pgdata /var/lib/postgresql/data" in pkg_config(), so all that will do is run /bin/true as postgres. It is also (in revision 1.5) still doing this: pkg_preinst() { if ! groupmod postgresql ; then groupadd -g 70 postgres || die "problem adding group postgres" fi if ! id postgresql; then useradd -g postgres -s /dev/null -d /var/lib/postgresql -c "postgres" postgres assert "problem adding user postgres" fi } Note that it is testing the wrong user/group. Also pkg_install() does this: exeinto /etc/init.d/ doexe ${FILESDIR}/${PV}/${PN} However, files/7.2.1/postgresql doesn't exist. Finally there a bogus RCS (non-)tag in the ebuild: # /space/gentoo/cvsroot/gentoo-x86/dev-db/postgresql/postgresql-7.2.1.ebuild,v 1.2 2002/06/17 04:05:39 rphillips Exp Probably should be replaced with: # $Header$
Created attachment 2129 [details, diff] User and initial database creation This fixes the user/group creation problem and initial database creation (adds RDEPENDS on daemontools). There are still some missing files, particularly the init script, and some ${P}-build.xml file.
I'm not sure if this is related, but my last postgres install didn't create an initscript in /etc/init.d. Maybe this should be a separate issue.
this should be fixed now... waiting confirmation.
Yeah, looks good.