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



28
29
30
31
32
33
34
35
# File 'lib/gaffer/repro.rb', line 28

def create_dirs
  repo_dirs.each do |dir|
    if not File.exists?("#{@root}/ubuntu/#{dir}")
      puts "* mkdir -p #{@root}/ubuntu/#{dir}"
      FileUtils.mkdir_p "#{@root}/ubuntu/#{dir}"
    end
  end
end

#include(file) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/gaffer/repro.rb', line 37

def include(file)
  bump_version
  file = File.expand_path(file)
  Dir.chdir("#{@root}/ubuntu") do
    run "reprepro includedeb #{@codename} #{file}"
  end
end

#initObject



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

def init
  if not Dir[@root].empty?
    raise "Dir #{@root} not empty - cannot init" unless @force
    FileUtils.rm_rf @root
  end
  create_dirs
  write_file "ubuntu/conf/options", options
  write_file "ubuntu/conf/distributions", distributes
  write_version 1
end

#pullObject



59
60
61
62
63
64
65
# File 'lib/gaffer/repro.rb', line 59

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
end

#pushObject



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

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
  puts " [apt source]"
  puts url
  puts ""
end

#ready!Object



45
46
47
# File 'lib/gaffer/repro.rb', line 45

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

#urlObject



67
68
69
# File 'lib/gaffer/repro.rb', line 67

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