From bbfb4a8d4e4522bfbdf51aedad93e833a2fbcc21 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Mon, 27 Feb 2023 21:48:16 +0100 Subject: [PATCH] parallel: rsync version 3.2.7 support. --- doc/haikus | 19 +++++++ doc/release_new_version | 4 +- src/parallel | 53 ++++++++++++------- testsuite/tests-to-run/parallel-local-ssh4.sh | 21 ++++++++ 4 files changed, 75 insertions(+), 22 deletions(-) diff --git a/doc/haikus b/doc/haikus index ab70ffe6..0b081af2 100644 --- a/doc/haikus +++ b/doc/haikus @@ -4,7 +4,26 @@ Quote of the month: + Recently learned how to use GNU parallel (from ChatGPT, no less!) and I've gone mad with power + -- Mark, Anthropomorphic Anuran @reject_resubmit@twitter + gnu parallel is actually like. really easy + -- tom (era) @slimefiend@twitter + + GNU parallel is magic, half of my work uses it, to the point where they're referenced and thanked in my thesis + -- Best Catboy Key Grip @alamogordoglass@twitter + + Love to make a dual processor workstation absolutely whir running dozens of analysis scripts at once + -- Best Catboy Key Grip @alamogordoglass@twitter + + i really didn't expect it to be as simple as it is, took me all of 5 minutes to implement and the results are exactly what i wanted + + gnu parallel babey, it's really simple actually lol + -- tom (era) @slimefiend@twitter + + GNU parallel is your friend. Unleash your cores! #GNU + -- Blake L @BlakeDL@twitter + --line-buffer, a flag parallel, now more precise diff --git a/doc/release_new_version b/doc/release_new_version index ffcea9e1..f7572292 100644 --- a/doc/release_new_version +++ b/doc/release_new_version @@ -262,9 +262,9 @@ from:tange@gnu.org to:parallel@gnu.org, bug-parallel@gnu.org stable-bcc: Jesse Alama -Subject: GNU Parallel 20230222 ('Gaziantep') released +Subject: GNU Parallel 20230322 ('Grækenland Larissa tog/Tiktok?') released -GNU Parallel 20230222 ('Gaziantep') has been released. It is available for download at: lbry://@GnuParallel:4 +GNU Parallel 20230322 ('<<>>') has been released. It is available for download at: lbry://@GnuParallel:4 Quote of the month: diff --git a/src/parallel b/src/parallel index 050bc771..152c70fb 100755 --- a/src/parallel +++ b/src/parallel @@ -5876,9 +5876,6 @@ sub citation() { "https://lists.gnu.org/archive/html/parallel/2013-11/msg00006.html", "https://www.gnu.org/software/parallel/parallel_design.html#citation-notice", "https://git.savannah.gnu.org/cgit/parallel.git/tree/doc/citation-notice-faq.txt", - "", - "If you send a copy of your published article to tange\@gnu.org, it will be", - "mentioned in the release notes of next version of GNU Parallel.", "" ); while(not grep { -e "$_/will-cite" } @Global::config_dirs) { @@ -8833,15 +8830,17 @@ sub rsync_transfer_cmd($) { } { - my $rsync_protocol; + my $rsync_fix; + my $rsync_version; sub rsync($) { - sub rsync_protocol { - # rsync 3.1.x uses protocol 31 which is unsupported by 2.5.7. - # If the version >= 3.1.0: downgrade to protocol 30 - # Returns: - # $rsync = "rsync" or "rsync --protocol 30" - if(not $rsync_protocol) { + # rsync 3.1.x uses protocol 31 which is unsupported by 2.5.7. + # If the version >= 3.1.0: downgrade to protocol 30 + # rsync 3.2.4 introduces a quoting bug: Add --old-args for that + # Returns: + # $rsync = "rsync" or "rsync --protocol 30 --old-args" + sub rsync_version { + if(not $rsync_version) { my @out = `rsync --version`; if(not @out) { if(::which("rsync")) { @@ -8854,23 +8853,37 @@ sub rsync_transfer_cmd($) { for (@out) { # rsync version 3.1.3 protocol version 31 # rsync version v3.2.3 protocol version 31 - if(/version v?(\d+.\d+)(.\d+)?/) { - if($1 >= 3.1) { - # Version 3.1.0 or later: Downgrade to protocol 30 - $rsync_protocol = "rsync --protocol 30"; - } else { - $rsync_protocol = "rsync"; - } + if(/version v?(\d+)\.(\d+)(\.(\d+))?/) { + # 3.2.27 => 03.0227 + $rsync_version = sprintf "%02d.%02d%02d",$1,$2,$4; } } - $rsync_protocol or + $rsync_version or ::die_bug("Cannot figure out version of rsync: @out"); } - return $rsync_protocol; + } + + sub rsync_fixup { + # rsync 3.1.x uses protocol 31 which is unsupported by 2.5.7. + # If the version >= 3.1.0: downgrade to protocol 30 + # Returns: + # $rsync = "rsync" or "rsync --protocol 30" + if(not $rsync_fix) { + rsync_version(); + if($rsync_version >= 3.01) { + # Version 3.1.0 or later: Downgrade to protocol 30 + $rsync_fix .= " --protocol 30"; + } + if($rsync_version >= 3.0204) { + # Version 3.2.4 .. 3.2.8: --old-args + $rsync_fix .= " --old-args"; + } + } + return $rsync_fix; } my $self = shift; - return rsync_protocol()." ".$ENV{'PARALLEL_RSYNC_OPTS'}. + return "rsync".rsync_fixup()." ".$ENV{'PARALLEL_RSYNC_OPTS'}. " -e".::Q($self->sshcmd()); } } diff --git a/testsuite/tests-to-run/parallel-local-ssh4.sh b/testsuite/tests-to-run/parallel-local-ssh4.sh index 6bc58d6a..556b9380 100644 --- a/testsuite/tests-to-run/parallel-local-ssh4.sh +++ b/testsuite/tests-to-run/parallel-local-ssh4.sh @@ -21,6 +21,27 @@ par_z_sshloginfile() { rm -f "$tmp" } +par__test_different_rsync_versions() { + echo '### different versions of rsync need fixups' + echo '### no output is good' + doit() { + rm -f 'a`b`c\ "$tmp"/rsync + chmod +x "$tmp"/rsync + PATH="$tmp":"$PATH" + parallel --trc {}.out -S sh@lo cp {} {}.out ::: 'a`b`c\