Bug 13217 - fix koha-upgrade-schema to work with git/dev installs
Summary: fix koha-upgrade-schema to work with git/dev installs
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Mason James
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-07 00:53 UTC by Mason James
Modified: 2016-06-20 11:41 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mason James 2014-11-07 00:53:58 UTC
koha-upgrade-schema seems to currently not work with git/dev koha-gitify installs

this patch attempts to fix this issue
Comment 1 Mason James 2014-11-07 00:55:34 UTC
here's an example of a failed attempt...

# koha-create --create-db master
# koha-gitify master /path/to/my/koha
# apachectl restart
# koha-upgrade-schema -v master
Upgrading database schema for -v
unable to locate Koha configuration file koha-conf.xml at /usr/share/koha/lib/C4/Context.pm line 373.
unable to locate Koha configuration file koha-conf.xml at /usr/share/koha/lib/C4/Context.pm line 373.
unable to locate Koha configuration file koha-conf.xml at /usr/share/koha/lib/C4/Context.pm line 373.
Can't call method "config" on unblessed reference at /usr/share/koha/lib/C4/Context.pm line 796.
Comment 2 Mason James 2014-11-07 01:06:59 UTC
> # koha-upgrade-schema -v master
> Upgrading database schema for -v

oops, typo ^

root@xen1:~# sh -x  /usr/sbin/koha-upgrade-schema master
+ set -e
+ update=/usr/share/koha/intranet/cgi-bin/installer/data/mysql/updatedatabase.pl
+ echo Upgrading database schema for master
Upgrading database schema for master
+ KOHA_CONF=/etc/koha/sites/master/koha-conf.xml PERL5LIB=/usr/share/koha/lib /usr/share/koha/intranet/cgi-bin/installer/data/mysql/updatedatabase.pl


this is a similar issue to 13216, where PERL5LIB is assumed be '/usr/share/koha'
Comment 3 Tomás Cohen Arazi 2015-10-22 03:14:36 UTC
I'd like to say that gitified instance issues should be handled outside Koha... With that in mind, I'd say the best approach to this is to make the scripts (all of them?)
- Test for PERL5LIB be defined (so we can make koha-gitify wrap things or... we'll solve it)
- Otherwise fallback to the system-wide one that is set in /etc/default/koha-common

So maintenance scripts should do something like this:

# include helper functions
if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then
    . "/usr/share/koha/bin/koha-functions.sh"
else
    echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2
    exit 1
fi

Ok, most of them do it already. And then add to koha-functions.sh the check+read:

if [ ! -z $PERL5LIB ]; then
    CLI_PERL5LIB=$PERL5LIB
fi

if [ -r /etc/default/$NAME ]; then
    # Debian / Ubuntu
    . /etc/default/$NAME
elif [ -r /etc/sysconfig/$NAME ]; then
    # RedHat / SuSE
    . /etc/sysconfig/$NAME
fi

if [ ! -z $CLI_PERL5LIB ]; then
    PERL5LIB=$CLI_PERL5LIB
fi
Comment 4 Marcel de Rooy 2016-06-20 11:41:12 UTC
(In reply to Tomás Cohen Arazi from comment #3)
> I'd like to say that gitified instance issues should be handled outside
> Koha... With that in mind, I'd say the best approach to this is to make the
> scripts (all of them?)
> - Test for PERL5LIB be defined (so we can make koha-gitify wrap things or...
> we'll solve it)
> - Otherwise fallback to the system-wide one that is set in
> /etc/default/koha-common

I submitted some patches on bug 16733 to adjust all debian scripts that use PERL5LIB (including this one).
With some minimal changes and less hardcoded paths, we can make life easier for those of us willing to use debian scripts and having a dev install.
My approach seems to be what Tomas suggested: read the defaults, add one line to koha-conf for dev installs, and adjust PERL5LIB if needed.