class Aptly::Watcher::AptlyShim
Public Class Methods
new(name, components, config)
click to toggle source
# File lib/aptly/watcher/aptly_shim.rb, line 4 def initialize(name, components, config) @name = name # distribution @components = components # repos @config = config create end
Public Instance Methods
add(repo, path)
click to toggle source
# File lib/aptly/watcher/aptly_shim.rb, line 31 def add(repo, path) # TODO: check if the file has already been added # TODO: check that the file is a Debian package output = `aptly repo add -remove-files=true #{config} #{repo} #{path} 2>&1` raise StandardError, "Failed to add #{path} to #{repo}\n#{output}" unless $?.success? end
create()
click to toggle source
# File lib/aptly/watcher/aptly_shim.rb, line 12 def create repo_list = `aptly repo list #{config} --raw` # create a repo for each component @components.each do |repo| next if repo_list.include? repo # avoid raising an error output = `aptly repo create #{distrib} #{config} #{component(repo)} #{repo} 2>&1` raise StandardError, "Failed to create repo #{repo}\n#{output}" unless $?.success? Aptly::Watcher.log :info, "Created repo #{@name}/#{repo}" end # publish the repos for the first time (empty) unless `aptly publish list #{config} --raw`.include? @name # avoid raising an error output = `aptly publish repo #{config} #{distrib} #{component(:all)} #{@components.join(' ')} 2>&1` raise StandardError, "Failed to publish #{@name} for the first time\n#{output}" unless $?.success? Aptly::Watcher.log :info, "Published repos #{@components.join('/')} for #{@name}" end end
publish()
click to toggle source
# File lib/aptly/watcher/aptly_shim.rb, line 38 def publish system "aptly publish update #{config} #{@name}" end
Private Instance Methods
component(repo)
click to toggle source
# File lib/aptly/watcher/aptly_shim.rb, line 44 def component(repo) repo = @components.join(',') if repo == :all "-component=#{repo}" end
config()
click to toggle source
# File lib/aptly/watcher/aptly_shim.rb, line 53 def config "-config='#{@config}'" end
distrib()
click to toggle source
# File lib/aptly/watcher/aptly_shim.rb, line 49 def distrib "-distribution=#{@name}" end