From 343bb293a078c1887af26696e502dedb6c852f10 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 4 Mar 2020 09:54:24 -0500 Subject: [PATCH 1/9] feat(striker-update): add --branch switch --- tools/striker-update | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/tools/striker-update b/tools/striker-update index 93b24f86..1500835c 100755 --- a/tools/striker-update +++ b/tools/striker-update @@ -137,14 +137,14 @@ my $an = AN::Tools->new({ }, url => { # By default, we will read the latest release from 'striker_latest'. If, however, we can't - # access that file, we'll use 'striker_default'. Optionally, the user can request the latest - # master with '--master', in which case we will download the 'striker_master' URL. In all + # access that file, we'll use 'striker_default'. Optionally, the user can request a branch + # with '--branch [branch_name]', in which case we will download the 'striker_source_prefix'.'branch_name' URL. In all # cases, the downloaded file will be saved as 'striker_zip_file'. - striker_default => "https://github.com/ClusterLabs/striker/archive/v2.0.8.zip", - striker_latest => "https://www.alteeve.com/an-repo/striker_latest.txt", - striker_master => "https://codeload.github.com/ClusterLabs/striker/zip/master", - support => "https://alteeve.com/w/Support", - ping_targets => "8.8.8.8,google.com,redhat.com,alteeve.com", + striker_default => "https://github.com/ClusterLabs/striker/archive/v2.0.8.zip", + striker_latest => "https://www.alteeve.com/an-repo/striker_latest.txt", + striker_source_prefix => "https://codeload.github.com/Tsu-ba-me/alteeve-m2/zip/", + support => "https://alteeve.com/w/Support", + ping_targets => "8.8.8.8,google.com,redhat.com,alteeve.com", }, switches => { offline => 0, @@ -323,9 +323,17 @@ if ($an->data->{switches}{'no-refresh'}) print "we will use what is already cached in:\n"; print "- Striker: [".$an->data->{path}{updates}{striker}."]\n\n"; } -elsif (($an->data->{switches}{master}) && (not $an->data->{switches}{offline})) +elsif ((($an->data->{switches}{master}) or ($an->data->{switches}{branch})) && (not $an->data->{switches}{offline})) { - print "We will download the latest source code from GitHub's master branch.\n"; + if ($an->data->{switches}{master}) + { + $an->data->{switches}{branch} = "master"; + } + + $an->data->{url}{striker_branch} = $an->data->{url}{striker_source_prefix} . $an->data->{switches}{branch}; + + print "We will download the latest source code from GitHub's [" . $an->data->{switches}{branch} . "] branch\n"; + print "by accessing URL [" . $an->data->{url}{striker_branch} . "]\n"; print "- NOTE: This should only be done on test and development platforms!\n\n"; } else @@ -425,9 +433,9 @@ if (not $an->data->{sys}{offline}) $an->Log->entry({log_level => 2, message_key => "an_variables_0001", message_variables => { name1 => "striker_source_test", value1 => $striker_source_test, }, file => $THIS_FILE, line => __LINE__}); - if ($an->data->{switches}{master}) + if ($an->data->{switches}{branch}) { - print "- Downloading: [".$an->data->{url}{striker_master}."]\n"; + print "- Downloading: [".$an->data->{url}{striker_branch}."]\n"; if ((-e $striker_source_test) && ($an->data->{switches}{'no-refresh'})) { print "- Skipping download, source appears to already exist and '--no-refresh' used.\n"; @@ -438,7 +446,7 @@ if (not $an->data->{sys}{offline}) print " testers only. Please don't use this in production!\n\n"; $an->data->{sys}{install_master} = 1; sleep 3; - download_and_extract_source($an, $an->data->{url}{striker_master}); + download_and_extract_source($an, $an->data->{url}{striker_branch}); } } else @@ -4549,10 +4557,13 @@ sub get_latest_version } if ($line =~ /^master:(http.*)$/) { - $an->data->{url}{striker_master} = $1; + if ($an->data->{switches}{master}) + { + $an->data->{url}{striker_branch} = $1; + } $set = 1; $an->Log->entry({log_level => 2, message_key => "an_variables_0001", message_variables => { - name1 => "url::striker_master", value1 => $an->data->{url}{striker_master}, + name1 => "url::striker_branch", value1 => $an->data->{url}{striker_branch}, }, file => $THIS_FILE, line => __LINE__}); } } From 0a45ab7b9f84278844583ce783323405cfb019f1 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 4 Mar 2020 10:02:44 -0500 Subject: [PATCH 2/9] style(striker-update): remove excess spaces in string concat --- tools/striker-update | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/striker-update b/tools/striker-update index 1500835c..dc54c6be 100755 --- a/tools/striker-update +++ b/tools/striker-update @@ -332,8 +332,8 @@ elsif ((($an->data->{switches}{master}) or ($an->data->{switches}{branch})) && ( $an->data->{url}{striker_branch} = $an->data->{url}{striker_source_prefix} . $an->data->{switches}{branch}; - print "We will download the latest source code from GitHub's [" . $an->data->{switches}{branch} . "] branch\n"; - print "by accessing URL [" . $an->data->{url}{striker_branch} . "]\n"; + print "We will download the latest source code from GitHub's [".$an->data->{switches}{branch}."] branch\n"; + print "by accessing URL [".$an->data->{url}{striker_branch}."]\n"; print "- NOTE: This should only be done on test and development platforms!\n\n"; } else From 7168fa689084e2939d71d3f16fe5f9a2c863410a Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 4 Mar 2020 10:14:10 -0500 Subject: [PATCH 3/9] fix(striker-update): avoid using using --master as condition Although --master is available, it should only be an alias to "--branch master" --- tools/striker-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/striker-update b/tools/striker-update index dc54c6be..f27cfc4e 100755 --- a/tools/striker-update +++ b/tools/striker-update @@ -4557,7 +4557,7 @@ sub get_latest_version } if ($line =~ /^master:(http.*)$/) { - if ($an->data->{switches}{master}) + if ($an->data->{switches}{branch} eq "master") { $an->data->{url}{striker_branch} = $1; } From 5353e3d2e7c0ee57e5cfe30c80955211d2b569a6 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 4 Mar 2020 10:41:49 -0500 Subject: [PATCH 4/9] fix(striker-update): ensure --branch has a value --- tools/striker-update | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/striker-update b/tools/striker-update index f27cfc4e..c610b8f4 100755 --- a/tools/striker-update +++ b/tools/striker-update @@ -317,13 +317,15 @@ else $show_anvil_warning = 0; } +my $is_branch_switch_set = (($an->data->{switches}{branch}) && ($an->data->{switches}{branch} ne "#!SET!#")); + if ($an->data->{switches}{'no-refresh'}) { print "We will NOT refresh our local copy of the Striker source code. If it exists,\n"; print "we will use what is already cached in:\n"; print "- Striker: [".$an->data->{path}{updates}{striker}."]\n\n"; } -elsif ((($an->data->{switches}{master}) or ($an->data->{switches}{branch})) && (not $an->data->{switches}{offline})) +elsif (($an->data->{switches}{master} or $is_branch_switch_set) && (not $an->data->{switches}{offline})) { if ($an->data->{switches}{master}) { From 1c1d3ea6192f7d33a08b2923e2b23cfd46c636a3 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 4 Mar 2020 10:48:51 -0500 Subject: [PATCH 5/9] fix(striker-update): remove misleading URL The printed URL for --branch or --master prior to the confirmation message can be misleading because the URL can change when the script checks for an up-to-date URL on the Alteeve site. --- tools/striker-update | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/striker-update b/tools/striker-update index c610b8f4..306e5c2f 100755 --- a/tools/striker-update +++ b/tools/striker-update @@ -334,8 +334,7 @@ elsif (($an->data->{switches}{master} or $is_branch_switch_set) && (not $an->dat $an->data->{url}{striker_branch} = $an->data->{url}{striker_source_prefix} . $an->data->{switches}{branch}; - print "We will download the latest source code from GitHub's [".$an->data->{switches}{branch}."] branch\n"; - print "by accessing URL [".$an->data->{url}{striker_branch}."]\n"; + print "We will download the latest source code from GitHub's [".$an->data->{switches}{branch}."] branch.\n"; print "- NOTE: This should only be done on test and development platforms!\n\n"; } else From e7daca0f3a4154e5649f4b8b038a936b22db95f0 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 4 Mar 2020 10:57:13 -0500 Subject: [PATCH 6/9] fix(striker-update): revert source_prefix to ClusterLabs/striker --- tools/striker-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/striker-update b/tools/striker-update index 306e5c2f..2d10e2ae 100755 --- a/tools/striker-update +++ b/tools/striker-update @@ -142,7 +142,7 @@ my $an = AN::Tools->new({ # cases, the downloaded file will be saved as 'striker_zip_file'. striker_default => "https://github.com/ClusterLabs/striker/archive/v2.0.8.zip", striker_latest => "https://www.alteeve.com/an-repo/striker_latest.txt", - striker_source_prefix => "https://codeload.github.com/Tsu-ba-me/alteeve-m2/zip/", + striker_source_prefix => "https://codeload.github.com/ClusterLabs/striker/zip/", support => "https://alteeve.com/w/Support", ping_targets => "8.8.8.8,google.com,redhat.com,alteeve.com", }, From 4daaa381461a4c0e8e57475ada16f9f6093f52f9 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 4 Mar 2020 11:06:16 -0500 Subject: [PATCH 7/9] style(striker-update): re-style with tab size 8 to remove excess changes --- tools/striker-update | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/striker-update b/tools/striker-update index 2d10e2ae..7297baeb 100755 --- a/tools/striker-update +++ b/tools/striker-update @@ -140,11 +140,11 @@ my $an = AN::Tools->new({ # access that file, we'll use 'striker_default'. Optionally, the user can request a branch # with '--branch [branch_name]', in which case we will download the 'striker_source_prefix'.'branch_name' URL. In all # cases, the downloaded file will be saved as 'striker_zip_file'. - striker_default => "https://github.com/ClusterLabs/striker/archive/v2.0.8.zip", - striker_latest => "https://www.alteeve.com/an-repo/striker_latest.txt", + striker_default => "https://github.com/ClusterLabs/striker/archive/v2.0.8.zip", + striker_latest => "https://www.alteeve.com/an-repo/striker_latest.txt", striker_source_prefix => "https://codeload.github.com/ClusterLabs/striker/zip/", - support => "https://alteeve.com/w/Support", - ping_targets => "8.8.8.8,google.com,redhat.com,alteeve.com", + support => "https://alteeve.com/w/Support", + ping_targets => "8.8.8.8,google.com,redhat.com,alteeve.com", }, switches => { offline => 0, From b6adc16a18d6b10adef763e45602c0821a75d9e4 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 4 Mar 2020 11:41:27 -0500 Subject: [PATCH 8/9] docs(striker-update): explain --branch --- tools/striker-update | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/striker-update b/tools/striker-update index 7297baeb..a2bf9d77 100755 --- a/tools/striker-update +++ b/tools/striker-update @@ -4892,10 +4892,16 @@ SWITCHES Show this dialogue and exit. + --branch + This will upgrade to a version identified by the given branch name on + GitHub: https://github.com/ClusterLabs/striker + --master This will upgrade to the latest (master branch) version available on GitHub: https://github.com/ClusterLabs/striker + + This is equivalent to '--branch master' ### WARNING: This is only recommended for developers or testers. Do not ### upgrade to master on production systems! From fc87d86ede88d51dfa9f0a98e09ff9fcdf3d680e Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 4 Mar 2020 12:15:28 -0500 Subject: [PATCH 9/9] fix(striker-update): print branch name instead of 'master' --- tools/striker-update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/striker-update b/tools/striker-update index a2bf9d77..feb7f72e 100755 --- a/tools/striker-update +++ b/tools/striker-update @@ -443,7 +443,7 @@ if (not $an->data->{sys}{offline}) } else { - print "\n[ Warning ] - Master branch requested. This should be used by developers and\n"; + print "\n[ Warning ] - ".$an->data->{switches}{branch}." branch requested. This should be used by developers and\n"; print " testers only. Please don't use this in production!\n\n"; $an->data->{sys}{install_master} = 1; sleep 3;