Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 426374 - app-backup/bacula fails to set database dependency in /etc/init.d/bacula-dir
Summary: app-backup/bacula fails to set database dependency in /etc/init.d/bacula-dir
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Thomas Beierlein
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-12 23:12 UTC by Jeremy Banks
Modified: 2012-08-07 18:09 UTC (History)
1 user (show)

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


Attachments
Patch to give a value to $mydbtype in the ebuild (bacula-5.2.5.ebuild.patch,300 bytes, patch)
2012-07-12 23:26 UTC, Jeremy Banks
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Banks 2012-07-12 23:12:15 UTC
Per the official Bacula documentation, the Bacula Director daemon requires the database to be running in order to work properly. If /etc/conf.d/bacula-dir specifies a local database should be used, the depend() section of /etc/init.d/bacula-dir conditionally specifies the database daemon set in the USE flags. The file bacula-dir.initd contains the placeholder %database% on line 9 in the depend() section, and the ebuild uses a case select statement starting on line 308 to replace this placeholder with the value of $mydbtype so as to set the proper database dependency upon install.

The case select statement starting on line 308 of the ebuild is the very first reference to $mydbtype, causing it to be blank. The case statement beginning on line 308 of the ebuild then copies that blank value in the depend() section of the init.d script. 

Also, in the pkg_postinst() section of the ebuild, the einfo statements starting on line 344 use this variable to notify the user he must run the upstream supplied scripts to initialize the database selected in the USE flags. As $mydbtype is blank, invalid script names are given.

/etc/init.d/bacula-dir can be manually edited to correctly specify a dependency on a database daemon, and a listing of the path supplied for the database setup scripts shows the correct names. However, manual edits of the init.d script are at risk of getting stomped on during a re-install or upgrade, and helpful messages at the end of an ebuild are more helpful if they're accurate.

Reproducible: Always

Steps to Reproduce:
Using postgres as an example:

USE="-sqlite3 postgres" emerge app-backup/bacula

Actual Results:  
/etc/init.d/bacula-dir contains:

depend() {
        need net
        if [ "${LOCAL_DB}" -eq 1 ]; then
                need ""
        fi
        use dns bacula-fd bacula-sd
}

emerge outputs:
 * If this is a new install, you must create the  databases with:
 *   /usr/libexec/bacula/create__database
 *   /usr/libexec/bacula/make__tables
 *   /usr/libexec/bacula/grant__privileges

Expected Results:  
/etc/init.d/bacula-dir should contain:
depend() {
        need net
        if [ "${LOCAL_DB}" -eq 1 ]; then
                need "postgresql"
        fi
        use dns bacula-fd bacula-sd
}

emerge should output:
 * If this is a new install, you must create the  databases with:
 *   /usr/libexec/bacula/create_postgresql_database
 *   /usr/libexec/bacula/make_postgresql_tables
 *   /usr/libexec/bacula/grant_postgresql_privileges

Portage 2.1.10.65 (hardened/linux/amd64, gcc-4.5.3, glibc-2.14.1-r3, 3.2.2-hardened-r1 x86_64)
=================================================================
System uname: Linux-3.2.2-hardened-r1-x86_64-AMD_Opteron-tm-_Processor_254-with-gentoo-2.1
Timestamp of tree: Mon, 09 Jul 2012 19:15:02 +0000
app-shells/bash:          4.2_p20
dev-lang/python:          2.7.3-r2, 3.2.3
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.9.8.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.68
sys-devel/automake:       1.11.1
sys-devel/binutils:       2.21.1-r1
sys-devel/gcc:            4.5.3-r2
sys-devel/gcc-config:     1.6
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 3.4 (virtual/os-headers)
sys-libs/glibc:           2.14.1-r3
Repositories: gentoo
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=opteron -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=opteron -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs candy config-protect-if-modified distlocks ebuild-locks fakeroot fixlafiles news parallel-fetch parse-eapi-ebuild-head protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://gentoo.osuosl.org/ http://mirrors.rit.edu/gentoo/ http://gentoo.mirrors.tds.net/gentoo http://gentoo.mirrors.pair.com/ http://gentoo.cites.uiuc.edu/pub/gentoo/"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
USE="acl amd64 berkdb bzip2 cli cracklib crypt cxx gdbm gpm hardened justify lzma modules mudflap multilib ncurses nptl nptlonly openmp pam pax_kernel pcre readline session ssl sysfs tcpd threads unicode urandom xml zlib" CURL_SSL="openssl" ELIBC="glibc" KERNEL="linux" USERLAND="GNU"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 Jeremy Banks 2012-07-12 23:26:27 UTC
Created attachment 318038 [details, diff]
Patch to give a value to $mydbtype in the ebuild

I added some if statements to the ebuild and reinstalled. The ebuild now behaves as I expected.
Comment 2 Thomas Beierlein gentoo-dev 2012-08-06 08:43:53 UTC
Which version of bacula are you talking about?
Comment 3 Jeremy Banks 2012-08-07 16:12:41 UTC
This would be 5.2.5. However, given the diff between bacula-5.2.5.ebuild and bacula-5.2.6.ebuild (or bacula-5.2.9.ebuild) files is just the changes on line 3 and 21 for the # $Header and KEYWORDS sections, this behavior should appear in 5.2.6 and 5.2.9 as well. 

I checked the diff between bacula-5.2.5.ebuild and bacula 5.0.3-r3.ebuild, and there's code to set $mydbtype in the 5.0.3-r3 ebuild.
Comment 4 Thomas Beierlein gentoo-dev 2012-08-07 16:38:10 UTC
(In reply to comment #3)
> This would be 5.2.5. However, given the diff between bacula-5.2.5.ebuild and
> bacula-5.2.6.ebuild (or bacula-5.2.9.ebuild) files is just the changes on
> line 3 and 21 for the # $Header and KEYWORDS sections, this behavior should
> appear in 5.2.6 and 5.2.9 as well. 
> 
> I checked the diff between bacula-5.2.5.ebuild and bacula 5.0.3-r3.ebuild,
> and there's code to set $mydbtype in the 5.0.3-r3 ebuild.

Right. I am just working on the problem and found the same versions affected.
The problem comes from the new handling of the case of multiple database USE flags by REQUIRED_USE.

Thanks for pointing it out - will be fixed in next hour.
Comment 5 Thomas Beierlein gentoo-dev 2012-08-07 18:09:33 UTC
Fixed.

+  07 Aug 2012; Thomas Beierlein <tomjbe@gentoo.org> bacula-5.2.5.ebuild,
+  -bacula-5.2.6.ebuild, bacula-5.2.9.ebuild:
+  Fix generation of init script (Bug 426374). Thanks Koreth. Drop old
+