Changeset 4


Ignore:
Timestamp:
10/25/05 16:59:09 (19 years ago)
Author:
kdeugau
Message:

/trunk

Checkpoint commit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r3 r4  
    3131my $srcpkg;
    3232my $verbosity = 0;
     33my %cmdopts = (type => '',
     34                stage => 'a',
     35                short => 'n'
     36        );
     37my %targets = ('p' => 'Prep',
     38                'c' => 'Compile',
     39                'i' => 'Install',
     40                'l' => 'Verify %files',
     41                'a' => 'Build binary and source',
     42                'b' => 'Build binary',
     43                's' => 'Build source'
     44        );
     45my $topdir = "/usr/src/debian";
    3346
     47load_userconfig();
    3448parse_cmd();
    3549
     50# Hokay.  Need to:
     51# Execute prep if *not* --short-circuit
     52prep() if ($cmdopts{short} ne 'y');
     53
     54if ($cmdopts{stage} =~ /ciab/) {
     55  # Execute build if bc
     56  # Execute build if bi, ba, bb and NOT --short-circuit
     57  build() if ( ($cmdopts{stage} eq 'c') ||
     58        (($cmdopts{stage} =~ /iab/) && ($cmdopts{short} ne 'y'))
     59        );
     60
     61  # -> Execute
     62  install() if ($cmdopts{short} ne 'y');
     63  binpackage();
     64}
     65
     66srcpackage();
     67
     68
     69
     70# Just in case.
     71exit 0;
     72
     73
     74## load_userconfig()
     75# Loads user configuration (if any)
     76# Currently only handles .debmacros
     77# Needs to handle "other files"
     78sub load_userconfig {
     79  (undef,undef,undef,undef,undef,undef,undef,$homedir,undef) = getpwuid($<);
     80  if (-e "$homedir/.debmacros") {
     81    open USERMACROS,"<$homedir/.debmacros";
     82    while (<USERMACROS>) {
     83      # And we also only handle the %_topdir macro at the moment.
     84      if (/^\%_topdir/) {
     85        (undef,$tmp) = split /\s+/, $_;
     86      }
     87    }
     88  }
     89} # end load_userconfig()
     90
     91
    3692## parse_cmd()
    37 # Parses command line into internal option (array|hash)
     93# Parses command line into global hash %cmdopts, other globals
    3894# Options based on rpmbuild's options
    3995sub parse_cmd {
     
    4298  # ... but I may have to:  (OTOH, rpm uses popt, so maybe we can too.)
    4399  #use Getopt::Popt qw(:all);
     100  # Or not.  >:(  Stupid Debian lack of findable Perl module names in packages.
    44101
    45102  # Stuff it.
     103  my $prevopt = '';
    46104  foreach (@ARGV) {
    47105    chomp;
     106    $prevopt = $_;
    48107    # Is it an option?
    49108    if (/^-/) {
    50109      # Is it a long option?
    51110      if (/^--/) {
    52         print "Long opt $_\n";
     111        if (/^--short-circuit/) {
     112          $cmdopts{short} = 'y';
     113        } else {
     114          print "Long opt $_\n";
     115        }
    53116      } else {
    54         print "Short opt $_\n";
     117        if (/^-[bts]/) {
     118          ($cmdopts{stage}) = (/^-[bts]([pcilabs])/);
     119          ($cmdopts{type}) = (/^-([bts])[pcilabs]/);
     120        } elsif (/^-v/) {
     121          # bump verbosity.  Not sure what I'll actually do here...
     122        } else {
     123          die "Bad option $_\n";
     124        }
    55125      }
    56126    } else {
    57127      print "Non-option arg $_\n";
    58128    }
     129  }
     130
     131  # Some cross-checks.  rpmbuild limits --short-circuit to just
     132  # the "compile" and "install" targets - with good reason IMO.
     133  # NB - this is NOT fatal, just ignored!
     134  if ($cmdopts{short} eq 'y') {
     135    warn "Can't use --short-circuit for $targets{$cmdopts{stage}} stage.  Ignoring.\n";
     136    $cmdopts{short} = 'n';
    59137  }
    60138  # Valid options, with example arguments (if any):
     
    93171} # end parse_cmd()
    94172
    95 ## unpack()
     173
     174## prep()
    96175# Unpacks the tarball from the SOURCES directory to the BUILD directory.
    97176# Speaks gzip and bzip2.
    98177# Requires the "package name"
    99 sub unpack(){}
     178# Finishes by applying patches in %prep section of spec file
     179sub prep {
     180  my $pkgname = shift;
     181 
     182} # end prep()
    100183
    101 sub patch(){}
    102 sub configure(){}
    103 sub build(){}
    104 sub install(){}
    105 sub package(){}
    106 sub srcpackage(){}
     184
     185sub build {}
     186sub install {}
     187sub binpackage {}
     188sub srcpackage {}
Note: See TracChangeset for help on using the changeset viewer.