From c81b52126eeb28bee3d82282cef9ee92b048cd54 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Mon, 14 Jul 2025 23:19:24 +0200 Subject: [PATCH] rubocop: style fixes --- .rubocop_todo.yml | 574 +---------------- lib/packaging.rb | 1 - lib/packaging/artifactory.rb | 76 ++- lib/packaging/config.rb | 29 +- lib/packaging/config/params.rb | 708 +++++++++++---------- lib/packaging/config/validations.rb | 2 - lib/packaging/deb.rb | 1 + lib/packaging/deb/repo.rb | 19 +- lib/packaging/gem.rb | 2 +- lib/packaging/nuget.rb | 1 + lib/packaging/paths.rb | 48 +- lib/packaging/platforms.rb | 14 +- lib/packaging/repo.rb | 24 +- lib/packaging/retrieve.rb | 7 +- lib/packaging/rpm/repo.rb | 9 +- lib/packaging/ship/artifactory.rb | 9 +- lib/packaging/ship/artifacts_bundle.rb | 2 +- lib/packaging/ship/distribution_server.rb | 21 +- lib/packaging/ship/ezbake.rb | 8 +- lib/packaging/ship/windows.rb | 5 +- lib/packaging/sign.rb | 1 + lib/packaging/sign/dmg.rb | 2 +- lib/packaging/sign/msi.rb | 6 +- lib/packaging/sign/rpm.rb | 4 +- lib/packaging/tar.rb | 4 +- lib/packaging/util.rb | 7 +- lib/packaging/util/date.rb | 1 - lib/packaging/util/execution.rb | 2 - lib/packaging/util/file.rb | 9 +- lib/packaging/util/git_tags.rb | 2 +- lib/packaging/util/gpg.rb | 8 +- lib/packaging/util/jenkins.rb | 5 +- lib/packaging/util/misc.rb | 1 + lib/packaging/util/net.rb | 47 +- lib/packaging/util/platform.rb | 1 + lib/packaging/util/rake_utils.rb | 3 +- lib/packaging/util/ship.rb | 13 +- lib/packaging/util/tool.rb | 4 +- spec/lib/packaging/artifactory_spec.rb | 57 +- spec/lib/packaging/config_spec.rb | 282 ++++---- spec/lib/packaging/deb/repo_spec.rb | 26 +- spec/lib/packaging/gem_spec.rb | 124 ++-- spec/lib/packaging/paths_spec.rb | 22 +- spec/lib/packaging/platforms_spec.rb | 10 +- spec/lib/packaging/repo_spec.rb | 13 +- spec/lib/packaging/retrieve_spec.rb | 52 +- spec/lib/packaging/rpm/repo_spec.rb | 30 +- spec/lib/packaging/sign_spec.rb | 58 +- spec/lib/packaging/tar_spec.rb | 22 +- spec/lib/packaging/util/execution_spec.rb | 4 +- spec/lib/packaging/util/file_spec.rb | 11 +- spec/lib/packaging/util/git_spec.rb | 2 + spec/lib/packaging/util/gpg_spec.rb | 1 + spec/lib/packaging/util/jenkins_spec.rb | 29 +- spec/lib/packaging/util/misc_spec.rb | 6 +- spec/lib/packaging/util/net_spec.rb | 51 +- spec/lib/packaging/util/rake_utils_spec.rb | 9 +- spec/lib/packaging/util/ship_spec.rb | 74 +-- spec/lib/packaging/util/version_spec.rb | 8 +- spec/lib/packaging_spec.rb | 6 +- spec/spec_helper.rb | 1 + tasks/00_utils.rake | 4 - tasks/30_metrics.rake | 24 +- tasks/apple.rake | 11 +- tasks/archive.rake | 1 - tasks/clean.rake | 1 - tasks/config.rake | 2 +- tasks/deb.rake | 7 +- tasks/deprecated.rake | 1 - tasks/education.rake | 2 - tasks/gem.rake | 3 +- tasks/jenkins.rake | 30 +- tasks/jenkins_dynamic.rake | 21 +- tasks/load_extras.rake | 2 +- tasks/mock.rake | 7 +- tasks/nightly_repos.rake | 6 +- tasks/pe_rpm.rake | 1 - tasks/pe_ship.rake | 14 +- tasks/retrieve.rake | 1 - tasks/rpm.rake | 3 +- tasks/ship.rake | 21 +- tasks/sign.rake | 4 +- tasks/tag.rake | 1 - tasks/tar.rake | 2 - tasks/update.rake | 1 - tasks/vanagon.rake | 1 + tasks/vendor_gems.rake | 3 +- tasks/version.rake | 1 - tasks/z_data_dump.rake | 1 - 89 files changed, 1112 insertions(+), 1642 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a4a62f82..7f3e4442 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,47 +6,13 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_argument, with_fixed_indentation -Layout/ArgumentAlignment: - Exclude: - - 'lib/packaging/artifactory.rb' - - 'lib/packaging/sign/msi.rb' - -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_element, with_fixed_indentation -Layout/ArrayAlignment: - Exclude: - - 'lib/packaging/util/net.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith. -# SupportedStylesAlignWith: either, start_of_block, start_of_line -Layout/BlockAlignment: - Exclude: - - 'spec/lib/packaging/rpm/repo_spec.rb' - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -Layout/BlockEndNewline: - Exclude: - - 'spec/lib/packaging/retrieve_spec.rb' - - 'spec/lib/packaging/sign_spec.rb' - - 'spec/lib/packaging/util/jenkins_spec.rb' - -# Offense count: 37 +# Offense count: 32 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. # SupportedStyles: case, end Layout/CaseIndentation: Exclude: - 'lib/packaging/config.rb' - - 'lib/packaging/paths.rb' - 'tasks/config.rake' - 'tasks/gem.rake' - 'tasks/jenkins.rake' @@ -61,181 +27,6 @@ Layout/ClosingHeredocIndentation: - 'spec/lib/packaging/sign_spec.rb' - 'tasks/nightly_repos.rake' -# Offense count: 64 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLineAfterGuardClause: - Enabled: false - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Exclude: - - 'lib/packaging/artifactory.rb' - - 'lib/packaging/util.rb' - - 'lib/packaging/util/file.rb' - - 'lib/packaging/util/ship.rb' - - 'tasks/mock.rake' - -# Offense count: 22 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLines: - Enabled: false - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: around, only_before -Layout/EmptyLinesAroundAccessModifier: - Exclude: - - 'lib/packaging/sign.rb' - - 'lib/packaging/util/platform.rb' - -# Offense count: 17 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Exclude: - - 'spec/lib/packaging/artifactory_spec.rb' - - 'spec/lib/packaging/config_spec.rb' - - 'spec/lib/packaging/paths_spec.rb' - - 'spec/lib/packaging/sign_spec.rb' - - 'spec/lib/packaging/util/jenkins_spec.rb' - - 'spec/lib/packaging/util/net_spec.rb' - - 'spec/lib/packaging_spec.rb' - - 'tasks/archive.rake' - - 'tasks/education.rake' - - 'tasks/pe_ship.rake' - - 'tasks/ship.rake' - - 'tasks/tar.rake' - -# Offense count: 15 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only -Layout/EmptyLinesAroundClassBody: - Exclude: - - 'lib/packaging/artifactory.rb' - - 'lib/packaging/config/validations.rb' - - 'lib/packaging/deb/repo.rb' - - 'lib/packaging/repo.rb' - - 'lib/packaging/ship/distribution_server.rb' - - 'lib/packaging/tar.rb' - - 'lib/packaging/util/execution.rb' - - 'lib/packaging/util/gpg.rb' - - 'lib/packaging/util/jenkins.rb' - - 'lib/packaging/util/net.rb' - - 'lib/packaging/util/tool.rb' - - 'tasks/vendor_gems.rake' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLinesAroundExceptionHandlingKeywords: - Exclude: - - 'tasks/mock.rake' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLinesAroundMethodBody: - Exclude: - - 'lib/packaging/ship/artifacts_bundle.rb' - - 'tasks/apple.rake' - -# Offense count: 14 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines -Layout/EmptyLinesAroundModuleBody: - Exclude: - - 'lib/packaging.rb' - - 'lib/packaging/artifactory.rb' - - 'lib/packaging/config/params.rb' - - 'lib/packaging/deb/repo.rb' - - 'lib/packaging/paths.rb' - - 'lib/packaging/platforms.rb' - - 'lib/packaging/repo.rb' - - 'lib/packaging/util/date.rb' - - 'lib/packaging/util/execution.rb' - - 'lib/packaging/util/file.rb' - - 'lib/packaging/util/jenkins.rb' - - 'lib/packaging/util/net.rb' - - 'lib/packaging/util/tool.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith, Severity. -# SupportedStylesAlignWith: keyword, variable, start_of_line -Layout/EndAlignment: - Exclude: - - 'lib/packaging/paths.rb' - - 'tasks/config.rake' - - 'tasks/gem.rake' - - 'tasks/jenkins.rake' - -# Offense count: 18 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'lib/packaging/config/params.rb' - - 'lib/packaging/util/net.rb' - - 'spec/lib/packaging_spec.rb' - - 'tasks/30_metrics.rake' - - 'tasks/apple.rake' - - 'tasks/deb.rake' - - 'tasks/jenkins.rake' - - 'tasks/jenkins_dynamic.rake' - - 'tasks/ship.rake' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstArgumentIndentation: - Exclude: - - 'lib/packaging/config.rb' - - 'lib/packaging/repo.rb' - - 'lib/packaging/util/net.rb' - - 'tasks/pe_ship.rake' - - 'tasks/ship.rake' - -# Offense count: 13 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/FirstArrayElementIndentation: - Exclude: - - 'lib/packaging/config/params.rb' - - 'spec/lib/packaging/artifactory_spec.rb' - - 'tasks/jenkins.rake' - - 'tasks/jenkins_dynamic.rake' - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/FirstHashElementIndentation: - Exclude: - - 'lib/packaging/artifactory.rb' - - 'spec/lib/packaging/artifactory_spec.rb' - - 'tasks/apple.rake' - -# Offense count: 80 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/HashAlignment: - Exclude: - - 'lib/packaging/artifactory.rb' - - 'spec/lib/packaging/gem_spec.rb' - - 'spec/lib/packaging/tar_spec.rb' - - 'spec/lib/packaging/util/version_spec.rb' - - 'tasks/30_metrics.rake' - - 'tasks/apple.rake' - # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). Layout/HeredocIndentation: @@ -246,43 +37,6 @@ Layout/HeredocIndentation: - 'spec/lib/packaging/sign_spec.rb' - 'tasks/nightly_repos.rake' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Width, AllowedPatterns. -Layout/IndentationWidth: - Exclude: - - 'spec/lib/packaging/util/net_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment, AllowRBSInlineAnnotation, AllowSteepAnnotation. -Layout/LeadingCommentSpace: - Exclude: - - 'lib/packaging/artifactory.rb' - - 'lib/packaging/paths.rb' - - 'tasks/nightly_repos.rake' - -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/LineContinuationSpacing: - Exclude: - - 'lib/packaging/artifactory.rb' - - 'lib/packaging/config.rb' - - 'lib/packaging/retrieve.rb' - - 'lib/packaging/ship/artifactory.rb' - - 'lib/packaging/ship/distribution_server.rb' - - 'spec/lib/packaging/config_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented -Layout/LineEndStringConcatenationIndentation: - Exclude: - - 'spec/lib/packaging/util/net_spec.rb' - # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. @@ -293,217 +47,6 @@ Layout/LineLength: - 'spec/lib/packaging/config_spec.rb' - 'tasks/ship.rake' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineArrayBraceLayout: - Exclude: - - 'lib/packaging/config/params.rb' - - 'spec/lib/packaging/config_spec.rb' - -# Offense count: 12 -# This cop supports safe autocorrection (--autocorrect). -Layout/MultilineBlockLayout: - Exclude: - - 'lib/packaging/config.rb' - - 'spec/lib/packaging/retrieve_spec.rb' - - 'spec/lib/packaging/sign_spec.rb' - - 'spec/lib/packaging/util/jenkins_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineHashBraceLayout: - Exclude: - - 'lib/packaging/util/net.rb' - - 'lib/packaging/util/ship.rb' - -# Offense count: 24 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'lib/packaging/artifactory.rb' - - 'lib/packaging/repo.rb' - - 'lib/packaging/retrieve.rb' - - 'lib/packaging/ship/artifactory.rb' - - 'lib/packaging/ship/distribution_server.rb' - - 'lib/packaging/ship/ezbake.rb' - - 'lib/packaging/util/net.rb' - - 'spec/lib/packaging/tar_spec.rb' - - 'spec/lib/packaging/util/net_spec.rb' - - 'tasks/sign.rake' - -# Offense count: 27 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'lib/packaging/ship/distribution_server.rb' - - 'spec/lib/packaging/util/ship_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceAfterComma: - Exclude: - - 'spec/lib/packaging/artifactory_spec.rb' - - 'spec/lib/packaging/util/misc_spec.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleInsidePipes. -# SupportedStylesInsidePipes: space, no_space -Layout/SpaceAroundBlockParameters: - Exclude: - - 'lib/packaging/sign/dmg.rb' - - 'lib/packaging/sign/msi.rb' - - 'tasks/rpm.rake' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceAroundMethodCallOperator: - Exclude: - - 'lib/packaging/deb/repo.rb' - -# Offense count: 75 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals. -# SupportedStylesForExponentOperator: space, no_space -# SupportedStylesForRationalLiterals: space, no_space -Layout/SpaceAroundOperators: - Exclude: - - 'spec/lib/packaging/gem_spec.rb' - - 'spec/lib/packaging/repo_spec.rb' - - 'spec/lib/packaging/sign_spec.rb' - - 'spec/lib/packaging/util/version_spec.rb' - - 'tasks/apple.rake' - - 'tasks/jenkins.rake' - - 'tasks/jenkins_dynamic.rake' - - 'tasks/ship.rake' - -# Offense count: 22 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Exclude: - - 'spec/lib/packaging/artifactory_spec.rb' - - 'spec/lib/packaging/platforms_spec.rb' - - 'spec/lib/packaging/repo_spec.rb' - - 'spec/lib/packaging/util/execution_spec.rb' - - 'spec/lib/packaging/util/jenkins_spec.rb' - - 'spec/lib/packaging/util/net_spec.rb' - - 'spec/lib/packaging/util/rake_utils_spec.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Exclude: - - 'spec/lib/packaging_spec.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBrackets: space, no_space -Layout/SpaceInsideArrayLiteralBrackets: - Exclude: - - 'spec/lib/packaging/tar_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceInsideArrayPercentLiteral: - Exclude: - - 'lib/packaging/paths.rb' - -# Offense count: 64 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Exclude: - - 'spec/lib/packaging/artifactory_spec.rb' - - 'spec/lib/packaging/config_spec.rb' - - 'spec/lib/packaging/deb/repo_spec.rb' - - 'spec/lib/packaging/platforms_spec.rb' - - 'spec/lib/packaging/repo_spec.rb' - - 'spec/lib/packaging/rpm/repo_spec.rb' - - 'spec/lib/packaging/util/jenkins_spec.rb' - - 'spec/lib/packaging/util/net_spec.rb' - - 'spec/lib/packaging/util/rake_utils_spec.rb' - -# Offense count: 87 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'spec/lib/packaging/artifactory_spec.rb' - - 'spec/lib/packaging/config_spec.rb' - - 'spec/lib/packaging/deb/repo_spec.rb' - - 'spec/lib/packaging/gem_spec.rb' - - 'spec/lib/packaging/repo_spec.rb' - - 'spec/lib/packaging/retrieve_spec.rb' - - 'spec/lib/packaging/rpm/repo_spec.rb' - - 'spec/lib/packaging/util/file_spec.rb' - - 'spec/lib/packaging/util/jenkins_spec.rb' - - 'spec/lib/packaging/util/misc_spec.rb' - - 'spec/lib/packaging/util/net_spec.rb' - -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, compact, no_space -Layout/SpaceInsideParens: - Exclude: - - 'lib/packaging/util.rb' - - 'spec/lib/packaging/deb/repo_spec.rb' - - 'spec/lib/packaging/rpm/repo_spec.rb' - - 'spec/lib/packaging/util/jenkins_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideStringInterpolation: - Exclude: - - 'tasks/mock.rake' - - 'tasks/nightly_repos.rake' - -# Offense count: 12 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingEmptyLines: - Exclude: - - 'lib/packaging/tar.rb' - - 'lib/packaging/util/file.rb' - - 'spec/lib/packaging_spec.rb' - - 'tasks/clean.rake' - - 'tasks/load_extras.rake' - - 'tasks/pe_rpm.rake' - - 'tasks/rpm.rake' - - 'tasks/tag.rake' - - 'tasks/tar.rake' - - 'tasks/update.rake' - - 'tasks/version.rake' - - 'tasks/z_data_dump.rake' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'spec/lib/packaging/platforms_spec.rb' - # Offense count: 7 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSafeAssignment. @@ -538,12 +81,6 @@ Lint/DuplicateMethods: - 'lib/packaging/tar.rb' - 'lib/packaging/util/git_tags.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Lint/ErbNewArguments: - Exclude: - - 'lib/packaging/util/file.rb' - # Offense count: 1 # Configuration parameters: MaximumRangeSize. Lint/MissingCopEnableDirective: @@ -842,47 +379,7 @@ RSpec/DescribedClass: - 'spec/lib/packaging/util/jenkins_spec.rb' - 'spec/lib/packaging/util/os_spec.rb' -# Offense count: 27 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowConsecutiveOneLiners. -RSpec/EmptyLineAfterExample: - Exclude: - - 'spec/lib/packaging/gem_spec.rb' - - 'spec/lib/packaging/paths_spec.rb' - - 'spec/lib/packaging/retrieve_spec.rb' - - 'spec/lib/packaging/sign_spec.rb' - - 'spec/lib/packaging/util/gpg_spec.rb' - - 'spec/lib/packaging/util/rake_utils_spec.rb' - - 'spec/lib/packaging/util/ship_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -RSpec/EmptyLineAfterExampleGroup: - Exclude: - - 'spec/lib/packaging/retrieve_spec.rb' - -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -RSpec/EmptyLineAfterFinalLet: - Exclude: - - 'spec/lib/packaging/gem_spec.rb' - - 'spec/lib/packaging/repo_spec.rb' - - 'spec/lib/packaging/retrieve_spec.rb' - - 'spec/lib/packaging/sign_spec.rb' - - 'spec/lib/packaging/tar_spec.rb' - - 'spec/lib/packaging/util/git_spec.rb' - - 'spec/lib/packaging/util/jenkins_spec.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowConsecutiveOneLiners. -RSpec/EmptyLineAfterHook: - Exclude: - - 'spec/lib/packaging/paths_spec.rb' - - 'spec/lib/packaging/retrieve_spec.rb' - - 'spec/lib/packaging/util/ship_spec.rb' - -# Offense count: 39 +# Offense count: 41 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 37 @@ -1183,7 +680,7 @@ Style/BarePercentLiterals: - 'lib/packaging/util/file.rb' - 'tasks/mock.rake' -# Offense count: 15 +# Offense count: 11 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces @@ -1791,7 +1288,7 @@ Style/StringConcatenation: - 'tasks/nightly_repos.rake' - 'tasks/rpm.rake' -# Offense count: 1309 +# Offense count: 1308 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -1830,69 +1327,6 @@ Style/SymbolProc: - 'lib/packaging/config.rb' - 'spec/lib/packaging/deb/repo_spec.rb' -# Offense count: 20 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInArguments: - Exclude: - - 'lib/packaging/artifactory.rb' - - 'lib/packaging/config.rb' - - 'lib/packaging/repo.rb' - - 'lib/packaging/ship/artifactory.rb' - - 'lib/packaging/ship/distribution_server.rb' - - 'lib/packaging/ship/windows.rb' - - 'lib/packaging/sign/msi.rb' - - 'lib/packaging/util/ship.rb' - - 'tasks/30_metrics.rake' - - 'tasks/pe_ship.rake' - - 'tasks/ship.rake' - -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma -Style/TrailingCommaInArrayLiteral: - Exclude: - - 'lib/packaging/config/params.rb' - - 'lib/packaging/deb/repo.rb' - - 'lib/packaging/paths.rb' - - 'lib/packaging/util/net.rb' - - 'lib/packaging/util/rake_utils.rb' - - 'lib/packaging/util/ship.rb' - - 'spec/lib/packaging/gem_spec.rb' - - 'spec/lib/packaging/repo_spec.rb' - - 'spec/lib/packaging/sign_spec.rb' - - 'spec/lib/packaging/tar_spec.rb' - - 'spec/lib/packaging/util/version_spec.rb' - - 'tasks/jenkins.rake' - - 'tasks/jenkins_dynamic.rake' - -# Offense count: 38 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma -Style/TrailingCommaInHashLiteral: - Enabled: false - -# Offense count: 30 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowNamedUnderscoreVariables. -Style/TrailingUnderscoreVariable: - Exclude: - - 'lib/packaging/config.rb' - - 'lib/packaging/deb/repo.rb' - - 'lib/packaging/paths.rb' - - 'lib/packaging/platforms.rb' - - 'lib/packaging/repo.rb' - - 'lib/packaging/rpm/repo.rb' - - 'lib/packaging/sign/rpm.rb' - - 'lib/packaging/util/file.rb' - - 'lib/packaging/util/git_tags.rb' - - 'lib/packaging/util/gpg.rb' - - 'lib/packaging/util/net.rb' - - 'tasks/ship.rake' - # Offense count: 47 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: WordRegex. diff --git a/lib/packaging.rb b/lib/packaging.rb index b29c6909..5a0d53c0 100644 --- a/lib/packaging.rb +++ b/lib/packaging.rb @@ -1,5 +1,4 @@ module Pkg - LIBDIR = File.expand_path(File.dirname(__FILE__)) $:.unshift(LIBDIR) unless diff --git a/lib/packaging/artifactory.rb b/lib/packaging/artifactory.rb index 30c20e90..d8f1efdf 100644 --- a/lib/packaging/artifactory.rb +++ b/lib/packaging/artifactory.rb @@ -5,13 +5,11 @@ require 'packaging/artifactory/extensions' module Pkg - # The Artifactory class # This class provides automation to access the artifactory repos maintained # by the Release Engineering team at Puppet. It has the ability to both push # artifacts to the repos, and to retrieve them back from the repos. class ManageArtifactory - # The Artifactory property that the artifactCleanup user plugin # {https://github.com/jfrog/artifactory-user-plugins/tree/master/cleanup/artifactCleanup} # uses to tell it to not clean a particular artifact @@ -46,7 +44,6 @@ def initialize(project, project_version, opts = {}) attr_reader :project attr_reader :project_version - # @param platform_tag [String] The platform tag string ('-' or # '--') for the repo we need # information on. If generic information is needed, pass in `generic` @@ -68,14 +65,12 @@ def location_for(platform_tag) case format when 'rpm' toplevel_repo = 'rpm' - repo_subdirectories = File.join( - repo_subdirectories, "#{platform}-#{version}-#{architecture}") + repo_subdirectories = File.join(repo_subdirectories, "#{platform}-#{version}-#{architecture}") when 'deb' toplevel_repo = 'debian__local' repo_subdirectories = File.join(repo_subdirectories, "#{platform}-#{version}") when 'swix', 'dmg', 'svr4', 'ips' - repo_subdirectories = File.join( - repo_subdirectories, "#{platform}-#{version}-#{architecture}") + repo_subdirectories = File.join(repo_subdirectories, "#{platform}-#{version}-#{architecture}") when 'msi' repo_subdirectories = File.join(repo_subdirectories, "#{platform}-#{architecture}") end @@ -106,7 +101,7 @@ def platform_specific_data(platform_tag) package_format: package_format, repo_name: repo_name, repo_subdirectories: repo_subdirectories, - full_artifactory_path: full_artifactory_path + full_artifactory_path: full_artifactory_path, } end @@ -118,7 +113,7 @@ def deb_list_contents(platform_tag) data = platform_specific_data(platform_tag) if data[:package_format] == 'deb' return format("deb %s/%s %s %s", @artifactory_uri, data[:repo_name], - data[:codename], data[:repo_subdirectories]) + data[:codename], data[:repo_subdirectories]) end raise "Error: the platform '#{platform_tag}' is not an apt-based system." @@ -142,6 +137,7 @@ def rpm_repo_contents(platform_tag) #repo_gpgcheck=1 DOC end + raise "The platform '#{platform_tag}' is not a yum-based system" end @@ -190,7 +186,7 @@ def deploy_properties(platform_tag, file_name) # current iteration, the hash isn't formatted properly and the attempt to # deploy to Artifactory bails out. I'm leaving this in so that we at least # have multiple places to remind us that it needs to happen. - #properties_hash = Pkg::Config.config_to_hash + # properties_hash = Pkg::Config.config_to_hash properties_hash = {} if data[:package_format] == 'deb' architecture = data[:architecture] @@ -198,11 +194,7 @@ def deploy_properties(platform_tag, file_name) if file_name =~ /_all\.deb$/ architecture = 'all' end - properties_hash.merge!({ - 'deb.distribution' => data[:codename], - 'deb.component' => data[:repo_subdirectories], - 'deb.architecture' => architecture, - }) + properties_hash.merge!({ 'deb.distribution' => data[:codename], 'deb.component' => data[:repo_subdirectories], 'deb.architecture' => architecture }) end properties_hash end @@ -213,10 +205,7 @@ def deploy_properties(platform_tag, file_name) # @return [Array] Artifactory search for packages named with the basename of the package. def package_exists_on_artifactory?(package) check_authorization - found_artifacts = Artifactory::Resource::Artifact.search( - name: File.basename(package), - artifactory_uri: @artifactory_uri - ) + found_artifacts = Artifactory::Resource::Artifact.search(name: File.basename(package), artifactory_uri: @artifactory_uri) return false if found_artifacts.empty? return found_artifacts @@ -270,7 +259,7 @@ def deploy_package(package) data[:repo_name], remote_path, deploy_properties(platform_tag, File.basename(package)), - headers + headers, ) end @@ -346,11 +335,13 @@ def promote_package(pkg, ref, platform_tag, repository, debian_component = nil) artifact_names = all_package_names(yaml_data[:platform_data], platform_tag) artifact_names.each do |artifact_name| artifact_search_results = Artifactory::Resource::Artifact.search( - name: artifact_name, :artifactory_uri => @artifactory_uri) + name: artifact_name, :artifactory_uri => @artifactory_uri, + ) if artifact_search_results.empty? raise "Error: could not find PKG=#{pkg} at REF=#{ref} for #{platform_tag}" end + artifact_to_promote = artifact_search_results[0] # This makes an assumption that we're using some consistent repo names @@ -373,7 +364,8 @@ def promote_package(pkg, ref, platform_tag, repository, debian_component = nil) unless properties.nil? artifacts = Artifactory::Resource::Artifact.search( name: artifact_name, - artifactory: @artifactory_uri) + artifactory: @artifactory_uri, + ) promoted_artifact = artifacts.select do |artifact| artifact.download_uri =~ %r{#{promotion_path}} end.first @@ -410,7 +402,8 @@ def download_packages(staging_directory, manifest, remote_path = '') artifacts = Artifactory::Resource::Artifact.checksum_search( md5: "#{info["md5"]}", repos: ["rpm_enterprise__local", "debian_enterprise__local"], - name: filename) + name: filename, + ) artifact_to_download = artifacts.select do |artifact| artifact.download_uri.include? remote_path end.first @@ -428,7 +421,8 @@ def download_packages(staging_directory, manifest, remote_path = '') artifacts = Artifactory::Resource::Artifact.checksum_search( md5: "#{info["md5"]}", repos: ["rpm_enterprise__local", "debian_enterprise__local"], - name: filename) + name: filename, + ) artifact_to_download = artifacts.select do |artifact| artifact.download_uri.include? remote_path end.first @@ -450,7 +444,6 @@ def download_packages(staging_directory, manifest, remote_path = '') end end - # Ship PE tarballs to specified artifactory repo and paths # @param local_tarball_directory [String] the local directory containing the tarballs # @param target_repo [String] the artifactory repo to ship the tarballs to @@ -461,10 +454,12 @@ def ship_pe_tarballs(local_tarball_directory, target_repo, ship_paths) ship_paths.each do |path| Dir.foreach(local_tarball_directory) do |pe_tarball| next if pe_tarball == '.' || pe_tarball == ".." + begin puts "Uploading #{pe_tarball} to #{target_repo}/#{path}#{pe_tarball}" artifact = Artifactory::Resource::Artifact.new( - local_path: "#{local_tarball_directory}/#{pe_tarball}") + local_path: "#{local_tarball_directory}/#{pe_tarball}", + ) artifact.upload(target_repo, "#{path}#{pe_tarball}") rescue Errno::EPIPE STDERR.puts "Warning: Could not upload #{pe_tarball} to #{target_repo}/#{path}. Skipping." @@ -485,6 +480,7 @@ def ship_pe_tarballs(local_tarball_directory, target_repo, ship_paths) # "X-Checksum-Md5" and "X-Checksum-Sha1" are typical def upload_file(local_path, target_repo, target_path, properties = {}, headers = {}) fail "Error: Couldn't find file at #{local_path}." unless File.exist? local_path + check_authorization artifact = Artifactory::Resource::Artifact.new(local_path: local_path) full_upload_path = File.join(target_path, File.basename(local_path)) @@ -516,11 +512,11 @@ def prevent_artifact_cleanup(repo, directory, pe_build_version) all_artifacts = Artifactory::Resource::Artifact.pattern_search( repo: repo, - pattern: all_artifacts_pattern + pattern: all_artifacts_pattern, ) latest_artifacts = Artifactory::Resource::Artifact.pattern_search( repo: repo, - pattern: latest_artifacts_pattern + pattern: latest_artifacts_pattern, ) # Clear cleanup.skip on all artifacts in directory @@ -560,6 +556,7 @@ def download_artifact(artifact_name, repo, path, target: '.', filename: nil) filename ||= artifact_name artifacts = search_with_path(artifact_name, repo, path) return nil if artifacts.empty? + # Only download the first of the artifacts since we're saving them to # the same location anyways artifacts.first.download(target, filename: filename) @@ -573,10 +570,12 @@ def download_artifact(artifact_name, repo, path, target: '.', filename: nil) def download_final_pe_tarballs(pe_version, repo, remote_path, local_path) check_authorization artifacts = Artifactory::Resource::Artifact.search( - name: pe_version, repos: repo, exact_match: false) + name: pe_version, repos: repo, exact_match: false, + ) artifacts.each do |artifact| next unless artifact.download_uri.include? remote_path next if artifact.download_uri.include? "-rc" + artifact.download(local_path) end end @@ -603,10 +602,12 @@ def download_beta_pe_tarballs(beta_tag, repo, remote_path, local_path) def copy_final_pe_tarballs(pe_version, repo, remote_path, target_path) check_authorization final_tarballs = Artifactory::Resource::Artifact.search( - name: pe_version, repos: repo, exact_match: false) + name: pe_version, repos: repo, exact_match: false, + ) final_tarballs.each do |artifact| next unless artifact.download_uri.include? remote_path next if artifact.download_uri.include? "-rc" + filename = File.basename(artifact.download_uri) # Artifactory does NOT like when you use `File.join`, so let's concatenate! full_target_path = "#{repo}/#{target_path}/#{filename}" @@ -629,7 +630,7 @@ def copy_artifact(artifact, target_repo, target_path, target_debian_component = begin artifact.copy(artifactory_target_path) rescue Artifactory::Error::HTTPError - STDERR.puts "Warning: Could not copy #{artifactory_target_path}. "\ + STDERR.puts "Warning: Could not copy #{artifactory_target_path}. " \ "Source and destination are the same. Skipping." end @@ -663,10 +664,12 @@ def populate_pe_repos(manifest, target_path) artifact = Artifactory::Resource::Artifact.checksum_search( md5: "#{info["md5"]}", repos: ["rpm_enterprise__local", "debian_enterprise__local"], - name: filename).first + name: filename, + ).first if artifact.nil? raise "Error: could not find package #{filename} with md5sum #{info["md5"]}" end + copy_artifact(artifact, artifact.repo, "#{target_path}/#{dist}/#{filename}") end end @@ -700,11 +703,14 @@ def remove_promoted_packages(manifest, remote_path, package, repos) manifest.each do |dist, packages| packages.each do |package_name, info| next unless package_name == package + filename = info["filename"] artifacts = Artifactory::Resource::Artifact.checksum_search( - md5: "#{info["md5"]}", repos: repos, name: filename) + md5: "#{info["md5"]}", repos: repos, name: filename, + ) artifacts.each do |artifact| next unless artifact.download_uri.include? remote_path + puts "Info: removing reverted package #{artifact.download_uri}" artifact.delete end @@ -723,9 +729,11 @@ def purge_copied_pe_tarballs(tarball_path, pe_repo) check_authorization Dir.foreach("#{tarball_path}/") do |pe_tarball| next if pe_tarball == '.' || pe_tarball == ".." + md5 = Digest::MD5.file("#{tarball_path}/#{pe_tarball}").hexdigest artifacts_to_delete = Artifactory::Resource::Artifact.checksum_search( - md5: md5, repos: pe_repo, name: pe_tarball) + md5: md5, repos: pe_repo, name: pe_tarball, + ) next if artifacts_to_delete.nil? begin diff --git a/lib/packaging/config.rb b/lib/packaging/config.rb index 88f67531..bd195cd2 100644 --- a/lib/packaging/config.rb +++ b/lib/packaging/config.rb @@ -79,13 +79,13 @@ def platform_data Pkg::Util::Net.check_host_ssh([self.builds_server]).empty? dir = "/opt/jenkins-builds/#{self.project}/#{self.ref}" - cmd = "if [ -s \"#{dir}/artifacts\" ]; then cd #{dir};"\ + cmd = "if [ -s \"#{dir}/artifacts\" ]; then cd #{dir};" \ "find ./artifacts -mindepth 2 -type f; fi" - artifacts, _ = Pkg::Util::Net.remote_execute( - self.builds_server, - cmd, - { capture_output: true } - ) + artifacts, = Pkg::Util::Net.remote_execute( + self.builds_server, + cmd, + { capture_output: true }, + ) artifacts = artifacts.split("\n") data = {} @@ -131,12 +131,12 @@ def platform_data case package_format when 'deb' - repo_config = "../repo_configs/deb/pl-#{self.project}-#{self.ref}-"\ + repo_config = "../repo_configs/deb/pl-#{self.project}-#{self.ref}-" \ "#{Pkg::Platforms.get_attribute(tag, :codename)}.list" when 'rpm' # Using original_tag here to not break legacy fedora repo targets unless tag.include? 'aix' - repo_config = "../repo_configs/rpm/pl-#{self.project}-"\ + repo_config = "../repo_configs/rpm/pl-#{self.project}-" \ "#{self.ref}-#{original_tag}.repo" end when 'swix', 'svr4', 'ips', 'dmg', 'msi' @@ -227,8 +227,8 @@ def print_config # the debian changelog. # def cow_list - self.cows.split(' ').map do - |cow| cow.split('-')[1] + self.cows.split(' ').map do |cow| + cow.split('-')[1] end.uniq.join(' ') end @@ -253,11 +253,11 @@ def load_default_configs got_config = false default_project_data = { path: File.join(@project_root, "ext", "project_data.yaml"), - required: false + required: false, } default_build_defaults = { path: File.join(@project_root, "ext", "build_defaults.yaml"), - required: true + required: true, } [default_project_data, default_build_defaults].each do |config| @@ -433,6 +433,7 @@ def perform_validations def string_to_array(str) delimiters = /[,\s;]/ return str if str.respond_to?('each') + str.split(delimiters).reject { |s| s.empty? }.map { |s| s.strip } end @@ -452,9 +453,11 @@ def mock_to_dist_version_arch(mock) def deb_build_targets if self.vanagon_project fail "ERROR: Could not find any deb targets. Try adding `deb_targets` to your build_defaults.yaml. If you don't want to build any debs, set this to an empty string." unless self.deb_targets + self.deb_targets.split(' ') else fail "ERROR: Could not find any deb targets. Try adding `cows` to your build_defaults.yaml. If you don't want to build any debs, set this to an empty string." unless self.cows + self.cows.split(' ').map do |cow| codename, arch = self.cow_to_codename_arch(cow) "#{codename}-#{arch}" @@ -465,9 +468,11 @@ def deb_build_targets def rpm_build_targets if self.vanagon_project fail "ERROR: Could not find any rpm targets. Try adding `rpm_targets` to your build_defaults.yaml. If you don't want to build any rpms, set this to an empty string." unless self.rpm_targets + self.rpm_targets.split(' ') else fail "ERROR: Could not find any rpm targets. Try adding `final_mocks` to your build_defaults.yaml. If you don't want to build any rpms, set this to an empty string." unless self.final_mocks + self.final_mocks.split(' ').map do |mock| platform, version, arch = self.mock_to_dist_version_arch(mock) "#{platform}-#{version}-#{arch}" diff --git a/lib/packaging/config/params.rb b/lib/packaging/config/params.rb index a6395163..e09e5614 100644 --- a/lib/packaging/config/params.rb +++ b/lib/packaging/config/params.rb @@ -3,194 +3,195 @@ # These are all of the parameters known to our packaging system. # They are ingested by the config class as class instance variables module Pkg::Params - BUILD_PARAMS = [:allow_dirty_tree, - :answer_override, - :apt_archive_path, - :apt_archive_repo_command, - :apt_host, - :apt_releases, - :apt_repo_command, - :apt_repo_name, - :apt_repo_path, - :apt_repo_staging_path, - :apt_repo_url, - :apt_signing_server, - :apt_staging_server, - :author, - :benchmark, - :build_data_repo, - :build_date, - :build_defaults, - :build_dmg, - :build_doc, - :build_gem, - :build_ips, - :build_msi, - :build_pe, - :build_tar, - :builder_data_file, - :builds_server, - :bundle_platforms, - :certificate_pem, - :cows, - :db_table, - :deb_build_host, - :deb_build_mirrors, - :deb_targets, - :debug, - :debversion, - :default_cow, - :default_mock, - :dev_build, - :description, - :distribution_server, - :dmg_host, - :dmg_path, - :dmg_staging_server, - :downloads_archive_path, - :email, - :files, - :final_mocks, - :foss_only, - :foss_platforms, - :freight_archive_path, - :freight_conf, - :gem_default_executables, - :gem_dependencies, - :gem_description, - :gem_devel_dependencies, - :gem_development_dependencies, - :gem_excludes, - :gem_executables, - :gem_files, - :gem_forge_project, - :gem_host, - :gem_name, - :gem_path, - :gem_platform_dependencies, - :gem_rdoc_options, - :gem_require_path, - :gem_required_ruby_version, - :gem_required_rubygems_version, - :gem_runtime_dependencies, - :gem_summary, - :gem_test_files, - :gemversion, - :gpg_key, - :gpg_name, - :homepage, - :internal_gem_host, - :ips_build_host, - :ips_host, - :ips_inter_cert, - :ips_package_host, - :ips_path, - :ips_repo, - :ips_root_cert, - :ips_signing_cert, - :ips_signing_key, - :ips_signing_server, - :ips_signing_ssh_key, - :ips_store, - :jenkins_build_host, - :jenkins_packaging_job, - :jenkins_repo_path, - :metrics, - :metrics_url, - :msi_host, - :msi_name, - :msi_path, - :msi_signing_cert, - :msi_signing_cert_pw, - :msi_signing_server, - :msi_signing_ssh_key, - :msi_staging_server, - :name, - :nonfinal_apt_repo_command, - :nonfinal_apt_repo_path, - :nonfinal_apt_repo_staging_path, - :nonfinal_dmg_path, - :nonfinal_gem_path, - :nonfinal_ips_path, - :nonfinal_msi_path, - :nonfinal_p5p_path, - :nonfinal_repo_name, - :nonfinal_repo_link_target, - :nonfinal_svr4_path, - :nonfinal_swix_path, - :nonfinal_yum_repo_path, - :notify, - :nuget_host, - :nuget_repo_path, - :origversion, - :osx_build_host, - :osx_signing_cert, - :osx_signing_keychain, - :osx_signing_keychain_pw, - :osx_signing_server, - :osx_signing_ssh_key, - :p5p_host, - :p5p_path, - :packager, - :packaging_repo, - :packaging_root, - :packaging_url, - :pbuild_conf, - :pe_feature_branch, - :pe_release_branch, - :pe_name, - :pe_platforms, - :pe_version, - :pg_major_version, - :platform_repos, - :pre_tar_task, - :pre_tasks, - :privatekey_pem, - :project, - :project_root, - :random_mockroot, - :rc_mocks, - :redis_hostname, - :ref, - :release, - :repo_link_target, - :repo_name, - :rpm_build_host, - :rpm_targets, - :rpmrelease, - :rpmversion, - :rsync_servers, - :s3_ship, - :short_ref, - :sign_tar, - :signing_bundle, - :signing_server, - :staging_server, - :summary, - :svr4_host, - :svr4_path, - :swix_host, - :swix_path, - :swix_staging_server, - :tar_excludes, - :tar_host, - :tar_staging_server, - :tarball_path, - :task, - :team, - :templates, - :update_version_file, - :vanagon_project, - :version, - :version_file, - :version_strategy, - :yum_archive_path, - :yum_host, - :yum_repo_command, - :yum_repo_name, - :yum_repo_path, - :yum_staging_server, - ] + BUILD_PARAMS = [ + :allow_dirty_tree, + :answer_override, + :apt_archive_path, + :apt_archive_repo_command, + :apt_host, + :apt_releases, + :apt_repo_command, + :apt_repo_name, + :apt_repo_path, + :apt_repo_staging_path, + :apt_repo_url, + :apt_signing_server, + :apt_staging_server, + :author, + :benchmark, + :build_data_repo, + :build_date, + :build_defaults, + :build_dmg, + :build_doc, + :build_gem, + :build_ips, + :build_msi, + :build_pe, + :build_tar, + :builder_data_file, + :builds_server, + :bundle_platforms, + :certificate_pem, + :cows, + :db_table, + :deb_build_host, + :deb_build_mirrors, + :deb_targets, + :debug, + :debversion, + :default_cow, + :default_mock, + :dev_build, + :description, + :distribution_server, + :dmg_host, + :dmg_path, + :dmg_staging_server, + :downloads_archive_path, + :email, + :files, + :final_mocks, + :foss_only, + :foss_platforms, + :freight_archive_path, + :freight_conf, + :gem_default_executables, + :gem_dependencies, + :gem_description, + :gem_devel_dependencies, + :gem_development_dependencies, + :gem_excludes, + :gem_executables, + :gem_files, + :gem_forge_project, + :gem_host, + :gem_name, + :gem_path, + :gem_platform_dependencies, + :gem_rdoc_options, + :gem_require_path, + :gem_required_ruby_version, + :gem_required_rubygems_version, + :gem_runtime_dependencies, + :gem_summary, + :gem_test_files, + :gemversion, + :gpg_key, + :gpg_name, + :homepage, + :internal_gem_host, + :ips_build_host, + :ips_host, + :ips_inter_cert, + :ips_package_host, + :ips_path, + :ips_repo, + :ips_root_cert, + :ips_signing_cert, + :ips_signing_key, + :ips_signing_server, + :ips_signing_ssh_key, + :ips_store, + :jenkins_build_host, + :jenkins_packaging_job, + :jenkins_repo_path, + :metrics, + :metrics_url, + :msi_host, + :msi_name, + :msi_path, + :msi_signing_cert, + :msi_signing_cert_pw, + :msi_signing_server, + :msi_signing_ssh_key, + :msi_staging_server, + :name, + :nonfinal_apt_repo_command, + :nonfinal_apt_repo_path, + :nonfinal_apt_repo_staging_path, + :nonfinal_dmg_path, + :nonfinal_gem_path, + :nonfinal_ips_path, + :nonfinal_msi_path, + :nonfinal_p5p_path, + :nonfinal_repo_name, + :nonfinal_repo_link_target, + :nonfinal_svr4_path, + :nonfinal_swix_path, + :nonfinal_yum_repo_path, + :notify, + :nuget_host, + :nuget_repo_path, + :origversion, + :osx_build_host, + :osx_signing_cert, + :osx_signing_keychain, + :osx_signing_keychain_pw, + :osx_signing_server, + :osx_signing_ssh_key, + :p5p_host, + :p5p_path, + :packager, + :packaging_repo, + :packaging_root, + :packaging_url, + :pbuild_conf, + :pe_feature_branch, + :pe_release_branch, + :pe_name, + :pe_platforms, + :pe_version, + :pg_major_version, + :platform_repos, + :pre_tar_task, + :pre_tasks, + :privatekey_pem, + :project, + :project_root, + :random_mockroot, + :rc_mocks, + :redis_hostname, + :ref, + :release, + :repo_link_target, + :repo_name, + :rpm_build_host, + :rpm_targets, + :rpmrelease, + :rpmversion, + :rsync_servers, + :s3_ship, + :short_ref, + :sign_tar, + :signing_bundle, + :signing_server, + :staging_server, + :summary, + :svr4_host, + :svr4_path, + :swix_host, + :swix_path, + :swix_staging_server, + :tar_excludes, + :tar_host, + :tar_staging_server, + :tarball_path, + :task, + :team, + :templates, + :update_version_file, + :vanagon_project, + :version, + :version_file, + :version_strategy, + :yum_archive_path, + :yum_host, + :yum_repo_command, + :yum_repo_name, + :yum_repo_path, + :yum_staging_server, + ] # Environment variable overrides for Pkg::Config parameters # @@ -199,144 +200,146 @@ module Pkg::Params # Note: :type is assumed :string if not present # ENV_VARS = [ - { :var => :allow_dirty_tree, :envvar => :ALLOW_DIRTY_TREE, :type => :bool }, - { :var => :answer_override, :envvar => :ANSWER_OVERRIDE }, - { :var => :apt_archive_path, :envvar => :APT_ARCHIVE_PATH }, - { :var => :apt_archive_repo_command, :envvar => :APT_ARCHIVE_REPO_COMMAND }, - { :var => :apt_host, :envvar => :APT_HOST }, - { :var => :apt_releases, :envvar => :APT_RELEASES, :type => :array }, - { :var => :apt_repo_path, :envvar => :APT_REPO }, - { :var => :apt_repo_staging_path, :envvar => :APT_REPO_STAGING_PATH }, - { :var => :apt_signing_server, :envvar => :APT_SIGNING_SERVER }, - { :var => :apt_staging_server, :envvar => :APT_STAGING_SERVER }, - { :var => :build_data_repo, :envvar => :BUILD_DATA_REPO }, - { :var => :build_dmg, :envvar => :DMG, :type => :bool }, - { :var => :build_doc, :envvar => :DOC, :type => :bool }, - { :var => :build_gem, :envvar => :GEM, :type => :bool }, - { :var => :build_ips, :envvar => :IPS, :type => :bool }, - { :var => :build_msi, :envvar => :MSI, :type => :bool }, - { :var => :build_pe, :envvar => :PE_BUILD, :type => :bool }, - { :var => :build_tar, :envvar => :TAR, :type => :bool }, - { :var => :certificate_pem, :envvar => :CERT_PEM }, - { :var => :cows, :envvar => :COW }, - { :var => :debug, :envvar => :DEBUG, :type => :bool }, - { :var => :default_cow, :envvar => :COW }, - { :var => :default_mock, :envvar => :MOCK }, - { :var => :dev_build, :envvar => :DEV_BUILD, :type => :bool }, - { :var => :dmg_host, :envvar => :DMG_HOST }, - { :var => :dmg_path, :envvar => :DMG_PATH }, - { :var => :dmg_staging_server, :envvar => :DMG_STAGING_SERVER }, - { :var => :downloads_archive_path, :envvar => :DOWNLOADS_ARCHIVE_PATH }, - { :var => :final_mocks, :envvar => :MOCK }, - { :var => :foss_only, :envvar => :FOSS_ONLY, :type => :bool }, - { :var => :foss_platforms, :envvar => :FOSS_PLATFORMS, :type => :array }, - { :var => :freight_archive_path, :envvar => :FREIGHT_ARCHIVE_PATH }, - { :var => :gem_host, :envvar => :GEM_HOST }, - { :var => :gpg_key, :envvar => :GPG_KEY }, - { :var => :gpg_name, :envvar => :GPG_NAME }, - { :var => :ips_host, :envvar => :IPS_HOST }, - { :var => :ips_inter_cert, :envvar => :IPS_INTER_CERT }, - { :var => :ips_path, :envvar => :IPS_PATH }, - { :var => :ips_repo, :envvar => :IPS_REPO }, - { :var => :ips_root_cert, :envvar => :IPS_ROOT_CERT }, - { :var => :ips_signing_cert, :envvar => :IPS_SIGNING_CERT }, - { :var => :ips_signing_key, :envvar => :IPS_SIGNING_KEY }, - { :var => :ips_signing_server, :envvar => :IPS_SIGNING_SERVER }, - { :var => :ips_signing_ssh_key, :envvar => :IPS_SIGNING_SSH_KEY }, - { :var => :msi_host, :envvar => :MSI_HOST }, - { :var => :msi_path, :envvar => :MSI_PATH }, - { :var => :msi_signing_cert, :envvar => :MSI_SIGNING_CERT }, - { :var => :msi_signing_cert_pw, :envvar => :MSI_SIGNING_CERT_PW }, - { :var => :msi_signing_server, :envvar => :MSI_SIGNING_SERVER }, - { :var => :msi_signing_ssh_key, :envvar => :MSI_SIGNING_SSH_KEY }, - { :var => :msi_staging_server, :envvar => :MSI_STAGING_SERVER }, - { :var => :nonfinal_apt_repo_command, :envvar => :NONFINAL_APT_REPO_COMMAND }, - { :var => :nonfinal_apt_repo_path, :envvar => :NONFINAL_APT_REPO_PATH }, - { :var => :nonfinal_apt_repo_staging_path, :envvar => :NONFINAL_APT_REPO_STAGING_PATH }, - { :var => :nonfinal_dmg_path, :envvar => :NONFINAL_DMG_PATH }, - { :var => :nonfinal_gem_path, :envvar => :NONFINAL_GEM_PATH }, - { :var => :nonfinal_ips_path, :envvar => :NONFINAL_IPS_PATH }, - { :var => :nonfinal_msi_path, :envvar => :NONFINAL_MSI_PATH }, - { :var => :nonfinal_p5p_path, :envvar => :NONFINAL_P5P_PATH }, - { :var => :nonfinal_repo_link_target, :envvar => :NONFINAL_REPO_LINK_TARGET }, - { :var => :nonfinal_repo_name, :envvar => :NONFINAL_REPO_NAME }, - { :var => :nonfinal_svr4_path, :envvar => :NONFINAL_SVR4_PATH }, - { :var => :nonfinal_swix_path, :envvar => :NONFINAL_SWIX_PATH }, - { :var => :nonfinal_yum_repo_path, :envvar => :NONFINAL_YUM_REPO_PATH }, - { :var => :notify, :envvar => :NOTIFY }, - { :var => :nuget_host, :envvar => :NUGET_HOST }, - { :var => :nuget_repo_path, :envvar => :NUGET_REPO }, - { :var => :osx_signing_cert, :envvar => :OSX_SIGNING_CERT }, - { :var => :osx_signing_keychain, :envvar => :OSX_SIGNING_KEYCHAIN }, - { :var => :osx_signing_keychain_pw, :envvar => :OSX_SIGNING_KEYCHAIN_PW }, - { :var => :osx_signing_server, :envvar => :OSX_SIGNING_SERVER }, - { :var => :osx_signing_ssh_key, :envvar => :OSX_SIGNING_SSH_KEY }, - { :var => :p5p_host, :envvar => :P5P_HOST }, - { :var => :p5p_path, :envvar => :P5P_PATH }, - { :var => :packager, :envvar => :PACKAGER }, - { :var => :pbuild_conf, :envvar => :PBUILDCONF }, - { :var => :pe_feature_branch, :envvar => :PE_FEATURE_BRANCH }, - { :var => :pe_version, :envvar => :PE_VER }, - { :var => :privatekey_pem, :envvar => :PRIVATE_PEM }, - { :var => :project, :envvar => :PROJECT_OVERRIDE }, - { :var => :project_root, :envvar => :PROJECT_ROOT }, - { :var => :random_mockroot, :envvar => :RANDOM_MOCKROOT, :type => :bool }, - { :var => :rc_mocks, :envvar => :MOCK }, - { :var => :ref, :envvar => :DEBUG_REF }, - { :var => :release, :envvar => :RELEASE }, - { :var => :repo_name, :envvar => :REPO_NAME }, - { :var => :repo_link_target, :envvar => :REPO_LINK_TARGET }, - { :var => :s3_ship, :envvar => :S3_SHIP, :type => :bool }, - { :var => :sign_tar, :envvar => :SIGN_TAR, :type => :bool }, - { :var => :signing_bundle, :envvar => :SIGNING_BUNDLE }, - { :var => :signing_server, :envvar => :SIGNING_SERVER }, - { :var => :staging_server, :envvar => :STAGING_SERVER }, - { :var => :swix_host, :envvar => :SWIX_HOST }, - { :var => :swix_staging_server, :envvar => :SWIX_STAGING_SERVER }, - { :var => :svr4_host, :envvar => :SVR4_HOST }, - { :var => :svr4_path, :envvar => :SVR4_PATH }, - { :var => :swix_path, :envvar => :SWIX_PATH }, - { :var => :tar_host, :envvar => :TAR_HOST }, - { :var => :tar_staging_server, :envvar => :TAR_STAGING_SERVER }, - { :var => :team, :envvar => :TEAM }, - { :var => :update_version_file, :envvar => :NEW_STYLE_PACKAGE }, - { :var => :vanagon_project, :envvar => :VANAGON_PROJECT, :type => :bool }, - { :var => :version, :envvar => :PACKAGING_PACKAGE_VERSION }, - { :var => :yum_archive_path, :envvar => :YUM_ARCHIVE_PATH }, - { :var => :yum_host, :envvar => :YUM_HOST }, - { :var => :yum_repo_path, :envvar => :YUM_REPO }, - { :var => :yum_staging_server, :envvar => :YUM_STAGING_SERVER }, - { :var => :internal_gem_host, :envvar => :INTERNAL_GEM_HOST }, - ] + { :var => :allow_dirty_tree, :envvar => :ALLOW_DIRTY_TREE, :type => :bool }, + { :var => :answer_override, :envvar => :ANSWER_OVERRIDE }, + { :var => :apt_archive_path, :envvar => :APT_ARCHIVE_PATH }, + { :var => :apt_archive_repo_command, :envvar => :APT_ARCHIVE_REPO_COMMAND }, + { :var => :apt_host, :envvar => :APT_HOST }, + { :var => :apt_releases, :envvar => :APT_RELEASES, :type => :array }, + { :var => :apt_repo_path, :envvar => :APT_REPO }, + { :var => :apt_repo_staging_path, :envvar => :APT_REPO_STAGING_PATH }, + { :var => :apt_signing_server, :envvar => :APT_SIGNING_SERVER }, + { :var => :apt_staging_server, :envvar => :APT_STAGING_SERVER }, + { :var => :build_data_repo, :envvar => :BUILD_DATA_REPO }, + { :var => :build_dmg, :envvar => :DMG, :type => :bool }, + { :var => :build_doc, :envvar => :DOC, :type => :bool }, + { :var => :build_gem, :envvar => :GEM, :type => :bool }, + { :var => :build_ips, :envvar => :IPS, :type => :bool }, + { :var => :build_msi, :envvar => :MSI, :type => :bool }, + { :var => :build_pe, :envvar => :PE_BUILD, :type => :bool }, + { :var => :build_tar, :envvar => :TAR, :type => :bool }, + { :var => :certificate_pem, :envvar => :CERT_PEM }, + { :var => :cows, :envvar => :COW }, + { :var => :debug, :envvar => :DEBUG, :type => :bool }, + { :var => :default_cow, :envvar => :COW }, + { :var => :default_mock, :envvar => :MOCK }, + { :var => :dev_build, :envvar => :DEV_BUILD, :type => :bool }, + { :var => :dmg_host, :envvar => :DMG_HOST }, + { :var => :dmg_path, :envvar => :DMG_PATH }, + { :var => :dmg_staging_server, :envvar => :DMG_STAGING_SERVER }, + { :var => :downloads_archive_path, :envvar => :DOWNLOADS_ARCHIVE_PATH }, + { :var => :final_mocks, :envvar => :MOCK }, + { :var => :foss_only, :envvar => :FOSS_ONLY, :type => :bool }, + { :var => :foss_platforms, :envvar => :FOSS_PLATFORMS, :type => :array }, + { :var => :freight_archive_path, :envvar => :FREIGHT_ARCHIVE_PATH }, + { :var => :gem_host, :envvar => :GEM_HOST }, + { :var => :gpg_key, :envvar => :GPG_KEY }, + { :var => :gpg_name, :envvar => :GPG_NAME }, + { :var => :ips_host, :envvar => :IPS_HOST }, + { :var => :ips_inter_cert, :envvar => :IPS_INTER_CERT }, + { :var => :ips_path, :envvar => :IPS_PATH }, + { :var => :ips_repo, :envvar => :IPS_REPO }, + { :var => :ips_root_cert, :envvar => :IPS_ROOT_CERT }, + { :var => :ips_signing_cert, :envvar => :IPS_SIGNING_CERT }, + { :var => :ips_signing_key, :envvar => :IPS_SIGNING_KEY }, + { :var => :ips_signing_server, :envvar => :IPS_SIGNING_SERVER }, + { :var => :ips_signing_ssh_key, :envvar => :IPS_SIGNING_SSH_KEY }, + { :var => :msi_host, :envvar => :MSI_HOST }, + { :var => :msi_path, :envvar => :MSI_PATH }, + { :var => :msi_signing_cert, :envvar => :MSI_SIGNING_CERT }, + { :var => :msi_signing_cert_pw, :envvar => :MSI_SIGNING_CERT_PW }, + { :var => :msi_signing_server, :envvar => :MSI_SIGNING_SERVER }, + { :var => :msi_signing_ssh_key, :envvar => :MSI_SIGNING_SSH_KEY }, + { :var => :msi_staging_server, :envvar => :MSI_STAGING_SERVER }, + { :var => :nonfinal_apt_repo_command, :envvar => :NONFINAL_APT_REPO_COMMAND }, + { :var => :nonfinal_apt_repo_path, :envvar => :NONFINAL_APT_REPO_PATH }, + { :var => :nonfinal_apt_repo_staging_path, :envvar => :NONFINAL_APT_REPO_STAGING_PATH }, + { :var => :nonfinal_dmg_path, :envvar => :NONFINAL_DMG_PATH }, + { :var => :nonfinal_gem_path, :envvar => :NONFINAL_GEM_PATH }, + { :var => :nonfinal_ips_path, :envvar => :NONFINAL_IPS_PATH }, + { :var => :nonfinal_msi_path, :envvar => :NONFINAL_MSI_PATH }, + { :var => :nonfinal_p5p_path, :envvar => :NONFINAL_P5P_PATH }, + { :var => :nonfinal_repo_link_target, :envvar => :NONFINAL_REPO_LINK_TARGET }, + { :var => :nonfinal_repo_name, :envvar => :NONFINAL_REPO_NAME }, + { :var => :nonfinal_svr4_path, :envvar => :NONFINAL_SVR4_PATH }, + { :var => :nonfinal_swix_path, :envvar => :NONFINAL_SWIX_PATH }, + { :var => :nonfinal_yum_repo_path, :envvar => :NONFINAL_YUM_REPO_PATH }, + { :var => :notify, :envvar => :NOTIFY }, + { :var => :nuget_host, :envvar => :NUGET_HOST }, + { :var => :nuget_repo_path, :envvar => :NUGET_REPO }, + { :var => :osx_signing_cert, :envvar => :OSX_SIGNING_CERT }, + { :var => :osx_signing_keychain, :envvar => :OSX_SIGNING_KEYCHAIN }, + { :var => :osx_signing_keychain_pw, :envvar => :OSX_SIGNING_KEYCHAIN_PW }, + { :var => :osx_signing_server, :envvar => :OSX_SIGNING_SERVER }, + { :var => :osx_signing_ssh_key, :envvar => :OSX_SIGNING_SSH_KEY }, + { :var => :p5p_host, :envvar => :P5P_HOST }, + { :var => :p5p_path, :envvar => :P5P_PATH }, + { :var => :packager, :envvar => :PACKAGER }, + { :var => :pbuild_conf, :envvar => :PBUILDCONF }, + { :var => :pe_feature_branch, :envvar => :PE_FEATURE_BRANCH }, + { :var => :pe_version, :envvar => :PE_VER }, + { :var => :privatekey_pem, :envvar => :PRIVATE_PEM }, + { :var => :project, :envvar => :PROJECT_OVERRIDE }, + { :var => :project_root, :envvar => :PROJECT_ROOT }, + { :var => :random_mockroot, :envvar => :RANDOM_MOCKROOT, :type => :bool }, + { :var => :rc_mocks, :envvar => :MOCK }, + { :var => :ref, :envvar => :DEBUG_REF }, + { :var => :release, :envvar => :RELEASE }, + { :var => :repo_name, :envvar => :REPO_NAME }, + { :var => :repo_link_target, :envvar => :REPO_LINK_TARGET }, + { :var => :s3_ship, :envvar => :S3_SHIP, :type => :bool }, + { :var => :sign_tar, :envvar => :SIGN_TAR, :type => :bool }, + { :var => :signing_bundle, :envvar => :SIGNING_BUNDLE }, + { :var => :signing_server, :envvar => :SIGNING_SERVER }, + { :var => :staging_server, :envvar => :STAGING_SERVER }, + { :var => :swix_host, :envvar => :SWIX_HOST }, + { :var => :swix_staging_server, :envvar => :SWIX_STAGING_SERVER }, + { :var => :svr4_host, :envvar => :SVR4_HOST }, + { :var => :svr4_path, :envvar => :SVR4_PATH }, + { :var => :swix_path, :envvar => :SWIX_PATH }, + { :var => :tar_host, :envvar => :TAR_HOST }, + { :var => :tar_staging_server, :envvar => :TAR_STAGING_SERVER }, + { :var => :team, :envvar => :TEAM }, + { :var => :update_version_file, :envvar => :NEW_STYLE_PACKAGE }, + { :var => :vanagon_project, :envvar => :VANAGON_PROJECT, :type => :bool }, + { :var => :version, :envvar => :PACKAGING_PACKAGE_VERSION }, + { :var => :yum_archive_path, :envvar => :YUM_ARCHIVE_PATH }, + { :var => :yum_host, :envvar => :YUM_HOST }, + { :var => :yum_repo_path, :envvar => :YUM_REPO }, + { :var => :yum_staging_server, :envvar => :YUM_STAGING_SERVER }, + { :var => :internal_gem_host, :envvar => :INTERNAL_GEM_HOST }, + ] # Default values that are supplied if the user does not supply them # # usage is the same as above # - DEFAULTS = [{ :var => :allow_dirty_tree, :val => false }, - { :var => :builder_data_file, :val => 'builder_data.yaml' }, - { :var => :team, :val => 'dev' }, - { :var => :random_mockroot, :val => true }, - { :var => :keychain_loaded, :val => false }, - { :var => :foss_only, :val => false }, - { :var => :build_data_repo, :val => 'https://github.com/puppetlabs/build-data.git' }, - { :var => :build_date, :val => Pkg::Util::Date.timestamp('-') }, - { :var => :release, :val => '1' }, - { :var => :internal_gem_host, :val => 'https://artifactory.delivery.puppetlabs.net/artifactory/api/gems/rubygems' }, - { :var => :build_tar, :val => true }, - { :var => :dev_build, :val => false }, - { :var => :osx_signing_cert, :val => '$OSX_SIGNING_CERT' }, - { :var => :osx_signing_keychain, :val => '$OSX_SIGNING_KEYCHAIN' }, - { :var => :osx_signing_keychain_pw, :val => '$OSX_SIGNING_KEYCHAIN_PW' }, - { :var => :ips_signing_cert, :val => '$IPS_SIGNING_CERT' }, - { :var => :ips_inter_cert, :val => '$IPS_INTER_CERT' }, - { :var => :ips_root_cert, :val => '$IPS_ROOT_CERT' }, - { :var => :ips_signing_key, :val => '$IPS_SIGNING_KEY' }, - { :var => :msi_signing_cert, :val => '$MSI_SIGNING_CERT' }, - { :var => :msi_signing_cert_pw, :val => '$MSI_SIGNING_CERT_PW' }, - { :var => :pe_feature_branch, :val => false }, - { :var => :pe_release_branch, :val => false }, - { :var => :s3_ship, :val => false }, - { :var => :apt_releases, :val => Pkg::Platforms.codenames }] + DEFAULTS = [ + { :var => :allow_dirty_tree, :val => false }, + { :var => :builder_data_file, :val => 'builder_data.yaml' }, + { :var => :team, :val => 'dev' }, + { :var => :random_mockroot, :val => true }, + { :var => :keychain_loaded, :val => false }, + { :var => :foss_only, :val => false }, + { :var => :build_data_repo, :val => 'https://github.com/puppetlabs/build-data.git' }, + { :var => :build_date, :val => Pkg::Util::Date.timestamp('-') }, + { :var => :release, :val => '1' }, + { :var => :internal_gem_host, :val => 'https://artifactory.delivery.puppetlabs.net/artifactory/api/gems/rubygems' }, + { :var => :build_tar, :val => true }, + { :var => :dev_build, :val => false }, + { :var => :osx_signing_cert, :val => '$OSX_SIGNING_CERT' }, + { :var => :osx_signing_keychain, :val => '$OSX_SIGNING_KEYCHAIN' }, + { :var => :osx_signing_keychain_pw, :val => '$OSX_SIGNING_KEYCHAIN_PW' }, + { :var => :ips_signing_cert, :val => '$IPS_SIGNING_CERT' }, + { :var => :ips_inter_cert, :val => '$IPS_INTER_CERT' }, + { :var => :ips_root_cert, :val => '$IPS_ROOT_CERT' }, + { :var => :ips_signing_key, :val => '$IPS_SIGNING_KEY' }, + { :var => :msi_signing_cert, :val => '$MSI_SIGNING_CERT' }, + { :var => :msi_signing_cert_pw, :val => '$MSI_SIGNING_CERT_PW' }, + { :var => :pe_feature_branch, :val => false }, + { :var => :pe_release_branch, :val => false }, + { :var => :s3_ship, :val => false }, + { :var => :apt_releases, :val => Pkg::Platforms.codenames }, + ] # These are variables which, over time, we decided to rename or replace. For # backwards compatibility, we assign the value of the old/deprecated @@ -345,38 +348,40 @@ module Pkg::Params # in case it is not set. # REASSIGNMENTS = [ - # These are fall-through values for shipping endpoints - { :oldvar => :staging_server, :newvar => :apt_staging_server }, - { :oldvar => :staging_server, :newvar => :dmg_staging_server }, - { :oldvar => :staging_server, :newvar => :swix_staging_server }, - { :oldvar => :staging_server, :newvar => :tar_staging_server }, - { :oldvar => :staging_server, :newvar => :yum_staging_server }, - # These are fall-through values for signing/repo endpoints - { :oldvar => :yum_staging_server, :newvar => :yum_host }, - { :oldvar => :apt_repo_staging_path, :newvar => :apt_repo_path }, - { :oldvar => :apt_signing_server, :newvar => :apt_host }, - # These are legitimately old values - { :oldvar => :gem_devel_dependencies, :newvar => :gem_development_dependencies }, - { :oldvar => :gpg_name, :newvar => :gpg_key }, - { :oldvar => :name, :newvar => :project }, - { :oldvar => :pe_name, :newvar => :project }, - { :oldvar => :project, :newvar => :gem_name }, - { :oldvar => :yum_host, :newvar => :swix_host }, - { :oldvar => :yum_host, :newvar => :dmg_host }, - { :oldvar => :yum_host, :newvar => :tar_host }, - ] - + # These are fall-through values for shipping endpoints + { :oldvar => :staging_server, :newvar => :apt_staging_server }, + { :oldvar => :staging_server, :newvar => :dmg_staging_server }, + { :oldvar => :staging_server, :newvar => :swix_staging_server }, + { :oldvar => :staging_server, :newvar => :tar_staging_server }, + { :oldvar => :staging_server, :newvar => :yum_staging_server }, + # These are fall-through values for signing/repo endpoints + { :oldvar => :yum_staging_server, :newvar => :yum_host }, + { :oldvar => :apt_repo_staging_path, :newvar => :apt_repo_path }, + { :oldvar => :apt_signing_server, :newvar => :apt_host }, + # These are legitimately old values + { :oldvar => :gem_devel_dependencies, :newvar => :gem_development_dependencies }, + { :oldvar => :gpg_name, :newvar => :gpg_key }, + { :oldvar => :name, :newvar => :project }, + { :oldvar => :pe_name, :newvar => :project }, + { :oldvar => :project, :newvar => :gem_name }, + { :oldvar => :yum_host, :newvar => :swix_host }, + { :oldvar => :yum_host, :newvar => :dmg_host }, + { :oldvar => :yum_host, :newvar => :tar_host }, + ] # These are variables that we have deprecated. If they are encountered in a # project's config, we issue deprecations for them. # - DEPRECATIONS = [{ :var => :gem_devel_dependencies, :message => " - DEPRECATED, 9-Nov-2013: 'gem_devel_dependencies' has been replaced with - 'gem_development_dependencies.' Please update this field in your - build_defaults.yaml or project_data.yaml" }, - { :var => :gpg_name, :message => " - DEPRECATED, 29-Jul-2014: 'gpg_name' has been replaced with 'gpg_key'. - Please update this field in your build_defaults.yaml" }] + DEPRECATIONS = [ + { + :var => :gem_devel_dependencies, + :message => " DEPRECATED, 9-Nov-2013: 'gem_devel_dependencies' has been replaced with 'gem_development_dependencies.' Please update this field in your build_defaults.yaml or project_data.yaml", + }, + { + :var => :gpg_name, + :message => " DEPRECATED, 29-Jul-2014: 'gpg_name' has been replaced with 'gpg_key'. Please update this field in your build_defaults.yaml", + }, + ] # Provide an open-ended template for validating BUILD_PARAMS. # @@ -384,7 +389,6 @@ module Pkg::Params # must pass from the Pkg::Params::Validations class. # VALIDATIONS = [ - { :var => :project, :validations => [:not_empty?] } + { :var => :project, :validations => [:not_empty?] }, ] - end diff --git a/lib/packaging/config/validations.rb b/lib/packaging/config/validations.rb index e804544d..d6bf0083 100644 --- a/lib/packaging/config/validations.rb +++ b/lib/packaging/config/validations.rb @@ -1,8 +1,6 @@ module Pkg class ConfigValidations - class << self - # As a validation, this one is kindof lame but is intended as a seed pattern for possibly # more robust ones. def not_empty?(value) diff --git a/lib/packaging/deb.rb b/lib/packaging/deb.rb index fc53d2b7..e960c05a 100644 --- a/lib/packaging/deb.rb +++ b/lib/packaging/deb.rb @@ -8,6 +8,7 @@ def set_cow_envs(cow) if elements.nil? fail "Didn't get a matching cow, e.g. 'base-squeeze-i386'" end + dist = elements[1] arch = elements[2] if Pkg::Config.build_pe diff --git a/lib/packaging/deb/repo.rb b/lib/packaging/deb/repo.rb index f29e8c1a..193dd200 100644 --- a/lib/packaging/deb/repo.rb +++ b/lib/packaging/deb/repo.rb @@ -2,9 +2,7 @@ require 'fileutils' module Pkg::Deb::Repo - class << self - # This is the default set of arches we are using for our reprepro repos. We # take this list and combine it with the list of supported arches for each # given platform to ensure a complete set of architectures. We use this @@ -43,7 +41,7 @@ def generate_repo_configs(source = "repos", target = "repo_configs") # First test if the directory even exists # begin - stdout, _, _ = Pkg::Util::Execution.capture3("#{wget} --spider -r -l 1 --no-parent #{repo_base} 2>&1") + stdout, = Pkg::Util::Execution.capture3("#{wget} --spider -r -l 1 --no-parent #{repo_base} 2>&1") rescue RuntimeError warn "No debian repos available for #{Pkg::Config.project} at #{Pkg::Config.ref}." return @@ -52,7 +50,6 @@ def generate_repo_configs(source = "repos", target = "repo_configs") # We want to exclude index and robots files and only include the http: prefixed elements repo_urls = stdout.split.uniq.reject { |x| x =~ /\?|index|robots/ }.select { |x| x =~ /http:/ }.map { |x| x.chomp('/') } - # Create apt sources.list files that can be added to hosts for installing # these packages. We use the list of distributions to create a config # file for every distribution. @@ -61,11 +58,11 @@ def generate_repo_configs(source = "repos", target = "repo_configs") repo_urls.each do |url| # We want to skip the base_url, which wget returns as one of the results next if "#{url}/" == repo_base + platform_tag = Pkg::Paths.tag_from_artifact_path(url) - platform, version, _ = Pkg::Platforms.parse_platform_tag(platform_tag) + platform, version, = Pkg::Platforms.parse_platform_tag(platform_tag) codename = Pkg::Platforms.codename_for_platform_version(platform, version) - repoconfig = ["# Packages for #{Pkg::Config.project} built from ref #{Pkg::Config.ref}", - "deb #{url} #{codename} #{reprepro_repo_name}"] + repoconfig = ["# Packages for #{Pkg::Config.project} built from ref #{Pkg::Config.ref}", "deb #{url} #{codename} #{reprepro_repo_name}"] config = File.join("pkg", target, "deb", "pl-#{Pkg::Config.project}-#{Pkg::Config.ref}-#{codename}.list") File.open(config, 'w') { |f| f.puts repoconfig } end @@ -76,7 +73,7 @@ def retrieve_repo_configs(target = "repo_configs") wget = Pkg::Util::Tool.check_tool("wget") FileUtils.mkdir_p("pkg/#{target}") config_url = "#{base_url}/#{target}/deb/" - stdout, _, _ = Pkg::Util::Execution.capture3("#{wget} -r -np -nH --cut-dirs 3 -P pkg/#{target} --reject 'index*' #{config_url}") + stdout, = Pkg::Util::Execution.capture3("#{wget} -r -np -nH --cut-dirs 3 -P pkg/#{target} --reject 'index*' #{config_url}") stdout rescue => e fail "Couldn't retrieve deb apt repo configs.\n#{e}" @@ -95,7 +92,7 @@ def repo_creation_command(repo_directory, artifact_paths) artifact_paths.each do |path| platform_tag = Pkg::Paths.tag_from_artifact_path(path) - platform, version, _ = Pkg::Platforms. parse_platform_tag(platform_tag) + platform, version, = Pkg::Platforms.parse_platform_tag(platform_tag) codename = Pkg::Platforms.codename_for_platform_version(platform, version) arches = Pkg::Platforms.arches_for_codename(codename) @@ -166,6 +163,7 @@ def sign_repos(target = "repos", message = "Signed apt repository") dists.each do |dist| next unless supported_codenames.include?(dist) + arches = Pkg::Platforms.arches_for_codename(dist) Dir.chdir("#{target}/apt/#{dist}") do File.open("conf/distributions", "w") do |f| @@ -178,7 +176,7 @@ def sign_repos(target = "repos", message = "Signed apt repository") SignWith: #{Pkg::Config.gpg_key}" end - stdout, _, _ = Pkg::Util::Execution.capture3("#{reprepro} -vvv --confdir ./conf --dbdir ./db --basedir ./ export") + stdout, = Pkg::Util::Execution.capture3("#{reprepro} -vvv --confdir ./conf --dbdir ./db --basedir ./ export") stdout end end @@ -259,6 +257,5 @@ def deploy_repos(apt_path, destination_staging_path, origin_server, destination_ Pkg::Util::Net.remote_execute(destination_server, cp_command) end end - end end diff --git a/lib/packaging/gem.rb b/lib/packaging/gem.rb index 0d2513e8..6730ab06 100644 --- a/lib/packaging/gem.rb +++ b/lib/packaging/gem.rb @@ -63,7 +63,7 @@ def ship_to_internal_mirror(file) internal_mirror_api_key_name = 'artifactory_api_key' ship_to_rubygems(file, { host: Pkg::Config.internal_gem_host, - key: internal_mirror_api_key_name + key: internal_mirror_api_key_name, }) end end diff --git a/lib/packaging/nuget.rb b/lib/packaging/nuget.rb index 0aafdb5a..f11f6e74 100644 --- a/lib/packaging/nuget.rb +++ b/lib/packaging/nuget.rb @@ -32,6 +32,7 @@ def ship(packages) stdout, retval = Pkg::Util::Net.curl_form_data("#{uri}/#{package_path}", form_data + package_form_data) end fail "The Package upload (curl) failed with error #{retval}" unless Pkg::Util::Execution.success?(retval) + stdout end end diff --git a/lib/packaging/paths.rb b/lib/packaging/paths.rb index ad33a5e4..fb5e93a7 100644 --- a/lib/packaging/paths.rb +++ b/lib/packaging/paths.rb @@ -16,6 +16,7 @@ def arch_from_artifact_path(platform, version, path) if source_formats.find { |fmt| path =~ /#{fmt}$/ } return Pkg::Platforms.get_attribute_for_platform_version(platform, version, :source_architecture) end + arches.find { |a| path.include?(package_arch(platform, a)) } || arches[0] rescue arches.find { |a| path.include?(package_arch(platform, a)) } || arches[0] @@ -98,6 +99,7 @@ def apt_repo_name(nonfinal = false) def link_name(nonfinal = false) return Pkg::Config.nonfinal_repo_link_target if nonfinal + return Pkg::Config.repo_link_target end @@ -170,7 +172,7 @@ def construct_link_path(path_data) # Given platform information, create symlink target (base_path) and link path in the # form of a 2-element array def artifacts_base_path_and_link_path(platform_tag, prefix = 'artifacts', is_nonfinal = false) - platform_name, _ = Pkg::Platforms.parse_platform_tag(platform_tag) + platform_name, = Pkg::Platforms.parse_platform_tag(platform_tag) package_format = Pkg::Platforms.package_format_for_tag(platform_tag) path_data = { @@ -179,17 +181,17 @@ def artifacts_base_path_and_link_path(platform_tag, prefix = 'artifacts', is_non package_format: package_format, platform_name: platform_name, platform_tag: platform_tag, - prefix: prefix + prefix: prefix, } return [ construct_base_path(path_data), - construct_link_path(path_data) + construct_link_path(path_data), ] end def artifacts_path(platform_tag, path_prefix = 'artifacts', nonfinal = false) - base_path, _ = artifacts_base_path_and_link_path(platform_tag, path_prefix, nonfinal) + base_path, = artifacts_base_path_and_link_path(platform_tag, path_prefix, nonfinal) platform, version, architecture = Pkg::Platforms.parse_platform_tag(platform_tag) package_format = Pkg::Platforms.package_format_for_tag(platform_tag) @@ -279,19 +281,19 @@ def remote_repo_base(platform_tag = nil, nonfinal: false, package_format: nil) package_format ||= Pkg::Platforms.package_format_for_tag(platform_tag) repo_base = case package_format - when 'rpm' - nonfinal ? Pkg::Config.nonfinal_yum_repo_path : Pkg::Config.yum_repo_path - when 'deb' - nonfinal ? Pkg::Config.nonfinal_apt_repo_path : Pkg::Config.apt_repo_path - when 'dmg' - nonfinal ? Pkg::Config.nonfinal_dmg_path : Pkg::Config.dmg_path - when 'swix' - nonfinal ? Pkg::Config.nonfinal_swix_path : Pkg::Config.swix_path - when 'msi' - nonfinal ? Pkg::Config.nonfinal_msi_path : Pkg::Config.msi_path - else - raise "Can't determine remote repo base path for package format '#{package_format}'." - end + when 'rpm' + nonfinal ? Pkg::Config.nonfinal_yum_repo_path : Pkg::Config.yum_repo_path + when 'deb' + nonfinal ? Pkg::Config.nonfinal_apt_repo_path : Pkg::Config.apt_repo_path + when 'dmg' + nonfinal ? Pkg::Config.nonfinal_dmg_path : Pkg::Config.dmg_path + when 'swix' + nonfinal ? Pkg::Config.nonfinal_swix_path : Pkg::Config.swix_path + when 'msi' + nonfinal ? Pkg::Config.nonfinal_msi_path : Pkg::Config.msi_path + else + raise "Can't determine remote repo base path for package format '#{package_format}'." + end # normalize the path for things shipping to the downloads server if repo_base.match(/^\/opt\/downloads\/\w+$/) @@ -306,7 +308,7 @@ def apt_package_base_path(platform_tag, repo_name, project, nonfinal = false) fail "Can't determine path for non-debian platform #{platform_tag}." end - platform, version, _ = Pkg::Platforms.parse_platform_tag(platform_tag) + platform, version, = Pkg::Platforms.parse_platform_tag(platform_tag) code_name = Pkg::Platforms.codename_for_platform_version(platform, version) remote_repo_path = remote_repo_base(platform_tag, nonfinal: nonfinal) @@ -322,7 +324,7 @@ def apt_package_base_path(platform_tag, repo_name, project, nonfinal = false) if %w(puppet7 puppet7-nightly puppet6 puppet6-nightly puppet5 puppet5-nightly - puppet puppet-nightly + puppet puppet-nightly puppet-tools).include? repo_name return File.join(remote_repo_path, 'pool', code_name, repo_name, project[0], project) end @@ -331,7 +333,7 @@ def apt_package_base_path(platform_tag, repo_name, project, nonfinal = false) end def release_package_link_path(platform_tag, nonfinal = false) - platform, version, _ = Pkg::Platforms.parse_platform_tag(platform_tag) + platform, version, = Pkg::Platforms.parse_platform_tag(platform_tag) package_format = Pkg::Platforms.package_format_for_tag(platform_tag) case package_format when 'rpm' @@ -352,6 +354,7 @@ def debian_component_from_path(path) matches = path.match(/(\d+\.\d+|master|main)\/(\w+)/) regex_for_substitution = /[\.\/]/ fail "Error: Could not determine Debian Component from path #{path}" if matches.nil? + base_component = matches[1] component_qualifier = matches[2] full_component = "#{base_component}/#{component_qualifier}" @@ -360,17 +363,18 @@ def debian_component_from_path(path) full_component.gsub!(regex_for_substitution, '_') end return base_component if component_qualifier == 'repos' + return full_component end - #for ubuntu-20.04-aarch64, debian package architecture is arm64 + # for ubuntu-20.04-aarch64, debian package architecture is arm64 def package_arch(platform, arch) if platform == 'ubuntu' && arch == 'aarch64' return 'arm64' end + arch end private :package_arch - end diff --git a/lib/packaging/platforms.rb b/lib/packaging/platforms.rb index 033e51be..2c89558d 100644 --- a/lib/packaging/platforms.rb +++ b/lib/packaging/platforms.rb @@ -2,7 +2,6 @@ # explicitly supports module Pkg module Platforms - module_function DEBIAN_SOURCE_FORMATS = ['debian.tar.gz', 'orig.tar.gz', 'dsc', 'changes'] @@ -78,7 +77,7 @@ module Platforms source_package_formats: ['src.rpm'], signature_format: 'v4', repo: true, - } + }, }, 'fedora' => { @@ -139,7 +138,7 @@ module Platforms source_package_formats: ['src.rpm'], signature_format: 'v3', repo: true, - } + }, }, 'sles' => { @@ -230,14 +229,14 @@ module Platforms architectures: ['x86', 'x64'], package_format: 'msi', repo: false, - } + }, }, 'windowsfips' => { '2012' => { architectures: ['x64'], package_format: 'msi', repo: false, - } + }, }, }.freeze @@ -283,7 +282,6 @@ def parse_platform_tag(platform_tag) version ||= (platform_elements & versions_for_platform(platform)).first - # For platform names with a dash in them, because everything is special supported_arches = arches_for_platform_version(platform, version, true) architecture = platform_tag.sub(/^(#{platform}-#{version}|#{codename})-?/, '') @@ -302,7 +300,7 @@ def parse_platform_tag(platform_tag) # platform-version-arch # @return [Hash] The hash of data associated with the given platform version def platform_lookup(platform_tag) - platform, version, _ = parse_platform_tag(platform_tag) + platform, version, = parse_platform_tag(platform_tag) PLATFORM_INFO[platform][version] end @@ -314,12 +312,14 @@ def platform_lookup(platform_tag) def get_attribute(platform_tag, attribute_name) info = platform_lookup(platform_tag) raise "#{platform_tag} doesn't have information about #{attribute_name} available" unless info.key?(attribute_name) + info[attribute_name] end def get_attribute_for_platform_version(platform, version, attribute_name) info = PLATFORM_INFO[platform][version] raise "#{platform_tag} doesn't have information about #{attribute_name} available" unless info.key?(attribute_name) + info[attribute_name] end diff --git a/lib/packaging/repo.rb b/lib/packaging/repo.rb index 29c293c0..29534692 100644 --- a/lib/packaging/repo.rb +++ b/lib/packaging/repo.rb @@ -1,7 +1,5 @@ module Pkg::Repo - class << self - ## ## Construct a local_target based upon the versioning style ## @@ -29,6 +27,7 @@ def create_signed_repo_archive(repo_location, archive_name, versioning) if ENV['FAIL_ON_MISSING_TARGET'] == "true" raise "Error: missing packages under #{repo_location}" end + warn "Warn: Skipping #{archive_name} because #{repo_location} has no files" return end @@ -37,7 +36,7 @@ def create_signed_repo_archive(repo_location, archive_name, versioning) puts "Info: Archiving #{repo_location} as #{archive_name}" target_tarball = File.join('repos', "#{archive_name}.tar.gz") tar_command = "#{tar} --owner=0 --group=0 --create --gzip --file #{target_tarball} #{repo_location}" - stdout, _, _ = Pkg::Util::Execution.capture3(tar_command) + stdout, = Pkg::Util::Execution.capture3(tar_command) return stdout end end @@ -68,7 +67,7 @@ def update_tarball_of_all_repos(project, platform, versioning) end tar_command = "#{tar} --owner=0 --group=0 #{tar_action} --file #{all_repos_tarball_name} #{repo_tarball_path}" - stdout, _, _ = Pkg::Util::Execution.capture3(tar_command) + stdout, = Pkg::Util::Execution.capture3(tar_command) puts stdout end end @@ -81,7 +80,7 @@ def compress_tarball_of_all_repos(all_repos_tarball_name) gzip = Pkg::Util::Tool.check_tool('gzip') gzip_command = "#{gzip} --fast #{all_repos_tarball_name}" - stdout, _, _ = Pkg::Util::Execution.capture3(gzip_command) + stdout, = Pkg::Util::Execution.capture3(gzip_command) puts stdout end @@ -110,11 +109,11 @@ def directories_that_contain_packages(artifact_directory, pkg_ext) cmd = "[ -d #{artifact_directory} ] || exit 1 ; " cmd << "pushd #{artifact_directory} > /dev/null && " cmd << "find . -name '*.#{pkg_ext}' -print0 | xargs --no-run-if-empty -0 -I {} dirname {} " - stdout, _ = Pkg::Util::Net.remote_execute( - Pkg::Config.distribution_server, - cmd, - { capture_output: true } - ) + stdout, = Pkg::Util::Net.remote_execute( + Pkg::Config.distribution_server, + cmd, + { capture_output: true }, + ) return stdout.split rescue => e fail "Error: Could not retrieve directories that contain #{pkg_ext} packages in #{Pkg::Config.distribution_server}:#{artifact_directory}" @@ -145,11 +144,12 @@ def update_repo(remote_host, command, options = {}) __REPO_HOST__: options[:repo_host], __REPO_URL__: options[:repo_url], __APT_PLATFORMS__: Pkg::Config.apt_releases.join(' '), - __GPG_KEY__: Pkg::Util::Gpg.key + __GPG_KEY__: Pkg::Util::Gpg.key, } Pkg::Util::Net.remote_execute( remote_host, - Pkg::Util::Misc.search_and_replace(command, whitelist)) + Pkg::Util::Misc.search_and_replace(command, whitelist), + ) end end end diff --git a/lib/packaging/retrieve.rb b/lib/packaging/retrieve.rb index e6adb907..51cded53 100644 --- a/lib/packaging/retrieve.rb +++ b/lib/packaging/retrieve.rb @@ -25,6 +25,7 @@ def default_wget_command(local_target, url, additional_options = {}) wget_command = wget options.each do |option, value| next unless value + if value.is_a?(TrueClass) wget_command << " --#{option}" else @@ -49,6 +50,7 @@ def foss_only_retrieve(build_url, local_target) unless Pkg::Config.foss_platforms fail "Error: FOSS_ONLY specified but no 'foss_platforms' specified in the configuration." end + default_wget(local_target, "#{build_url}/", { 'level' => 1 }) yaml_path = File.join(local_target, "#{Pkg::Config.ref}.yaml") unless File.readable?(yaml_path) @@ -72,9 +74,10 @@ def retrieve_all(build_url, rsync_path, local_target) begin warn "Info: could not find `wget`, rsyncing from #{Pkg::Config.distribution_server} instead" Pkg::Util::Net.rsync_from( - "#{rsync_path}/", Pkg::Config.distribution_server, "#{local_target}/") + "#{rsync_path}/", Pkg::Config.distribution_server, "#{local_target}/" + ) rescue => e - fail "Error: rsync from #{Pkg::Config.distribution_server}#{rsync_path}/ "\ + fail "Error: rsync from #{Pkg::Config.distribution_server}#{rsync_path}/ " \ "to #{local_target}/ failed: #{e}" end end diff --git a/lib/packaging/rpm/repo.rb b/lib/packaging/rpm/repo.rb index 499cfca8..c24502b0 100644 --- a/lib/packaging/rpm/repo.rb +++ b/lib/packaging/rpm/repo.rb @@ -48,6 +48,7 @@ def repo_creation_command(repo_directory, artifact_paths = nil) artifact_paths.each do |path| next if path.include? 'aix' + cmd << "if [ -d #{path} ]; then " cmd << "pushd #{path} && " cmd << '$createrepo --checksum=sha --checkts --update --delta-workers=0 --database . && ' @@ -117,7 +118,7 @@ def retrieve_repo_configs(target = "repo_configs") FileUtils.mkdir_p("pkg/#{target}") config_url = "#{base_url}/#{target}/rpm/" begin - stdout, _, _ = Pkg::Util::Execution.capture3("#{wget} -r -np -nH --cut-dirs 3 -P pkg/#{target} --reject 'index*' #{config_url}") + stdout, = Pkg::Util::Execution.capture3("#{wget} -r -np -nH --cut-dirs 3 -P pkg/#{target} --reject 'index*' #{config_url}") stdout rescue => e fail "Couldn't retrieve rpm yum repo configs.\n#{e}" @@ -149,7 +150,7 @@ def generate_repo_configs(source = "repos", target = "repo_configs", signed = fa # repodata folders in them, and second that those same directories also # contain rpms # - stdout, _, _ = Pkg::Util::Execution.capture3("#{wget} --spider -r -l 5 --no-parent #{repo_base} 2>&1") + stdout, = Pkg::Util::Execution.capture3("#{wget} --spider -r -l 5 --no-parent #{repo_base} 2>&1") stdout = stdout.split.uniq.reject { |x| x =~ /\?|index/ }.select { |x| x =~ /http:.*repodata\/$/ } # RPMs will always exist at the same directory level as the repodata @@ -157,7 +158,7 @@ def generate_repo_configs(source = "repos", target = "repo_configs", signed = fa # yum_repos = [] stdout.map { |x| x.chomp('repodata/') }.each do |url| - output, _, _ = Pkg::Util::Execution.capture3("#{wget} --spider -r -l 1 --no-parent #{url} 2>&1") + output, = Pkg::Util::Execution.capture3("#{wget} --spider -r -l 1 --no-parent #{url} 2>&1") unless output.split.uniq.reject { |x| x =~ /\?|index/ }.select { |x| x =~ /http:.*\.rpm$/ }.empty? yum_repos << url end @@ -204,7 +205,7 @@ def generate_repo_configs(source = "repos", target = "repo_configs", signed = fa end def create_local_repos(directory = "repos") - stdout, _, _ = Pkg::Util::Execution.capture3("bash -c '#{repo_creation_command(directory)}'") + stdout, = Pkg::Util::Execution.capture3("bash -c '#{repo_creation_command(directory)}'") stdout end diff --git a/lib/packaging/ship/artifactory.rb b/lib/packaging/ship/artifactory.rb index 09a9b6c5..9f9b39f3 100644 --- a/lib/packaging/ship/artifactory.rb +++ b/lib/packaging/ship/artifactory.rb @@ -4,7 +4,7 @@ module Pkg::Ship::Artifactory class << self def ship(local_build_directory, remote_artifacts_directory) unless Pkg::Config.project - fail 'Error: "project" is unset. It must be set in build_defaults.yaml or '\ + fail 'Error: "project" is unset. It must be set in build_defaults.yaml or ' \ 'the "PROJECT_OVERRIDE" environment variable.' end @@ -26,13 +26,13 @@ def ship(local_build_directory, remote_artifacts_directory) Pkg::Config.jenkins_repo_path, Pkg::Config.project, Pkg::Config.ref, - remote_artifacts_directory + remote_artifacts_directory, ) Pkg::Util::Net.rsync_to( ref_yaml_file, Pkg::Config.distribution_server, "#{remote_ref_yaml_directory}/#{File.basename(ref_yaml_file)}", - extra_flags: [] + extra_flags: [], ) # Now back to our Artifactory-specific work @@ -44,7 +44,8 @@ def ship(local_build_directory, remote_artifacts_directory) # Like that we'll still allow overwriting of yaml and json files. permitted_files = overwrite_guardian(artifactory, local_artifacts_directory) artifacts_tarball = Pkg::Ship::ArtifactsBundle.create_tarball( - local_artifacts_directory, permitted_files) + local_artifacts_directory, permitted_files + ) artifactory.deploy_archive(artifacts_tarball) end diff --git a/lib/packaging/ship/artifacts_bundle.rb b/lib/packaging/ship/artifacts_bundle.rb index 96044e59..c9dfd37f 100644 --- a/lib/packaging/ship/artifacts_bundle.rb +++ b/lib/packaging/ship/artifacts_bundle.rb @@ -15,7 +15,6 @@ module Pkg::Ship::ArtifactsBundle class << self def create(build_directory, artifacts_directory = 'artifacts') - # If the artifacts directory exists, don't rebuild it. if Dir.exist?(artifacts_directory) puts "Info: '#{artifacts_directory}' directory exists. Not rebuilding it." @@ -102,6 +101,7 @@ def artifacts_tarball_name def artifacts_tarball_exist? return artifacts_tarball_name if File.readable?(artifacts_tarball_name) + return false end end diff --git a/lib/packaging/ship/distribution_server.rb b/lib/packaging/ship/distribution_server.rb index 538e3cc9..11d06a93 100644 --- a/lib/packaging/ship/distribution_server.rb +++ b/lib/packaging/ship/distribution_server.rb @@ -2,13 +2,12 @@ module Pkg::Ship::DistributionServer class << self - DS_FILE_OWNER = 'root' DS_FILE_GROUP = 'release' def ship(local_build_directory, remote_artifacts_directory) unless Pkg::Config.project - fail 'Error: "project" is unset. It must be set in build_defaults.yaml or '\ + fail 'Error: "project" is unset. It must be set in build_defaults.yaml or ' \ 'the "PROJECT_OVERRIDE" environment variable.' end local_artifacts_directory = Pkg::Ship::ArtifactsBundle.create(local_build_directory) @@ -23,12 +22,12 @@ def send_artifacts(local_artifacts_directory, remote_artifacts_directory) Pkg::Config.jenkins_repo_path, Pkg::Config.project, Pkg::Config.ref, - remote_artifacts_directory + remote_artifacts_directory, ) Pkg::Util::Net.remote_execute( distribution_server, - "mkdir --mode=775 --parents #{remote_target_directory}" + "mkdir --mode=775 --parents #{remote_target_directory}", ) Pkg::Util::Execution.retry_on_fail(times: 3) do @@ -41,24 +40,26 @@ def send_artifacts(local_artifacts_directory, remote_artifacts_directory) # Set the shipped ownership to root/release. Make the files immutable. remote_directories = Dir.glob("#{local_artifacts_directory}/**/*") - .select { |d| File.directory?(d) } - .map { |d| d.sub(local_artifacts_directory, remote_target_directory) } + .select { |d| File.directory?(d) } + .map { |d| d.sub(local_artifacts_directory, remote_target_directory) } Pkg::Util::Net.remote_set_ownership( distribution_server, DS_FILE_OWNER, DS_FILE_GROUP, remote_directories ) Pkg::Util::Net.remote_set_permissions( - distribution_server, '0775', remote_directories) + distribution_server, '0775', remote_directories + ) remote_files = Dir.glob("#{local_artifacts_directory}/**/*") - .select { |f| File.file?(f) } - .map { |f| f.sub(local_artifacts_directory, remote_target_directory) } + .select { |f| File.file?(f) } + .map { |f| f.sub(local_artifacts_directory, remote_target_directory) } # We need to keep .yaml mutable because it can be updated by multiple processes # Yes, this is an ugly race condition. immutable_files = remote_files.reject { |f| f.end_with? "#{Pkg::Config.ref}.yaml" } Pkg::Util::Net.remote_set_ownership( - distribution_server, DS_FILE_OWNER, DS_FILE_GROUP, remote_files) + distribution_server, DS_FILE_OWNER, DS_FILE_GROUP, remote_files + ) Pkg::Util::Net.remote_set_permissions(distribution_server, '0664', remote_files) Pkg::Util::Net.remote_set_immutable(distribution_server, immutable_files) end diff --git a/lib/packaging/ship/ezbake.rb b/lib/packaging/ship/ezbake.rb index 32127263..26ee8252 100644 --- a/lib/packaging/ship/ezbake.rb +++ b/lib/packaging/ship/ezbake.rb @@ -10,7 +10,8 @@ def add_manifest(target_directory) ezbake_manifest_target_path = nil if File.exist?(ezbake_manifest_source_path) ezbake_manifest_target_path = File.join( - target_directory, "#{Pkg::Config.ref}.#{manifest_name}") + target_directory, "#{Pkg::Config.ref}.#{manifest_name}" + ) FileUtils.cp(ezbake_manifest_source_path, ezbake_manifest_target_path) end @@ -19,13 +20,14 @@ def add_manifest(target_directory) ezbake_yaml_target_path = nil if File.exist?(ezbake_yaml_source_path) ezbake_yaml_target_path = File.join( - target_directory, "#{Pkg::Config.ref}.#{yaml_name}") + target_directory, "#{Pkg::Config.ref}.#{yaml_name}" + ) FileUtils.cp(ezbake_yaml_source_path, ezbake_yaml_target_path) end return { manifest_path: ezbake_manifest_target_path, - yaml_path: ezbake_yaml_target_path + yaml_path: ezbake_yaml_target_path, } end end diff --git a/lib/packaging/ship/windows.rb b/lib/packaging/ship/windows.rb index 1343982c..224e982c 100644 --- a/lib/packaging/ship/windows.rb +++ b/lib/packaging/ship/windows.rb @@ -7,7 +7,7 @@ class << self def add_msi_links(local_source_directory) { 'windows' => ['x86', 'x64'], - 'windowsfips' => ['x64'] + 'windowsfips' => ['x64'], }.each_pair do |platform, archs| packages = Dir["#{local_source_directory}/#{platform}/*"] @@ -21,10 +21,11 @@ def add_msi_links(local_source_directory) link_filename = File.join( local_source_directory, platform, - "#{Pkg::Config.project}-#{arch}.msi" + "#{Pkg::Config.project}-#{arch}.msi", ) next unless !packages.include?(link_filename) && packages.include?(package_filename) + FileUtils.ln(package_filename, link_filename) end end diff --git a/lib/packaging/sign.rb b/lib/packaging/sign.rb index 9b971575..b3a4b709 100644 --- a/lib/packaging/sign.rb +++ b/lib/packaging/sign.rb @@ -4,5 +4,6 @@ module Pkg::Sign require 'packaging/sign/ips' require 'packaging/sign/msi' require 'packaging/sign/rpm' + module_function end diff --git a/lib/packaging/sign/dmg.rb b/lib/packaging/sign/dmg.rb index ac2aa6b7..f846c2dd 100644 --- a/lib/packaging/sign/dmg.rb +++ b/lib/packaging/sign/dmg.rb @@ -33,7 +33,7 @@ def sign(target_dir = 'pkg') /bin/rm #{work_dir}/$dmg.dmg ; /usr/bin/hdiutil create -volname $dmg -srcfolder #{signed}/ #{work_dir}/$dmg.dmg ; /bin/rm #{signed}/* ; done]) - dmgs.each do | dmg | + dmgs.each do |dmg| Pkg::Util::Net.rsync_from("#{work_dir}/#{File.basename(dmg)}", rsync_host_string, File.dirname(dmg)) end Pkg::Util::Net.remote_execute(ssh_host_string, "if [ -d '#{work_dir}' ]; then rm -rf '#{work_dir}'; fi") diff --git a/lib/packaging/sign/msi.rb b/lib/packaging/sign/msi.rb index b06cbf32..728a812c 100644 --- a/lib/packaging/sign/msi.rb +++ b/lib/packaging/sign/msi.rb @@ -11,7 +11,7 @@ def sign(target_dir = 'pkg') Pkg::Util::Net.remote_execute(ssh_host_string, "mkdir -p C:/#{work_dir}") msis = Dir.glob("#{target_dir}/windows*/**/*.msi") Pkg::Util::Net.rsync_to(msis.join(" "), rsync_host_string, "/cygdrive/c/#{work_dir}", - extra_flags: ["--ignore-existing --relative"]) + extra_flags: ["--ignore-existing --relative"]) # Please Note: # We are currently adding two signatures to the msi. @@ -114,9 +114,9 @@ def sign(target_dir = 'pkg') Pkg::Util::Net.remote_execute( ssh_host_string, sign_command, - { fail_fast: false } + { fail_fast: false }, ) - msis.each do | msi | + msis.each do |msi| Pkg::Util::Net.rsync_from("/cygdrive/c/#{work_dir}/#{msi}", rsync_host_string, File.dirname(msi)) end Pkg::Util::Net.remote_execute(ssh_host_string, "if [ -d '/cygdrive/c/#{work_dir}' ]; then rm -rf '/cygdrive/c/#{work_dir}'; fi") diff --git a/lib/packaging/sign/rpm.rb b/lib/packaging/sign/rpm.rb index 6428fdbb..0b33a642 100644 --- a/lib/packaging/sign/rpm.rb +++ b/lib/packaging/sign/rpm.rb @@ -44,6 +44,7 @@ def has_sig?(rpm) # which bails out with non-0 exit codes. Instead, check that the output # looks more-or-less how we expect it to. fail "Something went wrong checking the signature of #{rpm}." unless signature_check_output.include? "Header" + return signature_check_output.include? "key ID #{key}" end @@ -70,7 +71,7 @@ def sign_all(rpm_directory) v4_rpms = [] rpms_to_sign.each do |rpm| platform_tag = Pkg::Paths.tag_from_artifact_path(rpm) - platform, version, _ = Pkg::Platforms.parse_platform_tag(platform_tag) + platform, version, = Pkg::Platforms.parse_platform_tag(platform_tag) # We don't sign AIX rpms next if platform_tag.include?('aix') @@ -103,6 +104,7 @@ def sign_all(rpm_directory) # Using the map of paths to basenames, we re-hardlink the rpms we deleted. all_rpms.each do |link_path, rpm_filename| next if File.exist? link_path + FileUtils.mkdir_p(File.dirname(link_path)) # Find paths where the signed rpm has the same basename, but different # full path, as the one we need to link. diff --git a/lib/packaging/tar.rb b/lib/packaging/tar.rb index fecc8d47..b7bbe69c 100644 --- a/lib/packaging/tar.rb +++ b/lib/packaging/tar.rb @@ -45,6 +45,7 @@ def initialize if Pkg::Config.templates @templates = Pkg::Config.templates.dup fail "templates must be an array" unless @templates.is_a?(Array) + expand_templates end end @@ -141,6 +142,7 @@ def tar(target, source) unless $?.success? fail "Failed to create .tar.gz archive with #{@tar}. Please ensure the tar command in your path accepts the flags '-c', '-z', and '-f'" end + mv File.basename(target), target end end @@ -157,7 +159,5 @@ def pkg! self.tar(@target, workdir) self.clean_up workdir end - end end - diff --git a/lib/packaging/util.rb b/lib/packaging/util.rb index 866a4e98..ac201453 100644 --- a/lib/packaging/util.rb +++ b/lib/packaging/util.rb @@ -24,7 +24,8 @@ module Pkg::Util require 'packaging/util/ship' def self.boolean_value(var) - return true if var == true || ( var.is_a?(String) && ( var.downcase == 'true' || var.downcase =~ /^y$|^yes$/)) + return true if var == true || (var.is_a?(String) && (var.downcase == 'true' || var.downcase =~ /^y$|^yes$/)) + return false end @@ -55,6 +56,7 @@ def self.get_var(var) # @raise [RuntimeError] raises an exception if the variable is not set and is required def self.check_var(varname, var) fail "Requires #{varname} be set!" if var.nil? + var end @@ -95,6 +97,7 @@ def self.ask_yes_or_no(force = false) answer = Pkg::Util.get_input return true if answer =~ /^y$|^yes$/ return false if answer =~ /^n$|^no$/ + puts "Nope, try something like yes or no or y or n, etc:" Pkg::Util.ask_yes_or_no end @@ -112,10 +115,10 @@ def self.confirm_ship(files) def self.filter_configs(filter = nil) return Pkg::Config.instance_values.select { |key, _| key.match(/#{filter}/) } if filter + Pkg::Config.instance_values end - # Construct a probably-correct (or correct-enough) URI for # tools like ssh or rsync. Currently lacking support for intuitive # joins, ports, protocols, fragments, or 75% of what Addressable::URI diff --git a/lib/packaging/util/date.rb b/lib/packaging/util/date.rb index 08a018ae..db8e9604 100644 --- a/lib/packaging/util/date.rb +++ b/lib/packaging/util/date.rb @@ -1,7 +1,6 @@ # Utilities for managing/querying date/time module Pkg::Util::Date - class << self def timestamp(separator = nil) if s = separator diff --git a/lib/packaging/util/execution.rb b/lib/packaging/util/execution.rb index 93bdd343..29a4a150 100644 --- a/lib/packaging/util/execution.rb +++ b/lib/packaging/util/execution.rb @@ -1,9 +1,7 @@ # Utility methods for handling system calls and interactions module Pkg::Util::Execution - class << self - # Alias to $?.success? that makes success? slightly easier to test and stub # If immediately run, $? will not be instanciated, so only call success? if # $? exists, otherwise return nil diff --git a/lib/packaging/util/file.rb b/lib/packaging/util/file.rb index 9e7d7991..f059352c 100644 --- a/lib/packaging/util/file.rb +++ b/lib/packaging/util/file.rb @@ -2,7 +2,6 @@ require 'fileutils' module Pkg::Util::File - class << self def exist?(file) ::File.exist?(file) @@ -15,7 +14,7 @@ def directory?(file) def mktemp mktemp = Pkg::Util::Tool.find_tool('mktemp', :required => true) - stdout, _, _ = Pkg::Util::Execution.capture3("#{mktemp} -d -t pkgXXXXXX") + stdout, = Pkg::Util::Execution.capture3("#{mktemp} -d -t pkgXXXXXX") stdout.strip end @@ -38,12 +37,12 @@ def files_with_ext(dir, ext) Dir.glob("#{dir}/**/*#{ext}") end - def file_exists?(file, args = { :required => false }) exists = File.exist? file if !exists and args[:required] fail "Required file #{file} could not be found" end + exists end @@ -52,6 +51,7 @@ def file_writable?(file, args = { :required => false }) if !writable and args[:required] fail "File #{file} is not writable" end + writable end @@ -79,7 +79,7 @@ def untar_into(source, target = nil, options = "") target_opts = "-C #{target}" end if file_exists?(source, :required => true) - stdout, _, _ = Pkg::Util::Execution.capture3(%Q(#{tar} #{options} #{target_opts} -xf #{source})) + stdout, = Pkg::Util::Execution.capture3(%Q(#{tar} #{options} #{target_opts} -xf #{source})) stdout end end @@ -122,4 +122,3 @@ def install_files_into_dir(file_patterns, workdir) end end end - diff --git a/lib/packaging/util/git_tags.rb b/lib/packaging/util/git_tags.rb index db93f9c3..fe5a616d 100644 --- a/lib/packaging/util/git_tags.rb +++ b/lib/packaging/util/git_tags.rb @@ -43,7 +43,7 @@ def split_ref(ref) # Fetch the full ref using ls-remote, this should raise an error if it returns non-zero # because that means this ref doesn't exist in the repo def fetch_full_ref - stdout, _, _ = Pkg::Util::Execution.capture3("#{GIT} ls-remote --tags --heads --exit-code #{address} #{ref}") + stdout, = Pkg::Util::Execution.capture3("#{GIT} ls-remote --tags --heads --exit-code #{address} #{ref}") stdout.split.last rescue RuntimeError => e raise "ERROR : Not a ref or sha!\n#{e}" diff --git a/lib/packaging/util/gpg.rb b/lib/packaging/util/gpg.rb index f9ab9f6f..c785a53c 100644 --- a/lib/packaging/util/gpg.rb +++ b/lib/packaging/util/gpg.rb @@ -1,6 +1,5 @@ module Pkg::Util::Gpg class << self - # Please note that this method is not used in determining what key is used # to sign the debian repos. That is defined in the freight config that # lives on our internal repo staging host. The debian conf/distribution @@ -8,6 +7,7 @@ class << self # reflect that. def key fail "You need to set `gpg_key` in your build defaults." unless Pkg::Config.gpg_key && !Pkg::Config.gpg_key.empty? + Pkg::Config.gpg_key end @@ -31,14 +31,14 @@ def load_keychain def kill_keychain if keychain - stdout, _, _ = Pkg::Util::Execution.capture3("#{keychain} -k mine") + stdout, = Pkg::Util::Execution.capture3("#{keychain} -k mine") stdout end end def start_keychain if keychain - keychain_output, _, _ = Pkg::Util::Execution.capture3("#{keychain} -q --agents gpg --eval #{key}") + keychain_output, = Pkg::Util::Execution.capture3("#{keychain} -q --agents gpg --eval #{key}") keychain_output.chomp! new_env = keychain_output.match(/GPG_AGENT_INFO=([^;]*)/) ENV["GPG_AGENT_INFO"] = new_env[1] @@ -56,7 +56,7 @@ def sign_file(file) return true end use_tty = "--no-tty --use-agent" if ENV['RPM_GPG_AGENT'] - stdout, _, _ = Pkg::Util::Execution.capture3("#{gpg} #{use_tty} --armor --detach-sign -u #{key} #{file}") + stdout, = Pkg::Util::Execution.capture3("#{gpg} #{use_tty} --armor --detach-sign -u #{key} #{file}") stdout else fail "No gpg available. Cannot sign #{file}." diff --git a/lib/packaging/util/jenkins.rb b/lib/packaging/util/jenkins.rb index a6f7b2f1..d655ba5c 100644 --- a/lib/packaging/util/jenkins.rb +++ b/lib/packaging/util/jenkins.rb @@ -3,9 +3,7 @@ require 'json' module Pkg::Util::Jenkins - class << self - # Use the curl to create a jenkins job from a valid XML # configuration file. # Returns the URL to the job @@ -25,6 +23,7 @@ def jenkins_job_exists?(name) form_args = ["--silent", "--fail"] output, retval = Pkg::Util::Net.curl_form_data(job_url, form_args, :quiet => true) return output if retval.nil? + return Pkg::Util::Execution.success?(retval) end @@ -64,6 +63,7 @@ def get_jenkins_info(url) unless response.code == '200' raise "Unable to query #{uri}, please check that it is valid." end + return JSON.parse(response.body) end @@ -90,6 +90,5 @@ def poll_jenkins_job(job_url) wait_for_build job_hash['lastBuild']['url'] end - end end diff --git a/lib/packaging/util/misc.rb b/lib/packaging/util/misc.rb index e1e8afea..42a77a78 100644 --- a/lib/packaging/util/misc.rb +++ b/lib/packaging/util/misc.rb @@ -32,6 +32,7 @@ def load_from_json(file) unless data.is_a?(Hash) raise "Hash required. Got '#{data.class}' when parsing '#{file}'" end + # We explicity return data here b/c the unless clause above will cause the # Function to return nil. # -Sean P. M. 05/11/2016 diff --git a/lib/packaging/util/net.rb b/lib/packaging/util/net.rb index 71753573..5df78e82 100644 --- a/lib/packaging/util/net.rb +++ b/lib/packaging/util/net.rb @@ -1,9 +1,7 @@ # Utility methods for handling network calls and interactions module Pkg::Util::Net - class << self - # This simple method does an HTTP get of a URI and writes it to a file # in a slightly more platform agnostic way than curl/wget def fetch_uri(uri, target) @@ -24,6 +22,7 @@ def check_host(host, options = { required: true }) return true if hostname == host fail "Error: #{hostname} does not match #{host}" if options[:required] + return nil end @@ -68,7 +67,7 @@ def remote_execute(target_host, command, user_options = {}) capture_output: false, extra_options: '', fail_fast: true, - trace: false + trace: false, } options = option_defaults.merge(user_options) @@ -112,13 +111,14 @@ def remote_execute(target_host, command, user_options = {}) ### ### Deprecated method implemented as a shim to the new `remote_execute` method ### - def remote_ssh_cmd(target, command, capture_output = false, extra_options = '', fail_fast = true, trace = false) # rubocop:disable Metrics/ParameterLists + def remote_ssh_cmd(target, command, capture_output = false, extra_options = '', fail_fast = true, trace = false) # rubocop:disable Metrics/ParameterLists puts "Warn: \"remote_ssh_cmd\" call in packaging is deprecated. Use \"remote_execute\" instead." remote_execute(target, command, { capture_output: capture_output, extra_options: extra_options, fail_fast: fail_fast, - trace: trace }) + trace: trace, + }) end # Construct a valid rsync command @@ -149,7 +149,8 @@ def rsync_cmd(origin_path, opts = {}) target_path: nil, target_host: nil, extra_flags: nil, - dryrun: false }.merge(opts) + dryrun: false, + }.merge(opts) origin = Pathname.new(origin_path) target = options[:target_path] || origin.parent @@ -187,9 +188,10 @@ def rsync_exec(source, opts = {}) target_path: nil, target_host: nil, extra_flags: nil, - dryrun: ENV['DRYRUN'] }.merge(opts.delete_if { |_, value| value.nil? }) + dryrun: ENV['DRYRUN'], + }.merge(opts.delete_if { |_, value| value.nil? }) - stdout, _, _ = Pkg::Util::Execution.capture3(rsync_cmd(source, options), true) + stdout, = Pkg::Util::Execution.capture3(rsync_cmd(source, options), true) stdout end @@ -223,7 +225,7 @@ def s3sync_to(source, target_bucket, target_directory = "", flags = []) s3cmd = Pkg::Util::Tool.check_tool('s3cmd') if Pkg::Util::File.file_exists?(File.join(ENV['HOME'], '.s3cfg')) - stdout, _, _ = Pkg::Util::Execution.capture3("#{s3cmd} sync #{flags.join(' ')} '#{source}' s3://#{target_bucket}/#{target_directory}/") + stdout, = Pkg::Util::Execution.capture3("#{s3cmd} sync #{flags.join(' ')} '#{source}' s3://#{target_bucket}/#{target_directory}/") stdout else fail "#{File.join(ENV['HOME'], '.s3cfg')} does not exist. It is required to ship files using s3cmd." @@ -277,9 +279,9 @@ def uri_status_code(uri) '--silent', '--location', '--write-out "%{http_code}"', - '--output /dev/null' + '--output /dev/null', ] - stdout, _ = Pkg::Util::Net.curl_form_data(uri, data) + stdout, = Pkg::Util::Net.curl_form_data(uri, data) stdout end @@ -294,11 +296,11 @@ def print_url_info(url_string) def remote_set_ownership(host, owner, group, files) remote_cmd = %W( for file in #{files.join(" ")}; do - if [[ -d $file ]] || ! `lsattr $file | grep -q '\\-i\\-'`; then - sudo chown #{owner}:#{group} $file; - else - echo \"Info: $file is immutable\"; - fi; + if [[ -d $file ]] || ! `lsattr $file | grep -q '\\-i\\-'`; then + sudo chown #{owner}:#{group} $file; + else + echo \"Info: $file is immutable\"; + fi; done ).join(' ') @@ -308,11 +310,11 @@ def remote_set_ownership(host, owner, group, files) def remote_set_permissions(host, permissions, files) remote_cmd = %W( for file in #{files.join(" ")}; do - if [[ -d $file ]] || ! `lsattr $file | grep -q '\\-i\\-'`; then - sudo chmod #{permissions} $file; - else - echo \"Info: $file is immutable\"; - fi; + if [[ -d $file ]] || ! `lsattr $file | grep -q '\\-i\\-'`; then + sudo chmod #{permissions} $file; + else + echo \"Info: $file is immutable\"; + fi; done ).join(' ') Pkg::Util::Net.remote_execute(host, remote_cmd) @@ -367,7 +369,8 @@ def remote_create_latest_symlink(package_name, dir, platform_ext, options = {}) CMD _, err = Pkg::Util::Net.remote_execute( - Pkg::Config.staging_server, cmd, { capture_output: true }) + Pkg::Config.staging_server, cmd, { capture_output: true } + ) $stderr.puts err end diff --git a/lib/packaging/util/platform.rb b/lib/packaging/util/platform.rb index 493ea454..0c757224 100644 --- a/lib/packaging/util/platform.rb +++ b/lib/packaging/util/platform.rb @@ -1,5 +1,6 @@ module Pkg::Util::Platform module_function + ########################################################################## # DEPRECATED METHODS # diff --git a/lib/packaging/util/rake_utils.rb b/lib/packaging/util/rake_utils.rb index 886d2f1a..e7420912 100644 --- a/lib/packaging/util/rake_utils.rb +++ b/lib/packaging/util/rake_utils.rb @@ -55,6 +55,7 @@ def evaluate_pre_tasks unless Pkg::Config.pre_tasks.is_a?(Hash) fail "The 'pre_tasks' key must be a Hash of depender => dependency pairs" end + Pkg::Config.pre_tasks.each do |depender, dependency| add_dependency(depender, dependency) end @@ -99,7 +100,7 @@ def load_packaging_tasks(packaging_root = Pkg::Config.packaging_root) 'z_data_dump.rake', 'config.rake', 'vanagon.rake', - 'deprecated.rake' + 'deprecated.rake', ] tasks.each do |task| diff --git a/lib/packaging/util/ship.rb b/lib/packaging/util/ship.rb index 0956c913..410ce732 100644 --- a/lib/packaging/util/ship.rb +++ b/lib/packaging/util/ship.rb @@ -6,6 +6,7 @@ module Pkg::Util::Ship def collect_packages(pkg_exts, excludes = []) # rubocop:disable Metrics/MethodLength pkgs = pkg_exts.map { |ext| Dir.glob(ext) }.flatten return [] if pkgs.empty? + excludes.each do |exclude| pkgs.delete_if { |p| p.match(exclude) } end if excludes @@ -62,7 +63,8 @@ def ship_pkgs(pkg_exts, staging_server, remote_path, opts = {}) excludes: [], chattr: true, platform_independent: false, - nonfinal: false }.merge(opts) + nonfinal: false, + }.merge(opts) # First find the packages to be shipped. We must find them before moving # to our temporary staging directory @@ -90,7 +92,7 @@ def ship_pkgs(pkg_exts, staging_server, remote_path, opts = {}) File.join(tmpdir, pkg), staging_server, remote_basepath, - extra_flags: extra_flags + extra_flags: extra_flags, ) Pkg::Util::Net.remote_set_ownership(staging_server, 'root', 'release', @@ -106,7 +108,7 @@ def ship_pkgs(pkg_exts, staging_server, remote_path, opts = {}) def ship_rpms(local_staging_directory, remote_path, opts = {}) things_to_ship = [ "#{local_staging_directory}/**/*.rpm", - "#{local_staging_directory}/**/*.srpm" + "#{local_staging_directory}/**/*.srpm", ] ship_pkgs(things_to_ship, Pkg::Config.yum_staging_server, remote_path, opts) end @@ -117,7 +119,7 @@ def ship_debs(local_staging_directory, remote_path, opts = {}) "#{local_staging_directory}/**/*.orig.tar.gz", "#{local_staging_directory}/**/*.dsc", "#{local_staging_directory}/**/*.deb", - "#{local_staging_directory}/**/*.changes" + "#{local_staging_directory}/**/*.changes", ] ship_pkgs(things_to_ship, Pkg::Config.apt_signing_server, remote_path, opts) end @@ -139,12 +141,11 @@ def ship_dmg(local_staging_directory, remote_path, opts = {}) Pkg::Util::Net.remote_create_latest_symlink( Pkg::Config.project, Pkg::Paths.artifacts_path(platform_tag, remote_path, opts[:nonfinal]), - 'dmg' + 'dmg', ) end end - def ship_swix(local_staging_directory, remote_path, opts = {}) ship_pkgs(["#{local_staging_directory}/**/*.swix"], Pkg::Config.swix_staging_server, remote_path, opts) end diff --git a/lib/packaging/util/tool.rb b/lib/packaging/util/tool.rb index d733414d..3d2de334 100644 --- a/lib/packaging/util/tool.rb +++ b/lib/packaging/util/tool.rb @@ -1,7 +1,6 @@ # Utility methods for handling system binaries module Pkg::Util::Tool - # Set up utility methods for handling system binaries # class << self @@ -26,16 +25,15 @@ def find_tool(tool, args = { :required => false }) return location if FileTest.executable? location end fail "#{tool} tool not found...exiting" if args[:required] + return nil end alias :has_tool :find_tool - end # Set up paths to system tools we use in the packaging repo # no matter what distribution we're packaging for. GIT = Pkg::Util::Tool.check_tool('git') - end diff --git a/spec/lib/packaging/artifactory_spec.rb b/spec/lib/packaging/artifactory_spec.rb index e8654908..2593dfed 100644 --- a/spec/lib/packaging/artifactory_spec.rb +++ b/spec/lib/packaging/artifactory_spec.rb @@ -3,7 +3,6 @@ require 'packaging/artifactory' describe 'artifactory.rb' do - project = 'puppet-agent' project_version = 'ashawithlettersandnumbers' default_repo_name = 'testing' @@ -59,7 +58,7 @@ :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/el-6-x86_64", :package_format => 'rpm', :package_name => 'path/to/a/el/6/package/puppet-agent-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm', - :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm'] + :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.el6.x86_64.rpm'], }, 'ubuntu-16.04-amd64' => { :toplevel_repo => 'debian__local', @@ -67,7 +66,7 @@ :codename => 'xenial', :arch => 'amd64', :package_name => 'path/to/a/xenial/package/puppet-agent_5.3.1.34.gf65f9ef-1xenial_amd64.deb', - :all_package_names => ['puppet-agent_5.3.1.34.gf65f9ef-1xenial_amd64.deb', 'puppet-agent-extras_5.3.1.34.gf65f9ef-1xenial_amd64.deb'] + :all_package_names => ['puppet-agent_5.3.1.34.gf65f9ef-1xenial_amd64.deb', 'puppet-agent-extras_5.3.1.34.gf65f9ef-1xenial_amd64.deb'], }, 'debian-10-amd64' => { :toplevel_repo => 'debian__local', @@ -75,41 +74,41 @@ :codename => 'buster', :arch => 'all', :package_name => 'path/to/a/buster/package/puppetdb_5.3.1.34.gf65f9ef-1buster_all.deb', - :all_package_names => ['puppetdb_5.3.1.34.gf65f9ef-1buster_all.deb', 'puppetdb-termini_5.3.1.34.gf65f9ef-1buster_all.deb'] + :all_package_names => ['puppetdb_5.3.1.34.gf65f9ef-1buster_all.deb', 'puppetdb-termini_5.3.1.34.gf65f9ef-1buster_all.deb'], }, 'windows-2012-x86' => { :toplevel_repo => 'generic', :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/windows-x86", :package_name => 'path/to/a/windows/package/puppet-agent-5.3.1.34-x86.msi', - :all_package_names => ['puppet-agent-5.3.1.34-x86.msi','puppet-agent-extras-5.3.1.34-x86.msi'] + :all_package_names => ['puppet-agent-5.3.1.34-x86.msi', 'puppet-agent-extras-5.3.1.34-x86.msi'], }, 'windowsfips-2012-x64' => { :toplevel_repo => 'generic', :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/windowsfips-x64", :package_name => 'path/to/a/windowsfips/package/puppet-agent-5.3.1.34-x64.msi', - :all_package_names => ['puppet-agent-5.3.1.34-x64.msi','puppet-agent-extras-5.3.1.34-x64.msi'] + :all_package_names => ['puppet-agent-5.3.1.34-x64.msi', 'puppet-agent-extras-5.3.1.34-x64.msi'], }, 'osx-10.15-x86_64' => { :toplevel_repo => 'generic', :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/osx-10.15-x86_64", :package_name => 'path/to/an/osx/10.15/package/puppet-agent-5.3.1.34.gf65f9ef-1.osx10.15.dmg', - :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.osx10.15.dmg', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx10.15.dmg'] + :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.osx10.15.dmg', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx10.15.dmg'], }, 'osx-11-x86_64' => { :toplevel_repo => 'generic', :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/osx-11-x86_64", :package_name => 'path/to/an/osx/11/package/puppet-agent-5.3.1.34.gf65f9ef-1.osx11.dmg', - :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.osx11.dmg', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx11.dmg'] + :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.osx11.dmg', 'puppet-agent-extras-5.3.1.34.gf65f9ef-1.osx11.dmg'], }, 'solaris-10-sparc' => { :toplevel_repo => 'generic', :repo_subdirectories => "#{default_repo_name}/#{project}/#{project_version}/solaris-10-sparc", :package_name => 'path/to/a/solaris/10/package/puppet-agent-5.3.1.34.gf65f9ef-1.sparc.pkg.gz', - :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.sparc.pkg.gz'] + :all_package_names => ['puppet-agent-5.3.1.34.gf65f9ef-1.sparc.pkg.gz'], }, } - let(:artifact) { Pkg::ManageArtifactory.new(project, project_version, {:repo_base => default_repo_name, :artifactory_uri => artifactory_uri})} + let(:artifact) { Pkg::ManageArtifactory.new(project, project_version, { :repo_base => default_repo_name, :artifactory_uri => artifactory_uri }) } around(:each) do |example| original_artifactory_api_key = ENV['ARTIFACTORY_API_KEY'] @@ -123,24 +122,24 @@ if platform_tag_data[:codename] it 'returns the expected repo name and paths by default, prepending `pool` for debian-ish platforms' do expect(artifact.location_for(platform_tag)).to match_array([ - platform_tag_data[:toplevel_repo], - platform_tag_data[:repo_subdirectories], - ]) + platform_tag_data[:toplevel_repo], + platform_tag_data[:repo_subdirectories], + ]) end else it 'returns the expected repo name and paths by default' do expect(artifact.location_for(platform_tag)).to match_array([ - platform_tag_data[:toplevel_repo], - platform_tag_data[:repo_subdirectories], - ]) + platform_tag_data[:toplevel_repo], + platform_tag_data[:repo_subdirectories], + ]) end end it 'returns the correct paths for the passed in format' do expect(artifact.location_for('generic')).to match_array([ - 'generic', - File.join(default_repo_name, project, project_version), - ]) + 'generic', + File.join(default_repo_name, project, project_version), + ]) end end @@ -152,7 +151,7 @@ it 'fails if it cannot find a valid platform name' do new_platform_data = platform_data new_platform_data.delete_if { |k| k.match(platform_tag) } - expect{artifact.package_name(new_platform_data, platform_tag)}.to raise_error + expect { artifact.package_name(new_platform_data, platform_tag) }.to raise_error end end @@ -169,7 +168,7 @@ it 'fails if it cannot find a valid platform name' do new_platform_data = platform_data new_platform_data.delete_if { |k| k.match(platform_tag) } - expect{artifact.package_name(new_platform_data, platform_tag)}.to raise_error + expect { artifact.package_name(new_platform_data, platform_tag) }.to raise_error end end @@ -178,7 +177,7 @@ if platform_tag_data[:codename] expect(artifact.deb_list_contents(platform_tag)).to eq("deb #{artifactory_uri}/#{platform_tag_data[:toplevel_repo].chomp('/pool')} #{platform_tag_data[:codename]} #{platform_tag_data[:repo_subdirectories]}") else - expect{artifact.deb_list_contents(platform_tag)}.to raise_error + expect { artifact.deb_list_contents(platform_tag) }.to raise_error end end end @@ -188,7 +187,7 @@ if platform_tag_data[:package_format] == 'rpm' expect(artifact.rpm_repo_contents(platform_tag)).to include("baseurl=#{artifactory_uri}\/#{platform_tag_data[:toplevel_repo]}\/#{platform_tag_data[:repo_subdirectories]}") else - expect{artifact.rpm_repo_contents(platform_tag)}.to raise_error + expect { artifact.rpm_repo_contents(platform_tag) }.to raise_error end end end @@ -197,14 +196,14 @@ it "returns the correct contents for the deploy properties for #{platform_tag}" do if platform_tag_data[:codename] expect(artifact.deploy_properties(platform_tag, File.basename(platform_tag_data[:package_name]))).to include({ - 'deb.distribution' => platform_tag_data[:codename], - 'deb.component' => platform_tag_data[:repo_subdirectories], - 'deb.architecture' => platform_tag_data[:arch] - }) + 'deb.distribution' => platform_tag_data[:codename], + 'deb.component' => platform_tag_data[:repo_subdirectories], + 'deb.architecture' => platform_tag_data[:arch], + }) else expect(artifact.deploy_properties(platform_tag, File.basename(platform_tag_data[:package_name]))).not_to include({ - 'deb.component' => platform_tag_data[:repo_subdirectories] - }) + 'deb.component' => platform_tag_data[:repo_subdirectories], + }) end end end diff --git a/spec/lib/packaging/config_spec.rb b/spec/lib/packaging/config_spec.rb index cae82534..4b94077b 100644 --- a/spec/lib/packaging/config_spec.rb +++ b/spec/lib/packaging/config_spec.rb @@ -3,140 +3,140 @@ require 'yaml' describe "Pkg::Config" do - - Build_Params = [:apt_archive_path, - :apt_archive_repo_command, - :apt_host, - :apt_releases, - :apt_repo_path, - :apt_repo_url, - :apt_repo_name, - :apt_repo_command, - :author, - :benchmark, - :build_date, - :build_defaults, - :build_dmg, - :build_doc, - :build_gem, - :build_ips, - :build_msi, - :build_pe, - :build_tar, - :builder_data_file, - :bundle_platforms, - :certificate_pem, - :cows, - :db_table, - :deb_build_host, - :deb_build_mirrors, - :debversion, - :debug, - :default_cow, - :default_mock, - :description, - :dmg_path, - :downloads_archive_path, - :email, - :files, - :final_mocks, - :freight_archive_path, - :freight_conf, - :gem_default_executables, - :gem_dependencies, - :gem_description, - :gem_devel_dependencies, - :gem_development_dependencies, - :gem_excludes, - :gem_executables, - :gem_files, - :gem_forge_project, - :gem_host, - :gem_name, - :gem_path, - :gem_platform_dependencies, - :gem_rdoc_options, - :gem_require_path, - :gem_required_ruby_version, - :gem_required_rubygems_version, - :gem_runtime_dependencies, - :gem_summary, - :gem_test_files, - :gemversion, - :gpg_key, - :gpg_name, - :homepage, - :ips_build_host, - :ips_host, - :ips_inter_cert, - :ips_package_host, - :ips_path, - :ips_repo, - :ips_store, - :jenkins_build_host, - :jenkins_packaging_job, - :jenkins_repo_path, - :metrics, - :metrics_url, - :msi_name, - :name, - :nonfinal_apt_repo_command, - :nonfinal_apt_repo_path, - :nonfinal_apt_repo_staging_path, - :nonfinal_dmg_path, - :nonfinal_gem_path, - :nonfinal_ips_path, - :nonfinal_msi_path, - :nonfinal_p5p_path, - :nonfinal_repo_name, - :nonfinal_repo_link_target, - :nonfinal_svr4_path, - :nonfinal_swix_path, - :nonfinal_yum_repo_path, - :notify, - :project, - :origversion, - :osx_build_host, - :packager, - :packaging_repo, - :packaging_root, - :packaging_url, - :pbuild_conf, - :pe_name, - :pe_version, - :pg_major_version, - :pre_tar_task, - :pre_tasks, - :privatekey_pem, - :random_mockroot, - :rc_mocks, - :release, - :rpm_build_host, - :rpmrelease, - :rpmversion, - :ref, - :repo_name, - :short_ref, - :sign_tar, - :signing_server, - :summary, - :svr4_host, - :svr4_path, - :swix_path, - :tar_excludes, - :tar_host, - :tarball_path, - :team, - :templates, - :update_version_file, - :version, - :version_file, - :version_strategy, - :yum_archive_path, - :yum_host, - :yum_repo_path, - :yum_repo_name, - :yum_repo_command, + Build_Params = [ + :apt_archive_path, + :apt_archive_repo_command, + :apt_host, + :apt_releases, + :apt_repo_path, + :apt_repo_url, + :apt_repo_name, + :apt_repo_command, + :author, + :benchmark, + :build_date, + :build_defaults, + :build_dmg, + :build_doc, + :build_gem, + :build_ips, + :build_msi, + :build_pe, + :build_tar, + :builder_data_file, + :bundle_platforms, + :certificate_pem, + :cows, + :db_table, + :deb_build_host, + :deb_build_mirrors, + :debversion, + :debug, + :default_cow, + :default_mock, + :description, + :dmg_path, + :downloads_archive_path, + :email, + :files, + :final_mocks, + :freight_archive_path, + :freight_conf, + :gem_default_executables, + :gem_dependencies, + :gem_description, + :gem_devel_dependencies, + :gem_development_dependencies, + :gem_excludes, + :gem_executables, + :gem_files, + :gem_forge_project, + :gem_host, + :gem_name, + :gem_path, + :gem_platform_dependencies, + :gem_rdoc_options, + :gem_require_path, + :gem_required_ruby_version, + :gem_required_rubygems_version, + :gem_runtime_dependencies, + :gem_summary, + :gem_test_files, + :gemversion, + :gpg_key, + :gpg_name, + :homepage, + :ips_build_host, + :ips_host, + :ips_inter_cert, + :ips_package_host, + :ips_path, + :ips_repo, + :ips_store, + :jenkins_build_host, + :jenkins_packaging_job, + :jenkins_repo_path, + :metrics, + :metrics_url, + :msi_name, + :name, + :nonfinal_apt_repo_command, + :nonfinal_apt_repo_path, + :nonfinal_apt_repo_staging_path, + :nonfinal_dmg_path, + :nonfinal_gem_path, + :nonfinal_ips_path, + :nonfinal_msi_path, + :nonfinal_p5p_path, + :nonfinal_repo_name, + :nonfinal_repo_link_target, + :nonfinal_svr4_path, + :nonfinal_swix_path, + :nonfinal_yum_repo_path, + :notify, + :project, + :origversion, + :osx_build_host, + :packager, + :packaging_repo, + :packaging_root, + :packaging_url, + :pbuild_conf, + :pe_name, + :pe_version, + :pg_major_version, + :pre_tar_task, + :pre_tasks, + :privatekey_pem, + :random_mockroot, + :rc_mocks, + :release, + :rpm_build_host, + :rpmrelease, + :rpmversion, + :ref, + :repo_name, + :short_ref, + :sign_tar, + :signing_server, + :summary, + :svr4_host, + :svr4_path, + :swix_path, + :tar_excludes, + :tar_host, + :tarball_path, + :team, + :templates, + :update_version_file, + :version, + :version_file, + :version_strategy, + :yum_archive_path, + :yum_host, + :yum_repo_path, + :yum_repo_name, + :yum_repo_command, ] describe "#new" do @@ -228,7 +228,7 @@ "./artifacts/windows/puppet-agent-x64.msi\n" \ "./artifacts/windows/puppet-agent-5.3.2-x86.wixpdb\n" \ "./artifacts/windows/puppet-agent-5.3.2-x86.msi\n" \ - "./artifacts/windows/puppet-agent-5.3.2-x64.msi\n"\ + "./artifacts/windows/puppet-agent-5.3.2-x64.msi\n" \ "./artifacts/windowsfips/puppet-agent-x64.msi\n" \ "./artifacts/windowsfips/puppet-agent-5.3.2-x64.msi" @@ -286,8 +286,8 @@ it "should collect packages whose extname differ from package_format" do allow(Pkg::Util::Net).to receive(:remote_execute).and_return(solaris_artifacts, nil) data = Pkg::Config.platform_data - expect(data).to include('solaris-10-i386' => {:artifact => './solaris/10/PC1/puppet-agent-5.3.2-1.i386.pkg.gz', :repo_config => nil}) - expect(data).to include('solaris-11-sparc' => {:artifact => './solaris/11/PC1/puppet-agent@5.3.2,5.11-1.sparc.p5p', :repo_config => nil}) + expect(data).to include('solaris-10-i386' => { :artifact => './solaris/10/PC1/puppet-agent-5.3.2-1.i386.pkg.gz', :repo_config => nil }) + expect(data).to include('solaris-11-sparc' => { :artifact => './solaris/11/PC1/puppet-agent@5.3.2,5.11-1.sparc.p5p', :repo_config => nil }) end it "should collect versioned msis" do @@ -539,7 +539,7 @@ # explicitly set everything to nil to prevent any hazardous effects on # the rest of the tests. after(:all) do - reset_env(Pkg::Params::ENV_VARS.map {|hash| hash[:envvar].to_s}) + reset_env(Pkg::Params::ENV_VARS.map { |hash| hash[:envvar].to_s }) end Pkg::Params::ENV_VARS.each do |v| @@ -547,7 +547,7 @@ when :bool it "should set boolean value on #{v[:var]} for :type == :bool" do ENV[v[:envvar].to_s] = "FOO" - Pkg::Util.stub(:boolean_value) {"FOO"} + Pkg::Util.stub(:boolean_value) { "FOO" } allow(Pkg::Config).to receive(:instance_variable_set) expect(Pkg::Util).to receive(:boolean_value).with("FOO") expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", "FOO") @@ -556,7 +556,7 @@ when :array it "should set Pkg::Config##{v[:var]} to an Array for :type == :array" do ENV[v[:envvar].to_s] = "FOO BAR ARR RAY" - Pkg::Config.stub(:string_to_array) {%w(FOO BAR ARR RAY)} + Pkg::Config.stub(:string_to_array) { %w(FOO BAR ARR RAY) } allow(Pkg::Config).to receive(:instance_variable_set) expect(Pkg::Config).to receive(:string_to_array).with("FOO BAR ARR RAY") expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", %w(FOO BAR ARR RAY)) @@ -565,7 +565,7 @@ else it "should set Pkg::Config##{v[:var]} to ENV[#{v[:envvar].to_s}]" do ENV[v[:envvar].to_s] = "FOO" - Pkg::Util.stub(:boolean_value) {"FOO"} + Pkg::Util.stub(:boolean_value) { "FOO" } allow(Pkg::Config).to receive(:instance_variable_set) expect(Pkg::Config).to receive(:instance_variable_set).with("@#{v[:var]}", "FOO") Pkg::Config.load_envvars diff --git a/spec/lib/packaging/deb/repo_spec.rb b/spec/lib/packaging/deb/repo_spec.rb index a22ab3fa..6c9b4003 100644 --- a/spec/lib/packaging/deb/repo_spec.rb +++ b/spec/lib/packaging/deb/repo_spec.rb @@ -7,9 +7,9 @@ let(:ref) { "1234abcd" } let(:base_url) { "http://#{builds_server}/#{project}/#{ref}" } let(:cows) { ["xenial", "jessie", "trusty", "stretch", ""] } - let(:wget_results) { cows.map {|cow| "#{base_url}/repos/apt/#{cow}" }.join("\n") } + let(:wget_results) { cows.map { |cow| "#{base_url}/repos/apt/#{cow}" }.join("\n") } let(:wget_garbage) { "\n and an index\nhttp://somethingelse.com/robots" } - let(:repo_configs) { cows.reject {|cow| cow.empty?}.map {|dist| "pkg/repo_configs/deb/pl-#{project}-#{ref}-#{dist}.list" } } + let(:repo_configs) { cows.reject { |cow| cow.empty? }.map { |dist| "pkg/repo_configs/deb/pl-#{project}-#{ref}-#{dist}.list" } } # Setup and tear down for the tests around do |example| @@ -31,19 +31,19 @@ describe "#generate_repo_configs" do it "fails if wget isn't available" do - Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_raise(RuntimeError) - expect {Pkg::Deb::Repo.generate_repo_configs}.to raise_error(RuntimeError) + Pkg::Util::Tool.should_receive(:find_tool).with("wget", { :required => true }).and_raise(RuntimeError) + expect { Pkg::Deb::Repo.generate_repo_configs }.to raise_error(RuntimeError) end it "warns if there are no deb repos available for the build" do - Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget) + Pkg::Util::Tool.should_receive(:find_tool).with("wget", { :required => true }).and_return(wget) Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 1 --no-parent #{base_url}/repos/apt/ 2>&1").and_raise(RuntimeError) Pkg::Deb::Repo.should_receive(:warn).with("No debian repos available for #{project} at #{ref}.") Pkg::Deb::Repo.generate_repo_configs end it "writes the expected repo configs to disk" do - Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget) + Pkg::Util::Tool.should_receive(:find_tool).with("wget", { :required => true }).and_return(wget) Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 1 --no-parent #{base_url}/repos/apt/ 2>&1").and_return(wget_results + wget_garbage) FileUtils.should_receive(:mkdir_p).with("pkg/repo_configs/deb") config = [] @@ -58,15 +58,15 @@ describe "#retrieve_repo_configs" do it "fails if wget isn't available" do - Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_raise(RuntimeError) - expect {Pkg::Deb::Repo.generate_repo_configs}.to raise_error(RuntimeError) + Pkg::Util::Tool.should_receive(:find_tool).with("wget", { :required => true }).and_raise(RuntimeError) + expect { Pkg::Deb::Repo.generate_repo_configs }.to raise_error(RuntimeError) end it "warns if there are no deb repos available for the build" do - Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget) + Pkg::Util::Tool.should_receive(:find_tool).with("wget", { :required => true }).and_return(wget) FileUtils.should_receive(:mkdir_p).with("pkg/repo_configs").and_return(true) Pkg::Util::Execution.should_receive(:capture3).with("#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{base_url}/repo_configs/deb/").and_raise(RuntimeError) - expect {Pkg::Deb::Repo.retrieve_repo_configs}.to raise_error(RuntimeError, /Couldn't retrieve deb apt repo configs/) + expect { Pkg::Deb::Repo.retrieve_repo_configs }.to raise_error(RuntimeError, /Couldn't retrieve deb apt repo configs/) end end @@ -88,14 +88,14 @@ let(:pkg_directories) { ['place/to/deb/xenial', 'other/deb/trusty'] } it "generates repo configs remotely and then ships them" do - File.stub(:join) {artifact_directory} + File.stub(:join) { artifact_directory } Pkg::Repo.should_receive(:directories_that_contain_packages).and_return(pkg_directories) Pkg::Repo.should_receive(:populate_repo_directory) Pkg::Deb::Repo.should_receive(:repo_creation_command).and_return(command) Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, command) Pkg::Deb::Repo.should_receive(:generate_repo_configs) Pkg::Deb::Repo.should_receive(:ship_repo_configs) - Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock" ) + Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock") Pkg::Deb::Repo.create_repos end end @@ -123,7 +123,7 @@ describe "#sign_repos" do it "fails without reprepro" do - Pkg::Util::Tool.should_receive(:find_tool).with('reprepro', {:required => true}).and_raise(RuntimeError) + Pkg::Util::Tool.should_receive(:find_tool).with('reprepro', { :required => true }).and_raise(RuntimeError) expect { Pkg::Deb::Repo.sign_repos }.to raise_error(RuntimeError) end diff --git a/spec/lib/packaging/gem_spec.rb b/spec/lib/packaging/gem_spec.rb index 207ba921..38711d4b 100644 --- a/spec/lib/packaging/gem_spec.rb +++ b/spec/lib/packaging/gem_spec.rb @@ -4,80 +4,84 @@ describe '#shipped_to_rubygems?' do let(:gem_data) { [ - {"authors"=>"Puppet Labs", - "built_at"=>"2018-12-17T00:00:00.000Z", - "created_at"=>"2018-12-18T17:31:50.852Z", - "description"=>"Puppet, an automated configuration management tool", - "downloads_count"=>32750, - "metadata"=>{}, - "number"=>"6.1.0", - "summary"=>"Puppet, an automated configuration management tool", - "platform"=>"ruby", - "rubygems_version"=>"> 1.3.1", - "ruby_version"=>">= 2.3.0", - "prerelease"=>false, - "licenses"=>[], - "requirements"=>[], - "sha"=>"71ecec1f554cd7a7f23abf1523e4f0f15fb8ddbc973201234d0cc2a889566373"}, - {"authors"=>"Puppet Labs", - "built_at"=>"2019-01-14T00:00:00.000Z", - "created_at"=>"2019-01-15T15:25:25.183Z", - "description"=>"Puppet, an automated configuration management tool", - "downloads_count"=>540, - "metadata"=>{}, - "number"=>"6.0.5", - "summary"=>"Puppet, an automated configuration management tool", - "platform"=>"ruby", - "rubygems_version"=>"> 1.3.1", - "ruby_version"=>">= 2.3.0", - "prerelease"=>false, - "licenses"=>[], - "requirements"=>[], - "sha"=>"76811bcf4c5ab75470dd6ae5eea552347767748bd80136cac74261336b208916"}, - {"authors"=>"Puppet Labs", - "built_at"=>"2018-10-31T00:00:00.000Z", - "created_at"=>"2018-11-01T17:07:19.274Z", - "description"=>"Puppet, an automated configuration management tool", - "downloads_count"=>71808, - "metadata"=>{}, - "number"=>"6.0.4", - "summary"=>"Puppet, an automated configuration management tool", - "platform"=>"ruby", - "rubygems_version"=>"> 1.3.1", - "ruby_version"=>">= 2.3.0", - "prerelease"=>false, - "licenses"=>[], - "requirements"=>[], - "sha"=>"203e8b529d37260115ab7e804e607dde5e543144331b40c3c4a77c2d33445026"}, - {"authors"=>"Puppet Labs", - "built_at"=>"2018-10-31T00:00:00.000Z", - "created_at"=>"2018-11-01T17:07:10.268Z", - "description"=>"Puppet, an automated configuration management tool", - "downloads_count"=>1179, - "metadata"=>{}, - "number"=>"6.0.4", - "summary"=>"Puppet, an automated configuration management tool", - "platform"=>"x86-mingw32", - "rubygems_version"=>"> 1.3.1", - "ruby_version"=>">= 2.3.0", - "prerelease"=>false, - "licenses"=>[], - "requirements"=>[], - "sha"=>"e57ef7d537aaf66343615d7413d1ff759cc2b6ae95cc90514dd8f3caf0f08cb1"} + { "authors" => "Puppet Labs", + "built_at" => "2018-12-17T00:00:00.000Z", + "created_at" => "2018-12-18T17:31:50.852Z", + "description" => "Puppet, an automated configuration management tool", + "downloads_count" => 32750, + "metadata" => {}, + "number" => "6.1.0", + "summary" => "Puppet, an automated configuration management tool", + "platform" => "ruby", + "rubygems_version" => "> 1.3.1", + "ruby_version" => ">= 2.3.0", + "prerelease" => false, + "licenses" => [], + "requirements" => [], + "sha" => "71ecec1f554cd7a7f23abf1523e4f0f15fb8ddbc973201234d0cc2a889566373", }, + { "authors" => "Puppet Labs", + "built_at" => "2019-01-14T00:00:00.000Z", + "created_at" => "2019-01-15T15:25:25.183Z", + "description" => "Puppet, an automated configuration management tool", + "downloads_count" => 540, + "metadata" => {}, + "number" => "6.0.5", + "summary" => "Puppet, an automated configuration management tool", + "platform" => "ruby", + "rubygems_version" => "> 1.3.1", + "ruby_version" => ">= 2.3.0", + "prerelease" => false, + "licenses" => [], + "requirements" => [], + "sha" => "76811bcf4c5ab75470dd6ae5eea552347767748bd80136cac74261336b208916", }, + { "authors" => "Puppet Labs", + "built_at" => "2018-10-31T00:00:00.000Z", + "created_at" => "2018-11-01T17:07:19.274Z", + "description" => "Puppet, an automated configuration management tool", + "downloads_count" => 71808, + "metadata" => {}, + "number" => "6.0.4", + "summary" => "Puppet, an automated configuration management tool", + "platform" => "ruby", + "rubygems_version" => "> 1.3.1", + "ruby_version" => ">= 2.3.0", + "prerelease" => false, + "licenses" => [], + "requirements" => [], + "sha" => "203e8b529d37260115ab7e804e607dde5e543144331b40c3c4a77c2d33445026", }, + { "authors" => "Puppet Labs", + "built_at" => "2018-10-31T00:00:00.000Z", + "created_at" => "2018-11-01T17:07:10.268Z", + "description" => "Puppet, an automated configuration management tool", + "downloads_count" => 1179, + "metadata" => {}, + "number" => "6.0.4", + "summary" => "Puppet, an automated configuration management tool", + "platform" => "x86-mingw32", + "rubygems_version" => "> 1.3.1", + "ruby_version" => ">= 2.3.0", + "prerelease" => false, + "licenses" => [], + "requirements" => [], + "sha" => "e57ef7d537aaf66343615d7413d1ff759cc2b6ae95cc90514dd8f3caf0f08cb1", }, ] } + it 'returns true if gem version has already been shipped' do allow(JSON).to receive(:parse).and_return(gem_data) expect(Pkg::Gem.shipped_to_rubygems?('puppet', '6.0.5', 'ruby')).to be true end + it 'returns false if the platform doesn\'t match' do allow(JSON).to receive(:parse).and_return(gem_data) expect(Pkg::Gem.shipped_to_rubygems?('puppet', '6.0.5', 'x64-mingw32')).to be false end + it 'returns false if gem version has not already been shipped' do allow(JSON).to receive(:parse).and_return(gem_data) expect(Pkg::Gem.shipped_to_rubygems?('puppet', '6.0.9', 'ruby')).to be false end + it 'returns false if gem is not found at all on rubygems' do expect { Pkg::Gem.shipped_to_rubygems?('totally-not-a-real-gem', '9.9.9', 'ruby') }.to_not raise_error expect(Pkg::Gem.shipped_to_rubygems?('totally-not-a-real-gem', '9.9.9', 'ruby')).to be false diff --git a/spec/lib/packaging/paths_spec.rb b/spec/lib/packaging/paths_spec.rb index 90aad9a7..96eeca4e 100644 --- a/spec/lib/packaging/paths_spec.rb +++ b/spec/lib/packaging/paths_spec.rb @@ -11,7 +11,7 @@ ['artifacts/ubuntu-16.04-i386/puppetserver_5.0.1-0.1SNAPSHOT.2017.07.27T2346puppetlabs1.debian.tar.gz', 'ubuntu', '16.04'] => 'source', ['artifacts/deb/jessie/PC1/puppetserver_5.0.1.master.orig.tar.gz', 'debian', '8'] => 'source', - ['artifacts/el/6/PC1/SRPMS/puppetserver-5.0.1.master-0.1SNAPSHOT.2017.08.18T0951.el6.src.rpm', 'el', '6'] => 'SRPMS' + ['artifacts/el/6/PC1/SRPMS/puppetserver-5.0.1.master-0.1SNAPSHOT.2017.08.18T0951.el6.src.rpm', 'el', '6'] => 'SRPMS', } arch_transformations.each do |path_array, arch| it "should correctly return #{arch} for #{path_array[0]}" do @@ -144,6 +144,7 @@ expect(Pkg::Paths.artifacts_path('ubuntu-18.04-amd64')) .to eq('artifacts/FUTURE-puppet7/bionic') end + it 'should be correct for focal' do expect(Pkg::Paths.artifacts_path('ubuntu-20.04-amd64')) .to eq('artifacts/FUTURE-puppet7/focal') @@ -264,22 +265,27 @@ allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return(fake_yum_nightly_repo_path) allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return(fake_apt_nightly_repo_path) end + it 'returns yum_repo_path for rpms' do expect(Pkg::Paths.remote_repo_base('el-7-x86_64')) .to eq(fake_yum_repo_path) end + it 'returns apt_repo_path for debs' do expect(Pkg::Paths.remote_repo_base('ubuntu-18.04-amd64')) .to eq(fake_apt_repo_path) end + it 'returns nonfinal_yum_repo_path for nonfinal rpms' do expect(Pkg::Paths.remote_repo_base('fedora-31-x86_64', nonfinal: true)) .to eq(fake_yum_nightly_repo_path) end + it 'returns nonfinal_apt_repo_path for nonfinal debs' do expect(Pkg::Paths.remote_repo_base('debian-9-amd64', nonfinal: true)) .to eq(fake_apt_nightly_repo_path) end + it 'fails if neither tag nor package_format is provided' do expect { Pkg::Paths.remote_repo_base } .to raise_error(/Pkg::Paths.remote_repo_base must have/) @@ -308,9 +314,8 @@ .to eq('/opt/repository/apt/pool/bionic/puppet6/p/puppet-agent') expect(Pkg::Paths.apt_package_base_path('debian-9-amd64', 'puppet6', 'bolt-server')) .to eq('/opt/repository/apt/pool/stretch/puppet6/b/bolt-server') - - end + it 'returns the appropriate nonfinal repo path' do allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository-nightlies/apt') expect(Pkg::Paths.apt_package_base_path('ubuntu-18.04-amd64', 'puppet6-nightly', @@ -330,6 +335,7 @@ expect(Pkg::Paths.apt_package_base_path('ubuntu-20.04-amd64', 'FUTURE-puppet7', 'puppet-agent')) .to eq('/opt/repository/apt/FUTURE-puppet7/pool/focal/p/puppet-agent') end + it 'returns the appropriate nonfinal repo path' do allow(Pkg::Paths).to receive(:remote_repo_base).and_return('/opt/repository-nightlies/apt') expect(Pkg::Paths.apt_package_base_path('debian-10-amd64', 'FUTURE-puppet7-nightly', 'pdk', true)) @@ -354,22 +360,27 @@ allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return(nonfinal_yum_repo_path) allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return(nonfinal_apt_repo_path) end + it 'returns the appropriate link path for rpm release packages' do expect(Pkg::Paths.release_package_link_path('sles-12-ppc64le')) .to eq("#{yum_repo_path}/#{repo_name}-release-sles-12.noarch.rpm") end + it 'returns the appropriate link path for deb release packages' do expect(Pkg::Paths.release_package_link_path('ubuntu-16.04-amd64')) .to eq("#{apt_repo_path}/#{repo_name}-release-xenial.deb") end + it 'returns the appropriate link path for nonfinal rpm release packages' do expect(Pkg::Paths.release_package_link_path('el-7-x86_64', true)) .to eq("#{nonfinal_yum_repo_path}/#{nonfinal_repo_name}-release-el-7.noarch.rpm") end + it 'returns the appropriate link path for nonfinal deb release packages' do expect(Pkg::Paths.release_package_link_path('debian-9-i386', true)) .to eq("#{nonfinal_apt_repo_path}/#{nonfinal_repo_name}-release-stretch.deb") end + it 'returns nil for package formats that do not have release packages' do expect(Pkg::Paths.release_package_link_path('osx-10.15-x86_64')).to be_nil expect(Pkg::Paths.release_package_link_path('osx-11-x86_64')).to be_nil @@ -392,22 +403,27 @@ allow(Pkg::Config).to receive(:nonfinal_yum_repo_path).and_return(nonfinal_yum_repo_path) allow(Pkg::Config).to receive(:nonfinal_apt_repo_path).and_return(nonfinal_apt_repo_path) end + it 'returns the appropriate link path for rpm release packages' do expect(Pkg::Paths.release_package_link_path('sles-12-ppc64le')) .to eq("#{yum_repo_path}/#{repo_name}-release-sles-12.noarch.rpm") end + it 'returns the appropriate link path for deb release packages' do expect(Pkg::Paths.release_package_link_path('ubuntu-20.04-amd64')) .to eq("#{apt_repo_path}/#{repo_name}-release-focal.deb") end + it 'returns the appropriate link path for nonfinal rpm release packages' do expect(Pkg::Paths.release_package_link_path('el-8-x86_64', true)) .to eq("#{nonfinal_yum_repo_path}/#{nonfinal_repo_name}-release-el-8.noarch.rpm") end + it 'returns the appropriate link path for nonfinal deb release packages' do expect(Pkg::Paths.release_package_link_path('debian-10-i386', true)) .to eq("#{nonfinal_apt_repo_path}/#{nonfinal_repo_name}-release-buster.deb") end + it 'returns nil for package formats that do not have release packages' do expect(Pkg::Paths.release_package_link_path('osx-10.15-x86_64')).to be_nil expect(Pkg::Paths.release_package_link_path('osx-11-x86_64')).to be_nil diff --git a/spec/lib/packaging/platforms_spec.rb b/spec/lib/packaging/platforms_spec.rb index b3d1d582..330741d4 100644 --- a/spec/lib/packaging/platforms_spec.rb +++ b/spec/lib/packaging/platforms_spec.rb @@ -30,7 +30,7 @@ end it 'should raise an error if given a nonexistent platform' do - expect{Pkg::Platforms.versions_for_platform('notaplatform') }.to raise_error + expect { Pkg::Platforms.versions_for_platform('notaplatform') }.to raise_error end end @@ -47,7 +47,7 @@ end it 'should fail if given nil as a codename' do - expect{Pkg::Platforms.codename_to_platform_version(nil)}.to raise_error + expect { Pkg::Platforms.codename_to_platform_version(nil) }.to raise_error end end @@ -101,12 +101,12 @@ it 'should return a hash of platform info' do expect(Pkg::Platforms.platform_lookup(platform)).to be_instance_of(Hash) end - + it 'should include at least arch and package format keys' do expect(Pkg::Platforms.platform_lookup(platform).keys).to include(:architectures) expect(Pkg::Platforms.platform_lookup(platform).keys).to include(:package_format) end - end + end end describe '#get_attribute' do @@ -159,7 +159,7 @@ fail_cases.each do |platform_tag| it "fails out for #{platform_tag}" do - expect { Pkg::Platforms.parse_platform_tag(platform_tag)}.to raise_error + expect { Pkg::Platforms.parse_platform_tag(platform_tag) }.to raise_error end end end diff --git a/spec/lib/packaging/repo_spec.rb b/spec/lib/packaging/repo_spec.rb index fa1e704c..50f79462 100644 --- a/spec/lib/packaging/repo_spec.rb +++ b/spec/lib/packaging/repo_spec.rb @@ -3,11 +3,12 @@ describe "#Pkg::Repo" do let(:platform_repo_stub) do [ - {"name"=>"el-4-i386", "repo_location"=>"repos/el/4/**/i386"}, - {"name"=>"el-5-i386", "repo_location"=>"repos/el/5/**/i386"}, - {"name"=>"el-6-i386", "repo_location"=>"repos/el/6/**/i386"} + { "name" => "el-4-i386", "repo_location" => "repos/el/4/**/i386" }, + { "name" => "el-5-i386", "repo_location" => "repos/el/5/**/i386" }, + { "name" => "el-6-i386", "repo_location" => "repos/el/6/**/i386" }, ] end + describe "#create_signed_repo_archive" do it "should change to the correct dir" do allow(Pkg::Util::Tool).to receive(:check_tool).and_return("tarcommand") @@ -54,7 +55,7 @@ allow(Pkg::Util::File).to receive(:empty_dir?).and_return(true) ENV['FAIL_ON_MISSING_TARGET'] = 'true' - expect{Pkg::Repo.create_signed_repo_archive('/path', 'project-debian-6-i386', 'version')}.to raise_error(RuntimeError, 'Error: missing packages under /path') + expect { Pkg::Repo.create_signed_repo_archive('/path', 'project-debian-6-i386', 'version') }.to raise_error(RuntimeError, 'Error: missing packages under /path') end it "should only warn if ENV['FAIL_ON_MISSING_TARGET'] is false and empty_dir? is true" do @@ -66,7 +67,7 @@ allow(Pkg::Util::File).to receive(:empty_dir?).and_return(true) ENV['FAIL_ON_MISSING_TARGET'] = "false" - expect{Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "version")}.not_to raise_error + expect { Pkg::Repo.create_signed_repo_archive("/path", "project-debian-6-i386", "version") }.not_to raise_error end it 'should invoke tar correctly' do @@ -124,7 +125,7 @@ end it 'should fail if required params are nil' do - expect{ Pkg::Repo.update_repo(remote_host, repo_command, { :repo_path => repo_path }) }.to raise_error(RuntimeError, /Missing required argument 'repo_name'/) + expect { Pkg::Repo.update_repo(remote_host, repo_command, { :repo_path => repo_path }) }.to raise_error(RuntimeError, /Missing required argument 'repo_name'/) end it 'should execute command if optional params are nil' do diff --git a/spec/lib/packaging/retrieve_spec.rb b/spec/lib/packaging/retrieve_spec.rb index 8aa794cd..06e48688 100644 --- a/spec/lib/packaging/retrieve_spec.rb +++ b/spec/lib/packaging/retrieve_spec.rb @@ -8,16 +8,16 @@ project = 'puppet-agent' ref = 'b25e64984dd505391f248fe5501ad81e2645b6d2' foss_platforms = ['el-7-x86_64', 'ubuntu-16.04-amd64', 'osx-10.15-x86_64', 'osx-11-x86_64', 'windows-2012-x64'] - platform_data = {:platform_data => { - 'aix-7.1-power' => {:artifact => './aix/7.1/PC1/ppc/puppet-agent-5.3.2.155.gb25e649-1.aix7.1.ppc.rpm'}, - 'el-7-x86_64' => {:artifact => './el/7/PC1/x86_64/puppet-agent-5.3.2.155.gb25e649-1.el7.x86_64.rpm'}, - 'osx-10.15-x86_64' => {:artifact => './apple/10.15/PC1/x86_64/puppet-agent-5.3.2.155.gb25e649-1.osx10.15.dmg'}, - 'osx-11-x86_64' => {:artifact => './apple/11/PC1/x86_64/puppet-agent-5.3.2.155.gb25e649-1.osx11.dmg'}, - 'sles-11-i386' => {:artifact => './sles/11/PC1/i386/puppet-agent-5.3.2.155.gb25e649-1.sles11.i386.rpm'}, - 'solaris-10-sparc' => {:artifact => './solaris/10/PC1/puppet-agent-5.3.2.155.gb25e649-1.sparc.pkg.gz'}, - 'ubuntu-16.04-amd64' => {:artifact => './deb/xenial/PC1/puppet-agent_5.3.2.155.gb25e649-1xenial_amd64.deb'}, - 'windows-2012-x64' => {:artifact => './windows/puppet-agent-x64.msi'}, - }} + platform_data = { :platform_data => { + 'aix-7.1-power' => { :artifact => './aix/7.1/PC1/ppc/puppet-agent-5.3.2.155.gb25e649-1.aix7.1.ppc.rpm' }, + 'el-7-x86_64' => { :artifact => './el/7/PC1/x86_64/puppet-agent-5.3.2.155.gb25e649-1.el7.x86_64.rpm' }, + 'osx-10.15-x86_64' => { :artifact => './apple/10.15/PC1/x86_64/puppet-agent-5.3.2.155.gb25e649-1.osx10.15.dmg' }, + 'osx-11-x86_64' => { :artifact => './apple/11/PC1/x86_64/puppet-agent-5.3.2.155.gb25e649-1.osx11.dmg' }, + 'sles-11-i386' => { :artifact => './sles/11/PC1/i386/puppet-agent-5.3.2.155.gb25e649-1.sles11.i386.rpm' }, + 'solaris-10-sparc' => { :artifact => './solaris/10/PC1/puppet-agent-5.3.2.155.gb25e649-1.sparc.pkg.gz' }, + 'ubuntu-16.04-amd64' => { :artifact => './deb/xenial/PC1/puppet-agent_5.3.2.155.gb25e649-1xenial_amd64.deb' }, + 'windows-2012-x64' => { :artifact => './windows/puppet-agent-x64.msi' }, + } } build_url = "builds.delivery.puppetlabs.net/#{project}/#{ref}/#{remote_target}" build_path = "/opt/jenkins-builds/#{project}/#{ref}/#{remote_target}" @@ -30,19 +30,23 @@ end describe '#default_wget_command' do - let(:options) { [ - "--quiet", - "--recursive", - "--no-parent", - "--no-host-directories", - "--level=0", - "--cut-dirs=3", - "--directory-prefix=#{local_target}", - "--reject='index*", - ] } + let(:options) { + [ + "--quiet", + "--recursive", + "--no-parent", + "--no-host-directories", + "--level=0", + "--cut-dirs=3", + "--directory-prefix=#{local_target}", + "--reject='index*", + ] + } + before :each do allow(Pkg::Util::Tool).to receive(:check_tool).with('wget').and_return('wget') end + context 'when no options passed' do it 'should include default options' do options.each do |option| @@ -50,18 +54,20 @@ end end end + context 'when options are passed' do it 'should add to existing options' do options.push('--convert-links') options.each do |option| - expect(Pkg::Retrieve.default_wget_command(local_target, build_url, {'convert-links' => true})).to include(option) + expect(Pkg::Retrieve.default_wget_command(local_target, build_url, { 'convert-links' => true })).to include(option) end end + it 'should replace default values' do options.push('--level=1').delete('--level=0') - expect(Pkg::Retrieve.default_wget_command(local_target, build_url, {'level' => 1})).to_not include('--level=0') + expect(Pkg::Retrieve.default_wget_command(local_target, build_url, { 'level' => 1 })).to_not include('--level=0') options.each do |option| - expect(Pkg::Retrieve.default_wget_command(local_target, build_url, {'level' => 1})).to include(option) + expect(Pkg::Retrieve.default_wget_command(local_target, build_url, { 'level' => 1 })).to include(option) end end end diff --git a/spec/lib/packaging/rpm/repo_spec.rb b/spec/lib/packaging/rpm/repo_spec.rb index c6e96085..8d56708d 100644 --- a/spec/lib/packaging/rpm/repo_spec.rb +++ b/spec/lib/packaging/rpm/repo_spec.rb @@ -8,11 +8,11 @@ let(:base_url) { "http://#{builds_server}/#{project}/#{ref}" } let(:mocks) { ["el-5-i386", "el-5-x86_64", "el-5-SRPMS"] } let(:wget_results) { - mocks.map do |mock| - dist, version, arch = mock.split('-') - "http://#{builds_server}/#{project}/#{ref}/repos/#{dist}/#{version}/products/#{arch}/repodata/" - end.join("\n") - } + mocks.map do |mock| + dist, version, arch = mock.split('-') + "http://#{builds_server}/#{project}/#{ref}/repos/#{dist}/#{version}/products/#{arch}/repodata/" + end.join("\n") + } let(:wget_garbage) { "\nother things\n and an index\nhttp://somethingelse.com" } let(:repo_configs) { mocks.map { |mock| "pkg/repo_configs/rpm/pl-#{project}-#{ref}-#{mock}.repo" } } @@ -36,19 +36,19 @@ describe "#generate_repo_configs" do it "fails if wget isn't available" do - Pkg::Util::Tool.stub(:find_tool).with("wget", {:required => true}) {false} - expect {Pkg::Rpm::Repo.generate_repo_configs}.to raise_error(RuntimeError) + Pkg::Util::Tool.stub(:find_tool).with("wget", { :required => true }) { false } + expect { Pkg::Rpm::Repo.generate_repo_configs }.to raise_error(RuntimeError) end it "warns if there are no rpm repos available for the build" do - Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget) + Pkg::Util::Tool.should_receive(:find_tool).with("wget", { :required => true }).and_return(wget) Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1").and_return("") Pkg::Rpm::Repo.should_receive(:warn).with("No rpm repos were found to generate configs from!") Pkg::Rpm::Repo.generate_repo_configs end it "writes the expected repo configs to disk" do - Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget) + Pkg::Util::Tool.should_receive(:find_tool).with("wget", { :required => true }).and_return(wget) Pkg::Util::Execution.should_receive(:capture3).with("#{wget} --spider -r -l 5 --no-parent #{base_url}/repos/ 2>&1").and_return(wget_results + wget_garbage) wget_results.split.each do |result| cur_result = result.chomp('repodata/') @@ -69,15 +69,15 @@ describe "#retrieve_repo_configs" do it "fails if wget isn't available" do - Pkg::Util::Tool.stub(:find_tool).with("wget", {:required => true}) {false} - expect {Pkg::Rpm::Repo.generate_repo_configs}.to raise_error(RuntimeError) + Pkg::Util::Tool.stub(:find_tool).with("wget", { :required => true }) { false } + expect { Pkg::Rpm::Repo.generate_repo_configs }.to raise_error(RuntimeError) end it "fails if there are no deb repos available for the build" do - Pkg::Util::Tool.should_receive(:find_tool).with("wget", {:required => true}).and_return(wget) + Pkg::Util::Tool.should_receive(:find_tool).with("wget", { :required => true }).and_return(wget) FileUtils.should_receive(:mkdir_p).with("pkg/repo_configs").and_return(true) Pkg::Util::Execution.should_receive(:capture3).with("#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{base_url}/repo_configs/rpm/").and_raise(RuntimeError) - expect {Pkg::Rpm::Repo.retrieve_repo_configs}.to raise_error(RuntimeError, /Couldn't retrieve rpm yum repo configs/) + expect { Pkg::Rpm::Repo.retrieve_repo_configs }.to raise_error(RuntimeError, /Couldn't retrieve rpm yum repo configs/) end end @@ -98,14 +98,14 @@ let(:pkg_directories) { ['el-6-i386', 'el/7/x86_64'] } it "makes a repo in the target directory" do - File.stub(:join) {artifact_directory} + File.stub(:join) { artifact_directory } Pkg::Repo.should_receive(:directories_that_contain_packages).and_return(pkg_directories) Pkg::Repo.should_receive(:populate_repo_directory) Pkg::Rpm::Repo.should_receive(:repo_creation_command).and_return(command) Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, command) Pkg::Rpm::Repo.should_receive(:generate_repo_configs) Pkg::Rpm::Repo.should_receive(:ship_repo_configs) - Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock" ) + Pkg::Util::Net.should_receive(:remote_execute).with(Pkg::Config.distribution_server, "rm -f #{artifact_directory}/repos/.lock") Pkg::Rpm::Repo.create_remote_repos end end diff --git a/spec/lib/packaging/sign_spec.rb b/spec/lib/packaging/sign_spec.rb index 6e0567c7..19bb4a85 100644 --- a/spec/lib/packaging/sign_spec.rb +++ b/spec/lib/packaging/sign_spec.rb @@ -3,59 +3,68 @@ describe 'Pkg::Sign' do describe 'Pkg::Sign::Rpm' do - before :each do allow(Pkg::Config).to receive(:gpg_key).and_return('7F438280EF8D349F') end describe '#has_sig?' do let(:rpm) { 'foo.rpm' } - let(:el7_signed_response) { <<-DOC + let(:el7_signed_response) { + <<-DOC Header V4 RSA/SHA256 Signature, key ID ef8d349f: NOKEY Header SHA1 digest: OK (3cb7e9861e8bc09783a1b6c8d88243a3c16daa81) V4 RSA/SHA256 Signature, key ID ef8d349f: NOKEY MD5 digest: OK (d5f06ba2a9053de532326d0659ec0d11) DOC } - let(:el5_signed_response) { <<-DOC + let(:el5_signed_response) { + <<-DOC Header V3 RSA/SHA1 signature: NOKEY, key ID ef8d349f Header SHA1 digest: OK (12ea7bd578097a3aecc5deb8ada6aca6147d68e3) V3 RSA/SHA1 signature: NOKEY, key ID ef8d349f MD5 digest: OK (27353c6153068a3c9902fcb4ad5b8b92) DOC } - let(:sles12_signed_response) { <<-DOC + let(:sles12_signed_response) { + <<-DOC Header V4 RSA/SHA256 Signature, key ID ef8d349f: NOKEY Header SHA1 digest: OK (e713487cf21ebeb933aefd5ec9211a34603233d2) V4 RSA/SHA256 Signature, key ID ef8d349f: NOKEY MD5 digest: OK (3093a09ac39bc17751f913e19ca74432) DOC } - let(:unsigned_response) { <<-DOC + let(:unsigned_response) { + <<-DOC Header SHA1 digest: OK (f9404cc95f200568c2dbb1fd24e1119e3e4a40a9) MD5 digest: OK (816095f3cee145091c3fa07a0915ce85) DOC } + it 'returns true if rpm has been signed (el7)' do allow(Pkg::Sign::Rpm).to receive(:`).and_return(el7_signed_response) expect(Pkg::Sign::Rpm.has_sig?(rpm)).to be true end + it 'returns true if rpm has been signed (el5)' do allow(Pkg::Sign::Rpm).to receive(:`).and_return(el5_signed_response) expect(Pkg::Sign::Rpm.has_sig?(rpm)).to be true end + it 'returns true if rpm has been signed (sles12)' do allow(Pkg::Sign::Rpm).to receive(:`).and_return(sles12_signed_response) expect(Pkg::Sign::Rpm.has_sig?(rpm)).to be true end + it 'returns false if rpm has not been signed' do allow(Pkg::Sign::Rpm).to receive(:`).and_return(unsigned_response) expect(Pkg::Sign::Rpm.has_sig?(rpm)).to be false end + it 'fails with unexpected output' do allow(Pkg::Sign::Rpm).to receive(:`).and_return('something that is definitely not a normal response') expect { Pkg::Sign::Rpm.has_sig?(rpm) }.to raise_error(RuntimeError, /Something went wrong checking the signature/) end + it 'fails if gpg_key is not set' do allow(Pkg::Config).to receive(:gpg_key).and_return(nil) expect { Pkg::Sign::Rpm.has_sig?(rpm) }.to raise_error(RuntimeError, /You need to set `gpg_key` in your build defaults./) @@ -64,28 +73,21 @@ describe '#sign_all' do let(:rpm_directory) { 'foo' } - let(:rpms_not_to_sign) { [ - "#{rpm_directory}/aix/7.1/PC1/ppc/puppet-agent-5.5.3-1.aix7.1.ppc.rpm", - ] } - let(:v3_rpms) { [ - "#{rpm_directory}/el/5/PC1/i386/puppet-agent-5.5.3-1.el5.i386.rpm", - "#{rpm_directory}/sles/11/PC1/x86_64/puppet-agent-5.5.3-1.sles11.x86_64.rpm", - ] } - let(:v4_rpms) { [ - "#{rpm_directory}/el/7/PC1/aarch64/puppet-agent-5.5.3-1.el7.aarch64.rpm", - ] } + let(:rpms_not_to_sign) { ["#{rpm_directory}/aix/7.1/PC1/ppc/puppet-agent-5.5.3-1.aix7.1.ppc.rpm"] } + let(:v3_rpms) { ["#{rpm_directory}/el/5/PC1/i386/puppet-agent-5.5.3-1.el5.i386.rpm", "#{rpm_directory}/sles/11/PC1/x86_64/puppet-agent-5.5.3-1.sles11.x86_64.rpm"] } + let(:v4_rpms) { ["#{rpm_directory}/el/7/PC1/aarch64/puppet-agent-5.5.3-1.el7.aarch64.rpm"] } let(:rpms) { rpms_not_to_sign + v3_rpms + v4_rpms } - let(:already_signed_rpms) { [ - "#{rpm_directory}/el/6/PC1/x86_64/puppet-agent-5.5.3-1.el6.x86_64.rpm", - ] } - let(:noarch_rpms) { [ - "#{rpm_directory}/el/6/puppet5/i386/puppetserver-5.3.3-1.el6.noarch.rpm", - "#{rpm_directory}/el/6/puppet5/x86_64/puppetserver-5.3.3-1.el6.noarch.rpm", - "#{rpm_directory}/el/7/puppet5/i386/puppetserver-5.3.3-1.el7.noarch.rpm", - "#{rpm_directory}/el/7/puppet5/x86_64/puppetserver-5.3.3-1.el7.noarch.rpm", - "#{rpm_directory}/sles/12/puppet5/i386/puppetserver-5.3.3-1.sles12.noarch.rpm", - "#{rpm_directory}/sles/12/puppet5/x86_64/puppetserver-5.3.3-1.sles12.noarch.rpm" - ] } + let(:already_signed_rpms) { ["#{rpm_directory}/el/6/PC1/x86_64/puppet-agent-5.5.3-1.el6.x86_64.rpm"] } + let(:noarch_rpms) { + [ + "#{rpm_directory}/el/6/puppet5/i386/puppetserver-5.3.3-1.el6.noarch.rpm", + "#{rpm_directory}/el/6/puppet5/x86_64/puppetserver-5.3.3-1.el6.noarch.rpm", + "#{rpm_directory}/el/7/puppet5/i386/puppetserver-5.3.3-1.el7.noarch.rpm", + "#{rpm_directory}/el/7/puppet5/x86_64/puppetserver-5.3.3-1.el7.noarch.rpm", + "#{rpm_directory}/sles/12/puppet5/i386/puppetserver-5.3.3-1.sles12.noarch.rpm", + "#{rpm_directory}/sles/12/puppet5/x86_64/puppetserver-5.3.3-1.sles12.noarch.rpm", + ] + } it 'signs both v3 and v4 rpms' do allow(Dir).to receive(:[]).with("#{rpm_directory}/**/*.rpm").and_return(rpms) @@ -119,8 +121,8 @@ allow(Dir).to receive(:[]).with("#{rpm_directory}/**/*.rpm").and_return(noarch_rpms) allow(Pkg::Sign::Rpm).to receive(:sign) allow(Pkg::Sign::Rpm).to receive(:has_sig?) - expect(FileUtils).to receive(:rm).exactly(noarch_rpms.count/2).times - expect(FileUtils).to receive(:ln).exactly(noarch_rpms.count/2).times + expect(FileUtils).to receive(:rm).exactly(noarch_rpms.count / 2).times + expect(FileUtils).to receive(:ln).exactly(noarch_rpms.count / 2).times Pkg::Sign::Rpm.sign_all(rpm_directory) end diff --git a/spec/lib/packaging/tar_spec.rb b/spec/lib/packaging/tar_spec.rb index 365bb71d..e3c21d78 100644 --- a/spec/lib/packaging/tar_spec.rb +++ b/spec/lib/packaging/tar_spec.rb @@ -4,32 +4,34 @@ describe "tar.rb" do let(:project) { "packaging" } let(:version) { "1.2.3" } - let(:files) { [ "a", "b", "c" ] } + let(:files) { ["a", "b", "c"] } let(:templates) do [ "ext/redhat/spec.erb", { "source" => "ext/debian/control.erb", "target" => "ext/debian/not-a-control-file" }, "ext/debian/changelog.erb", - "ext/packaging/thing.erb" + "ext/packaging/thing.erb", ] end let(:expanded_templates) do [ "#{PROJECT_ROOT}/ext/redhat/spec.erb", { "source" => "ext/debian/control.erb", "target" => "ext/debian/not-a-control-file" }, - "#{PROJECT_ROOT}/ext/debian/changelog.erb" + "#{PROJECT_ROOT}/ext/debian/changelog.erb", ] end + before(:each) do Pkg::Config.config_from_hash( { - :templates => templates, - :project => project, - :version => version, - :files => files, - :project_root => PROJECT_ROOT, - :packaging_root => "ext/packaging" - }) + :templates => templates, + :project => project, + :version => version, + :files => files, + :project_root => PROJECT_ROOT, + :packaging_root => "ext/packaging", + }, + ) end describe '#initialize' do diff --git a/spec/lib/packaging/util/execution_spec.rb b/spec/lib/packaging/util/execution_spec.rb index 1346cd93..f5a436ca 100644 --- a/spec/lib/packaging/util/execution_spec.rb +++ b/spec/lib/packaging/util/execution_spec.rb @@ -30,7 +30,7 @@ it "should raise an error if the command fails" do Pkg::Util::Execution.should_receive(:`).with(command).and_return(true) Pkg::Util::Execution.should_receive(:success?).and_return(false) - expect{ Pkg::Util::Execution.ex(command) }.to raise_error(RuntimeError) + expect { Pkg::Util::Execution.ex(command) }.to raise_error(RuntimeError) end it "should return the output of the command for success" do @@ -44,7 +44,7 @@ it "should raise an error if the command fails" do Open3.should_receive(:capture3).with(command).and_return([output, '', 1]) Pkg::Util::Execution.should_receive(:success?).with(1).and_return(false) - expect{ Pkg::Util::Execution.capture3(command) }.to raise_error(RuntimeError, /#{output}/) + expect { Pkg::Util::Execution.capture3(command) }.to raise_error(RuntimeError, /#{output}/) end it "should return the output of the command for success" do diff --git a/spec/lib/packaging/util/file_spec.rb b/spec/lib/packaging/util/file_spec.rb index 82aeed42..e0ed0240 100644 --- a/spec/lib/packaging/util/file_spec.rb +++ b/spec/lib/packaging/util/file_spec.rb @@ -10,33 +10,32 @@ let(:dirs) { ["foo"] } let(:empty_dirs) { ["bar"] } - describe "#untar_into" do before :each do Pkg::Util::Tool.stub(:find_tool).with('tar', :required => true) { tar } end it "raises an exception if the source doesn't exist" do - Pkg::Util::File.should_receive(:file_exists?).with(source, {:required => true}).and_raise(RuntimeError) + Pkg::Util::File.should_receive(:file_exists?).with(source, { :required => true }).and_raise(RuntimeError) Pkg::Util::Execution.should_not_receive(:capture3) expect { Pkg::Util::File.untar_into(source) }.to raise_error(RuntimeError) end it "unpacks the tarball to the current directory if no target is passed" do - Pkg::Util::File.should_receive(:file_exists?).with(source, {:required => true}) { true } + Pkg::Util::File.should_receive(:file_exists?).with(source, { :required => true }) { true } Pkg::Util::Execution.should_receive(:capture3).with("#{tar} -xf #{source}") Pkg::Util::File.untar_into(source) end it "unpacks the tarball to the current directory with options if no target is passed" do - Pkg::Util::File.should_receive(:file_exists?).with(source, {:required => true}) { true } + Pkg::Util::File.should_receive(:file_exists?).with(source, { :required => true }) { true } Pkg::Util::Execution.should_receive(:capture3).with("#{tar} #{options} -xf #{source}") Pkg::Util::File.untar_into(source, nil, options) end it "unpacks the tarball into the target" do File.stub(:capture3ist?).with(source) { true } - Pkg::Util::File.should_receive(:file_exists?).with(source, {:required => true}) { true } + Pkg::Util::File.should_receive(:file_exists?).with(source, { :required => true }) { true } Pkg::Util::File.should_receive(:file_writable?).with(target) { true } Pkg::Util::Execution.should_receive(:capture3).with("#{tar} -C #{target} -xf #{source}") Pkg::Util::File.untar_into(source, target) @@ -44,7 +43,7 @@ it "unpacks the tarball into the target with options passed" do File.stub(:capture3ist?).with(source) { true } - Pkg::Util::File.should_receive(:file_exists?).with(source, {:required => true}) { true } + Pkg::Util::File.should_receive(:file_exists?).with(source, { :required => true }) { true } Pkg::Util::File.should_receive(:file_writable?).with(target) { true } Pkg::Util::Execution.should_receive(:capture3).with("#{tar} #{options} -C #{target} -xf #{source}") Pkg::Util::File.untar_into(source, target, options) diff --git a/spec/lib/packaging/util/git_spec.rb b/spec/lib/packaging/util/git_spec.rb index 5427806b..97a6f0a4 100644 --- a/spec/lib/packaging/util/git_spec.rb +++ b/spec/lib/packaging/util/git_spec.rb @@ -26,6 +26,7 @@ context '#tag' do let(:version) { '1.2.3' } let(:gpg_key) { '1231242354asdfawd' } + around do |example| prev_gpg_key = Pkg::Config.gpg_key Pkg::Config.gpg_key = gpg_key @@ -48,6 +49,7 @@ let(:project) { 'fooproj' } let(:string) { 'bar' } let(:temp) { '/other/path/to/place' } + around do |example| prev_project = Pkg::Config.project prev_version = Pkg::Config.version diff --git a/spec/lib/packaging/util/gpg_spec.rb b/spec/lib/packaging/util/gpg_spec.rb index 81d572af..01757d3c 100644 --- a/spec/lib/packaging/util/gpg_spec.rb +++ b/spec/lib/packaging/util/gpg_spec.rb @@ -16,6 +16,7 @@ allow(Pkg::Config).to receive(:gpg_key).and_return(nil) expect { Pkg::Util::Gpg.key }.to raise_error(RuntimeError) end + it "fails if Pkg::Config.gpg_key is an empty string" do allow(Pkg::Config).to receive(:gpg_key).and_return('') expect { Pkg::Util::Gpg.key }.to raise_error(RuntimeError) diff --git a/spec/lib/packaging/util/jenkins_spec.rb b/spec/lib/packaging/util/jenkins_spec.rb index 6d5d7374..34d3a238 100644 --- a/spec/lib/packaging/util/jenkins_spec.rb +++ b/spec/lib/packaging/util/jenkins_spec.rb @@ -2,8 +2,9 @@ require 'spec_helper' describe Pkg::Util::Jenkins do - let(:build_host) {"Jenkins-foo"} - let(:name) {"job-foo"} + let(:build_host) { "Jenkins-foo" } + let(:name) { "job-foo" } + around do |example| old_build_host = Pkg::Config.jenkins_build_host Pkg::Config.jenkins_build_host = build_host @@ -12,7 +13,7 @@ end describe "#create_jenkins_job" do - let(:xml_file) {"bar.xml"} + let(:xml_file) { "bar.xml" } it "should call curl_form_data with the correct arguments" do Pkg::Util::Net.should_receive(:curl_form_data).with("http://#{build_host}/createItem?name=#{name}", ["-H", '"Content-Type: application/xml"', "--data-binary", "@#{xml_file}"]) @@ -21,7 +22,6 @@ end describe "#jenkins_job_exists?" do - it "should call curl_form_data with correct arguments" do Pkg::Util::Net.should_receive(:curl_form_data).with("http://#{build_host}/job/#{name}/config.xml", ["--silent", "--fail"], :quiet => true).and_return(['output', 0]) Pkg::Util::Execution.should_receive(:success?).and_return(true) @@ -50,8 +50,8 @@ let(:job_url) { "http://cat.meow/" } let(:build_url) { "#{job_url}/1" } let(:result) { "SUCCESS" } - let(:job_hash) { {'lastBuild' => { 'url' => build_url } }} - let(:build_hash) { {'result' => result, 'building' => false } } + let(:job_hash) { { 'lastBuild' => { 'url' => build_url } } } + let(:build_hash) { { 'result' => result, 'building' => false } } before :each do subject.stub(:get_jenkins_info).with(job_url).and_return(job_hash) @@ -68,7 +68,7 @@ describe '#wait_for_build' do let(:job_url) { "http://cat.meow/" } let(:build_url) { "#{job_url}/1" } - let(:build_hash) { {'building' => false } } + let(:build_hash) { { 'building' => false } } context "when waiting for the given build to finish" do it "return the resulting build_hash when build completes successfully" do @@ -82,14 +82,16 @@ let(:url) { "http://cat.meow/" } let(:uri) { URI(url) } let(:response) { double } - let(:valid_json) { "{\"employees\":[ + let(:valid_json) { + "{\"employees\":[ {\"firstName\":\"John\", \"lastName\":\"Doe\"}, {\"firstName\":\"Anna\", \"lastName\":\"Smith\"}, - {\"firstName\":\"Peter\", \"lastName\":\"Jones\"} ]}" } + {\"firstName\":\"Peter\", \"lastName\":\"Jones\"} ]}" + } before :each do - response.stub(:body).and_return( valid_json ) - response.stub(:code).and_return( '200' ) + response.stub(:body).and_return(valid_json) + response.stub(:code).and_return('200') Pkg::Util::Jenkins.should_receive(:URI).and_return(uri) end @@ -100,13 +102,12 @@ end it "should raise Runtime error when response is error" do - response.stub(:code).and_return( '400' ) + response.stub(:code).and_return('400') Net::HTTP.should_receive(:get_response).with(uri).and_return(response) - expect{ + expect { subject.get_jenkins_info(url) }.to raise_error(Exception, /Unable to query .*, please check that it is valid./) end end end - end diff --git a/spec/lib/packaging/util/misc_spec.rb b/spec/lib/packaging/util/misc_spec.rb index ef9a8437..0fe3559f 100644 --- a/spec/lib/packaging/util/misc_spec.rb +++ b/spec/lib/packaging/util/misc_spec.rb @@ -13,17 +13,17 @@ end it 'replaces the token with the Pkg::Config variable' do - Pkg::Config.config_from_hash({:project => "foo", :repo_name => 'abcdefg'}) + Pkg::Config.config_from_hash({ :project => "foo", :repo_name => 'abcdefg' }) Pkg::Util::Misc.search_and_replace(orig_string, good_replacements).should eq(updated_string) end it 'does no replacement if the Pkg::Config variable is not set' do - Pkg::Config.config_from_hash({:project => 'foo',}) + Pkg::Config.config_from_hash({ :project => 'foo' }) Pkg::Util::Misc.search_and_replace(orig_string, good_replacements).should eq(orig_string) end it 'warns and continues if the Pkg::Config variable is unknown to packaging' do - Pkg::Config.config_from_hash({:project => 'foo',}) + Pkg::Config.config_from_hash({ :project => 'foo' }) Pkg::Util::Misc.should_receive(:warn).with("replacement value for '#{warn_replacements.keys.first}' probably shouldn't be nil") Pkg::Util::Misc.search_and_replace(orig_string, warn_replacements).should eq(orig_string) end diff --git a/spec/lib/packaging/util/net_spec.rb b/spec/lib/packaging/util/net_spec.rb index 8b8a1228..4e57e20c 100644 --- a/spec/lib/packaging/util/net_spec.rb +++ b/spec/lib/packaging/util/net_spec.rb @@ -27,7 +27,6 @@ end describe "hostname utils" do - describe "hostname" do it "should return the hostname of the current host" do Socket.stub(:gethostname) { "foo" } @@ -40,7 +39,7 @@ it "should raise an exception if the passed host does not match the current host" do Socket.stub(:gethostname) { "foo" } Pkg::Util::Net.should_receive(:check_host).and_raise(RuntimeError) - expect{ Pkg::Util::Net.check_host("bar", :required => true) }.to raise_error(RuntimeError) + expect { Pkg::Util::Net.check_host("bar", :required => true) }.to raise_error(RuntimeError) end end @@ -66,23 +65,25 @@ it "should fail if ssh is not present" do Pkg::Util::Tool.stub(:find_tool).with("ssh") { fail } Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_raise(RuntimeError) - expect{ Pkg::Util::Net.remote_execute("foo", "bar") }.to raise_error(RuntimeError) + expect { Pkg::Util::Net.remote_execute("foo", "bar") }.to raise_error(RuntimeError) end it "should be able to not fail fast" do - Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh) - Kernel.should_receive(:system).with("#{ssh} -t foo 'bar'") - Pkg::Util::Execution.should_receive(:success?).and_return(true) - Pkg::Util::Net.remote_execute( - "foo", "bar", capture_output: false, extra_options: '', fail_fast: false) + Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh) + Kernel.should_receive(:system).with("#{ssh} -t foo 'bar'") + Pkg::Util::Execution.should_receive(:success?).and_return(true) + Pkg::Util::Net.remote_execute( + "foo", "bar", capture_output: false, extra_options: '', fail_fast: false + ) end it "should be able to trace output" do - Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh) - Kernel.should_receive(:system).with("#{ssh} -t foo 'set -x;bar'") - Pkg::Util::Execution.should_receive(:success?).and_return(true) - Pkg::Util::Net.remote_execute( - "foo", "bar", capture_output: false, fail_fast: false, trace: true) + Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh) + Kernel.should_receive(:system).with("#{ssh} -t foo 'set -x;bar'") + Pkg::Util::Execution.should_receive(:success?).and_return(true) + Pkg::Util::Net.remote_execute( + "foo", "bar", capture_output: false, fail_fast: false, trace: true + ) end context "without output captured" do @@ -104,7 +105,7 @@ Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh) Kernel.should_receive(:system).with("#{ssh} -t foo 'set -e;bar'") Pkg::Util::Execution.should_receive(:success?).and_return(false) - expect{ Pkg::Util::Net.remote_execute("foo", "bar") } + expect { Pkg::Util::Net.remote_execute("foo", "bar") } .to raise_error(RuntimeError, /failed./) end end @@ -128,7 +129,7 @@ Pkg::Util::Tool.should_receive(:check_tool).with("ssh").and_return(ssh) Pkg::Util::Execution.should_receive(:capture3).with("#{ssh} -t foo 'set -e;bar'") Pkg::Util::Execution.should_receive(:success?).and_return(false) - expect{ Pkg::Util::Net.remote_execute("foo", "bar", capture_output: true) } + expect { Pkg::Util::Net.remote_execute("foo", "bar", capture_output: true) } .to raise_error(RuntimeError, /failed./) end end @@ -139,7 +140,7 @@ it "should fail if rsync is not present" do Pkg::Util::Tool.stub(:find_tool).with("rsync") { fail } Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_raise(RuntimeError) - expect{ Pkg::Util::Net.rsync_to("foo", "bar", "boo") }.to raise_error(RuntimeError) + expect { Pkg::Util::Net.rsync_to("foo", "bar", "boo") }.to raise_error(RuntimeError) end it "should rsync 'thing' to 'foo@bar:/home/foo' with flags '#{defaults} --ignore-existing'" do @@ -165,13 +166,13 @@ it "should fail if s3cmd is not present" do Pkg::Util::Tool.should_receive(:find_tool).with('s3cmd', :required => true).and_raise(RuntimeError) Pkg::Util::Execution.should_not_receive(:capture3).with("#{s3cmd} sync 'foo' s3://bar/boo/") - expect{ Pkg::Util::Net.s3sync_to("foo", "bar", "boo") }.to raise_error(RuntimeError) + expect { Pkg::Util::Net.s3sync_to("foo", "bar", "boo") }.to raise_error(RuntimeError) end it "should fail if ~/.s3cfg is not present" do Pkg::Util::Tool.should_receive(:check_tool).with("s3cmd").and_return(s3cmd) Pkg::Util::File.should_receive(:file_exists?).with(File.join(ENV['HOME'], '.s3cfg')).and_return(false) - expect{ Pkg::Util::Net.s3sync_to("foo", "bar", "boo") }.to raise_error(RuntimeError, /does not exist/) + expect { Pkg::Util::Net.s3sync_to("foo", "bar", "boo") }.to raise_error(RuntimeError, /does not exist/) end it "should s3 sync 'thing' to 's3://foo@bar/home/foo/' with no flags" do @@ -194,7 +195,7 @@ it "should fail if rsync is not present" do Pkg::Util::Tool.stub(:find_tool).with("rsync") { fail } Pkg::Util::Tool.should_receive(:check_tool).with("rsync").and_raise(RuntimeError) - expect{ Pkg::Util::Net.rsync_from("foo", "bar", "boo") }.to raise_error(RuntimeError) + expect { Pkg::Util::Net.rsync_from("foo", "bar", "boo") }.to raise_error(RuntimeError) end it "should not include the flags '--ignore-existing' by default" do @@ -217,9 +218,9 @@ end describe "#curl_form_data" do - let(:curl) {"/bin/curl"} - let(:form_data) {["name=FOO"]} - let(:options) { {:quiet => true} } + let(:curl) { "/bin/curl" } + let(:form_data) { ["name=FOO"] } + let(:options) { { :quiet => true } } it "should return false on failure" do Pkg::Util::Tool.should_receive(:check_tool).with("curl").and_return(curl) @@ -227,7 +228,6 @@ Pkg::Util::Net.curl_form_data(target_uri).should eq(['stdout', 1]) end - it "should curl with just the uri" do Pkg::Util::Tool.should_receive(:check_tool).with("curl").and_return(curl) Pkg::Util::Execution.should_receive(:capture3).with("#{curl} -i '#{target_uri}'") @@ -245,14 +245,13 @@ Pkg::Util::Execution.should_receive(:capture3).with("#{curl} -i #{form_data[0]} '#{target_uri}'").and_return(['stdout', 'stderr', 0]) Pkg::Util::Net.curl_form_data(target_uri, form_data, options).should eq(['', 0]) end - end describe "#print_url_info" do it "should output correct formatting" do Pkg::Util::Net.should_receive(:puts).with("\n#{'/' * 80}\n\n" \ - "Build submitted. To view your build progress, go to\nhttp://google.com\n\n" \ - "#{'/' * 80}\n\n") + "Build submitted. To view your build progress, go to\nhttp://google.com\n\n" \ + "#{'/' * 80}\n\n") Pkg::Util::Net.print_url_info(target_uri) end end diff --git a/spec/lib/packaging/util/rake_utils_spec.rb b/spec/lib/packaging/util/rake_utils_spec.rb index 03736978..d401e134 100644 --- a/spec/lib/packaging/util/rake_utils_spec.rb +++ b/spec/lib/packaging/util/rake_utils_spec.rb @@ -3,8 +3,8 @@ describe "Pkg::Util::RakeUtils" do let(:foo_defined?) { Rake::Task.task_defined?(:foo) } let(:bar_defined?) { Rake::Task.task_defined?(:bar) } - let(:define_foo) { body = proc{}; Rake::Task.define_task(:foo, &body) } - let(:define_bar) { body = proc{}; Rake::Task.define_task(:bar, &body) } + let(:define_foo) { body = proc {}; Rake::Task.define_task(:foo, &body) } + let(:define_bar) { body = proc {}; Rake::Task.define_task(:bar, &body) } before(:each) do if foo_defined? @@ -15,11 +15,12 @@ describe "#task_defined?" do context "given a Rake::Task task name" do it "should return true if the task exists" do - Rake::Task.stub(:task_defined?).with(:foo) {true} + Rake::Task.stub(:task_defined?).with(:foo) { true } expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be true end + it "should return false if the task does not exist" do - Rake::Task.stub(:task_defined?).with(:foo) {false} + Rake::Task.stub(:task_defined?).with(:foo) { false } expect(Pkg::Util::RakeUtils.task_defined?(:foo)).to be false end end diff --git a/spec/lib/packaging/util/ship_spec.rb b/spec/lib/packaging/util/ship_spec.rb index d661e6e1..d2d07ae3 100644 --- a/spec/lib/packaging/util/ship_spec.rb +++ b/spec/lib/packaging/util/ship_spec.rb @@ -23,16 +23,14 @@ before :each do allow(Dir).to receive(:glob).with('pkg/**/*.msi').and_return(msi_packages) end + it 'correctly excludes any packages that match a passed excludes argument' do - expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi'])) - .not_to include('pkg/windows/puppet6/puppet-agent-x86.msi') - expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi'])) - .not_to include('pkg/windows/puppet6/puppet-agent-x64.msi') + expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi'])).not_to include('pkg/windows/puppet6/puppet-agent-x86.msi') + expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['puppet-agent-x(86|64).msi'])).not_to include('pkg/windows/puppet6/puppet-agent-x64.msi') end + it 'correctly includes packages that do not match a passed excluded argument' do - expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], - ['bogus-puppet-agent-x(86|64).msi'])) - .to match_array(msi_packages) + expect(Pkg::Util::Ship.collect_packages(['pkg/**/*.msi'], ['bogus-puppet-agent-x(86|64).msi'])).to match_array(msi_packages) end end @@ -98,15 +96,13 @@ original_packages = retrieved_packages it 'leaves the old packages in place' do - reorganized_packages = Pkg::Util::Ship - .reorganize_packages(retrieved_packages, scratch_directory) + reorganized_packages = Pkg::Util::Ship.reorganize_packages(retrieved_packages, scratch_directory) expect(retrieved_packages).to eq(original_packages) end it 'returns a list of properly reorganized packages' do - reorganized_packages = Pkg::Util::Ship - .reorganize_packages(retrieved_packages, scratch_directory) + reorganized_packages = Pkg::Util::Ship.reorganize_packages(retrieved_packages, scratch_directory) expect(reorganized_packages).to eq(expected_reorganized_packages) end end @@ -123,41 +119,39 @@ it 'ships the packages to the staging server' do allow(Pkg::Util::Ship) .to receive(:collect_packages) - .and_return(retrieved_packages) + .and_return(retrieved_packages) allow(Pkg::Util::Ship) .to receive(:reorganize_packages) - .and_return(expected_reorganized_packages) + .and_return(expected_reorganized_packages) allow(Pkg::Util).to receive(:ask_yes_or_no).and_return(true) # All of these expects must be called in the same block in order for the # tests to work without actually shipping anything expect(Pkg::Util::Net) .to receive(:remote_execute) - .with(test_staging_server, /#{test_remote_path}/) - .exactly(retrieved_packages.count).times + .with(test_staging_server, /#{test_remote_path}/) + .exactly(retrieved_packages.count).times expect(Pkg::Util::Net) .to receive(:rsync_to) - .with(anything, test_staging_server, /#{test_remote_path}/, anything) - .exactly(retrieved_packages.count).times + .with(anything, test_staging_server, /#{test_remote_path}/, anything) + .exactly(retrieved_packages.count).times expect(Pkg::Util::Net) .to receive(:remote_set_ownership) - .with(test_staging_server, 'root', 'release', anything) - .exactly(retrieved_packages.count).times + .with(test_staging_server, 'root', 'release', anything) + .exactly(retrieved_packages.count).times expect(Pkg::Util::Net) .to receive(:remote_set_permissions) - .with(test_staging_server, '775', anything) - .exactly(retrieved_packages.count).times + .with(test_staging_server, '775', anything) + .exactly(retrieved_packages.count).times expect(Pkg::Util::Net) .to receive(:remote_set_permissions) - .with(test_staging_server, '0664', anything) - .exactly(retrieved_packages.count).times + .with(test_staging_server, '0664', anything) + .exactly(retrieved_packages.count).times expect(Pkg::Util::Net) .to receive(:remote_set_immutable) - .with(test_staging_server, anything) - .exactly(retrieved_packages.count).times - reorganized_packages = Pkg::Util::Ship - .reorganize_packages(retrieved_packages, Dir.mktmpdir) - expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, test_remote_path)) - .to eq(reorganized_packages) + .with(test_staging_server, anything) + .exactly(retrieved_packages.count).times + reorganized_packages = Pkg::Util::Ship.reorganize_packages(retrieved_packages, Dir.mktmpdir) + expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, test_remote_path)).to eq(reorganized_packages) end it 'ships packages containing the string `pkg` to the right place' do @@ -175,32 +169,28 @@ # tests to work without actually shipping anything expect(Pkg::Util::Net) .to receive(:remote_execute) - .with(test_staging_server, /#{test_remote_path}/) + .with(test_staging_server, /#{test_remote_path}/) expect(Pkg::Util::Net) .to receive(:rsync_to) - .with(anything, test_staging_server, /#{test_remote_path}/, anything) + .with(anything, test_staging_server, /#{test_remote_path}/, anything) expect(Pkg::Util::Net) .to receive(:remote_set_ownership) - .with(test_staging_server, 'root', 'release', - [repository_base_path, "#{repository_base_path}/#{package_basename}"]) + .with(test_staging_server, 'root', 'release', + [repository_base_path, "#{repository_base_path}/#{package_basename}"]) expect(Pkg::Util::Net) .to receive(:remote_set_permissions) - .with(test_staging_server, '775', anything) + .with(test_staging_server, '775', anything) expect(Pkg::Util::Net) .to receive(:remote_set_permissions) - .with(test_staging_server, '0664', anything) + .with(test_staging_server, '0664', anything) expect(Pkg::Util::Net) .to receive(:remote_set_immutable) - .with(test_staging_server, anything) - expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, - test_remote_path, excludes: ['puppet-agent'])) - .to eq(['pkg/puppet6/el/7/x86_64/puppet-agent-6.19.0-1.el7.x86_64.rpm']) + .with(test_staging_server, anything) + expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.rpm'], test_staging_server, test_remote_path, excludes: ['puppet-agent'])).to eq(['pkg/puppet6/el/7/x86_64/puppet-agent-6.19.0-1.el7.x86_64.rpm']) end it 'returns false if there are no packages to ship' do - expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.msi'], - test_staging_server, test_remote_path)) - .to be(false) + expect(Pkg::Util::Ship.ship_pkgs(['pkg/**/*.msi'], test_staging_server, test_remote_path)).to be(false) end end end diff --git a/spec/lib/packaging/util/version_spec.rb b/spec/lib/packaging/util/version_spec.rb index 9bbab26f..f650fcf0 100644 --- a/spec/lib/packaging/util/version_spec.rb +++ b/spec/lib/packaging/util/version_spec.rb @@ -34,7 +34,7 @@ '5.9.7-rc4-65-gabc1234' => ['5.9.7.65.gabc1234', '0.1rc4'], '5.9.7-rc4-65-gabc1234-dirty' => ['5.9.7.65.gabc1234', '0.1rc4dirty'], '4.99.0-dirty' => ['4.99.0', '0.1dirty'], - '4.99.0-56-gabc1234-dirty' => ['4.99.0.56.gabc1234', '0.1dirty'] + '4.99.0-56-gabc1234-dirty' => ['4.99.0.56.gabc1234', '0.1dirty'], } version_hash.each do |pre, post| before do @@ -55,7 +55,7 @@ '2017.6.5.3', '0.6.8', '2068.532.6', - '96.5' + '96.5', ] non_final_versions = [ @@ -63,7 +63,7 @@ '1.0.0-658-gabc1234', '5.0.0.master.SNAPSHOT.2017.05.16T1357', '5.9.7-rc4', - '4.99.0-56-dirty' + '4.99.0-56-dirty', ] final_versions.each do |version| @@ -110,7 +110,7 @@ '5.3.0-18-gfbddc8f-dirty' => '5.3.0-18-dirty', '0.7.0-rc1' => '0.7.0-rc1', '0.7.0-rc1-63-g51ccc51' => '0.7.0-rc1-63', - '0.7.0-rc1-63-g51ccc51-dirty'=> '0.7.0-rc1-63-dirty', + '0.7.0-rc1-63-g51ccc51-dirty' => '0.7.0-rc1-63-dirty', } versions.each do |describe, reformatted| it "correctly returns #{reformatted} when #{describe} is the git describe version" do diff --git a/spec/lib/packaging_spec.rb b/spec/lib/packaging_spec.rb index 68d64548..58880153 100644 --- a/spec/lib/packaging_spec.rb +++ b/spec/lib/packaging_spec.rb @@ -7,13 +7,11 @@ Pkg::Util.should_not be_nil end - it "should require the configuration module, Pkg::Config" do + it "should require the configuration module, Pkg::Config" do Pkg::Config.should_not be_nil end - it "should require the tar library, Pkg::Tar" do + it "should require the tar library, Pkg::Tar" do Pkg::Tar.should_not be_nil end - end - diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b5329d99..e0dbdc7c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,6 +11,7 @@ def load_task(name) return false if (@loaded ||= {})[name] + load File.join(SPECDIR, '..', 'tasks', name) @loaded[name] = true end diff --git a/tasks/00_utils.rake b/tasks/00_utils.rake index 4cea8def..87be8c68 100644 --- a/tasks/00_utils.rake +++ b/tasks/00_utils.rake @@ -19,10 +19,6 @@ # # ####################################################################### - - - - # Utility methods used by the various rake tasks ####################################################################### diff --git a/tasks/30_metrics.rake b/tasks/30_metrics.rake index 5eeb26a8..48c8a3d0 100644 --- a/tasks/30_metrics.rake +++ b/tasks/30_metrics.rake @@ -1,11 +1,11 @@ -@metrics = [] +@metrics = [] def add_shipped_metrics(args) @metrics << { - :type => 'shipped', - :package => (args[:package] || Pkg::Config.project), - :version => (args[:version] || Pkg::Config.version), - :pe_version => (args[:pe_version] || Pkg::Config.pe_version), - :is_rc => (args[:is_rc] || false), + :type => 'shipped', + :package => (args[:package] || Pkg::Config.project), + :version => (args[:version] || Pkg::Config.version), + :pe_version => (args[:pe_version] || Pkg::Config.pe_version), + :is_rc => (args[:is_rc] || false), } end @@ -22,12 +22,12 @@ def post_shipped_metrics res = Net::HTTP.post_form( uri, { - 'type' => type, - 'package' => package, - 'version' => version, - 'pe_version' => pe_version, - 'is_rc' => is_rc, - } + 'type' => type, + 'package' => package, + 'version' => version, + 'pe_version' => pe_version, + 'is_rc' => is_rc, + }, ) end end diff --git a/tasks/apple.rake b/tasks/apple.rake index dba204be..a9e86ccb 100644 --- a/tasks/apple.rake +++ b/tasks/apple.rake @@ -46,10 +46,10 @@ def make_directory_tree project_tmp = "#{Pkg::Util::File.mktemp}/#{@package_name}" @scratch = "#{project_tmp}/#{@title}" @working_tree = { - 'scripts' => "#{@scratch}/scripts", - 'resources' => "#{@scratch}/resources", - 'working' => "#{@scratch}/root", - 'payload' => "#{@scratch}/payload", + 'scripts' => "#{@scratch}/scripts", + 'resources' => "#{@scratch}/resources", + 'working' => "#{@scratch}/root", + 'payload' => "#{@scratch}/payload", } puts "Cleaning Tree: #{project_tmp}" rm_rf(project_tmp) @@ -72,7 +72,6 @@ def make_directory_tree if File.exist?('ext/packaging/static_artifacts/PackageInfo.plist') cp 'ext/packaging/static_artifacts/PackageInfo.plist', "#{@scratch}/PackageInfo.plist" end - end # method: build_dmg @@ -131,7 +130,7 @@ end # installed as the package's payload. # def pack_source - work = "#{@working_tree['working']}" + work = "#{@working_tree['working']}" source = pwd # Make all necessary directories diff --git a/tasks/archive.rake b/tasks/archive.rake index 751de46e..a65e741c 100644 --- a/tasks/archive.rake +++ b/tasks/archive.rake @@ -1,6 +1,5 @@ namespace :pl do namespace :remote do - desc "Move packages from repo paths to archive staging paths" task :stage_archives, [:yum_directories, :apt_directories, :downloads_directories] => 'pl:fetch' do |_t, args| yum_directories = args.yum_directories ? args.yum_directories.split(' ') : [] diff --git a/tasks/clean.rake b/tasks/clean.rake index 7f920d8e..102ce26a 100644 --- a/tasks/clean.rake +++ b/tasks/clean.rake @@ -2,4 +2,3 @@ desc "Clean all built packages, eg rm -rf pkg" task :clean do rm_rf 'pkg' end - diff --git a/tasks/config.rake b/tasks/config.rake index 6e5d4402..44544b09 100644 --- a/tasks/config.rake +++ b/tasks/config.rake @@ -25,7 +25,7 @@ namespace :config do "expects one or more space, comma, or semicolon delimited value; treated as an array" when :bool "expects a boolean value" - end + end msg = "#{values[:var]}: #{values[:envvar]}" msg += " (#{type})" if type diff --git a/tasks/deb.rake b/tasks/deb.rake index 8a8a6c16..c3d7d96d 100644 --- a/tasks/deb.rake +++ b/tasks/deb.rake @@ -38,7 +38,6 @@ task :prep_deb_tars, :work_dir do |t, args| mv "#{Pkg::Config.project}-#{Pkg::Config.version}.tar.gz", "#{Pkg::Config.project}_#{Pkg::Config.origversion}.orig.tar.gz" end - # This assumes that work_dir is absolute, which I hope is a safe assumption. # # Also, it turns out that invoking 'find' on a directory that doesn't exist @@ -70,10 +69,10 @@ task :build_deb, :deb_command, :cow do |t, args| work_dir = Pkg::Util::File.mktemp subdir = 'pe/' if Pkg::Config.build_pe codename = /base-(.*)-(.*)\.cow/.match(cow)[1] unless cow.nil? - dest_dir = File.join(Pkg::Config.project_root, "pkg", "#{subdir}deb", codename.to_s, subrepo.to_s) + dest_dir = File.join(Pkg::Config.project_root, "pkg", "#{subdir}deb", codename.to_s, subrepo.to_s) Pkg::Util::Tool.check_tool(deb_build) mkdir_p dest_dir - deb_args = { :work_dir => work_dir, :cow => cow } + deb_args = { :work_dir => work_dir, :cow => cow } Rake::Task[:prep_deb_tars].reenable Rake::Task[:prep_deb_tars].invoke(work_dir) cd "#{work_dir}/#{Pkg::Config.project}-#{Pkg::Config.debversion}" do @@ -112,7 +111,7 @@ end namespace :pl do desc "Create a deb from this repo using the default cow #{Pkg::Config.default_cow}." - task :deb => "package:tar" do + task :deb => "package:tar" do Pkg::Util.check_var('PE_VER', Pkg::Config.pe_version) if Pkg::Config.build_pe Rake::Task[:build_deb].invoke('pdebuild', Pkg::Config.default_cow) end diff --git a/tasks/deprecated.rake b/tasks/deprecated.rake index b5d5058e..0e849473 100644 --- a/tasks/deprecated.rake +++ b/tasks/deprecated.rake @@ -1,6 +1,5 @@ # Emit useful messages for tasks that have been moved or removed. - deprecation_message_winston = "The ticket generation tasks have moved. These now live in Winston: https://github.com/puppetlabs/winston" namespace :pl do diff --git a/tasks/education.rake b/tasks/education.rake index 28cd9956..a19138a1 100644 --- a/tasks/education.rake +++ b/tasks/education.rake @@ -1,7 +1,6 @@ namespace :pl do namespace :jenkins do task :deploy_learning_vm, [:vm, :md5, :target_bucket, :target_directory] => "pl:fetch" do |t, args| - vm = args.vm or fail ":vm is a required argument for #{t}" md5 = args.md5 or fail ":md5 is a required argument for #{t}" target_bucket = args.target_bucket or fail ":target_bucket is a required argument for #{t}" @@ -14,7 +13,6 @@ namespace :pl do end task :deploy_training_vm, [:vm, :md5, :target_host, :target_directory] => "pl:fetch" do |t, args| - vm = args.vm or fail ":vm is a required argument for #{t}" md5 = args.md5 or fail ":md5 is a required argument for #{t}" target_host = args.target_host or fail ":target_host is a required argument for #{t}" diff --git a/tasks/gem.rake b/tasks/gem.rake index 2e7fc2d6..589b7880 100644 --- a/tasks/gem.rake +++ b/tasks/gem.rake @@ -99,6 +99,7 @@ end def unknown_gems_platform?(platform) return true if platform.os == "unknown" + false end @@ -118,7 +119,7 @@ def create_platform_specific_gems "development" else fail "Platform specific gem dependency type must be 'gem_runtime_dependencies' or 'gem_development_dependencies', not '#{type}'" - end + end gems.each do |gem, version| spec = add_gem_dependency(:spec => spec, :gem => gem, :version => version, :type => t) end diff --git a/tasks/jenkins.rake b/tasks/jenkins.rake index 3fb61f3e..c42c3d6b 100644 --- a/tasks/jenkins.rake +++ b/tasks/jenkins.rake @@ -119,7 +119,7 @@ namespace :pl do when /gem/ then "gem" when /tar/ then "tar" else raise "Could not determine build type for #{build_task}" - end + end # Create a string of metrics to send to Jenkins for data analysis dist = case build_type @@ -135,7 +135,7 @@ namespace :pl do when /sles/ then "sles" when /tar/ then "tar" else raise "Could not determine build type for #{build_task}" - end + end if Pkg::Config.pe_version metrics = "#{ENV['USER']}~#{Pkg::Config.version}~#{Pkg::Config.pe_version}~#{dist}~#{Pkg::Config.team}" @@ -152,7 +152,7 @@ namespace :pl do { "name" => "PROJECT_BUNDLE", "file" => "file1" }, { "name" => "PROJECT", "value" => "#{Pkg::Config.project}" }, { "name" => "BUILD_TYPE", "label" => "#{build_type}" }, - { "name" => "METRICS", "value" => "#{metrics}" }] + { "name" => "METRICS", "value" => "#{metrics}" },] # Initialize the args array that will hold all of the arguments we pass # to the curl utility method. @@ -172,14 +172,14 @@ namespace :pl do # Construct the remaining form arguments. For visual clarity, params that are tied # together are on the same line. # - args << [ - "-Fname=BUILD_PROPERTIES", "-Ffile0=@#{properties}", - "-Fname=PROJECT_BUNDLE", "-Ffile1=@#{bundle}", - "-Fname=PROJECT", "-Fvalue=#{Pkg::Config.project}", - "-Fname=BUILD_TYPE", "-Fvalue=#{build_type}", - "-Fname=METRICS", "-Fvalue=#{metrics}", - "-FSubmit=Build", - "-Fjson=#{json.to_json}", + args << [ + "-Fname=BUILD_PROPERTIES", "-Ffile0=@#{properties}", + "-Fname=PROJECT_BUNDLE", "-Ffile1=@#{bundle}", + "-Fname=PROJECT", "-Fvalue=#{Pkg::Config.project}", + "-Fname=BUILD_TYPE", "-Fvalue=#{build_type}", + "-Fname=METRICS", "-Fvalue=#{metrics}", + "-FSubmit=Build", + "-Fjson=#{json.to_json}", ] # We have several arrays inside args by now, flatten it up. @@ -555,13 +555,13 @@ namespace :pl do end # Assemble the JSON string for the JSON parameter - json = JSON.generate("parameter" => [{ "name" => "SHA", "value" => "#{Pkg::Config.ref}" }]) + json = JSON.generate("parameter" => [{ "name" => "SHA", "value" => "#{Pkg::Config.ref}" }]) # Assemble our arguments to the post args = [ - "-Fname=SHA", "-Fvalue=#{Pkg::Config.ref}", - "-Fjson=#{json.to_json}", - "-FSubmit=Build" + "-Fname=SHA", "-Fvalue=#{Pkg::Config.ref}", + "-Fjson=#{json.to_json}", + "-FSubmit=Build", ] _, retval = Pkg::Util::Net.curl_form_data(uri, args) diff --git a/tasks/jenkins_dynamic.rake b/tasks/jenkins_dynamic.rake index 227ab015..6ec76c43 100644 --- a/tasks/jenkins_dynamic.rake +++ b/tasks/jenkins_dynamic.rake @@ -37,7 +37,7 @@ namespace :pl do # Generate an XML file for every job configuration erb and attempt to # create a jenkins job from that XML config templates.each do |t| - erb_template = File.join(template_dir, t) + erb_template = File.join(template_dir, t) xml_file = File.join(work_dir, t.gsub('.erb', '')) Pkg::Util::File.erb_file(erb_template, xml_file, nil, :binding => Pkg::Config.get_binding) # If we're creating a job meant to run on a windows box, we need to limit the path length @@ -49,7 +49,7 @@ namespace :pl do else ref = Pkg::Config.ref end - job_name = "#{Pkg::Config.project}-#{t.gsub('.xml.erb', '')}-#{Pkg::Config.build_date}-#{ref}" + job_name = "#{Pkg::Config.project}-#{t.gsub('.xml.erb', '')}-#{Pkg::Config.build_date}-#{ref}" puts "Checking for existence of #{job_name}..." if Pkg::Util::Jenkins.jenkins_job_exists?(job_name) raise "Job #{job_name} already exists on #{Pkg::Config.jenkins_build_host}" @@ -63,6 +63,7 @@ namespace :pl do unless Pkg::Util::Jenkins.jenkins_job_exists?(job_name) raise "Unable to verify Jenkins job, trying again..." end + puts "Jenkins job created at #{url}" end end @@ -156,20 +157,20 @@ namespace :pl do parameters = [{ "name" => "BUILD_PROPERTIES", "file" => "file0" }, { "name" => "PROJECT_BUNDLE", "file" => "file1" }, { "name" => "PROJECT", "value" => "#{Pkg::Config.project}" }, - { "name" => "METRICS", "value" => "#{metrics}" }] + { "name" => "METRICS", "value" => "#{metrics}" },] # Contruct the json string json = JSON.generate("parameter" => parameters) # The args array that holds all of the arguments we pass # to the curl utility method. - curl_args = [ - "-Fname=BUILD_PROPERTIES", "-Ffile0=@#{properties}", - "-Fname=PROJECT_BUNDLE", "-Ffile1=@#{bundle}", - "-Fname=PROJECT", "-Fvalue=#{Pkg::Config.project}", - "-Fname=METRICS", "-Fvalue=#{metrics}", - "-FSubmit=Build", - "-Fjson=#{json.to_json}", + curl_args = [ + "-Fname=BUILD_PROPERTIES", "-Ffile0=@#{properties}", + "-Fname=PROJECT_BUNDLE", "-Ffile1=@#{bundle}", + "-Fname=PROJECT", "-Fvalue=#{Pkg::Config.project}", + "-Fname=METRICS", "-Fvalue=#{metrics}", + "-FSubmit=Build", + "-Fjson=#{json.to_json}", ] # Contstruct the job url diff --git a/tasks/load_extras.rake b/tasks/load_extras.rake index 6263e7ad..de2a3061 100644 --- a/tasks/load_extras.rake +++ b/tasks/load_extras.rake @@ -10,6 +10,7 @@ namespace :pl do unless ENV['PARAMS_FILE'] && ENV['PARAMS_FILE'] != '' tempdir = args.tempdir raise "pl:load_extras requires a directory containing extras data" if tempdir.nil? + Pkg::Config.config_from_yaml("#{tempdir}/#{Pkg::Config.builder_data_file}") # Environment variables take precedence over those loaded from configs, @@ -18,4 +19,3 @@ namespace :pl do end end end - diff --git a/tasks/mock.rake b/tasks/mock.rake index 38ac29c2..a7f40270 100644 --- a/tasks/mock.rake +++ b/tasks/mock.rake @@ -21,6 +21,7 @@ def mock_artifact(mock_config, cmd_args, mockfile) unless mock = Pkg::Util::Tool.find_tool('mock') raise "mock is required for building srpms with mock. Please install mock and try again." end + randomize = Pkg::Config.random_mockroot configdir = nil basedir = File.join('var', 'lib', 'mock') @@ -37,7 +38,6 @@ def mock_artifact(mock_config, cmd_args, mockfile) # Return a FileList of the build artifacts return FileList[File.join(result_dir, '*.rpm')] - rescue RuntimeError => error build_log = File.join(result_dir, 'build.log') root_log = File.join(result_dir, 'root.log') @@ -79,6 +79,7 @@ def mock_srpm(mock_config, spec, sources, mockfile, defines = nil) unless srpms.size == 1 fail "#{srpms} contains an unexpected number of artifacts." end + srpms[0] end @@ -142,11 +143,10 @@ def rpm_family_and_version "#{rpm_el_family}-#{rpm_el_version}" end else - Pkg::Config.final_mocks.split.map { |mock| "#{mock_el_family(mock)}-#{mock_el_ver(mock) }" } + Pkg::Config.final_mocks.split.map { |mock| "#{mock_el_family(mock)}-#{mock_el_ver(mock)}" } end end - # Checks to see if the pe agnostic config template is in place. # If it is then the mock config is set to point to the generated config file. # The generated config file is formed by substituting the pe_version into the erb @@ -332,7 +332,6 @@ def randomize_mock_config_dir(mock_config, mockfile) return basedir, configdir end - namespace :pl do desc "Use default mock to make a final rpm, keyed to PL infrastructure, pass MOCK to specify config" task :mock => "package:tar" do diff --git a/tasks/nightly_repos.rake b/tasks/nightly_repos.rake index 423bb55b..2f4401c3 100644 --- a/tasks/nightly_repos.rake +++ b/tasks/nightly_repos.rake @@ -158,13 +158,13 @@ DOC # Get the directories together - we need to figure out which bits to ship based on the include_path # First we get the build itself - Pkg::Util::Execution.capture3(%(find #{include_paths.map { |path| "pkg/#{Pkg::Config.project}/**/#{path}" }.join(' ') } | sort > include_file)) + Pkg::Util::Execution.capture3(%(find #{include_paths.map { |path| "pkg/#{Pkg::Config.project}/**/#{path}" }.join(' ')} | sort > include_file)) Pkg::Util::Execution.capture3(%(mkdir -p tmp && tar -T include_file -cf - | (cd ./tmp && tar -xf -))) # Then we find grab the appropriate meta-data only - Pkg::Util::Execution.capture3(%(find #{include_paths.map { |path| "pkg/#{Pkg::Config.project}-latest/#{path}" unless path.include? "repos" }.join(' ') } | sort > include_file_latest)) + Pkg::Util::Execution.capture3(%(find #{include_paths.map { |path| "pkg/#{Pkg::Config.project}-latest/#{path}" unless path.include? "repos" }.join(' ')} | sort > include_file_latest)) - #include /repos in the include_file_latest so we correctly include the symlink in the final file list to ship + # include /repos in the include_file_latest so we correctly include the symlink in the final file list to ship Pkg::Util::Execution.capture3(%(echo "pkg/#{Pkg::Config.project}-latest/repos" >> include_file_latest)) Pkg::Util::Execution.capture3(%(tar -T include_file_latest -cf - | (cd ./tmp && tar -xf -))) diff --git a/tasks/pe_rpm.rake b/tasks/pe_rpm.rake index 000243c5..bc115d79 100644 --- a/tasks/pe_rpm.rake +++ b/tasks/pe_rpm.rake @@ -10,4 +10,3 @@ if Pkg::Config.build_pe task :mock => ["pl:fetch", "pl:mock"] end end - diff --git a/tasks/pe_ship.rake b/tasks/pe_ship.rake index dcc84c2f..7d5561c7 100644 --- a/tasks/pe_ship.rake +++ b/tasks/pe_ship.rake @@ -74,7 +74,6 @@ if Pkg::Config.build_pe Rake::Task["pe:remote:apt"].reenable Rake::Task["pe:remote:apt"].invoke(target_path, dist) end - end end @@ -99,7 +98,6 @@ if Pkg::Config.build_pe puts "Shipping all built artifacts to to archive directories on #{Pkg::Config.apt_host}" - Pkg::Config.deb_build_targets.each do |target| dist, arch = target.match(/(.*)-(.*)/)[1, 2] unless Pkg::Util::File.empty_dir? "pkg/pe/deb/#{dist}" @@ -137,7 +135,6 @@ if Pkg::Config.build_pe namespace :remote do desc "Update remote rpm repodata for PE on #{Pkg::Config.yum_host}" task :update_yum_repo => "pl:fetch" do - # Paths to the repos. repo_base_path = Pkg::Config.yum_target_path @@ -172,10 +169,10 @@ if Pkg::Config.build_pe fi eos stdout, stderr = Pkg::Util::Net.remote_execute( - Pkg::Config.apt_host, - cmd, - { capture_output: true } - ) + Pkg::Config.apt_host, + cmd, + { capture_output: true }, + ) output = stdout.to_s + stderr.to_s @@ -190,13 +187,13 @@ if Pkg::Config.build_pe puts "Cleaning up apt repo 'incoming' dir on #{Pkg::Config.apt_host}" Pkg::Util::Net.remote_execute(Pkg::Config.apt_host, "rm -r #{incoming_dir}") - end # Throw more tires on the fire desc "Remotely link shipped rpm packages into feature repo on #{Pkg::Config.yum_host}" task :link_shipped_rpms_to_feature_repo => "pl:fetch" do next if Pkg::Config.pe_feature_branch + repo_base_path = Pkg::Config.yum_target_path feature_repo_path = Pkg::Config.yum_target_path(true) pkgs = FileList['pkg/pe/rpm/**/*.rpm'].select { |path| path.gsub!('pkg/pe/rpm/', '') } @@ -211,6 +208,7 @@ if Pkg::Config.build_pe desc "Remotely link shipped deb packages into feature repo on #{Pkg::Config.apt_host}" task :link_shipped_debs_to_feature_repo => "pl:fetch" do next if Pkg::Config.pe_feature_branch + base_path = Pkg::Config.apt_target_path feature_base_path = Pkg::Config.apt_target_path(true) pkgs = FileList["pkg/pe/deb/**/*.deb"].select { |path| path.gsub!('pkg/pe/deb/', '') } diff --git a/tasks/retrieve.rake b/tasks/retrieve.rake index 88c0e900..0ee0c2f6 100644 --- a/tasks/retrieve.rake +++ b/tasks/retrieve.rake @@ -9,7 +9,6 @@ # release of 3.1.0, checkout 3.1.0 locally before retrieving. # - namespace :pl do namespace :jenkins do desc "Retrieve packages from the distribution server. Check out commit to retrieve" diff --git a/tasks/rpm.rake b/tasks/rpm.rake index 93616168..c8da9d4b 100644 --- a/tasks/rpm.rake +++ b/tasks/rpm.rake @@ -47,7 +47,7 @@ def build_rpm(buildarg = "-bs") puts output = FileList['pkg/*/*.rpm'] puts "Wrote:" - output.each do | line | + output.each do |line| puts line end end @@ -63,4 +63,3 @@ namespace :package do build_rpm("-ba") end end - diff --git a/tasks/ship.rake b/tasks/ship.rake index a4696121..6b232cb5 100644 --- a/tasks/ship.rake +++ b/tasks/ship.rake @@ -72,7 +72,7 @@ namespace :pl do end desc "Update remote ips repository on #{Pkg::Config.ips_host}" - task :update_ips_repo => 'pl:fetch' do + task :update_ips_repo => 'pl:fetch' do if Dir['pkg/ips/pkgs/**/*'].empty? && Dir['pkg/solaris/11/**/*'].empty? $stdout.puts "There aren't any p5p packages in pkg/ips/pkgs or pkg/solaris/11. Maybe something went wrong?" else @@ -83,11 +83,11 @@ namespace :pl do source_dir = 'pkg/solaris/11/' end - tmpdir, _ = Pkg::Util::Net.remote_execute( - Pkg::Config.ips_host, - 'mktemp -d -p /var/tmp', - { capture_output: true } - ) + tmpdir, = Pkg::Util::Net.remote_execute( + Pkg::Config.ips_host, + 'mktemp -d -p /var/tmp', + { capture_output: true }, + ) tmpdir.chomp! Pkg::Util::Net.rsync_to(source_dir, Pkg::Config.ips_host, tmpdir) @@ -166,7 +166,7 @@ namespace :pl do Pkg::Config.apt_repo_staging_path, Pkg::Config.apt_signing_server, Pkg::Config.apt_host, - ENV['DRYRUN'] + ENV['DRYRUN'], ) end end @@ -192,7 +192,7 @@ namespace :pl do Pkg::Config.yum_repo_path, Pkg::Config.yum_staging_server, Pkg::Config.yum_host, - ENV['DRYRUN'] + ENV['DRYRUN'], ) end end @@ -304,6 +304,7 @@ namespace :pl do puts 'This will ship to an internal gem mirror, a public file server, and rubygems.org' puts "Do you want to start shipping the rubygem '#{gem_file}'?" next unless Pkg::Util.ask_yes_or_no + Rake::Task['pl:ship_gem_to_rubygems'].execute(file: gem_file) end @@ -321,6 +322,7 @@ namespace :pl do if Pkg::Config.build_gem fail 'Value `Pkg::Config.gem_host` not defined, skipping nightly ship' unless Pkg::Config.gem_host fail 'Value `Pkg::Config.nonfinal_gem_path` not defined, skipping nightly ship' unless Pkg::Config.nonfinal_gem_path + FileList['pkg/*.gem'].each do |gem_file| Pkg::Gem.ship_to_internal_mirror(gem_file) end @@ -506,7 +508,7 @@ namespace :pl do Pkg::Util::Net.remote_execute( Pkg::Config.osx_signing_server, %(/usr/bin/security -q unlock-keychain -p "#{Pkg::Config.osx_signing_keychain_pw}" "#{Pkg::Config.osx_signing_keychain}"), - { extra_options: '-oBatchMode=yes' } + { extra_options: '-oBatchMode=yes' }, ) end rescue @@ -564,7 +566,6 @@ namespace :pl do Pkg::Ship::DistributionServer.ship(local_dir, target) Pkg::Ship::Artifactory.ship(local_dir, target) - end desc 'Ship generated repository configs to the distribution server' diff --git a/tasks/sign.rake b/tasks/sign.rake index 96c31451..48e7f6f6 100644 --- a/tasks/sign.rake +++ b/tasks/sign.rake @@ -73,6 +73,7 @@ namespace :pl do end end fail unless signed + puts "All rpms signed" end @@ -139,7 +140,8 @@ namespace :pl do sign_tasks << "pl:sign_ips" if Pkg::Config.vanagon_project sign_tasks << "pl:sign_msi" if Pkg::Config.build_msi || Pkg::Config.vanagon_project remote_repo = Pkg::Util::Net.remote_unpack_git_bundle( - Pkg::Config.signing_server, 'HEAD', nil, signing_bundle) + Pkg::Config.signing_server, 'HEAD', nil, signing_bundle + ) Pkg::Util::Net.rsync_to(root_dir, Pkg::Config.signing_server, remote_repo) params_file = File.join(remote_repo, 'pkg', "#{Pkg::Config.ref}.yaml") diff --git a/tasks/tag.rake b/tasks/tag.rake index 5e32cc11..5cb26776 100644 --- a/tasks/tag.rake +++ b/tasks/tag.rake @@ -5,4 +5,3 @@ namespace 'pl' do Pkg::Util::Git.tag(ENV['TAG']) end end - diff --git a/tasks/tar.rake b/tasks/tar.rake index e68becbc..add0aee5 100644 --- a/tasks/tar.rake +++ b/tasks/tar.rake @@ -1,7 +1,6 @@ namespace :package do desc "Create a source tar archive" task :tar => [:clean] do - if Pkg::Config.pre_tar_task Pkg::Util::RakeUtils.invoke_task(Pkg::Config.pre_tar_task) end @@ -25,4 +24,3 @@ end namespace :pl do task :tar => ["package:tar"] end - diff --git a/tasks/update.rake b/tasks/update.rake index 032f2e4d..4e98a399 100644 --- a/tasks/update.rake +++ b/tasks/update.rake @@ -13,4 +13,3 @@ namespace :package do end end end - diff --git a/tasks/vanagon.rake b/tasks/vanagon.rake index 3f774e49..85c5a2de 100644 --- a/tasks/vanagon.rake +++ b/tasks/vanagon.rake @@ -30,6 +30,7 @@ namespace :vanagon do Rake::Task["vanagon:check_tags"].invoke puts "Does this look correct?" return unless Pkg::Util.ask_yes_or_no + Rake::Task["pl:jenkins:uber_build"].invoke(args.poll_interval) end end diff --git a/tasks/vendor_gems.rake b/tasks/vendor_gems.rake index 0793b19d..65689aac 100644 --- a/tasks/vendor_gems.rake +++ b/tasks/vendor_gems.rake @@ -46,6 +46,7 @@ if Pkg::Config.pre_tar_task def level=(level) raise ArgumentError unless LEVELS.include?(level.to_s) + @level = level end @@ -59,7 +60,6 @@ if Pkg::Config.pre_tar_task ensure @level = old_level end - end class RGProxy < ::Gem::SilentUI @@ -77,7 +77,6 @@ if Pkg::Config.pre_tar_task end end - # Cache all the gems locally without using the shared GEM_PATH Bundler.settings[:cache_all] = true Bundler.settings[:local] = true diff --git a/tasks/version.rake b/tasks/version.rake index 0fe05802..bd610ae3 100644 --- a/tasks/version.rake +++ b/tasks/version.rake @@ -30,4 +30,3 @@ namespace :package do end end end - diff --git a/tasks/z_data_dump.rake b/tasks/z_data_dump.rake index ef86b48e..dec124d7 100644 --- a/tasks/z_data_dump.rake +++ b/tasks/z_data_dump.rake @@ -62,4 +62,3 @@ namespace :pl do end end end -