Ignore:
Timestamp:
2014-12-11T18:45:10+13:00 (9 years ago)
Author:
Jeremy Symon
Message:

Modifying package generation to use sub-packages in order to avoid compiling the same source multiple times. Currently works for Pacman. Needs testing (and fixing) for other package managers.

Location:
main/trunk/package-kits/linux
Files:
1 added
6 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/package-kits/linux/global.conf

    r29583 r29595  
     1MAINTAINER_NAME:        Greenstone Team
     2MAINTAINER_EMAIL:       [email protected]
    13PKG_GREENSTONE:
    24    greenstone
  • main/trunk/package-kits/linux/perllib/Greenstone/Package.pm

    r29583 r29595  
    88use File::Copy 'cp';
    99use POSIX 'uname';
     10use Storable 'dclone';
    1011use Greenstone::Helpers;
    1112use base 'Exporter';
     
    127128sub add_package {
    128129    my $self = shift;
     130   
     131    # Add the (relatively) static files
    129132    $self->add ("managers/$self->{config}->{MANAGER}", $self->{output});
     133
     134    if (exists $self->{config}->{SUB_PACKAGES}) {
     135        my $packages = [];
     136        for my $subpackage (sort @{$self->{config}->{SUB_PACKAGES}}) {
     137            my $config = {};
     138            for my $key (keys %{$self->{config}}) {
     139                if ($key =~ /^${subpackage}_(.*)$/) {
     140                    # print "setting '$1' to '$key' = '$self->{config}->{$key}'\n";
     141                    $config->{$1} = $self->{config}->{$key};
     142                }
     143            }
     144            # hashdump $self->{config};
     145            push @{$packages}, $config;
     146        }
     147        $self->add_package_impl ($packages);
     148    } else {
     149        $self->add_package_impl;
     150    }
    130151}
    131152
  • main/trunk/package-kits/linux/perllib/Greenstone/Package/_apt.pm

    r29550 r29595  
    3535}
    3636
     37sub 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
     54sub 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
    37851;
  • main/trunk/package-kits/linux/perllib/Greenstone/Package/_pacman.pm

    r29546 r29595  
    3939
    4040sub write_function {
    41     my ($name, $out, @lines) = @_;
     41    my ($self, $name, $out, @lines) = @_;
    4242    print $out $name, "() {\n";
    4343    for my $line (@lines) {
     44        $self->subst ($line);
    4445        print $out "\t", $line, "\n";
    4546    }
     
    5455        exists $self->{config}->{POST_REMOVE}) {
    5556        my $name = "$self->{config}->{NAME}.install";
    56         open my $INSTALL, '>', "/tmp/$name";
     57        open my $INSTALL, '>', "/tmp/gspkg.$name";
    5758        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}};
     59            $self->write_function ("pre_install", $INSTALL, @{$self->{config}->{PRE_INSTALL}});
     60            $self->write_function ("pre_upgrade", $INSTALL, @{$self->{config}->{PRE_INSTALL}});
    6061        };
    6162        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}};
     63            $self->write_function ("post_install", $INSTALL, @{$self->{config}->{POST_INSTALL}});
     64            $self->write_function ("post_upgrade", $INSTALL, @{$self->{config}->{POST_INSTALL}});
    6465        };
    6566        exists $self->{config}->{PRE_REMOVE} and
    66             write_function "pre_remove", $INSTALL, @{$self->{config}->{PRE_REMOVE}};
     67            $self->write_function ("pre_remove", $INSTALL, @{$self->{config}->{PRE_REMOVE}});
    6768        exists $self->{config}->{POST_REMOVE} and
    68             write_function "post_remove", $INSTALL, @{$self->{config}->{POST_REMOVE}};
     69            $self->write_function ("post_remove", $INSTALL, @{$self->{config}->{POST_REMOVE}});
    6970        close $INSTALL;
    70         $self->add ("/tmp/$name", "$self->{output}/$name");
    71         $self->{config}->{INSTALL} = "install=$name";
     71        $self->add ("/tmp/gspkg.$name", "$self->{output}/$name");
     72        return "install=$name";
    7273    } else {
    73         $self->{config}->{INSTALL} = "";
     74        return "";
    7475    }
    7576}
    7677
     78sub add_package_impl {
     79    my ($self, $packages) = @_;
     80    if (defined $packages) {
     81        $self->{config}->{NAME} = '';
     82        for my $package (@{$packages}) {
     83            $self->{config}->{NAME} .= " $package->{NAME}";
     84        }
     85    }
     86    open my $PKGBUILD, '>', "/tmp/gspkg.PKGBUILD";
     87    for my $line (
     88        '# Maintainer: %MAINTAINER_NAME% <%MAINTAINER_EMAIL%>',
     89        'pkgname=(%NAME%)',
     90        'pkgver=%VERSION%',
     91        'pkgrel=%RELEASE%',
     92        'url=%HOMEPAGE%',
     93        'license=%LICENSE_SHORT%',
     94        'arch=(any)',
     95        'makedepends=(',
     96        '%MAKEDEPENDS%',
     97        ')',
     98        'source=(',
     99        '%SOURCES%',
     100        ')',
     101        'md5sums=(',
     102        '%SOURCE_SUMS%',
     103        ')',
     104        'build() {',
     105        '  cd ${srcdir}',
     106        '  make build',
     107        '}'
     108    ) {
     109        my $copy = $line;
     110        $self->subst ($copy);
     111        print $PKGBUILD $copy, "\n";
     112    }
     113    if (defined $packages) {
     114        my $config = $self->{config};
     115        for my $package (@{$packages}) {
     116            $self->{config} = $package;
     117            $self->write_function ("package_$package->{NAME}", $PKGBUILD,
     118                'pkgdesc=%DESCRIPTION%',
     119                'arch=(\'%ARCHITECTURE%\')',
     120                'depends=(',
     121                '%DEPENDS%',
     122                ')',
     123                'optdepends=(',
     124                '%OPTDEPENDS%',
     125                ')',
     126                'provides=(',
     127                '%PROVIDES%',
     128                ')',
     129                $self->add_install,
     130                'DESTDIR=${pkgdir} make install_%NAME%',
     131            );
     132        }
     133        $self->{config} = $config;
     134    } else {
     135        print $PKGBUILD $self->add_install, "\n";
     136        $self->write_function ('package', $PKGBUILD, 'DESTDIR=${pkgdir} make install');
     137    }
     138    close $PKGBUILD;
     139    $self->add ("/tmp/gspkg.PKGBUILD", "$self->{output}/PKGBUILD");
     140}
     141
    771421;
  • main/trunk/package-kits/linux/perllib/Greenstone/Package/_rpm.pm

    r29559 r29595  
    3333sub add_install {
    3434    my $self = shift;
    35     $self->{config}->{INSTALL} = "";
     35    my $ret = '';
    3636    exists $self->{config}->{PRE_INSTALL} and
    37         $self->{config}->{INSTALL} .= write_function "pre", @{$self->{config}->{PRE_INSTALL}};
     37        $ret .= write_function "pre", @{$self->{config}->{PRE_INSTALL}};
    3838    exists $self->{config}->{POST_INSTALL} and
    39         $self->{config}->{INSTALL} .= write_function "post", @{$self->{config}->{POST_INSTALL}};
     39        $ret .= write_function "post", @{$self->{config}->{POST_INSTALL}};
    4040    exists $self->{config}->{PRE_REMOVE} and
    41         $self->{config}->{INSTALL} .= write_function "preun", @{$self->{config}->{PRE_INSTALL}};
     41        $ret .= write_function "preun", @{$self->{config}->{PRE_INSTALL}};
    4242    exists $self->{config}->{POST_REMOVE} and
    43         $self->{config}->{INSTALL} .= write_function "postun", @{$self->{config}->{POST_INSTALL}};
     43        $ret .= write_function "postun", @{$self->{config}->{POST_INSTALL}};
     44    return $ret;
     45}
     46
     47sub add_package_impl {
     48    my ($self, $packages) = @_;
     49    open my $SPEC, '>', '/tmp/gspkg.spec';
     50    for my $line (
     51        'Name:          %NAME%',
     52        'Version:       %VERSION%',
     53        'Release:       %RELEASE%',
     54        'License:       %LICENSE_SHORT%',
     55        'URL:           %HOMEPAGE%',
     56        'Source0:       %NAME%',
     57        'AutoReqProv:   no',
     58        'BuildRequires: %MAKEDEPENDS%',
     59        '',
     60        '%prep',
     61        'cp -pr %SOURCE0 .',
     62        '',
     63        '%build',
     64        'cd %NAME%',
     65        'make %{?_smp_mflags}',
     66        '',
     67        '%install',
     68        'cd %NAME%',
     69        '%make_install',
     70        '',
     71        '%changelog',
     72        ''
     73    ) {
     74        my $copy = $line;
     75        $self->subst ($copy);
     76        print $SPEC $copy, "\n";
     77    }
     78    if (defined $packages) {
     79        my $config = $self->{config};
     80        for my $package (@{$packages}) {
     81            $self->{config} = $package;
     82            for my $line (
     83                '%package %NAME%',
     84                '%requires',
     85                '%DEPENDS%',
     86                '%description',
     87                '%DESCRIPTION%',
     88                $self->add_install,
     89                '%files',
     90                '%FILES%'
     91            ) {
     92                my $copy = $line;
     93                $self->subst ($copy);
     94                print $SPEC $copy, "\n";
     95            }
     96        }
     97        $self->{config} = $config;
     98    } else {
     99        for my $line (
     100            '%requires',
     101            '%DEPENDS%',
     102            '%description',
     103            '%DESCRIPTION%',
     104            $self->add_install,
     105            '%files',
     106            '%FILES%'
     107        ) {
     108            my $copy = $line;
     109            $self->subst ($copy);
     110            print $SPEC $copy, "\n";
     111        }
     112    }
     113    close $SPEC;
     114    $self->add ("/tmp/gspkg.spec", "$self->{output}/$self->{config}->{NAME}.spec");
    44115}
    45116
  • main/trunk/package-kits/linux/segments/base

    r29577 r29595  
    1212all: build
    1313
    14 .PHONY: all svn clean cleanall install
     14.PHONY: all svn clean cleanall install install_greenstone install_greenstone-native install_greenstone-tools
  • main/trunk/package-kits/linux/segments/main

    r29583 r29595  
    1 install:
     1install_greenstone:
    22    install -d $(DESTDIR)/$(web)
    33    install -dm775 $(DESTDIR)/$(tomcatlib)
  • main/trunk/package-kits/linux/segments/native

    r29583 r29595  
    1 install:
     1install_greenstone-native:
    22    install -d $(DESTDIR)/$(systemlib)
    33    install -Dm755 src/lib/jni/*.so $(DESTDIR)/$(systemlib)
  • main/trunk/package-kits/linux/segments/tools

    r29508 r29595  
    1 install:
     1install_greenstone-tools:
    22    install -d $(DESTDIR)/$(gstools)
    33    rsync -a --info=STATS --exclude build-src --exclude common-src --exclude collect/demo --exclude .svn src/gs2build $(DESTDIR)/$(gstools)/
Note: See TracChangeset for help on using the changeset viewer.