| Arepa documentation | Contained in the Arepa distribution. |
Arepa::Builder - Arepa builder base "class"
my $module = Arepa::Builder->ui_module;
Arepa::Builder->ui_module($new_ui_module);
Arepa::Builder->init($builder_name);
Arepa::Builder->compile_package_from_dsc($builder_name, $dsc_file);
Arepa::Builder->compile_package_from_dsc($builder_name, $dsc_file,
output_dir => 1);
Arepa::Builder->compile_package_from_repository($builder_name,
$dsc_file);
Arepa::Builder->compile_package_from_repository($builder_name,
$dsc_file,
output_dir => 1,
bin_nmu => 1);
my $log = Arepa::Builder->last_build_log;
Arepa::Builder->create($builder_dir, $mirror, $distribution);
This module contains the interface for an Arepa builder. It should be the
"subclass" for any builder module. Every Arepa builder type must have a module
implementing this API. Arepa::BuilderFarm, when manipulating the builders,
will use the correct builder module according to the builder type (e.g. for
type 'sbuild', Arepa::Builder::Sbuild).
This module is never used directly, but through "subclasses" in
Arepa::BuilderFarm.
Returns the UI module being used (by default, Arepa::UI::Text. If a
parameter is passed, the UI module is changed to that, and the new value is
returned.
Initialises the given $builder_name to be able to use it. This should be
done once per machine boot (e.g. in an init script).
Compiles the source package described by the given $dsc_file using the given
$builder_name. The resulting .deb files are put in the current directory
by default. Valid options are output_dir and bin_nmu (see
compile_package_from_repository documentation).
Compiles the source package with the given $name and $version using the
given $builder_name. By default, the resulting .deb files are put in the
current directory. The only valid options are output_dir (to specify the
directory where the resulting .deb files should end up in) and bin_nmu
(to specify if the compilation should be considered a binNMU).
Returns the log text of the last build.
Creates a new builder in the given directory $builder_dir, using the Debian
mirror $mirror and the distribution $distribution.
Arepa::BuilderFarm, Arepa::Config.
Esteban Manchado Velázquez <estebanm@opera.com>.
This code is offered under the Open Source BSD license.
Copyright (c) 2010, Opera Software. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Opera Software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| Arepa documentation | Contained in the Arepa distribution. |
package Arepa::Builder; use strict; use warnings; use Carp; use Cwd; use File::chmod; use File::Temp; use File::Basename; use File::Path; use File::Find; use File::Copy; use Config::Tiny; use YAML::Syck; use Arepa; my $ui_module = 'Arepa::UI::Text'; sub ui_module { my ($self, $module) = @_; if (defined $module) { $ui_module = $module; } eval qq(use $ui_module;); die $@ if $@; return $ui_module; } sub type { my ($self) = @_; my $class = ref($self) || $self; $class =~ s/.+:://; if (!$class) { croak "You should use a proper builder class, not ".ref($self); } return lc($class); } sub new { my ($class, %attrs) = @_; return bless { %attrs, }, $class; } sub name { $_[0]->{name} } sub last_build_log { $_[0]->{last_build_log} } sub config { my ($self, $key) = @_; return $self->{$key}; } # To be implemented by each type sub do_init { my ($self, $builder) = @_; croak "Not implemented"; } sub init { my ($self, $builder) = @_; $self->do_init($builder); } sub do_uninit { my ($self, $builder) = @_; croak "Not implemented"; } sub uninit { my ($self, $builder) = @_; $self->do_uninit($builder); } sub do_compile_package_from_dsc { my ($self, $dsc_file, %user_opts) = @_; croak "Not implemented"; } sub compile_package_from_dsc { my ($self, $dsc_file, %user_opts) = @_; $self->do_compile_package_from_dsc($dsc_file, %user_opts); } sub do_compile_package_from_repository { my ($self, $pkg_name, $pkg_version, %user_opts) = @_; croak "Not implemented"; } sub compile_package_from_repository { my ($self, $pkg_name, $pkg_version, %user_opts) = @_; $self->do_compile_package_from_repository($pkg_name, $pkg_version, %user_opts); } sub do_create { my ($self, $builder_dir, $mirror, $distribution, %opts) = @_; croak "Not implemented"; } sub create { my ($self, $builder_dir, $mirror, $distribution, %user_opts) = @_; my %opts = (builder_config_dir => '/etc/arepa/builders', arch => `dpkg-architecture -qDEB_BUILD_ARCH`, %user_opts); chomp($opts{arch}); $self->do_create($builder_dir, $mirror, $distribution, %opts); $self->ui_module->print_title("Configuration for config.yml"); my $type = $self->type; my $config_string = <<EOD; type: $type architecture: $opts{arch} # Compile "Architecture: all" packages with this builder? architecture_all: 0 # This is the distribution the packages compiled by this builder go to. For a # package to be compiled by this builder, it has to have the correct # architecture and this distribution (or an alias or similar, see below) in # its *.changes file. distribution: $distribution # Other names for this distribution (if the distribution name is # mycompany-squeeze, you might want 'squeeze' and 'testing' as aliases) distribution_aliases: [] # Recompile packages (binNMU or Binary-only Non-Maintainer Upload; see # http://www.debian.org/doc/developers-reference/pkgs.html#nmu-binnmu) # originally uploaded for other distributions in this builder. This option is # an easy way to get "for free" packages compiled for several distributions. # Typical values for this list would be 'unstable' or 'lenny' bin_nmu_for: [] EOD my $builder_name = basename($builder_dir); my $path = File::Spec->catfile($opts{builder_config_dir}, "$builder_name.yml"); open F, ">$path" or croak "Can't write builder configuration in $path"; print F $config_string; close F; print "You can tweak the builder configuration in $path\n"; my $sources_list_path = File::Spec->catfile($builder_dir, "etc", "apt", "sources.list"); print "You should also review $sources_list_path\n"; } 1; __END__