Class: FRM::ArchRelease

Inherits:
Base
  • Object
show all
Defined in:
lib/frm/arch_release.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#compute_md5, #compute_sha1, #compute_sha2, #generate_gzip_pipe, #gpg_clearsign, #gpg_detached, #gpg_export_pubkey, #gunzip_pipe, #handle_errors, #run

Constructor Details

#initialize(opts = {}) ⇒ ArchRelease

Returns a new instance of ArchRelease.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/frm/arch_release.rb', line 6

def initialize(opts={})
  super()
  @opts = opts
  @opts[:packages] = []
  @opts[:package_paths] ||= []
  @opts[:release] ||= run ". /etc/lsb-release && echo $DISTRIB_CODENAME"
  @opts[:component] ||= 'main'
  @opts[:origin] ||= 'FRM'
  @opts[:lablel] ||= 'FRM'
  @opts[:description] = "FRM apt repo"
  @opts[:package_paths].each { |path| @opts[:packages] << Package.new(path) }
  case run("uname -m")
  when "x86_64"
    @opts[:arch] ||= 'amd64'
  else
    @opts[:arch] ||= run "uname -m"
  end
  raise "you need to pass a remote_store object that responds to exists? and get"\
     unless @opts[:remote_store] \
       and @opts[:remote_store].respond_to? 'exists?' \
       and @opts[:remote_store].respond_to? 'get'

  @opts[:release_file_path] = "#{@opts[:component]}/binary-#{@opts[:arch]}/Release"
  @opts[:package_file_path] = "#{@opts[:component]}/binary-#{@opts[:arch]}/Packages"
  @opts[:gzipped_package_file_path] = "#{@opts[:component]}/binary-#{@opts[:arch]}/Packages.gz"

  @opts[:package_file] = merge_package_files
  @opts[:gzipped_package_file] = generate_gzip_pipe(@opts[:package_file]).read
  @opts[:release_file] = release_file

  @opts[:package_file_size] = @opts[:package_file].size
  @opts[:gzipped_package_file_size] = @opts[:gzipped_package_file].size
  @opts[:release_file_size] = @opts[:release_file].size

  @opts[:package_file_md5sum] = compute_md5(@opts[:package_file])
  @opts[:gzipped_package_file_md5sum] = compute_md5(@opts[:gzipped_package_file])
  @opts[:release_file_md5sum] = compute_md5(@opts[:release_file])

  @opts[:package_file_sha1] = compute_sha1(@opts[:package_file])
  @opts[:gzipped_package_file_sha1] = compute_sha1(@opts[:gzipped_package_file])
  @opts[:release_file_sha1] = compute_sha1(@opts[:release_file])

  @opts[:package_file_sha256] = compute_sha2(@opts[:package_file])
  @opts[:gzipped_package_file_sha256] = compute_sha2(@opts[:gzipped_package_file])
  @opts[:release_file_sha256] = compute_sha2(@opts[:release_file])
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



4
5
6
# File 'lib/frm/arch_release.rb', line 4

def opts
  @opts
end

Instance Method Details

#pushObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/frm/arch_release.rb', line 53

def push
  @opts[:packages].each do |p| 
    if @opts[:remote_store].exists?(p.info['Filename']) 
      STDERR.puts "package #{p.path} already exists"
      unless @opts[:remote_store].etag(p.info['Filename']) == p.info['MD5sum']
        raise <<EOE
trying to overwrite this package file: #{remote_path}
local md5 is #{package.info['MD5sum']}
remote md5 (etag) is #{@s3.etag(remote_path,@bucket)}
EOE
      end
    else
      STDERR.puts "pushing package #{p.path}"
      @opts[:remote_store].put(p.info['Filename'],p.content)
    end
  end
  STDERR.puts "pushing arch release files"
  @opts[:remote_store].put(File.join("dists/#{@opts[:release]}/",@opts[:release_file_path]),@opts[:release_file])
  @opts[:remote_store].put(File.join("dists/#{@opts[:release]}/",@opts[:gzipped_package_file_path]),@opts[:gzipped_package_file])
  @opts[:remote_store].put(File.join("dists/#{@opts[:release]}/",@opts[:package_file_path]),@opts[:package_file])
end