X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=debian%2Fbuild-git-snapshot;h=cedddae525b838e9b07597c2e83c9938e2821830;hb=d66ea510b3167cce3a52f147e8cd487fa9676168;hp=4b63141a339a17f9ae6a81028c094e68d010b0f9;hpb=604d871d27b715369f8d4e4636cb5e1799bbf7ae;p=koha-ffzg.git diff --git a/debian/build-git-snapshot b/debian/build-git-snapshot index 4b63141a33..cedddae525 100755 --- a/debian/build-git-snapshot +++ b/debian/build-git-snapshot @@ -1,60 +1,156 @@ -#!/bin/sh +#!/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. # -# This script will build a .deb from a git snapshot of koha. -# Don't use it for building actual versions for uploading to Debian. +# 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. # -# To use: -# - commit any changes into git -# - run this script +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +# Written by Robin Sheat and +# Srdjan Jankovic +# 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) = @_; -set -e + 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) = @_; -die() -{ - echo "$@" - exit 1 + print "$command\n" if $debug; + system($command) == 0 or die "Command '$command' returns an error ($?)\n"; } -everything_is_commited() -{ - if git status --short | grep -q '^' - then - return 1 - else - return 0 - fi +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; } -latest_sha1() { - git rev-parse --short=8 HEAD +sub help_and_exit { + my $msg = shift; + if ($msg) { + print "$msg\n\n"; + } + print < "../koha_$1.tar.gz" - pdebuild +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" ); } -if ! everything_is_commited -then - die "cannot build: uncommited changes" -fi +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(); -version="$(newversion)" -adjust_debian_changelog "$version" -build_package "$version" -reset_debian_changelog