lib/s3repo/repo.rb in s3repo-1.0.0 vs lib/s3repo/repo.rb in s3repo-2.0.0

- old
+ new

@@ -3,29 +3,27 @@ module S3Repo ## # Repo object, represents an Arch repo inside an S3 bucket class Repo < Base - def initialize(params = {}) - super - end - - def build_packages(paths, makepkg_flags = '') + def build_packages(paths) paths.each do |path| dir = File.dirname(path) puts "Building #{File.basename(dir)}" - Dir.chdir(dir) { run "makepkg #{makepkg_flags}" } + Dir.chdir(dir) { run "makepkg #{@options[:makepkg_flags]}" } end end def add_packages(paths) paths.select! { |path| upload_package(path) } metadata.add_packages(paths) unless paths.empty? + templates.update! unless paths.empty? end def remove_packages(packages) metadata.remove_packages(packages) + templates.update! end def prune_files if orphans.empty? puts 'No orphaned files' @@ -45,33 +43,37 @@ def include?(key) !packages.find { |x| x.key == key }.nil? end - def serve(key) - refresh = !key.match(/\.pkg\.tar\.xz$/) - file_cache.serve(key, refresh) - end - private def upload_package(path) key = File.basename(path) - sig_key, sig_path = [key, path].map { |x| x + '.sig' } return false if include? key - client.upload!(sig_key, sig_path) if ENV['S3REPO_SIGN_PACKAGES'] - client.upload!(key, path) + sig_path = signer.sign(path) + sig_key = key + '.sig' + client.upload_file(sig_key, sig_path) if @options[:sign_packages] + client.upload_file(key, path) true end def orphans (packages + signatures).map(&:key).reject do |x| metadata.packages.include? x.reverse.split('-', 2).last.reverse end end def metadata - @metadata ||= Metadata.new(client: client, file_cache: file_cache) + @options[:metadata] ||= Metadata.new(@options) + end + + def signer + @options[:signer] ||= Signer.new(@options) + end + + def templates + @templates ||= Templates.new(@options) end def package_cache @package_cache ||= BasicCache::TimeCache.new lifetime: 60 end