Debian::Package::Make::Debhelper - Perl extension for autobuilding Debian packages


Debian-Package-Make documentation Contained in the Debian-Package-Make distribution.

Index


Code Index:

NAME

Top

Debian::Package::Make::Debhelper - Perl extension for autobuilding Debian packages

SYNOPSIS

Top

Debian::Package::Make::Debhelper is an implementation of the Debian::Package::Make interface that creates default files for debhelper(7).

ATTRIBUTES

Top

* standards_version
* build_depends build_depends_indep
* binaries

PUBLIC INTERFACE

Top

add_binary

Causes a binary package $binname with $attributes to be added.

Valid attributes include:

* depends suggests recommends conflicts

ARRAYs containing the dependencies. This may include terms that are interpreted by Debhelper scripts, i.e. ${shlib:Depends}.

* description, longdesc

The short and long description for the binary package.

prepare_files

prepare_files populates $self-{files}> with sensible defaults for a debhelper(7)-based setup. At the moment, this includes the following files, but other files may be added in later versions of Debian::Package::Make.

* debian/control
* debian/changelog
* debian/compat
* debian/rules

A subclass that uses prepare_files should add a proper debian/copyright file and populate debian/install, debian/docs, debian/links and/or patch the entry for debian/rules. See debhelper(7) for details.

BUGS

Top

* This module lacks documentation. For the time being, please refer to the scripts in the examples directory.

SEE ALSO

Top

Debian::Package::Make, debhelper(7)

AUTHOR

Top

Hilko Bengen, <bengen@debian.org>

COPYRIGHT AND LICENSE

Top


Debian-Package-Make documentation Contained in the Debian-Package-Make distribution.
package Debian::Package::Make::Debhelper;

use strict;
use warnings;

our $VERSION = 0.04;

use Debian::Package::Make 0.04;
use Text::Wrap;

our @ISA    = qw(Debian::Package::Make);
our @EXPORT = qw(@ATTRIBUTES);

push @ATTRIBUTES, (
    qw( standards_version
      binaries
      build_depends
      build_depends_indep)
);

sub new {
    my ( $class, %param ) = @_;
    my $self = $class->SUPER::new(%param);
    $self->{standards_version} ||= '3.7.3';
    push( @{ $self->{build_depends} }, 'debhelper (>> 5)' )
      unless grep /debhelper/, @{ $self->{build_depends} };
    bless $self, $class;
}

sub add_binary {
    my ( $self, $binname, $attributes ) = @_;
    carp("Binary $binname already defined")
      if ( exists $self->{binaries}{$binname} );
    $self->{binaries}{$binname} = $attributes;
}

sub prepare_files {
    my ( $self, %param ) = @_;
    my %f = %{ $self->{files} };
    local $" = ", ";

    $f{'debian/control'} = <<EOF;
Source: $self->{source}
Section: $self->{section}
Priority: $self->{priority}
Maintainer: $self->{maintainer}
EOF
    if ( exists $self->{uploaders} ) {
        $f{'debian/control'} .= "Uploaders: @{$self->{uploaders}}\n";
    }
    if ( exists $self->{build_depends} ) {
        $f{'debian/control'} .= "Build-Depends: @{$self->{build_depends}}\n";
    }
    if ( exists $self->{build_depends_indep} ) {
        $f{'debian/control'} .=
          "Build-Depends-Indep: @{$self->{build_depends_indep}}\n";
    }
    $f{'debian/control'} .= "Standards-Version: $self->{standards_version}\n";
    foreach my $name ( keys %{ $self->{binaries} } ) {
        my %binary = %{ $self->{binaries}{$name} };
        $f{'debian/control'} .= <<EOF;

Package: $name
Architecture: $binary{architecture}
EOF
        foreach my $attr (qw(depends suggests recommends conflicts)) {
            next unless exists $binary{$attr};
            $f{'debian/control'} .= ucfirst($attr) . ": @{$binary{$attr}}\n";
        }
        $f{'debian/control'} .= "Description: $binary{description}\n";
        if ( exists $binary{longdesc} ) {
            local $Text::Wrap::columns = 72;
            local $Text::Wrap::huge    = 'overflow';
            my $longdesc = Text::Wrap::fill( " .\n ", ' ', $binary{longdesc} );
            $longdesc =~ s/^ \.\n//g;
            $f{'debian/control'} .= "$longdesc\n";
        }
    }

    $f{'debian/changelog.in'} = <<EOF;
#SOURCE# (#VERSION#) #DISTRIBUTION#; urgency=#URGENCY#

  * #CHANGES#

 -- #USERNAME# <#EMAIL#>  #DATE#

EOF

    # FIXME append old changelog if present
    $f{'debian/compat'} = "5\n";
    $f{'debian/rules'}  = <<EOF;
#!/usr/bin/make -f
configure:
	#CONFIGURE#
build: build-indep build-arch
build-indep:
	#BUILDINDEP#
build-arch:
	#BUILDARCH#
clean:
	dh_testdir
	dh_testroot
	#CLEAN#
	dh_clean
install: install-indep install-arch
install-indep: build-indep
	dh_testdir
	dh_testroot
	dh_clean -k -i
	dh_installdirs -i
	#INSTALLINDEP#
	dh_install -i
install-arch: build-arch
	dh_testdir
	dh_testroot
	dh_clean -k -s
	dh_installdirs -s
	#INSTALLARCH#
	dh_install -s
binary-indep: build-indep install-indep
binary-arch: build-arch install-arch
binary: binary-arch binary-indep
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
#	dh_installexamples
#	dh_installmenu
#	dh_installdebconf	
#	dh_installlogrotate	
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_python
#	dh_installinit
#	dh_installcron
#	dh_installinfo
#	dh_installman
	dh_link
#	dh_strip
	dh_compress
	dh_fixperms
#	dh_perl
#	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb
.PHONY: build clean binary-indep binary-arch binary install install-indep install-arch
EOF
    $self->{files} = \%f;
    $self->process_templates;
    1;
}

1;