Class: Akabei::Omakase::CLI

Inherits:
Thor
  • Object
show all
Includes:
BuildHelper, Thor::Actions, Thor::Shell
Defined in:
lib/akabei/omakase/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BuildHelper

#build_in_chroot

Class Method Details



19
20
21
# File 'lib/akabei/omakase/cli.rb', line 19

def self.banner(task, namespace = nil, subcommand = false)
  super(task, nil, true)
end

.source_rootObject



15
16
17
# File 'lib/akabei/omakase/cli.rb', line 15

def self.source_root
  File.expand_path('../templates', __FILE__)
end

Instance Method Details

#build(package_name) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/akabei/omakase/cli.rb', line 71

def build(package_name)
  builder = Builder.new(
    signer: config.package_signer,
    srcdest: config.srcdest,
    logdest: config.logdest,
  )
  repo_signer = config.repo_signer
  s3 = S3.new(config['s3'], shell)

  config.builds.each do |arch, config_file|
    chroot = ChrootTree.new(config_file['chroot'], arch)
    chroot.makepkg_config = config_file['makepkg']
    chroot.pacman_config = config_file['pacman']

    repo_path = config.repo_path(arch)
    repo_path.mkpath
    builder.pkgdest = repo_path

    db_path = config.db_path(arch)
    files_path = config.files_path(arch)
    abs = Abs.new(config.abs_path(arch), config.name)

    s3.before!(config, arch)
    repo_db = Repository.load(db_path, signer: repo_signer)
    repo_files = Repository.load(files_path, include_files: true)

    packages = build_in_chroot(builder, chroot, repo_db, repo_files, abs, config.package_dir(package_name))
    repo_db.save(db_path)
    repo_files.save(files_path)
    s3.after!(config, arch, packages)
  end
end

#init(name) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/akabei/omakase/cli.rb', line 36

def init(name)
  # Check key's validity
  if options[:repo_key]
    Signer.new(options[:repo_key])
  end
  if options[:package_key]
    Signer.new(options[:package_key])
  end

  if options[:s3]
    begin
      require 'aws-sdk-core'
    rescue LoadError => e
      say("WARNING: You don't have aws-sdk-core installed. Disable S3 repository.", :yellow)
      options[:s3] = false
    end
  end

  @name = name
  @archs = %w[i686 x86_64]
  template('.akabei.yml.tt')
  empty_directory(name)
  empty_directory('sources')
  empty_directory('logs')
  empty_directory('PKGBUILDs')
  empty_directory('etc')
  @archs.each do |arch|
    copy_file("makepkg.#{arch}.conf", "etc/makepkg.#{arch}.conf")
    copy_file("pacman.#{arch}.conf", "etc/pacman.#{arch}.conf")
  end

  say('Edit etc/makepkg.*.conf and set PACKAGER first!', :green)
end

#remove(package_name) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/akabei/omakase/cli.rb', line 105

def remove(package_name)
  repo_signer = config.repo_signer
  s3 = S3.new(config['s3'], shell)

  config.builds.each do |arch, config_file|
    db_path = config.db_path(arch)
    files_path = config.files_path(arch)
    abs = Abs.new(config.abs_path(arch), config.name)

    s3.before!(config, arch)
    repo_db = Repository.load(db_path, signer: repo_signer)
    repo_files = Repository.load(files_path, include_files: true)

    remove_it(repo_db, package_name)
    remove_it(repo_files, package_name)
    abs.remove(package_name)
    repo_db.save(db_path)
    repo_files.save(files_path)
    s3.after!(config, arch, [])
  end
end