source: main/trunk/package-kits/linux/perllib/Greenstone/Package/_apt.pm@ 29598

Last change on this file since 29598 was 29598, checked in by Jeremy Symon, 9 years ago

Changed package generators to not use the tmp directory needlessly, and fixed some problems with the debian generator. Still need to test on systems with rpm/apt and fix all the problems.

File size: 2.3 KB
RevLine 
[29539]1package Greenstone::Package::_apt;
2
3use strict;
4use warnings;
5use utf8;
6use parent 'Greenstone::Package';
7
8sub replacement_array {
9 my $self = shift;
10 my $array = shift;
11 return join ", ", @{$array};
12}
13
[29546]14sub write_function {
15 my ($self, $name, @lines) = @_;
[29598]16 my $file = "$self->{output}/debian/$name";
17 print " - $file\n";
18 open my $OUT, '>', $file;
[29546]19 for my $line (@lines) {
[29598]20 print $OUT $line, "\n";
[29546]21 }
[29598]22 close $OUT;
23 chmod 0755, $file;
[29546]24}
25
26sub add_install {
27 my $self = shift;
28 exists $self->{config}->{PRE_INSTALL} and
29 $self->write_function ("preinst", @{$self->{config}->{PRE_INSTALL}});
30 exists $self->{config}->{POST_INSTALL} and
31 $self->write_function ("postinst", @{$self->{config}->{POST_INSTALL}});
32 exists $self->{config}->{PRE_REMOVE} and
33 $self->write_function ("prerm", @{$self->{config}->{PRE_REMOVE}});
34 exists $self->{config}->{POST_REMOVE} and
35 $self->write_function ("postrm", @{$self->{config}->{POST_REMOVE}});
36}
37
[29595]38sub add_package_section {
39 my ($self, $out) = @_;
40 for my $line (
41 'Package: %NAME%',
42 'Architecture: %ARCHITECTURE%',
43 'Homepage: %HOMEPAGE%',
44 'Depends:',
[29598]45 ' %DEPENDS%',
[29595]46 'Description: %DESCRIPTION_SHORT',
47 ' %DESCRIPTION'
48 ) {
49 my $copy = $line;
50 $self->subst ($copy);
51 print $out $copy, "\n";
52 }
53}
54
55sub add_package_impl {
56 my ($self, $packages) = @_;
57 $self->add_install;
[29598]58 my $file = "$self->{output}/debian/control";
59 print " - $file\n";
60 open my $CONTROL, '>', $file;
[29595]61 for my $line (
62 'Source: %NAME%',
63 'Section: java',
64 'Priority: optional',
65 'Maintainer: %MAINTAINER_NAME% <%MAINTAINER_EMAIL%>',
[29598]66 'Build-Depends:',
67 ' %MAKEDEPENDS%',
[29595]68 ) {
69 my $copy = $line;
70 $self->subst ($copy);
71 print $CONTROL $copy, "\n";
72 }
73 if (defined $packages) {
74 my $config = $self->{config};
75 for my $package (@{$packages}) {
76 $package->{HOMEPAGE} = $config->{HOMEPAGE};
77 $self->{config} = $package;
78 $self->add_package_section ($CONTROL);
79 }
80 $self->{config} = $config;
81 } else {
82 $self->add_package_section ($CONTROL);
83 }
84 close $CONTROL;
85}
86
[29539]871;
Note: See TracBrowser for help on using the repository browser.