Created
March 16, 2017 11:51
-
-
Save shadeslayer/635f4499360669305083592cdfd17158 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| #!/usr/bin/env ruby | |
| require 'aptly' | |
| require 'optparse' | |
| require 'ostruct' | |
| require 'uri' | |
| require 'net/ssh/gateway' | |
| require 'logger' | |
| require 'logger/colors' | |
| require 'pp' | |
| options = OpenStruct.new | |
| options.repos = nil | |
| options.all = false | |
| options.host = 'localhost' | |
| options.port = '8080' | |
| options.distribution = nil | |
| parser = OptionParser.new do |opts| | |
| opts.banner = "Usage: #{opts.program_name} [options] --repo yolo" | |
| opts.on('-g', '--gateway URI', 'open gateway to remote') do |v| | |
| options.gateway = URI(v) | |
| end | |
| opts.on('-d', '--distribution DIST', 'Override distribution in released repository') do |v| | |
| options.distribution = v | |
| end | |
| end | |
| parser.parse! | |
| if options.gateway | |
| case options.gateway.scheme | |
| when 'ssh' | |
| gateway = Net::SSH::Gateway.new(options.gateway.host, options.gateway.user) | |
| options.port = gateway.open('localhost', options.gateway.port) | |
| else | |
| raise 'Gateway scheme not supported' | |
| end | |
| end | |
| Aptly.configure do |config| | |
| config.host = options.host | |
| config.port = options.port | |
| end | |
| Faraday.default_connection_options = | |
| Faraday::ConnectionOptions.new(timeout: 2 * 60 * 60) | |
| @log = Logger.new(STDOUT).tap do |l| | |
| l.progname = 'component migrater' | |
| l.level = Logger::INFO | |
| end | |
| @repos = Aptly::Repository.list.select { |x| x.Name.end_with?('1703') } | |
| @repos.each do |repo| | |
| component = repo.Name.match(/(.*)-1703/)[1].freeze | |
| repo.published_in.each(&:drop) | |
| repo.edit!(DefaultComponent: component) | |
| end | |
| @repos = Aptly::Repository.list.select { |x| x.Name.end_with?('1703') } | |
| @sources = @repos.collect do |repo| | |
| { Name: repo.Name, Component: repo.DefaultComponent } | |
| end | |
| Aptly.publish(@sources, 'netrunner', DefaultDistribution: 'netrunner-1703') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment