~ubuntu-branches/ubuntu/karmic/sbuild/karmic-proposed

« back to all changes in this revision

Viewing changes to lib/Sbuild/OptionsBase.pm

  • Committer: Bazaar Package Importer
  • Author(s): Roger Leigh, Roger Leigh
  • Date: 2009-05-17 15:52:53 UTC
  • mfrom: (8.1.7 upstream) (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090517155253-fbxadfsyaf940ete
Tags: 0.58.3-1
[ Roger Leigh ]
* New release.
* debian/control:
  - Update to Standards Version 3.8.1.
  - Add buildd package.
  - Add libsbuild-perl package.
  - All packages depend upon libsbuild-perl.
* Add support for appending a tag to version numbers (Closes: #475777).
  Thanks to Timothy G Abbott for this patch.
* When using the --help or --version options, don't abort if not
  in the sbuild group (Closes: #523670).  Group membership is now
  only performed after options parsing, and only if required.
* Allow config files to use $HOME (Closes: #524564).  Thanks to
  James Vega for this patch.
* Restore buildd package.
* Split common library functions into new libsbuild-perl package.
* debian/sbuild.(preinst|postinst|postrm):
  - Remove special cases for versions older than oldstable.  Update
    addition and removal of sbuild group to use return value of getent
    rather than parsing getent output.
  - Use addgroup/delgroup in place of adduser/deluser.
  - Use --system when adding and deleting group, to ensure creation
    of a system group.  Migrate existing non-system group and group
    members if the system group is not present.
  - Handle removal of 50sbuild setup script.
* debian/buildd.(preinst|postinst|postrm): Add maintainer scripts for
  buildd package.  Move configuration file from /etc/buildd.conf to
  /etc/buildd/buildd.conf if present.  Also create buildd user and
  group for running the buildd daemon.
* Sbuild::Conf: Don't default MAINTAINER_NAME to $DEBEMAIL if unset
  in the configuration file (Closes: #520158).
* /etc/schroot/setup.d/50sbuild: Remove.  The setup tasks performed by
  this script are now handled internally by sbuild.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# OptionsBase.pm: options parser (base functionality) for sbuild
 
3
# Copyright © 2005      Ryan Murray <rmurray@debian.org>
 
4
# Copyright © 2005-2009 Roger Leigh <rleigh@debian.org>
 
5
# Copyright © 2008      Simon McVittie <smcv@debian.org>
 
6
#
 
7
# This program is free software: you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation, either version 2 of the License, or
 
10
# (at your option) any later version.
 
11
#
 
12
# This program is distributed in the hope that it will be useful, but
 
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
# General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with this program.  If not, see
 
19
# <http://www.gnu.org/licenses/>.
 
20
#
 
21
#######################################################################
 
22
 
 
23
package Sbuild::OptionsBase;
 
24
 
 
25
use strict;
 
26
use warnings;
 
27
 
 
28
use Getopt::Long qw(:config no_ignore_case auto_abbrev gnu_getopt);
 
29
use Sbuild qw(help_text version_text usage_error);
 
30
use Sbuild::Base;
 
31
use Sbuild::Conf;
 
32
 
 
33
BEGIN {
 
34
    use Exporter ();
 
35
    our (@ISA, @EXPORT);
 
36
 
 
37
    @ISA = qw(Exporter Sbuild::Base);
 
38
 
 
39
    @EXPORT = qw();
 
40
}
 
41
 
 
42
sub new {
 
43
    my $class = shift;
 
44
    my $conf = shift;
 
45
    my $program = shift;
 
46
    my $section = shift;
 
47
 
 
48
    my $self = $class->SUPER::new($conf);
 
49
    bless($self, $class);
 
50
 
 
51
    $self->add_options("h|help" => sub { help_text($section, $program); },
 
52
                       "V|version" => sub {version_text($program); },
 
53
                       "D|debug" => sub {
 
54
                           $self->set_conf('DEBUG',
 
55
                                           $self->get_conf('DEBUG') + 1); },
 
56
                       "v|verbose" => sub {
 
57
                           $self->set_conf('VERBOSE',
 
58
                                           $self->get_conf('VERBOSE') + 1);
 
59
                       },
 
60
                       "q|quiet" => sub {
 
61
                           $self->set_conf('VERBOSE',
 
62
                                           $self->get_conf('VERBOSE') - 1)
 
63
                               if $self->get_conf('VERBOSE');
 
64
                       });
 
65
 
 
66
    $self->set_options();
 
67
 
 
68
    if (!$self->parse_options()) {
 
69
        usage_error($program, "Error parsing command-line options");
 
70
        return undef;
 
71
    }
 
72
    return $self;
 
73
}
 
74
 
 
75
sub add_options () {
 
76
    my $self = shift;
 
77
    my @newopts = @_;
 
78
 
 
79
    my %options;
 
80
    if (defined($self->get('Options'))) {
 
81
        %options = (%{$self->get('Options')}, @newopts);
 
82
    } else {
 
83
        %options = (@newopts);
 
84
    }
 
85
    $self->set('Options', \%options);
 
86
}
 
87
 
 
88
sub set_options () {
 
89
    my $self = shift;
 
90
}
 
91
 
 
92
sub parse_options {
 
93
    my $self = shift;
 
94
 
 
95
    return GetOptions((%{$self->get('Options')}));
 
96
}
 
97
 
 
98
1;