X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=dgit;h=9d8f9d428e4f6752fe247ecc2133f91b0b47e9b0;hp=930a59440e776d5145d2c277e8b442eb95ccad95;hb=ece82c50afff320eaf1cd09ba540e10f24984b60;hpb=b2e1996507c2a614cdec9ec328a35c5db7456e04 diff --git a/dgit b/dgit index 930a5944..9d8f9d42 100755 --- a/dgit +++ b/dgit @@ -177,6 +177,13 @@ sub changedir ($) { chdir $newdir or die "chdir: $newdir: $!"; } +sub stat_exists ($) { + my ($f) = @_; + return 1 if stat $f; + return 0 if $!==&ENOENT; + die "stat $f: $!"; +} + #---------- remote protocol support, common ---------- # remote push initiator/responder protocol: @@ -766,7 +773,7 @@ sub madison_parse ($) { $5 eq 'source' or die "$rmad ?"; push @out, [$vsn,pool_dsc_subpath($vsn,$component),$newsuite]; } - return sort { -version_compare_string($a->[0],$b->[0]); } @out; + return sort { -version_compare($a->[0],$b->[0]); } @out; } sub canonicalise_suite_madison ($$) { @@ -824,7 +831,7 @@ sub archive_query_sshpsql ($$) { AND source.source='$package' AND files.filename LIKE '%.dsc'; END - @rows = sort { -version_compare_string($a->[0],$b->[0]) } @rows; + @rows = sort { -version_compare($a->[0],$b->[0]) } @rows; my $digester = Digest::SHA->new(256); @rows = map { my ($vsn,$component,$filename,$sha256sum) = @$_; @@ -882,7 +889,7 @@ sub archive_query_dummycat ($$) { } C->error and die "$dpath: $!"; close C; - return sort { -version_compare_string($a->[0],$b->[0]); } @rows; + return sort { -version_compare($a->[0],$b->[0]); } @rows; } sub canonicalise_suite () { @@ -969,6 +976,12 @@ sub prep_ud () { mkdir $ud or die $!; } +sub mktree_in_ud_here () { + runcmd qw(git init -q); + rmtree('.git/objects'); + symlink '../../../../objects','.git/objects' or die $!; +} + sub mktree_in_ud_from_only_subdir () { # changes into the subdir my (@dirs) = <*/.>; @@ -976,11 +989,8 @@ sub mktree_in_ud_from_only_subdir () { $dirs[0] =~ m#^([^/]+)/\.$# or die; my $dir = $1; changedir $dir; - fail "source package contains .git directory" if stat '.git'; - die $! unless $!==&ENOENT; - runcmd qw(git init -q); - rmtree('.git/objects'); - symlink '../../../../objects','.git/objects' or die $!; + fail "source package contains .git directory" if stat_exists '.git'; + mktree_in_ud_here(); runcmd @git, qw(add -Af); my $tree = cmdoutput @git, qw(write-tree); $tree =~ m/^\w+$/ or die "$tree ?"; @@ -1018,9 +1028,12 @@ sub dsc_files () { map { $_->{Filename} } dsc_files_info(); } -sub is_orig_file ($) { - local ($_) = @_; - m/\.orig(?:-\w+)?\.tar\.\w+$/; +sub is_orig_file ($;$) { + local ($_) = $_[0]; + my $base = $_[1]; + m/\.orig(?:-\w+)?\.tar\.\w+$/ or return 0; + defined $base or return 1; + return $` eq $base; } sub make_commit ($) { @@ -1096,7 +1109,7 @@ END my $oldclogp = parsecontrol('../changelogold.tmp','previous changelog'); my $oversion = getfield $oldclogp, 'Version'; my $vcmp = - version_compare_string($oversion, $cversion); + version_compare($oversion, $cversion); if ($vcmp < 0) { # git upload/ is earlier vsn than archive, use archive open C, ">../commit2.tmp" or die $!; @@ -1140,11 +1153,9 @@ sub complete_file_from_dsc ($$) { my $tf = "$dstdir/$f"; my $downloaded = 0; - if (stat $tf) { + if (stat_exists $tf) { progress "using existing $f"; } else { - die "$tf $!" unless $!==&ENOENT; - my $furl = $dscurl; $furl =~ s{/[^/]+$}{}; $furl .= "/$f"; @@ -1278,7 +1289,7 @@ END my $gotclogp = parsechangelog("-l$clogf"); my $got_vsn = getfield $gotclogp, 'Version'; printdebug "SKEW CHECK GOT $got_vsn\n"; - if (version_compare_string($got_vsn, $skew_warning_vsn) < 0) { + if (version_compare($got_vsn, $skew_warning_vsn) < 0) { print STDERR <[0] } @vsns; - @vsns = sort { -version_compare_string($a, $b) } @vsns; + @vsns = sort { -version_compare($a, $b) } @vsns; $changes_since_version = $vsns[0]; progress "changelog will contain changes since $vsns[0]"; } else { @@ -2118,8 +2131,9 @@ sub cmd_sbuild { changedir ".."; my $pat = "${package}_".(stripepoch $version)."_*.changes"; if (act_local()) { - stat $dscfn or fail "$dscfn (in parent directory): $!"; - stat $sourcechanges or fail "$sourcechanges (in parent directory): $!"; + stat_exist $dscfn or fail "$dscfn (in parent directory): $!"; + stat_exists $sourcechanges + or fail "$sourcechanges (in parent directory): $!"; foreach my $cf (glob $pat) { next if $cf eq $sourcechanges; unlink $cf or fail "remove $cf: $!"; @@ -2136,7 +2150,7 @@ sub cmd_sbuild { runcmd_ordryrun_local @mergechanges, @changesfiles; my $multichanges = "${package}_".(stripepoch $version)."_multi.changes"; if (act_local()) { - stat $multichanges or fail "$multichanges: $!"; + stat_exists $multichanges or fail "$multichanges: $!"; } printdone "build successful, results in $multichanges\n" or die $!; }