Ignore:
Timestamp:
2014-12-12T15:12:15+13:00 (9 years ago)
Author:
Jeremy Symon
Message:

Changes to get Ubuntu working.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/package-kits/linux/perllib/Greenstone/Package/_apt.pm

    r29598 r29607  
    66use parent 'Greenstone::Package';
    77
     8# Deb packages expect lists to be comma separated
    89sub replacement_array {
    910    my $self = shift;
     
    1617    my $file = "$self->{output}/debian/$name";
    1718    print "    - $file\n";
    18     open my $OUT, '>', $file;
     19    open my $OUT, '>', $file
     20        or die "Failed to open $file: $!";
    1921    for my $line (@lines) {
    2022        print $OUT $line, "\n";
     
    2426}
    2527
     28# Add pre/post install/remove hooks
    2629sub add_install {
    27     my $self = shift;
     30    my ($self, $name) = @_;
     31    my $prefix = (defined $name ? "$name." : "");
    2832    exists $self->{config}->{PRE_INSTALL} and
    29         $self->write_function ("preinst", @{$self->{config}->{PRE_INSTALL}});
     33        $self->write_function ("${prefix}preinst", @{$self->{config}->{PRE_INSTALL}});
    3034    exists $self->{config}->{POST_INSTALL} and
    31         $self->write_function ("postinst", @{$self->{config}->{POST_INSTALL}});
     35        $self->write_function ("${prefix}postinst", @{$self->{config}->{POST_INSTALL}});
    3236    exists $self->{config}->{PRE_REMOVE} and
    33         $self->write_function ("prerm", @{$self->{config}->{PRE_REMOVE}});
     37        $self->write_function ("${prefix}prerm", @{$self->{config}->{PRE_REMOVE}});
    3438    exists $self->{config}->{POST_REMOVE} and
    35         $self->write_function ("postrm", @{$self->{config}->{POST_REMOVE}});
     39        $self->write_function ("${prefix}postrm", @{$self->{config}->{POST_REMOVE}});
    3640}
    3741
     42# Adds a definition for a package or subpackage
    3843sub add_package_section {
    3944    my ($self, $out) = @_;
     
    4247        'Architecture: %ARCHITECTURE%',
    4348        'Homepage: %HOMEPAGE%',
    44         'Depends:',
    45         '  %DEPENDS%',
    46         'Description: %DESCRIPTION_SHORT',
    47         '  %DESCRIPTION'
     49        'Depends: %DEPENDS%',
     50        'Description: %DESCRIPTION_SHORT%',
     51        '  %DESCRIPTION%',
     52        ''
    4853    ) {
    4954        my $copy = $line;
     
    5358}
    5459
     60# Handles the apt-specific package generation
    5561sub add_package_impl {
    5662    my ($self, $packages) = @_;
    57     $self->add_install;
    5863    my $file = "$self->{output}/debian/control";
    5964    print "    - $file\n";
    60     open my $CONTROL, '>', $file;
     65    open my $CONTROL, '>', $file
     66        or die "Failed to open $file: $!";
    6167    for my $line (
    6268        'Source: %NAME%',
     
    6470        'Priority: optional',
    6571        'Maintainer: %MAINTAINER_NAME% <%MAINTAINER_EMAIL%>',
    66         'Build-Depends:',
    67         '  %MAKEDEPENDS%',
     72        'Build-Depends: %MAKEDEPENDS%',
     73        ''
    6874    ) {
    6975        my $copy = $line;
     
    7379    if (defined $packages) {
    7480        my $config = $self->{config};
     81        my @names;
    7582        for my $package (@{$packages}) {
     83            push @names, $package->{NAME};
    7684            $package->{HOMEPAGE} = $config->{HOMEPAGE};
    7785            $self->{config} = $package;
     86            $self->add_install ($package->{NAME});
    7887            $self->add_package_section ($CONTROL);
     88            my $install = "$self->{output}/debian/$self->{config}->{NAME}.install";
     89            open my $INSTALL, '>', $install;
     90            for my $line (@{$self->{config}->{FILES}}) {
     91                print $INSTALL $line, "\n";
     92            }
     93            close $INSTALL;
    7994        }
    8095        $self->{config} = $config;
     96        my $rules = "$self->{output}/debian/rules";
     97        open my $RULES, '>>', $rules
     98            or die "Failed to open $rules: $!";
     99        print $RULES "\noverride_dh_gencontrol:\n";
     100        for my $name (@names) {
     101            print $RULES "\tdh_gencontrol -p$name\n";
     102        }
     103        close $RULES;
    81104    } else {
     105        $self->add_install;
    82106        $self->add_package_section ($CONTROL);
    83107    }
Note: See TracChangeset for help on using the changeset viewer.