File: conf_install.PLS

package info (click to toggle)
libchado-perl 1.23-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,976 kB
  • ctags: 10,378
  • sloc: xml: 192,540; sql: 165,945; perl: 28,339; sh: 101; python: 73; makefile: 46
file content (92 lines) | stat: -rw-r--r-- 2,801 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!perl
use Config;
use File::Basename qw(&basename &dirname);
use Cwd;
                                                                                
$origdir = cwd;
chdir dirname($0);
$file = basename($0, '.PL','.PLS');
$file .= $^O eq 'VMS' ? '.com' : '.pl';
                                                                                
open OUT,">$file" or die "Can't create $file: $!";
                                                                                
print "Extracting $file (with variable substitutions)\n";
                                                                                
print OUT "$Config{startperl}\n";

print OUT <<'!NO!SUBS!';
use strict;
use Cwd;
use FindBin '$Bin';

foreach (@ARGV) {
  $_ =~ s/^\'(.*)\'$/$1/;
}

my %options = map {split /=/} @ARGV;
my $gmod_root = $options{GMOD_ROOT};
my $version   = $options{VERSION};
my $confdir   = "$gmod_root/conf";
my $tmpdir    = "$gmod_root/tmp";

my $origdir = cwd;
my $homedir = "$Bin/..";
                                                                                
chdir $homedir or die "couldn't cd to $homedir: $!\n";

# create GMOD_ROOT and conf dir if they dont already exist
if (! (-e $gmod_root)) {
    mkdir($gmod_root, 0777) or die "unable to make $gmod_root directory";
}

if (! (-e $confdir)) {
    mkdir($confdir, 0777) or die "unable to make $confdir directory";
}

if (! (-e $tmpdir)) {
    mkdir($tmpdir, 0777) or die "unable to make $tmpdir directory";
    chmod 0777, $tmpdir;
}

my $localconf = 'build.conf';
my %confitems;
open LOCALCONF, $localconf or die "unable to open $localconf: $!";
while (<LOCALCONF>) {
    chomp;
    my ($key, $value) = split /=/;
    if ($key =~ /^DB/ or $key eq 'DEFAULT' or $key eq 'SCHEMA') {
        $confitems{$key} = $value;
    }
}
close LOCALCONF;              

my $gmodconf    = "$confdir/gmod.conf";
my $defaultconf = "$confdir/default.conf";
my $dbconf      = "$confdir/$confitems{DBNAME}.conf";

open GMODCONF, ">$gmodconf" or die "unable to open $gmodconf: $!";
print GMODCONF "CONF=$gmod_root/conf\n";
print GMODCONF "TMP=$gmod_root/tmp\n";
print GMODCONF "VERSION=$version\n";
close GMODCONF;

open DBCONF,  ">$dbconf" or die "unable to open $dbconf: $!";
foreach my $key (keys %confitems) {
    print DBCONF  "$key=$confitems{$key}\n";
}
print DBCONF  "SQLFILE=$gmod_root/src/chado/modules/complete.sql\n";
close DBCONF;

if (lc($confitems{'DEFAULT'}) =~ /^y/) {
  unlink $defaultconf;
  symlink($dbconf,$defaultconf);
}

chdir $origdir;

!NO!SUBS!
close OUT or die "Can't close $file: $!";
chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
chdir $origdir;