From fd3f3bb1ef896c82312ed09bfa85d3bf9665800f Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 26 Apr 2018 23:02:53 +0200 Subject: [PATCH] chg: tries to see if GIT is installed. Simplified substring. --- tools/mkversion.pl | 51 ++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/tools/mkversion.pl b/tools/mkversion.pl index 2a47903ca..791fe09fe 100644 --- a/tools/mkversion.pl +++ b/tools/mkversion.pl @@ -1,4 +1,5 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w + # Output a version.c file that includes information about the current build # Normally a couple of lines of bash would be enough (see openpcd project, original firmware by Harald Welte and Milosch Meriac) # but this will, at least in theory, also work on Windows with our current compile environment. @@ -12,35 +13,45 @@ $ENV{'LC_ALL'} = "C"; $ENV{'LANG'} = "C"; -my $githistory = `git fetch --all`; -my $gitversion = `git describe --dirty`; -my $gitbranch = `git rev-parse --abbrev-ref HEAD`; -my $clean = $gitversion =~ '-dirty' ? 0 : 1; -my $ctime = ''; - # if you are making your own fork, change this line to reflect your fork-name my $fullgitinfo = 'iceman'; +my $ctime = ''; +# GIT status 0 = dirty, 1 = clean , 2 = undecided +my $clean = 2; +# Do we have acces to git command? +my $commandGIT = `sh which git`; -if ( defined $gitbranch and defined $gitversion ) { - $fullgitinfo = $fullgitinfo.'/'. $gitbranch . '/' . $gitversion; +if ( defined($commandGIT) ) { - my @compiletime = localtime(); - $compiletime[4] += 1; - $compiletime[5] += 1900; - $ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @compiletime); + my $githistory = `git fetch --all`; + my $gitversion = `git describe --dirty`; + my $gitbranch = `git rev-parse --abbrev-ref HEAD`; + $clean = $gitversion =~ '-dirty' ? 0 : 1; + + if ( defined($gitbranch) and defined($gitversion) ) { + $fullgitinfo = $fullgitinfo.'/'. $gitbranch . '/' . $gitversion; + + my @compiletime = localtime(); + $compiletime[4] += 1; + $compiletime[5] += 1900; + $ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @compiletime); + } else { + $fullgitinfo = $fullgitinfo.'/master/release (git)'; + } } else { - $fullgitinfo = $fullgitinfo.'/master/release-build (no_git)'; - - my @dl_time = localtime( (stat('../README.md'))[10] ); - $dl_time[4] += 1; - $dl_time[5] += 1900; - $ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @dl_time); + $fullgitinfo = $fullgitinfo.'/master/release (no_git)'; } +my @dl_time = localtime( (stat('../README.md'))[10] ); +$dl_time[4] += 1; +$dl_time[5] += 1900; +$ctime = sprintf("%6\$04i-%5\$02i-%4\$02i %3\$02i:%2\$02i:%1\$02i", @dl_time); + $fullgitinfo =~ s/(\s)//g; # Crop so it fits within 50 characters -$fullgitinfo =~ s/.{50}\K.*//s; +#$fullgitinfo =~ s/.{50}\K.*//s; +$fullgitinfo = substr $fullgitinfo, 0, 49; print <