Class: RightPublish::AptRepo

Inherits:
Repo
  • Object
show all
Defined in:
lib/right_publish/repos/apt.rb

Constant Summary collapse

DEFAULT_APT_AUTO =
true
DEFAULT_APT_DIR =
'apt/'
DEFAULT_DESCRIPTION =
"Apt Repository"
REPO_KEY =
:apt_repo
REPO_OPTIONS =
{
:dists => :addr_optional,
:description => DEFAULT_DESCRIPTION,
:auto => DEFAULT_APT_AUTO,
:subdir => DEFAULT_APT_DIR,
:gpg_key_id => :attr_optional,
:gpg_password => :attr_optional }
BIN_EXTENSION =
'deb'
SRC_EXTENSION =
'dsc'
BIN_ALL_ARCH =
'all'
@@supported_archs =
[ 'amd64' ]
@@all_archs =
[ 'amd64', BIN_ALL_ARCH ]

Constants inherited from Repo

Repo::LOCK_FILE_NAME, Repo::LOCK_PERIOD, Repo::LOCK_RETRY_INTERVAL

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Repo

#initialize, #publish, #pull, #push

Constructor Details

This class inherits a constructor from RightPublish::Repo

Class Method Details

.pkg_parts(pkg_name) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/right_publish/repos/apt.rb', line 62

def self.pkg_parts(pkg_name)
  result = {:name=>nil, :version=>nil, :arch=>nil, :ext=>nil}
  if pkg_name.end_with?(SRC_EXTENSION)
    if /([A-Za-z0-9\.\-+]+)_([A-Za-z0-9\-\.:~]+)\.#{SRC_EXTENSION}\Z/.match(pkg_name)
      result[:name] = $1
      result[:version] = $2
      result[:ext] = SRC_EXTENSION
    end
  else
    if /([A-Za-z0-9\.\-+]+)_([A-Za-z0-9\-\.:~]+)_(#{@@all_archs.join('|')})\.#{BIN_EXTENSION}\Z/.match(pkg_name)
      result[:name] = $1
      result[:version] = $2
      result[:arch] = $3
      result[:ext] = BIN_EXTENSION
    end
  end
  result
end

Instance Method Details

#add(file_or_dir, target) ⇒ Object



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
52
53
54
# File 'lib/right_publish/repos/apt.rb', line 23

def add(file_or_dir, target)
  repo_updates = {}

  # If we specified a target, let's make sure it's in our profile
  if target
    fail("specified distribution is not listed in this profile!") unless repo_config[:dists].include?(target)
  end

  pkgs = []
  get_pkg_list(file_or_dir, [BIN_EXTENSION, SRC_EXTENSION]) do |path|
    if path.end_with? BIN_EXTENSION and repo_config[:auto]
      arch = AptRepo.pkg_parts(path)[:arch] || fail("could not determine architecture for package: #{path}")
      fail("you probably want to specify a distribution target for binary packages!") unless target || arch == BIN_ALL_ARCH
    end
    pkgs << path
  end

  repo_path = File.join(Profile.config[:local_storage][:cache_dir], repo_config[:subdir])
  write_conf_file repo_path if repo_config[:auto]

  pkgs.each do |pkg|
    Profile.log("Adding package [#{pkg}]...")
    if repo_config[:auto]
      # If source package, remove existing sources so we don't get a hash clash
      auto_repo_remove(repo_path, pkg, target)
      auto_repo_add(repo_path, pkg, target)
    else
      trivial_repo_add(pkg)
    end
  end
  rebuild_index(repo_config[:subdir]) if not repo_config[:auto]
end

#annotate(options = {}) ⇒ Object



56
57
58
59
60
# File 'lib/right_publish/repos/apt.rb', line 56

def annotate(options={})
  options[:subdir] ||= File.join(repo_config[:subdir], 'pool', 'main')
  options[:filter] = ['*.deb', '*.dsc', '*.tar.gz']
  super(options)
end