-
Notifications
You must be signed in to change notification settings - Fork 1
/
makerelease
executable file
·99 lines (86 loc) · 2.98 KB
/
makerelease
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/perl
use strict;
use XML::Simple;
use Data::Dumper;
use Makerelease;
our $VERSION = '0.1';
my %opts = (c => "makerelease.xml");
my %parameters;
my $descr;
#XXX: should probably forcearray => 1 for everything
our @XMLinopts = (ForceArray => [qw(steps step commands command
modifications modify
perl code files file
)],
KeyAttr => 'boguspleasedontkey');
LocalGetOptions(\%opts,
['c|config-file=s', 'makerelease xml config file to use'],
['r|regexp-ignore-steps=s','Ignore these REGEXP steps'],
['s|start-at=s', 'Skip all steps until ARG'],
['p|parameters=s', 'Parameters: parameter=value,...'],
['i|interactive', 'Prompt whether to do each step'],
['S|sleep=i', 'Sleep INTEGER seconds between steps'],
['n|dry-run', 'Dry run only. Don\'t actually do anything.'],
['T|list-toc', 'Just print a step Table-of-Contents.'],
['t|test-only', 'Only test the configuration file.'],
['v|verbose', 'Verbose output about steps taken.'],
['h|help', 'Help']) || exit;
my $extrajunk = shift;
die "Unexpected argument ($extrajunk)" if ($extrajunk);
######################################################################
# Parse the parameters
if ($opts{'p'}) {
foreach my $def (split(/,\s*/,$opts{'p'})) {
my ($name, $value) = ($def =~ /^([^=]+)=(.*)/);
die "bad parameter spec: $def\n" if (!defined($name));
$parameters{$name} = $value;
}
}
######################################################################
# read in XML structure
if (!-f $opts{'c'}) {
print STDERR "Can't find a configuration file: $opts{'c'} (use the -c flag to specify one)\n";
exit 1;
}
my $relinfo = XMLin($opts{'c'}, @XMLinopts);
######################################################################
# Process steps
my $makerelease = new Makerelease(opts => \%opts, parameters => \%parameters);
if ($makerelease->test_steps($relinfo,'')) {
print STDERR
"Can not continue; release step instructions contained errors\n";
exit 1;
}
exit 0 if ($opts{'t'});
if ($opts{'T'}) {
$makerelease->print_toc($relinfo,'');
exit;
}
$makerelease->process_steps($relinfo,'');
#######################################################################
# getopt long gui portability code
#
sub LocalGetOptions {
if (eval {require Getopt::GUI::Long;}) {
import Getopt::GUI::Long;
Getopt::GUI::Long::Configure(qw(display_help no_ignore_case));
return GetOptions(@_);
} else {
require Getopt::Long;
Getopt::Long::Configure(qw(auto_help no_ignore_case));
import Getopt::Long;
}
GetOptions(LocalOptionsMap(@_));
}
sub LocalOptionsMap {
my ($st, $cb, @opts) = ((ref($_[0]) eq 'HASH')
? (1, 1, $_[0]) : (0, 2));
for (my $i = $st; $i <= $#_; $i += $cb) {
if ($_[$i]) {
next if (ref($_[$i]) eq 'ARRAY' && $_[$i][0] =~ /^GUI:/);
push @opts, ((ref($_[$i]) eq 'ARRAY') ? $_[$i][0] : $_[$i]);
push @opts, $_[$i+1] if ($cb == 2);
}
}
return @opts;
}