Changeset 29546 for main/trunk/package-kits/linux/perllib
- Timestamp:
- 2014-12-08T12:19:58+13:00 (9 years ago)
- Location:
- main/trunk/package-kits/linux/perllib/Greenstone
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/package-kits/linux/perllib/Greenstone/Config.pm
r29536 r29546 4 4 use warnings; 5 5 use utf8; 6 use Greenstone::Helpers; 6 7 7 8 # Formats an array … … 31 32 } 32 33 34 # Reads a config file into the config hashmap 35 sub readconf { 36 my ($self, $conf) = @_; 37 $self->{config} = {} unless exists $self->{config}; 38 open CONF, '<', $conf 39 or die "Failed to open '$conf' for reading: $!"; 40 my $var; 41 while (my $line = <CONF>) { 42 if (empty $line or comment $line) { 43 $var = undef; 44 } elsif (defined $var and $line =~ /^\s/) { 45 trim $line; 46 $self->subst ($line); 47 escape $line; 48 push @{$self->{config}->{$var}}, $line; 49 } else { 50 ($var, my $val) = trim (split ":", $line, 2); 51 defined $var and defined $val or die "Invalid variable assignment: '$line'"; 52 if (empty $val) { 53 $self->{config}->{$var} = []; 54 } else { 55 $self->subst ($val); 56 escape $val; 57 $self->{config}->{$var} = $val; 58 } 59 } 60 } 61 close CONF; 62 } 63 33 64 1; -
main/trunk/package-kits/linux/perllib/Greenstone/Package.pm
r29536 r29546 8 8 use Greenstone::Helpers; 9 9 use base 'Exporter'; 10 require Greenstone::Config::Loader;11 10 12 11 use parent 'Greenstone::Config'; … … 53 52 54 53 # Classify ourselves as config and load the config 55 my $self = bless({}, 'Greenstone::Config ::Loader');54 my $self = bless({}, 'Greenstone::Config'); 56 55 57 56 $self->readconf ("global.conf"); 58 57 $self->readconf ($distro_conf); 59 $self->readconf ($package_conf); 60 58 61 59 die "Distro '$args{distro}' is invalid (does not specify a manager)" 62 60 unless (exists $self->{config}->{MANAGER}); 63 61 64 62 my $class = __PACKAGE__ . '::_' . lc $self->{config}->{MANAGER}; 65 eval "require $class; 1" or die "Package manager '$self->{config}->{MANAGER}' does not exist ";63 eval "require $class; 1" or die "Package manager '$self->{config}->{MANAGER}' does not exist or did not compile"; 66 64 67 65 # Reclassify as our implementation 68 66 bless $self, $class; 67 68 $self->readconf ($package_conf); 69 69 70 70 $self->{package} = $args{package}; … … 75 75 $self->add_sources; 76 76 $self->add_makefile; 77 $self->add_install; 77 78 $self->add_package; 78 79 } -
main/trunk/package-kits/linux/perllib/Greenstone/Package/_apt.pm
r29539 r29546 12 12 } 13 13 14 sub write_function { 15 my ($self, $name, @lines) = @_; 16 open OUT, '>', "/tmp/$name"; 17 for my $line (@lines) { 18 print OUT $line, "\n"; 19 } 20 close OUT; 21 $self->add ("/tmp/$name", "$self->{output}/$name"); 22 } 23 24 sub add_install { 25 my $self = shift; 26 exists $self->{config}->{PRE_INSTALL} and 27 $self->write_function ("preinst", @{$self->{config}->{PRE_INSTALL}}); 28 exists $self->{config}->{POST_INSTALL} and 29 $self->write_function ("postinst", @{$self->{config}->{POST_INSTALL}}); 30 exists $self->{config}->{PRE_REMOVE} and 31 $self->write_function ("prerm", @{$self->{config}->{PRE_REMOVE}}); 32 exists $self->{config}->{POST_REMOVE} and 33 $self->write_function ("postrm", @{$self->{config}->{POST_REMOVE}}); 34 } 35 14 36 1; -
main/trunk/package-kits/linux/perllib/Greenstone/Package/_pacman.pm
r29536 r29546 38 38 } 39 39 40 sub write_function { 41 my ($name, $out, @lines) = @_; 42 print $out $name, "() {\n"; 43 for my $line (@lines) { 44 print $out "\t", $line, "\n"; 45 } 46 print $out "}\n\n"; 47 } 48 49 sub add_install { 50 my $self = shift; 51 if (exists $self->{config}->{PRE_INSTALL} or 52 exists $self->{config}->{POST_INSTALL} or 53 exists $self->{config}->{PRE_REMOVE} or 54 exists $self->{config}->{POST_REMOVE}) { 55 my $name = "$self->{config}->{NAME}.install"; 56 open my $INSTALL, '>', "/tmp/$name"; 57 exists $self->{config}->{PRE_INSTALL} and do { 58 write_function "pre_install", $INSTALL, @{$self->{config}->{PRE_INSTALL}}; 59 write_function "pre_upgrade", $INSTALL, @{$self->{config}->{PRE_INSTALL}}; 60 }; 61 exists $self->{config}->{POST_INSTALL} and do { 62 write_function "post_install", $INSTALL, @{$self->{config}->{POST_INSTALL}}; 63 write_function "post_upgrade", $INSTALL, @{$self->{config}->{POST_INSTALL}}; 64 }; 65 exists $self->{config}->{PRE_REMOVE} and 66 write_function "pre_remove", $INSTALL, @{$self->{config}->{PRE_REMOVE}}; 67 exists $self->{config}->{POST_REMOVE} and 68 write_function "post_remove", $INSTALL, @{$self->{config}->{POST_REMOVE}}; 69 close $INSTALL; 70 $self->add ("/tmp/$name", "$self->{output}/$name"); 71 $self->{config}->{INSTALL} = "install=$name"; 72 } else { 73 $self->{config}->{INSTALL} = ""; 74 } 75 } 76 40 77 1; -
main/trunk/package-kits/linux/perllib/Greenstone/Package/_rpm.pm
r29539 r29546 12 12 } 13 13 14 sub write_function { 15 my ($name, @lines) = @_; 16 my $ret = ""; 17 $ret .= "%" . $name . "\n"; 18 for my $line (@lines) { 19 $ret .= $line . "\n"; 20 } 21 $ret .= "\n"; 22 return $ret; 23 } 24 25 sub add_install { 26 my $self = shift; 27 $self->{config}->{INSTALL} = ""; 28 exists $self->{config}->{PRE_INSTALL} and 29 $self->{config}->{INSTALL} .= write_function "pre", @{$self->{config}->{PRE_INSTALL}}; 30 exists $self->{config}->{POST_INSTALL} and 31 $self->{config}->{INSTALL} .= write_function "post", @{$self->{config}->{POST_INSTALL}}; 32 exists $self->{config}->{PRE_REMOVE} and 33 $self->{config}->{INSTALL} .= write_function "preun", @{$self->{config}->{PRE_INSTALL}}; 34 exists $self->{config}->{POST_REMOVE} and 35 $self->{config}->{INSTALL} .= write_function "postun", @{$self->{config}->{POST_INSTALL}}; 36 } 37 14 38 1;
Note:
See TracChangeset
for help on using the changeset viewer.