5c5d158b1b
Before patch: -D and -d are mistaken for --debug $ sudo DEB_BUILD_OPTIONS=nocheck ./debian/build-git-snapshot -r ~/debian -v 19.06~git --autoversion -d -D="stretch" Option d does not take an argument git status --porcelain -unormal git rev-parse --short=8 HEAD dch --force-distribution -D "squeeze-dev" -v "19.06~git+20190627205913.466f99e4-1" "Building git snapshot." dch warning: Recognised distributions are: experimental, unstable, testing, stable, oldstable, oldoldstable, {bullseye,buster,stretch,jessie,wheezy}-proposed-updates, {testing,stable,oldstable,oldoldstable}-proposed-updates, {bullseye,buster,stretch,jessie,wheezy}-security, {testing,stable,oldstable,oldoldstable}}-security, jessie-backports, stretch-backports and UNRELEASED. Using your request anyway. NOTE: squeeze-dev in the first dch line and warning about Option d. Apply patch: -D and -d are differentiated correctly. $ sudo DEB_BUILD_OPTIONS=nocheck ./debian/build-git-snapshot -r ~/debian -v 19.06~git --autoversion -d -D="stretch" git status --porcelain -unormal git rev-parse --short=8 HEAD dch --force-distribution -D "stretch" -v "19.06~git+20190627210316.b3f919a7-1" "Building git snapshot." dch warning: Previous package version was Debian native whilst new version is not dch -r "Building git snapshot." NOTE: No more 'Option d' error, and "stretch" in the first dch line. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
156 lines
4.6 KiB
Perl
Executable file
156 lines
4.6 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# Copyright 2010 Catalyst IT Ltd.
|
|
#
|
|
# This file is part of Koha.
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
|
|
|
# Written by Robin Sheat <robin@catalyst.net.nz> and
|
|
# Srdjan Jankovic <srdjan@catalyst.net.nz>
|
|
# Based on an sh version by Lars Wirzenius.
|
|
|
|
use Modern::Perl;
|
|
|
|
use Getopt::Long qw(:config no_ignore_case);
|
|
use POSIX qw/strftime/;
|
|
|
|
my $basetgz;
|
|
my $buildresult;
|
|
my $distribution='squeeze-dev';
|
|
my $git_checks='all';
|
|
my $version='16.06~git';
|
|
my $auto_version=1;
|
|
my $need_help;
|
|
my $debug;
|
|
|
|
GetOptions(
|
|
'basetgz|b=s' => \$basetgz,
|
|
'buildresult|r=s' => \$buildresult,
|
|
'distribution|D=s' => \$distribution,
|
|
'git-checks|g=s' => \$git_checks,
|
|
'version|v=s' => \$version,
|
|
'autoversion!' => \$auto_version,
|
|
'help|h' => \$need_help,
|
|
'debug|d' => \$debug,
|
|
);
|
|
|
|
help_and_exit() if $need_help;
|
|
|
|
|
|
sub sys_command_output {
|
|
my ($command) = @_;
|
|
|
|
print "$command\n" if $debug;
|
|
my $command_output;
|
|
open($command_output, "-|", "$command ")
|
|
or die qq{Cannot execute "$command": $!"};
|
|
return map { chomp; $_ } <$command_output>;
|
|
}
|
|
|
|
sub sys_command_output_screen {
|
|
my ($command) = @_;
|
|
|
|
print "$command\n" if $debug;
|
|
system($command) == 0 or die "Command '$command' returns an error ($?)\n";
|
|
}
|
|
|
|
sub everything_is_committed {
|
|
my $filter;
|
|
for ($git_checks) {
|
|
$_ eq "none"
|
|
and return 1;
|
|
|
|
$_ eq "modified"
|
|
and $filter = "no",
|
|
last;
|
|
|
|
$_ eq "all"
|
|
and $filter = "normal",
|
|
last;
|
|
|
|
help_and_exit("$0: --git-checks/-g must be one of 'all', 'modified', or 'none'");
|
|
}
|
|
my $has_changes = grep /^xxx/, sys_command_output("git status --porcelain -u${filter}");
|
|
|
|
return !$has_changes;
|
|
}
|
|
|
|
sub help_and_exit {
|
|
my $msg = shift;
|
|
if ($msg) {
|
|
print "$msg\n\n";
|
|
}
|
|
print <<EOH;
|
|
This builds Koha deb packages, from a git snapshot. It's not suitable for
|
|
making upstreamable verions, but handy for your own local packages.
|
|
|
|
Options:
|
|
--buildresult, -r
|
|
the location that the resulting .deb, .changes, etc. will be placed in.
|
|
Default is whatever pdebuild uses.
|
|
--distribution, -D
|
|
the distribution value to set in the changelog when editing it. Default
|
|
is 'squeeze-dev'.
|
|
--git-checks, -g
|
|
what level of git checks are run to determine if the working copy is
|
|
clean enough. One of 'all' (any changes are bad), 'modified' (only
|
|
tracked files with untracked changes will cause an error), and 'none'
|
|
(checking git status is skipped totally.) Default is 'all'.
|
|
--version, -v
|
|
the version string for the resulting package. Default is '$version'.
|
|
--(no)autoversion
|
|
whether or not to use the date and git commit ID in the version value.
|
|
Default is to include it.
|
|
--debug, -d
|
|
EOH
|
|
exit;
|
|
}
|
|
|
|
sub latest_sha1 {
|
|
return sys_command_output("git rev-parse --short=8 HEAD");
|
|
}
|
|
|
|
sub adjust_debian_changelog {
|
|
my ($newversion) = @_;
|
|
# debian revision
|
|
$newversion .= "-1";
|
|
|
|
sys_command_output( qq{dch --force-distribution -D "$distribution" -v "$newversion" "Building git snapshot."} );
|
|
sys_command_output( qq{dch -r "Building git snapshot."} );
|
|
}
|
|
|
|
sub reset_debian_changelog {
|
|
sys_command_output( qq{git checkout -- debian/changelog} );
|
|
}
|
|
|
|
sub build_package {
|
|
my ($newversion) = @_;
|
|
sys_command_output( qq{git archive --format=tar --prefix="koha-$newversion/" HEAD | gzip -9 > "../koha_$newversion.orig.tar.gz"} );
|
|
|
|
my $pdebuildopts = $buildresult ? "--buildresult $buildresult" : "";
|
|
my $pdebuildbasetgz = $basetgz ? "-- --basetgz /var/cache/pbuilder/" . $basetgz . ".tgz" : "";
|
|
sys_command_output_screen( "pdebuild $pdebuildbasetgz $pdebuildopts" );
|
|
}
|
|
|
|
everything_is_committed() or die "cannot build: uncommited changes";
|
|
|
|
my $newversion = $auto_version
|
|
? sprintf ('%s%s.%s', $version, strftime("+%Y%m%d%H%M%S", localtime), latest_sha1())
|
|
: $version;
|
|
|
|
adjust_debian_changelog( $newversion );
|
|
build_package( $newversion );
|
|
reset_debian_changelog();
|
|
|