| 1 | package MegaDistro::Package; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Exporter; | ||
| 7 | our @ISA = qw(Exporter); | ||
| 8 | our @EXPORT_OK = qw(make_tarball make_package); | ||
| 9 | |||
| 10 | use lib './MegaDistro'; | ||
| 11 | |||
| 12 | use MegaDistro::Config qw(:default $DEVNULL); | ||
| 13 | use MegaDistro::RpmMaker::Build qw(have_rpm build_rpm); | ||
| 14 | use MegaDistro::DebMaker::Build qw(have_deb build_deb); | ||
| 15 | |||
| 16 | use File::Spec::Functions qw(:ALL); | ||
| 17 | use File::Find; | ||
| 18 | use Archive::Tar; | ||
| 19 | |||
| 20 | no warnings 'File::Find'; | ||
| 21 | |||
| 22 | #create snapshot of buildtree | ||
| 23 | sub make_tarball { | ||
| 24 | # return tarball name here? | ||
| 25 | my ( $year, $month, $day ) = (localtime)[5,4,3]; | ||
| 26 | my $date = sprintf "%02d%02d%02d", $year + 1900, $month + 1, $day; | ||
| 27 | my $TARBALL = "megadistro-$date.tar.gz"; | ||
| 28 | my @files; | ||
| 29 | find(sub{push@files,abs2rel($File::Find::name,$Conf{'builddir'})},$Conf{'builddir'}); | ||
| 30 | shift @files if !$files[0]; | ||
| 31 | chdir $Conf{'builddir'}; | ||
| 32 | my $tar = Archive::Tar->create_archive(catdir($Conf{'rootdir'},$TARBALL),9,@files); | ||
| 33 | |||
| 34 | return -e catdir($Conf{'rootdir'},$TARBALL); | ||
| 35 | } | ||
| 36 | |||
| 37 | sub make_package { | ||
| 38 | # return built package names here, from calls? | ||
| 39 | if ( "$Conf{'disttype'}" eq "rpm" ) { | ||
| 40 | if ( &have_rpm ) { | ||
| 41 | &build_rpm; | ||
| 42 | } | ||
| 43 | else { #allow the possibility of another choice, "on-the-fly"/interactively here, since it's possible? | ||
| 44 | #override-able by --force, e.g. testing/development purposes | ||
| 45 | die "\nPackage system rpm, is not available on this system!\n"; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | elsif ( "$Conf{'disttype'}" eq "deb" ) { | ||
| 49 | if ( &have_deb ) { | ||
| 50 | &build_deb; | ||
| 51 | } | ||
| 52 | else { #allow the possibility of another choice, "on-the-fly"/interactively here, since it's possible? | ||
| 53 | #override-able by --force, e.g. testing/development purposes | ||
| 54 | die "\nPackage system deb, is not available on this system!\n"; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | 1; |