-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetadata.rb
40 lines (33 loc) · 901 Bytes
/
metadata.rb
1
2
3
4
5
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
# frozen_string_literal: true
require 'yaml'
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
def build_config
pkgs = %w[bin lib dev]
if !pkgs.include?(ENV['pkg']) && ARGV.first != 'clean'
raise "ERR: pkg env var must be one of: #{pkgs}"
end
config = YAML.load_file "#{File.expand_path(__dir__)}/config.yml"
cfg = {
version: config[:createrepo][:version],
sha256: config[:createrepo][:sha256],
pkg: ENV['pkg']
}
major_ver = cfg[:version].split('.').first
base_name = 'createrepo'
lib_name = "lib#{base_name}#{major_ver}"
case ENV['pkg']
when 'lib'
cfg[:name] = lib_name
cfg[:depends] = []
when 'dev'
cfg[:name] = "lib#{base_name}-dev"
cfg[:depends] = [lib_name]
else
cfg[:name] = base_name
cfg[:depends] = [lib_name]
end
cfg
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/MethodLength