1 | package Greenstone::Package::_apt;
|
---|
2 |
|
---|
3 | use strict;
|
---|
4 | use warnings;
|
---|
5 | use utf8;
|
---|
6 | use parent 'Greenstone::Package';
|
---|
7 |
|
---|
8 | sub replacement_array {
|
---|
9 | my $self = shift;
|
---|
10 | my $array = shift;
|
---|
11 | return join ", ", @{$array};
|
---|
12 | }
|
---|
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 | chmod 0755, "/tmp/$name";
|
---|
22 | $self->add ("/tmp/$name", "$self->{output}/debian/$name");
|
---|
23 | }
|
---|
24 |
|
---|
25 | sub add_install {
|
---|
26 | my $self = shift;
|
---|
27 | exists $self->{config}->{PRE_INSTALL} and
|
---|
28 | $self->write_function ("preinst", @{$self->{config}->{PRE_INSTALL}});
|
---|
29 | exists $self->{config}->{POST_INSTALL} and
|
---|
30 | $self->write_function ("postinst", @{$self->{config}->{POST_INSTALL}});
|
---|
31 | exists $self->{config}->{PRE_REMOVE} and
|
---|
32 | $self->write_function ("prerm", @{$self->{config}->{PRE_REMOVE}});
|
---|
33 | exists $self->{config}->{POST_REMOVE} and
|
---|
34 | $self->write_function ("postrm", @{$self->{config}->{POST_REMOVE}});
|
---|
35 | }
|
---|
36 |
|
---|
37 | sub add_package_section {
|
---|
38 | my ($self, $out) = @_;
|
---|
39 | for my $line (
|
---|
40 | 'Package: %NAME%',
|
---|
41 | 'Architecture: %ARCHITECTURE%',
|
---|
42 | 'Homepage: %HOMEPAGE%',
|
---|
43 | 'Depends:',
|
---|
44 | '%DEPENDS',
|
---|
45 | 'Description: %DESCRIPTION_SHORT',
|
---|
46 | ' %DESCRIPTION'
|
---|
47 | ) {
|
---|
48 | my $copy = $line;
|
---|
49 | $self->subst ($copy);
|
---|
50 | print $out $copy, "\n";
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | sub add_package_impl {
|
---|
55 | my ($self, $packages) = @_;
|
---|
56 | $self->add_install;
|
---|
57 | open my $CONTROL, '>', "/tmp/gspkg.control";
|
---|
58 | for my $line (
|
---|
59 | 'Source: %NAME%',
|
---|
60 | 'Section: java',
|
---|
61 | 'Priority: optional',
|
---|
62 | 'Maintainer: %MAINTAINER_NAME% <%MAINTAINER_EMAIL%>',
|
---|
63 | 'BuildDepends:',
|
---|
64 | '%MAKEDEPENDS%',
|
---|
65 | ) {
|
---|
66 | my $copy = $line;
|
---|
67 | $self->subst ($copy);
|
---|
68 | print $CONTROL $copy, "\n";
|
---|
69 | }
|
---|
70 | if (defined $packages) {
|
---|
71 | my $config = $self->{config};
|
---|
72 | for my $package (@{$packages}) {
|
---|
73 | $package->{HOMEPAGE} = $config->{HOMEPAGE};
|
---|
74 | $self->{config} = $package;
|
---|
75 | $self->add_package_section ($CONTROL);
|
---|
76 | }
|
---|
77 | $self->{config} = $config;
|
---|
78 | } else {
|
---|
79 | $self->add_package_section ($CONTROL);
|
---|
80 | }
|
---|
81 | close $CONTROL;
|
---|
82 | $self->add ("/tmp/gspkg.control", "$self->{output}/debian/control");
|
---|
83 | }
|
---|
84 |
|
---|
85 | 1;
|
---|