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 | my $file = "$self->{output}/debian/$name";
|
---|
17 | print " - $file\n";
|
---|
18 | open my $OUT, '>', $file;
|
---|
19 | for my $line (@lines) {
|
---|
20 | print $OUT $line, "\n";
|
---|
21 | }
|
---|
22 | close $OUT;
|
---|
23 | chmod 0755, $file;
|
---|
24 | }
|
---|
25 |
|
---|
26 | sub 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 |
|
---|
38 | sub add_package_section {
|
---|
39 | my ($self, $out) = @_;
|
---|
40 | for my $line (
|
---|
41 | 'Package: %NAME%',
|
---|
42 | 'Architecture: %ARCHITECTURE%',
|
---|
43 | 'Homepage: %HOMEPAGE%',
|
---|
44 | 'Depends:',
|
---|
45 | ' %DEPENDS%',
|
---|
46 | 'Description: %DESCRIPTION_SHORT',
|
---|
47 | ' %DESCRIPTION'
|
---|
48 | ) {
|
---|
49 | my $copy = $line;
|
---|
50 | $self->subst ($copy);
|
---|
51 | print $out $copy, "\n";
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | sub add_package_impl {
|
---|
56 | my ($self, $packages) = @_;
|
---|
57 | $self->add_install;
|
---|
58 | my $file = "$self->{output}/debian/control";
|
---|
59 | print " - $file\n";
|
---|
60 | open my $CONTROL, '>', $file;
|
---|
61 | for my $line (
|
---|
62 | 'Source: %NAME%',
|
---|
63 | 'Section: java',
|
---|
64 | 'Priority: optional',
|
---|
65 | 'Maintainer: %MAINTAINER_NAME% <%MAINTAINER_EMAIL%>',
|
---|
66 | 'Build-Depends:',
|
---|
67 | ' %MAKEDEPENDS%',
|
---|
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 |
|
---|
87 | 1;
|
---|