Lines 24-69
Link Here
|
24 |
use Modern::Perl; |
24 |
use Modern::Perl; |
25 |
|
25 |
|
26 |
use Getopt::Long qw(:config no_ignore_case); |
26 |
use Getopt::Long qw(:config no_ignore_case); |
27 |
use POSIX qw/strftime/; |
27 |
use POSIX qw/strftime/; |
28 |
|
28 |
|
29 |
my $basetgz; |
29 |
my $basetgz; |
30 |
my $buildresult; |
30 |
my $buildresult; |
31 |
my $distribution='testing'; |
31 |
my $distribution = 'testing'; |
32 |
my $git_checks='all'; |
32 |
my $git_checks = 'all'; |
33 |
my $version='16.06~git'; |
33 |
my $version = '16.06~git'; |
34 |
my $auto_version=1; |
34 |
my $auto_version = 1; |
35 |
my $auto_changelog=1; |
35 |
my $auto_changelog = 1; |
36 |
my $need_help; |
36 |
my $need_help; |
37 |
my $incr; |
37 |
my $incr; |
38 |
my $urgency='medium'; |
38 |
my $urgency = 'medium'; |
39 |
my $debug; |
39 |
my $debug; |
40 |
|
40 |
|
41 |
my $release_str; |
41 |
my $release_str; |
42 |
|
42 |
|
43 |
GetOptions( |
43 |
GetOptions( |
44 |
'basetgz|b=s' => \$basetgz, |
44 |
'basetgz|b=s' => \$basetgz, |
45 |
'buildresult|r=s' => \$buildresult, |
45 |
'buildresult|r=s' => \$buildresult, |
46 |
'distribution|D=s' => \$distribution, |
46 |
'distribution|D=s' => \$distribution, |
47 |
'git-checks|g=s' => \$git_checks, |
47 |
'git-checks|g=s' => \$git_checks, |
48 |
'version|v=s' => \$version, |
48 |
'version|v=s' => \$version, |
49 |
'incr|i=s' => \$incr, |
49 |
'incr|i=s' => \$incr, |
50 |
'urgency|u=s' => \$urgency, |
50 |
'urgency|u=s' => \$urgency, |
51 |
'autoversion!' => \$auto_version, |
51 |
'autoversion!' => \$auto_version, |
52 |
'autochangelog!' => \$auto_changelog, |
52 |
'autochangelog!' => \$auto_changelog, |
53 |
'help|h' => \$need_help, |
53 |
'help|h' => \$need_help, |
54 |
'debug|d' => \$debug, |
54 |
'debug|d' => \$debug, |
55 |
); |
55 |
); |
56 |
|
56 |
|
57 |
help_and_exit() if $need_help; |
57 |
help_and_exit() if $need_help; |
58 |
|
58 |
|
59 |
|
|
|
60 |
sub sys_command_output { |
59 |
sub sys_command_output { |
61 |
my ($command) = @_; |
60 |
my ($command) = @_; |
62 |
|
61 |
|
63 |
print "$command\n" if $debug; |
62 |
print "$command\n" if $debug; |
64 |
my $command_output; |
63 |
my $command_output; |
65 |
open($command_output, "-|", "$command ") |
64 |
open( $command_output, "-|", "$command " ) |
66 |
or die qq{Cannot execute "$command": $!"}; |
65 |
or die qq{Cannot execute "$command": $!"}; |
67 |
return map { chomp; $_ } <$command_output>; |
66 |
return map { chomp; $_ } <$command_output>; |
68 |
} |
67 |
} |
69 |
|
68 |
|
Lines 78-94
sub everything_is_committed {
Link Here
|
78 |
my $filter; |
77 |
my $filter; |
79 |
for ($git_checks) { |
78 |
for ($git_checks) { |
80 |
$_ eq "none" |
79 |
$_ eq "none" |
81 |
and return 1; |
80 |
and return 1; |
82 |
|
81 |
|
83 |
$_ eq "modified" |
82 |
$_ eq "modified" |
84 |
and $filter = "no", |
83 |
and $filter = "no", |
85 |
last; |
84 |
last; |
86 |
|
85 |
|
87 |
$_ eq "all" |
86 |
$_ eq "all" |
88 |
and $filter = "normal", |
87 |
and $filter = "normal", |
89 |
last; |
88 |
last; |
90 |
|
89 |
|
91 |
help_and_exit("$0: --git-checks/-g must be one of 'all', 'modified', or 'none'"); |
90 |
help_and_exit("$0: --git-checks/-g must be one of 'all', 'modified', or 'none'"); |
92 |
} |
91 |
} |
93 |
my $has_changes = grep /^xxx/, sys_command_output("git status --porcelain -u${filter}"); |
92 |
my $has_changes = grep /^xxx/, sys_command_output("git status --porcelain -u${filter}"); |
94 |
|
93 |
|
Lines 96-104
sub everything_is_committed {
Link Here
|
96 |
} |
95 |
} |
97 |
|
96 |
|
98 |
sub help_and_exit { |
97 |
sub help_and_exit { |
99 |
my $msg = shift; |
98 |
my $msg = shift; |
100 |
if ($msg) { |
99 |
if ($msg) { |
101 |
print "$msg\n\n"; |
100 |
print "$msg\n\n"; |
102 |
} |
101 |
} |
103 |
print <<EOH; |
102 |
print <<EOH; |
104 |
This builds Koha deb packages, from a git snapshot. It's not suitable for |
103 |
This builds Koha deb packages, from a git snapshot. It's not suitable for |
Lines 139-174
sub latest_sha1 {
Link Here
|
139 |
|
138 |
|
140 |
sub adjust_debian_changelog { |
139 |
sub adjust_debian_changelog { |
141 |
my ($newversion) = @_; |
140 |
my ($newversion) = @_; |
142 |
$newversion .= $incr ? "-$incr" : "-1"; |
141 |
$newversion .= $incr ? "-$incr" : "-1"; |
143 |
|
142 |
|
144 |
$release_str = "New upstream "; |
143 |
$release_str = "New upstream "; |
145 |
$release_str .= 'SECURITY ' if $urgency eq 'high'; |
144 |
$release_str .= 'SECURITY ' if $urgency eq 'high'; |
146 |
$release_str .= "release ($version)"; |
145 |
$release_str .= "release ($version)"; |
147 |
|
146 |
|
148 |
sys_command_output( qq{dch --urgency $urgency -b --force-distribution -D "$distribution" -v "$newversion" "$release_str"} ); |
147 |
sys_command_output( |
149 |
sys_command_output( qq{dch -r "$release_str"} ); |
148 |
qq{dch --urgency $urgency -b --force-distribution -D "$distribution" -v "$newversion" "$release_str"}); |
|
|
149 |
sys_command_output(qq{dch -r "$release_str"}); |
150 |
} |
150 |
} |
151 |
|
151 |
|
152 |
sub reset_debian_changelog { |
152 |
sub reset_debian_changelog { |
153 |
sys_command_output( qq{git checkout -- debian/changelog} ); |
153 |
sys_command_output(qq{git checkout -- debian/changelog}); |
154 |
} |
154 |
} |
155 |
|
155 |
|
156 |
sub build_package { |
156 |
sub build_package { |
157 |
my ($newversion) = @_; |
157 |
my ($newversion) = @_; |
158 |
sys_command_output( qq{git archive --format=tar --prefix="koha-$newversion/" HEAD | gzip -9 > "../koha_$newversion.orig.tar.gz"} ); |
158 |
sys_command_output( |
|
|
159 |
qq{git archive --format=tar --prefix="koha-$newversion/" HEAD | gzip -9 > "../koha_$newversion.orig.tar.gz"}); |
159 |
|
160 |
|
160 |
my $pdebuildopts = $buildresult ? "--buildresult $buildresult" : ""; |
161 |
my $pdebuildopts = $buildresult ? "--buildresult $buildresult" : ""; |
161 |
my $pdebuildbasetgz = $basetgz ? "-- --use-network yes --basetgz /var/cache/pbuilder/" . $basetgz . ".tgz" : ""; |
162 |
my $pdebuildbasetgz = $basetgz ? "-- --use-network yes --basetgz /var/cache/pbuilder/" . $basetgz . ".tgz" : ""; |
162 |
sys_command_output_screen( "pdebuild --debbuildopts -sa $pdebuildbasetgz $pdebuildopts" ); |
163 |
sys_command_output_screen("pdebuild --debbuildopts -sa $pdebuildbasetgz $pdebuildopts"); |
163 |
} |
164 |
} |
164 |
|
165 |
|
165 |
everything_is_committed() or die "cannot build: uncommited changes"; |
166 |
everything_is_committed() or die "cannot build: uncommited changes"; |
166 |
|
167 |
|
167 |
my $newversion = $auto_version |
168 |
my $newversion = |
168 |
? sprintf ('%s%s.%s', $version, strftime("+%Y%m%d%H%M%S", localtime), latest_sha1()) |
169 |
$auto_version |
169 |
: $version; |
170 |
? sprintf( '%s%s.%s', $version, strftime( "+%Y%m%d%H%M%S", localtime ), latest_sha1() ) |
|
|
171 |
: $version; |
170 |
|
172 |
|
171 |
adjust_debian_changelog( $newversion ) if $auto_changelog; |
173 |
adjust_debian_changelog($newversion) if $auto_changelog; |
172 |
build_package( $newversion ); |
174 |
build_package($newversion); |
173 |
reset_debian_changelog(); |
175 |
reset_debian_changelog(); |
174 |
|
176 |
|
175 |
- |
|
|