Class: AptStageArtifacts
- Inherits:
-
Object
- Object
- AptStageArtifacts
- Includes:
- Logging
- Defined in:
- lib/mixins/constants.rb,
lib/version.rb,
lib/apt_stage_artifacts.rb
Overview
Some constants that are used throughout the code
Constant Summary collapse
- VERSION =
'0.11.0'
- FREIGHT_COMMAND =
Details about freight itself
'/usr/bin/freight'
- FREIGHT_CONFIG_DIRECTORY =
'/etc/freight.conf.d'
- MANIFEST_JSON_FILENAME =
Name of the manifest.json file
'apt_stage_manifest.json'
- DEBIAN_CODENAMES =
Debian/Ubuntu codenames that we care about. Some codenames are skipped because we don’t/haven’t shipped for them.
%w[wheezy jessie stretch buster bullseye bookworm trixie]
- UBUNTU_CODENAMES =
%w[lucid precise trusty xenial bionic focal groovy jammy]
- VALID_CODENAMES =
DEBIAN_CODENAMES | UBUNTU_CODENAMES
- VALID_PUPPET_VERSIONS =
Validation constraints
%w[6 7 8 9]
- VALID_APT_COMPONENTS =
These are valid APT components. We use ‘stable’ instead of ‘main’ established by convention from docker dists (see download.docker.com/linux/ubuntu/dists/groovy)
%w[archive nightly stable]
- DOCUMENTATION =
<<~DOCOPT Stages .deb artifacts into a freight library from a Vanagon or packaging directory. Usage: apt-stage-artifacts [--component=<apt_component>] [<top_directory>] apt-stage-artifacts --version apt-stage-artifacts --help DOCOPT
Instance Method Summary collapse
-
#initialize(argv) ⇒ AptStageArtifacts
constructor
A new instance of AptStageArtifacts.
- #parse_options(argv = nil) ⇒ Object
- #run ⇒ Object
Methods included from Logging
Constructor Details
#initialize(argv) ⇒ AptStageArtifacts
Returns a new instance of AptStageArtifacts.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/apt_stage_artifacts.rb', line 25 def initialize(argv) @script_name = File.basename($PROGRAM_NAME) @log_level = Logger::INFO @user_options = (argv) @apt_component = @user_options['--component'] || 'stable' @version_string = "Version #{AptStageArtifacts::VERSION}" @artifacts_tarball_name = 'artifacts.tgz' @local_tarball_path = File.join(Dir.pwd, @artifacts_tarball_name) @builder_data_yaml = 'https://raw.githubusercontent.com/puppetlabs/build-data/release/builder_data.yaml' @remote_staging_command = 'apt-stage-from-tarball' end |
Instance Method Details
#parse_options(argv = nil) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/apt_stage_artifacts.rb', line 40 def (argv = nil) Docopt.docopt(DOCUMENTATION, { argv: argv }) rescue Docopt::Exit => e warn e. exit 1 end |
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/apt_stage_artifacts.rb', line 47 def run logger.info @version_string exit 0 if @user_options['--version'] unless AptStageArtifacts::VALID_APT_COMPONENTS.include? @apt_component fatal "Unknown APT component: \"#{@apt_component}\". Valid APT components are: " + AptStageArtifacts::VALID_APT_COMPONENTS.join(', ') end load_builder_data_yaml logger.info "Artifacts will be shipped to '#{@staging_server}'." collect_artifacts create_remote_staging_directory generate_manifest create_tarball ship_tarball_to_staging_server invoke_remote_staging cleanup_tarball logger.info 'Deb artifact staging successful.' end |