Class: Gaffer::Repro

Inherits:
Object
  • Object
show all
Defined in:
lib/gaffer/repro.rb

Instance Method Summary collapse

Constructor Details

#initialize(root, options = {}) ⇒ Repro

Returns a new instance of Repro.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/gaffer/repro.rb', line 4

def initialize(root, options = {})
  @root       = root
  @maintainer = options[:maintainer]
  @email      = options[:email]
  @key        = options[:key]
  @force      = options[:force]
  @codename   = options[:codename]
  @components = options[:components]
  @bucket     = options[:bucket]
  @aws_key    = options[:aws_key]
  @aws_secret = options[:aws_secret]
end

Instance Method Details

#create_dirsObject



32
33
34
35
36
37
38
# File 'lib/gaffer/repro.rb', line 32

def create_dirs
  repo_dir.create
  index_dir.create
  subdirs.each do |dir|
    repo_dir["#{dir}/"].create
  end
end

#include(file) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/gaffer/repro.rb', line 40

def include(file)
  f = Rush[File.expand_path(file)]
  bump_version
  raise "File already in index" if index_dir[f.name].exists?
  f.copy_to index_dir
  bucket_put "index/#{f.name}"
  includedeb f
  f.destroy
  puts "* #{f.name} -> index/#{f.name}"
end

#includedeb(file) ⇒ Object



59
60
61
# File 'lib/gaffer/repro.rb', line 59

def includedeb(file)
  repo_dir.bash "reprepro includedeb #{@codename} #{file}"
end

#initObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/gaffer/repro.rb', line 17

def init
  unless root_dir.exists?
    raise "Dir #{root_dir} exists - cannot init" unless @force
    root_dir.destroy
  end
  create_dirs
  conf_dir["options"].write options
  conf_dir["distributions"].write distributions
  write_version 1
end

#packagesObject



28
29
30
# File 'lib/gaffer/repro.rb', line 28

def packages
  index_dir["*"].map { |s| s.name }.sort
end

#pullObject



78
79
80
81
82
83
84
85
# File 'lib/gaffer/repro.rb', line 78

def pull
  raise "Local version #{local_version} is higher than local #{remote_version}.  Use --force to override" if (remote_version < local_version && !@force)
  create_dirs
  puts "Version: #{remote_version}"
  delete_local
  write_local
  touch
end

#pushObject



67
68
69
70
71
72
73
74
75
76
# File 'lib/gaffer/repro.rb', line 67

def push
  raise "Remote version #{remote_version} is higher than local #{local_version}.  Use --force to override" if (remote_version > local_version && !@force)
  puts "Version: #{local_version}"
  delete_remote
  write_remote
  touch
  puts " [apt source]"
  puts url
  puts ""
end

#ready!Object



63
64
65
# File 'lib/gaffer/repro.rb', line 63

def ready!
  raise "No repo.  Use 'gaffer pull' to download a repo from S3 or 'gaffer initrepo' to make a new one" unless File.include? "#{@root}/ubuntu/conf/distributions"
end

#rebuildObject



51
52
53
54
55
56
57
# File 'lib/gaffer/repro.rb', line 51

def rebuild
  repo_dir["*"].reject { |dir| dir.name == "conf" }.each { |dir| dir.destroy }
  create_dirs
  index_dir["*"].each do |file|
    includedeb file
  end
end

#urlObject



87
88
89
# File 'lib/gaffer/repro.rb', line 87

def url
  "deb http://#{@bucket}.s3.amazonaws.com/ubuntu/ #{@codename} #{@components}"
end