Bug 28519: Put CGI::Session::Serialize::yamlxs in lib directory
This patch adds a "lib" directory to the source tree which gets mapped to the same directory as "C4" and "Koha" for single and standard installations. CGI::Session::Serialize::yamlxs is put into this "lib" directory. This patch also includes some changes so that dev/git installations work as well. Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
323acde991
commit
40089a0a53
9 changed files with 74 additions and 37 deletions
34
C4/Auth.pm
34
C4/Auth.pm
|
@ -1,31 +1,3 @@
|
|||
package CGI::Session::Serialize::yamlxs;
|
||||
# Proof of concept: CGI::Session::Serialize::yamlxs for CGI::Session:
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# hacky hack to trick CGI::Session loader for serializers not to die in its "require":
|
||||
$INC{'CGI/Session/Serialize/yamlxs.pm'} = '1';
|
||||
|
||||
use CGI::Session::ErrorHandler;
|
||||
use YAML::XS ();
|
||||
|
||||
$CGI::Session::Serialize::yamlxs::VERSION = '0.1';
|
||||
@CGI::Session::Serialize::yamlxs::ISA = ( "CGI::Session::ErrorHandler" );
|
||||
|
||||
sub freeze {
|
||||
my ($self, $data) = @_;
|
||||
return YAML::XS::Dump($data);
|
||||
}
|
||||
|
||||
sub thaw {
|
||||
my ($self, $string) = @_;
|
||||
return (YAML::XS::Load($string))[0];
|
||||
}
|
||||
# ********************************************************************
|
||||
|
||||
|
||||
|
||||
package C4::Auth;
|
||||
|
||||
# Copyright 2000-2002 Katipo Communications
|
||||
|
@ -1899,7 +1871,11 @@ sub _get_session_params {
|
|||
sub get_session {
|
||||
my $sessionID = shift;
|
||||
my $params = _get_session_params();
|
||||
return CGI::Session->new( $params->{dsn}, $sessionID, $params->{dsn_args} );
|
||||
my $session = CGI::Session->new( $params->{dsn}, $sessionID, $params->{dsn_args} );
|
||||
if ( ! $session ){
|
||||
die CGI::Session->errstr();
|
||||
}
|
||||
return $session;
|
||||
}
|
||||
|
||||
|
||||
|
|
39
Makefile.PL
39
Makefile.PL
|
@ -334,6 +334,7 @@ my $target_map = {
|
|||
'./koha-tmpl/opac-tmpl' => {target => 'OPAC_TMPL_DIR', trimdir => -1},
|
||||
'./kohaversion.pl' => 'INTRANET_CGI_DIR',
|
||||
'./labels' => 'INTRANET_CGI_DIR',
|
||||
'./lib' => {target => 'PERL_MODULE_LIB_DIR', trimdir => -1},
|
||||
'./mainpage.pl' => 'INTRANET_CGI_DIR',
|
||||
'./Makefile.PL' => 'NONE',
|
||||
'./MANIFEST.SKIP' => 'NONE',
|
||||
|
@ -1433,6 +1434,7 @@ sub get_target_directories {
|
|||
$dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs', 'opac-tmpl');
|
||||
$dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs');
|
||||
$dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir(@basedir, $package, 'lib');
|
||||
$dirmap{'PERL_MODULE_LIB_DIR'} = File::Spec->catdir(@basedir, $package, 'lib');
|
||||
$dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc');
|
||||
$dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'zebradb');
|
||||
$dirmap{'Z3950_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'z3950');
|
||||
|
@ -1464,8 +1466,11 @@ sub get_target_directories {
|
|||
$skipdirs{'OPAC_TMPL_DIR'} = 1;
|
||||
$dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir($curdir, 'koha-tmpl');
|
||||
$skipdirs{'OPAC_WWW_DIR'} = 1;
|
||||
#NOTE: We're hacking the dirmap here, so that PERL_MODULE_DIR tokens get rewritten correctly for git installs
|
||||
$dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir($curdir);
|
||||
$skipdirs{'PERL_MODULE_DIR'} = 1;
|
||||
$dirmap{'PERL_MODULE_LIB_DIR'} = File::Spec->catdir($curdir,'lib');
|
||||
$skipdirs{'PERL_MODULE_LIB_DIR'} = 1;
|
||||
$dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc');
|
||||
$dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'zebradb');
|
||||
$dirmap{'Z3950_CONF_DIR'} = File::Spec->catdir(@basedir, $package, 'etc', 'z3950');
|
||||
|
@ -1494,6 +1499,7 @@ sub get_target_directories {
|
|||
$dirmap{'OPAC_TMPL_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs', 'opac-tmpl');
|
||||
$dirmap{'OPAC_WWW_DIR'} = File::Spec->catdir(@basedir, $package, 'opac', 'htdocs');
|
||||
$dirmap{'PERL_MODULE_DIR'} = File::Spec->catdir(@basedir, $package, 'lib');
|
||||
$dirmap{'PERL_MODULE_LIB_DIR'} = File::Spec->catdir(@basedir, $package, 'lib');
|
||||
$dirmap{'KOHA_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package);
|
||||
$dirmap{'ZEBRA_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package, 'zebradb');
|
||||
$dirmap{'Z3950_CONF_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'etc', $package, 'z3950');
|
||||
|
@ -1646,6 +1652,8 @@ sub install {
|
|||
# This means that we're completely overriding EU::MM's default
|
||||
# installation and uninstallation targets.
|
||||
|
||||
my $perl5lib_dirs = _build_perl5lib_string({ target_dirs => $target_directories });
|
||||
|
||||
# If installation is on Win32, we need to do permissions different from *nix
|
||||
if ( $^O =~ /darwin|linux|cygwin|freebsd|solaris/ ) { # this value needs to be verified for each platform and modified accordingly
|
||||
foreach my $key (sort keys %$target_directories) {
|
||||
|
@ -1700,7 +1708,7 @@ install :: all install_koha set_koha_ownership set_koha_permissions warn_koha_en
|
|||
$install .= "\t\$(NOECHO) \$(ECHO) you should set the following environment variables:\n";
|
||||
$install .= "\t\$(NOECHO) \$(ECHO)\n";
|
||||
$install .= "\t\$(NOECHO) \$(ECHO) export KOHA_CONF=\$(KOHA_DEST_KOHA_CONF_DIR)/koha-conf.xml\n";
|
||||
$install .= "\t\$(NOECHO) \$(ECHO) export PERL5LIB=$target_directories->{'PERL_MODULE_DIR'}\n";
|
||||
$install .= "\t\$(NOECHO) \$(ECHO) export PERL5LIB=$perl5lib_dirs\n";
|
||||
$install .= "\t\$(NOECHO) \$(ECHO)\n";
|
||||
$install .= "\t\$(NOECHO) \$(ECHO) For other post-installation tasks, please consult the README.\n";
|
||||
$install .= "\t\$(NOECHO) \$(ECHO)\n";
|
||||
|
@ -1767,9 +1775,16 @@ sub postamble {
|
|||
# rewrite-confg.PL
|
||||
|
||||
my $env;
|
||||
|
||||
#NOTE: Build __PERL5LIB_DIRS__ for rewrite-config.PL
|
||||
my $perl5lib_dirs = _build_perl5lib_string({ target_dirs => $target_directories });
|
||||
if ($perl5lib_dirs){
|
||||
$env .= "export __PERL5LIB_DIRS__ := $perl5lib_dirs\n"
|
||||
}
|
||||
|
||||
# Hereagain, we must alter syntax per platform...
|
||||
{
|
||||
$env = join("\n", map { "export __${_}__ := $target_directories->{$_}" } keys %$target_directories);
|
||||
$env .= join("\n", map { "export __${_}__ := $target_directories->{$_}" } keys %$target_directories);
|
||||
$env .= "\n\n";
|
||||
$env .= join("\n", map { "export __${_}__ := $config{$_}" } keys %config);
|
||||
}
|
||||
|
@ -1777,6 +1792,26 @@ sub postamble {
|
|||
return "$env\n";
|
||||
}
|
||||
|
||||
sub _build_perl5lib_string {
|
||||
my ($args) = @_;
|
||||
my %unique_map = ();
|
||||
my $perl5lib_str;
|
||||
my $target_dirs = $args->{target_dirs};
|
||||
my @dir_codes = ("PERL_MODULE_DIR","PERL_MODULE_LIB_DIR");
|
||||
if ($target_dirs){
|
||||
foreach my $code (@dir_codes){
|
||||
my $path = $target_dirs->{ $code };
|
||||
if ($path){
|
||||
$unique_map{$path} = 1 unless $unique_map{$path};
|
||||
}
|
||||
}
|
||||
my @paths = sort keys %unique_map;
|
||||
if (@paths){
|
||||
$perl5lib_str = join(':',@paths);
|
||||
}
|
||||
}
|
||||
return $perl5lib_str;
|
||||
}
|
||||
|
||||
__END__
|
||||
|
||||
|
|
2
debian/scripts/koha-functions.sh
vendored
2
debian/scripts/koha-functions.sh
vendored
|
@ -330,7 +330,7 @@ adjust_paths_dev_install()
|
|||
if [ "$dev_install" != "" ] && [ "$dev_install" != "0" ]; then
|
||||
DEV_INSTALL=1
|
||||
KOHA_HOME=$(run_safe_xmlstarlet $instancename intranetdir)
|
||||
PERL5LIB=$KOHA_HOME
|
||||
PERL5LIB="$KOHA_HOME:$KOHA_HOME/lib"
|
||||
else
|
||||
DEV_INSTALL=""
|
||||
fi
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
# CustomLog __LOG_DIR__/koha-opac-access.log combined
|
||||
# TransferLog __LOG_DIR__/koha-opac-access.log
|
||||
SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
|
||||
SetEnv PERL5LIB "__PERL_MODULE_DIR__"
|
||||
SetEnv PERL5LIB "__PERL5LIB_DIRS__"
|
||||
|
||||
# This syntax allows you to override a system preference
|
||||
# for a given virtual host. Use with caution!
|
||||
|
@ -143,7 +143,7 @@
|
|||
ErrorLog __LOG_DIR__/koha-error_log
|
||||
# TransferLog __LOG_DIR__/koha-access.log
|
||||
SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
|
||||
SetEnv PERL5LIB "__PERL_MODULE_DIR__"
|
||||
SetEnv PERL5LIB "__PERL5LIB_DIRS__"
|
||||
Options +FollowSymLinks
|
||||
|
||||
# If you are overriding any system preferences,
|
||||
|
@ -254,7 +254,7 @@
|
|||
# DocumentRoot __INTRANET_CGI_DIR__/api
|
||||
# ServerName api.__WEBSERVER_HOST__:__WEBSERVER_PORT__
|
||||
# SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
|
||||
# SetEnv PERL5LIB "__PERL_MODULE_DIR__"
|
||||
# SetEnv PERL5LIB "__PERL5LIB_DIRS__"
|
||||
# ErrorLog __LOG_DIR__/koha-api-error_log
|
||||
#
|
||||
# <IfModule mod_rewrite.c>
|
||||
|
|
|
@ -4,7 +4,7 @@ Description=Koha Task Queue Worker
|
|||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
Environment=PERL5LIB=__PERL_MODULE_DIR__
|
||||
Environment=PERL5LIB=__PERL5LIB_DIRS__
|
||||
Environment=KOHA_CONF=__KOHA_CONF_DIR__/koha-conf.xml
|
||||
ExecStart=__SCRIPT_DIR__/background_jobs_worker.pl
|
||||
Restart=on-failure
|
||||
|
|
22
lib/CGI/Session/Serialize/yamlxs.pm
Normal file
22
lib/CGI/Session/Serialize/yamlxs.pm
Normal file
|
@ -0,0 +1,22 @@
|
|||
package CGI::Session::Serialize::yamlxs;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use CGI::Session::ErrorHandler;
|
||||
use YAML::XS ();
|
||||
|
||||
$CGI::Session::Serialize::yamlxs::VERSION = '0.1';
|
||||
@CGI::Session::Serialize::yamlxs::ISA = ( "CGI::Session::ErrorHandler" );
|
||||
|
||||
sub freeze {
|
||||
my ($self, $data) = @_;
|
||||
return YAML::XS::Dump($data);
|
||||
}
|
||||
|
||||
sub thaw {
|
||||
my ($self, $string) = @_;
|
||||
return (YAML::XS::Load($string))[0];
|
||||
}
|
||||
|
||||
1;
|
|
@ -32,7 +32,7 @@ GROUP=__KOHA_GROUP__
|
|||
DBNAME=__DB_NAME__
|
||||
NAME=koha-index-daemon-$DBNAME
|
||||
LOGDIR=__LOG_DIR__
|
||||
PERL5LIB=__PERL_MODULE_DIR__
|
||||
PERL5LIB="__PERL5LIB_DIRS__"
|
||||
KOHA_CONF=__KOHA_CONF_DIR__/koha-conf.xml
|
||||
ERRLOG=$LOGDIR/koha-index-daemon.err
|
||||
STDOUT=$LOGDIR/koha-index-daemon.log
|
||||
|
|
|
@ -64,3 +64,5 @@ FONT_DIR=__FONT_DIR__
|
|||
USE_ELASTICSEARCH=__USE_ELASTICSEARCH__
|
||||
ELASTICSEARCH_SERVERS=__ELASTICSEARCH_SERVERS__
|
||||
ELASTICSEARCH_INDEX=__ELASTICSEARCH_INDEX__
|
||||
PERL_MODULE_LIB_DIR=__PERL_MODULE_LIB_DIR__
|
||||
PERL5LIB_DIRS=__PERL5LIB_DIRS__
|
||||
|
|
|
@ -159,6 +159,8 @@ my %configuration = (
|
|||
'__SMTP_USER_NAME__' => '',
|
||||
'__SMTP_PASSWORD__' => '',
|
||||
'__SMTP_DEBUG__' => '0',
|
||||
'__PERL_MODULE_LIB_DIR__' => "$prefix/lib",
|
||||
'__PERL5LIB_DIRS__' => "$prefix/lib",
|
||||
);
|
||||
|
||||
# Override configuration from the environment
|
||||
|
|
Loading…
Reference in a new issue