Bugzilla – Attachment 82620 Details for
Bug 21876
Untracked changes prevent building
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21876: tweak the build script
Bug-21876-tweak-the-build-script.patch (text/plain), 8.57 KB, created by
Mark Tompsett
on 2018-11-23 20:03:05 UTC
(
hide
)
Description:
Bug 21876: tweak the build script
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2018-11-23 20:03:05 UTC
Size:
8.57 KB
patch
obsolete
>From dd10dc0d271c46e7c77e591d01778e677398d191 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Fri, 23 Nov 2018 11:18:37 -0500 >Subject: [PATCH] Bug 21876: tweak the build script > >While trying to build following the instructions on the wiki, >error after error was encountered, and frustration rose. >Eventually, tcohen mentioned untracked files. So, all untracked >files were purposefully deleted all, and then building succeeded >again. > >To this end, the build script wa tweaked. > >1) Sorry, a bunch of perlcritic things to get it > perlcritic -2 clear were done. :) > >Proof: >perlcritic -1 debian/build-git-snapshot >-- fear the long scrolly output >apply the patch >repeat >-- much shorter, and who cares about the print return value! >perlcritic -2 debian/build-git-snapshot >-- OK. YAY! > >2) everything_is_committed was broken. It would always > return 1 and keep going. > >Proof: >touch foobar. >add a blank line to Koha.pm >now try to build. It will spend minutes and die miserably at the end. > >To address this, it was tweaked to check for two cases: >uncommitted and untracked. You can test this with a combination >of touch foobar and blank line to Koha.pm to see. > >3) While not a huge issue, the version should be better determined > rather than hard coded as 16.06~git. Logic was added to > better determine something based on Koha.pm through grep'ing, > so as to not need PERL5LIB set. > >Proof: >Try checking out 17.11.x >apply this patch (hopefully it does) >try to build without a -v parameter. >-- it should generate 17.11~git >Feel free to repeat with 18.05 and master >they should generate 18.05~git and 18.06~git > >As always run the qa test tools. ;) >Oh wait, they don't run unless you rename this to a .pl file. >I guess that's another bug. And if you do rename to test, >it should only complain about Robin's last name. >--- > debian/build-git-snapshot | 155 ++++++++++++++++++++++++++++++---------------- > 1 file changed, 102 insertions(+), 53 deletions(-) > >diff --git a/debian/build-git-snapshot b/debian/build-git-snapshot >index 0ae2197355..f9ca54a949 100755 >--- a/debian/build-git-snapshot >+++ b/debian/build-git-snapshot >@@ -1,4 +1,4 @@ >-#!/usr/bin/perl >+#!/usr/bin/perl > > # Copyright 2010 Catalyst IT Ltd. > # >@@ -23,76 +23,98 @@ > > use Modern::Perl; > >+use Carp; >+use English qw( -no_match_vars ); >+use File::Basename qw/dirname/; >+use File::Spec qw/rel2abs/; > use Getopt::Long; > use POSIX qw/strftime/; > >+our $VERSION = '1.1'; # Just to perlcritic -2 :) > my $basetgz; > my $buildresult; >-my $distribution='squeeze-dev'; >-my $git_checks='all'; >-my $version='16.06~git'; >-my $auto_version=1; >+my $distribution = 'jessie'; >+my $git_checks = 'all'; >+my $version; >+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, >+ '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; >+if ($need_help) { >+ help_and_exit(); >+} > >+if ( $git_checks ne 'all' >+ && $git_checks ne 'modified' >+ && $git_checks ne 'none' ) >+{ >+ help_and_exit( >+"$PROGRAM_NAME: --git-checks/-g must be one of 'all', 'modified', or 'none'" >+ ); >+} > > 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>; >+ if ($debug) { >+ print "$command\n"; >+ } >+ open my $command_output, q{-|}, >+ "$command " || croak qq{Cannot execute "$command": $OS_ERROR}; >+ my @output = <$command_output>; >+ chomp @output; >+ close $command_output || croak 'Difficulty closing command handle'; >+ if ($debug) { >+ print "output: @output\n"; >+ } >+ return @output; > } > > sub sys_command_output_screen { > my ($command) = @_; > >- print "$command\n" if $debug; >- system($command) == 0 or die "Command '$command' returns an error ($?)\n"; >+ if ($debug) { >+ print "$command\n"; >+ } >+ return system($command) == 0 >+ || croak "Command '$command' returns an error ($CHILD_ERROR)\n"; > } > > sub everything_is_committed { >+ my ($check_type) = @_; >+ my %filters; > my $filter; >- for ($git_checks) { >- $_ eq "none" >- and return 1; >- >- $_ eq "modified" >- and $filter = "no", >- last; >+ $filters{'uncommitted'} = 'no'; >+ $filters{'untracked'} = 'normal'; >+ $filter = $filters{$check_type}; > >- $_ eq "all" >- and $filter = "normal", >- last; >+ # No header, so wc -l generates a count of the changes. >+ my ($has_changes) = >+ sys_command_output("git status --porcelain -u${filter} | wc -l"); > >- help_and_exit("$0: --git-checks/-g must be one of 'all', 'modified', or 'none'"); >+ if ($debug) { >+ print "has changes: $has_changes\n"; > } >- 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"; >+ my $msg = shift; >+ if ($msg) { >+ print "$msg\n\n"; > } >- print <<EOH; >+ 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. > >@@ -119,38 +141,65 @@ EOH > } > > sub latest_sha1 { >- return sys_command_output("git rev-parse --short=8 HEAD"); >+ return sys_command_output('git rev-parse --short=8 HEAD'); > } > > sub adjust_debian_changelog { > my ($newversion) = @_; >+ > # debian revision >- $newversion .= "-1"; >+ $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."} ); >+ sys_command_output( >+qq{dch --force-distribution -D "$distribution" -v "$newversion" "Building git snapshot."} >+ ); >+ sys_command_output(qq{dch -r "Building git snapshot."}); >+ return; > } > > sub reset_debian_changelog { >- sys_command_output( qq{git checkout -- debian/changelog} ); >+ sys_command_output('git checkout -- debian/changelog'); >+ return; > } > > 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" ); >+ sys_command_output( >+qq{git archive --format=tar --prefix="koha-$newversion/" HEAD | gzip -9 > "../koha_$newversion.orig.tar.gz"} >+ ); >+ >+ my $pdebuildopts = $buildresult ? "--buildresult $buildresult" : q{}; >+ my $pdebuildbasetgz = >+ $basetgz ? '-- --basetgz /var/cache/pbuilder/' . $basetgz . '.tgz' : q{}; >+ sys_command_output_screen("pdebuild $pdebuildbasetgz $pdebuildopts"); >+ return; > } > >-everything_is_committed() or die "cannot build: uncommited changes"; >+# This logic doesn't require PERL5LIB set correctly. >+my $path_name = File::Spec->rel2abs($PROGRAM_NAME); > >-my $newversion = $auto_version >- ? sprintf ('%s%s.%s', $version, strftime("+%Y%m%d%H%M%S", localtime), latest_sha1()) >+# Koha.pm is always up a directory from this script. >+my $koha_file = dirname( dirname($path_name) ) . '/Koha.pm'; >+($version) = sys_command_output( >+ qq{grep VERSION $koha_file | grep = | cut -f2 -d\\\" | cut -f1-2 -d.}); >+$version .= '~git'; # YY.MM~git >+ >+if ( $git_checks ne 'none' ) { >+ everything_is_committed('uncommitted') >+ || croak 'cannot build: uncommited changes'; >+} >+if ( $git_checks eq 'all' ) { >+ everything_is_committed('untracked') >+ || croak 'cannot build: untracked 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 ); >+adjust_debian_changelog($newversion); >+build_package($newversion); > reset_debian_changelog(); >- >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21876
: 82620