Class: S3Repo::Repo

Inherits:
Base
  • Object
show all
Defined in:
lib/s3repo/repo.rb

Overview

Repo object, represents an Arch repo inside an S3 bucket

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from S3Repo::Base

Instance Method Details

#add_packages(paths) ⇒ Object



20
21
22
23
24
# File 'lib/s3repo/repo.rb', line 20

def add_packages(paths)
  paths.select! { |path| upload_package(path) }
  .add_packages(paths) unless paths.empty?
  templates.update! unless paths.empty?
end

#build_packages(paths) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/s3repo/repo.rb', line 8

def build_packages(paths)
  paths.each do |path|
    dir = File.dirname(path)
    puts "Building #{File.basename(dir)}"
    Dir.chdir(dir) do
      targets.each do |x|
        run "CARCH='#{x}' makepkg #{@options[:makepkg_flags]}"
      end
    end
  end
end

#include?(key) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/s3repo/repo.rb', line 48

def include?(key)
  !packages.find { |x| x.key == key }.nil?
end

#packagesObject



40
41
42
# File 'lib/s3repo/repo.rb', line 40

def packages
  package_cache.cache { parse_objects(/.*\.pkg\.tar\.xz$/) }
end

#prune_filesObject



31
32
33
34
35
36
37
38
# File 'lib/s3repo/repo.rb', line 31

def prune_files
  if orphans.empty?
    puts 'No orphaned files'
    return
  end
  puts "Pruning files: #{orphans.join(', ')}"
  client.delete_objects(delete: { objects: orphans.map { |x| { key: x } } })
end

#remove_packages(packages) ⇒ Object



26
27
28
29
# File 'lib/s3repo/repo.rb', line 26

def remove_packages(packages)
  .remove_packages(packages)
  templates.update!
end

#signaturesObject



44
45
46
# File 'lib/s3repo/repo.rb', line 44

def signatures
  parse_objects(/.*\.pkg\.tar\.xz\.sig$/)
end