pkgr 1.8.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -4
  3. data/data/build_dependencies/centos.yml +8 -2
  4. data/data/build_dependencies/debian.yml +20 -1
  5. data/data/build_dependencies/sles.yml +6 -1
  6. data/data/build_dependencies/ubuntu.yml +14 -1
  7. data/data/buildpacks/amazon-2014 +3 -3
  8. data/data/buildpacks/amazon-2015 +3 -3
  9. data/data/buildpacks/centos-10 +4 -0
  10. data/data/buildpacks/centos-6 +3 -3
  11. data/data/buildpacks/centos-7 +3 -3
  12. data/data/buildpacks/centos-8 +3 -3
  13. data/data/buildpacks/centos-9 +4 -0
  14. data/data/buildpacks/debian-10 +3 -3
  15. data/data/buildpacks/debian-11 +4 -0
  16. data/data/buildpacks/debian-12 +4 -0
  17. data/data/buildpacks/debian-13 +4 -0
  18. data/data/buildpacks/debian-6 +2 -2
  19. data/data/buildpacks/debian-7 +3 -3
  20. data/data/buildpacks/debian-8 +3 -3
  21. data/data/buildpacks/debian-9 +3 -3
  22. data/data/buildpacks/fedora-20 +3 -3
  23. data/data/buildpacks/sles-11 +3 -3
  24. data/data/buildpacks/sles-12 +3 -3
  25. data/data/buildpacks/sles-15 +3 -0
  26. data/data/buildpacks/sles-16 +3 -0
  27. data/data/buildpacks/ubuntu-10.04 +3 -3
  28. data/data/buildpacks/ubuntu-12.04 +3 -3
  29. data/data/buildpacks/ubuntu-14.04 +3 -3
  30. data/data/buildpacks/ubuntu-16.04 +3 -3
  31. data/data/buildpacks/ubuntu-18.04 +3 -3
  32. data/data/buildpacks/ubuntu-20.04 +3 -3
  33. data/data/buildpacks/ubuntu-22.04 +4 -0
  34. data/data/buildpacks/ubuntu-24.04 +4 -0
  35. data/data/buildpacks/ubuntu-26.04 +4 -0
  36. data/data/cli/cli.sh.erb +98 -31
  37. data/data/dependencies/centos.yml +4 -1
  38. data/data/dependencies/debian.yml +0 -5
  39. data/data/dependencies/sles.yml +2 -3
  40. data/data/dependencies/ubuntu.yml +20 -7
  41. data/data/hooks/postinstall.sh +9 -5
  42. data/data/hooks/preinstall.sh +1 -1
  43. data/data/init/systemd/default/process.service.erb +2 -3
  44. data/data/init/sysv/lsb-3.1/process.erb +4 -2
  45. data/lib/pkgr/builder.rb +19 -4
  46. data/lib/pkgr/buildpack.rb +23 -2
  47. data/lib/pkgr/config.rb +12 -1
  48. data/lib/pkgr/cron.rb +1 -1
  49. data/lib/pkgr/distributions/amazon.rb +3 -5
  50. data/lib/pkgr/distributions/base.rb +16 -5
  51. data/lib/pkgr/distributions/debian.rb +8 -4
  52. data/lib/pkgr/distributions/fedora.rb +4 -0
  53. data/lib/pkgr/distributions/redhat.rb +0 -1
  54. data/lib/pkgr/distributions/sles.rb +15 -2
  55. data/lib/pkgr/env.rb +4 -3
  56. data/lib/pkgr/env_value.rb +4 -0
  57. data/lib/pkgr/fpm_command.rb +2 -0
  58. data/lib/pkgr/version.rb +1 -1
  59. data/lib/pkgr.rb +9 -0
  60. metadata +48 -11
@@ -4,7 +4,6 @@ default:
4
4
  - libxml2
5
5
  - libxslt
6
6
  - libevent
7
- - mysql-libs
8
7
  - sqlite
9
8
  centos-6:
10
9
  - postgresql-libs
@@ -12,3 +11,7 @@ centos-7:
12
11
  - postgresql-libs
13
12
  centos-8:
14
13
  - libpq
14
+ centos-9:
15
+ - libpq
16
+ centos-10:
17
+ - libpq
@@ -1,5 +1,4 @@
1
1
  default:
2
- - mysql-common
3
2
  - libpq5
4
3
  - libsqlite3-0
5
4
  - openssl
@@ -7,7 +6,6 @@ default:
7
6
  - libxslt1.1
8
7
  debian-6:
9
8
  - libssl0.9.8
10
- - libmysqlclient16
11
9
  - libevent-1.4-2
12
10
  - libevent-core-1.4-2
13
11
  - libevent-extra-1.4-2
@@ -15,7 +13,6 @@ debian-6:
15
13
  - libreadline6
16
14
  debian-7:
17
15
  - libssl1.0.0
18
- - libmysqlclient18
19
16
  - libevent-2.0-5
20
17
  - libevent-core-2.0-5
21
18
  - libevent-extra-2.0-5
@@ -23,7 +20,6 @@ debian-7:
23
20
  - libreadline6
24
21
  debian-8:
25
22
  - libssl1.0.0
26
- - libmysqlclient18
27
23
  - libevent-2.0-5
28
24
  - libevent-core-2.0-5
29
25
  - libevent-extra-2.0-5
@@ -31,7 +27,6 @@ debian-8:
31
27
  - libreadline6
32
28
  debian-9:
33
29
  - libssl1.0.2
34
- - libmariadbclient18
35
30
  - libevent-2.0-5
36
31
  - libevent-core-2.0-5
37
32
  - libevent-extra-2.0-5
@@ -7,9 +7,8 @@ default:
7
7
  - sqlite3
8
8
  - shadow
9
9
  sles-11:
10
- - libmysqlclient15
11
- - libmysqlclient_r15
12
10
  - postgresql
13
11
  sles-12:
14
- - libmysqlclient18
15
12
  - postgresql
13
+ sles-15: []
14
+ sles-16: []
@@ -1,48 +1,61 @@
1
1
  default:
2
- - mysql-common
3
2
  - libpq5
4
3
  - libsqlite3-0
5
4
  - openssl
6
- - libxml2
7
5
  - libxslt1.1
8
6
  ubuntu-10.04:
9
7
  - libreadline5
10
8
  - libssl0.9.8
11
- - libmysqlclient16
12
9
  - libevent-1.4-2
13
10
  - libevent-core-1.4-2
14
11
  - libevent-extra-1.4-2
12
+ - libxml2
15
13
  ubuntu-12.04:
16
14
  - libreadline6
17
15
  - libssl1.0.0
18
- - libmysqlclient18
19
16
  - libevent-2.0-5
20
17
  - libevent-core-2.0-5
21
18
  - libevent-extra-2.0-5
19
+ - libxml2
22
20
  ubuntu-14.04:
23
21
  - libreadline6
24
22
  - libssl1.0.0
25
- - libmysqlclient18
26
23
  - libevent-2.0-5
27
24
  - libevent-core-2.0-5
28
25
  - libevent-extra-2.0-5
26
+ - libxml2
29
27
  ubuntu-16.04:
30
28
  - libreadline6
31
29
  - libssl1.0.0
32
- - libmysqlclient20
33
30
  - libevent-2.0-5
34
31
  - libevent-core-2.0-5
35
32
  - libevent-extra-2.0-5
33
+ - libxml2
36
34
  ubuntu-18.04:
37
35
  - libreadline7
38
36
  - libssl1.0.0
39
- - libmysqlclient20
40
37
  - libevent-2.1-6
41
38
  - libevent-core-2.1-6
42
39
  - libevent-extra-2.1-6
40
+ - libxml2
43
41
  ubuntu-20.04:
44
42
  - libreadline8
45
43
  - libssl1.1
46
44
  - libevent-2.1-7
47
45
  - libevent-core-2.1-7
48
46
  - libevent-extra-2.1-7
47
+ - libxml2
48
+ ubuntu-22.04:
49
+ - libreadline8
50
+ - libssl3
51
+ - libev4
52
+ - libxml2
53
+ ubuntu-24.04:
54
+ - libreadline8
55
+ - libssl3
56
+ - libev4
57
+ - libxml2
58
+ ubuntu-26.04:
59
+ - libreadline8
60
+ - libssl3
61
+ - libev4
@@ -10,23 +10,27 @@ export APP_HOME="<%= home %>"
10
10
  HOME_LOGS="${APP_HOME}/log"
11
11
  LOGS="/var/log/${APP_NAME}"
12
12
 
13
- chown -R ${APP_USER}.${APP_GROUP} ${APP_HOME}
13
+ chown -R ${APP_USER}:${APP_GROUP} ${APP_HOME}
14
14
 
15
15
  # link app log directory to /var/log/NAME
16
16
  mkdir -p ${LOGS}
17
17
  rm -rf ${HOME_LOGS}
18
- ln -fs ${LOGS} ${HOME_LOGS}
19
- chown -R ${APP_USER}.${APP_GROUP} ${LOGS}
18
+ ln -nfs ${LOGS} ${HOME_LOGS}
19
+ chown -R ${APP_USER}:${APP_GROUP} ${LOGS}
20
20
 
21
21
  # Add default conf.d file
22
22
  [ -f /etc/${APP_NAME}/conf.d/other ] || touch /etc/${APP_NAME}/conf.d/other
23
23
 
24
- chown -R ${APP_USER}.${APP_GROUP} /etc/${APP_NAME}
25
- chown ${APP_USER}.${APP_GROUP} /var/db/${APP_NAME}
24
+ chown -R ${APP_USER}:${APP_GROUP} /etc/${APP_NAME}
25
+ chown ${APP_USER}:${APP_GROUP} /var/db/${APP_NAME}
26
26
 
27
27
  chmod 0750 /etc/${APP_NAME} /etc/${APP_NAME}/conf.d
28
28
  find /etc/${APP_NAME} -type f -exec chmod 0640 {} +
29
29
 
30
+ <% if crons.any? %>
31
+ mkdir -p "<%= crons_dir %>"
32
+ <% end %>
33
+
30
34
  <% crons.each do |cron| %>
31
35
  rm -f <%= cron.destination %>
32
36
  cp <%= cron.source %> <%= cron.destination %>
@@ -8,7 +8,7 @@ export APP_GROUP="<%= group %>"
8
8
  export APP_HOME="<%= home %>"
9
9
 
10
10
  if ! getent passwd "${APP_USER}" > /dev/null; then
11
- if [ -f /etc/redhat-release ] || [ -f /etc/system-release ] || [ -f /etc/SuSE-release ]; then
11
+ if command -v groupadd &>/dev/null ; then
12
12
  if ! getent group "${APP_GROUP}" > /dev/null ; then
13
13
  groupadd --system "${APP_GROUP}"
14
14
  fi
@@ -4,12 +4,11 @@ Requires=<%= name %>-<%= process_name %>.service
4
4
  After=<%= name %>-<%= process_name %>.service
5
5
 
6
6
  [Service]
7
+ User=<%= user %>
8
+ Group=<%= group %>
7
9
  Environment=APP_PROCESS_INDEX=__PROCESS_INDEX__
8
10
  ExecStart=/usr/bin/<%= name %> run <%= process_name %>
9
11
  Restart=always
10
- StandardOutput=syslog
11
- StandardError=syslog
12
- SyslogIdentifier=%n
13
12
 
14
13
  [Install]
15
14
  WantedBy=<%= name %>-<%= process_name %>.service
@@ -24,8 +24,10 @@ full_process_name="${name}-${process_name}-${APP_PROCESS_INDEX}"
24
24
  pidfile="/var/run/${full_process_name}.pid"
25
25
 
26
26
  start() {
27
- # Run the program!
28
- ${name} run ${process_name} >> /var/log/${name}/${process_name}-${APP_PROCESS_INDEX}.log 2>&1 &
27
+ # Run the program! /var/log/${name} is writable by the app user, so the log
28
+ # file is only opened once privileges are dropped.
29
+ chroot --userspec "${user}:${group}" --groups="$(id -Gn ${user} | tr ' ' ',')" / \
30
+ sh -c 'exec "$@" >> "$0" 2>&1' "/var/log/${name}/${process_name}-${APP_PROCESS_INDEX}.log" ${name} run ${process_name} &
29
31
 
30
32
  # Generate the pidfile from here. If we instead made the forked process
31
33
  # generate it there will be a race condition between the pidfile writing
data/lib/pkgr/builder.rb CHANGED
@@ -45,7 +45,7 @@ module Pkgr
45
45
  opts[:input] = $stdin.read
46
46
  end
47
47
 
48
- tarball_extract = Mixlib::ShellOut.new("tar xzf #{tarball} -C #{source_dir}", opts)
48
+ tarball_extract = Mixlib::ShellOut.new("tar xzf #{tarball} --no-same-owner -C #{source_dir}", opts)
49
49
  tarball_extract.logger = Pkgr.logger
50
50
  tarball_extract.run_command
51
51
  tarball_extract.error!
@@ -69,6 +69,8 @@ module Pkgr
69
69
  end
70
70
  config.distribution = distribution
71
71
  config.env.variables.push("TARGET=#{distribution.target}")
72
+ config.env.variables.push("APP_PKG_VERSION=#{config.version}")
73
+ config.env.variables.push("APP_PKG_ITERATION=#{config.iteration}")
72
74
  # useful for templates that need to read files
73
75
  config.source_dir = source_dir
74
76
  config.build_dir = build_dir
@@ -163,12 +165,18 @@ module Pkgr
163
165
  end
164
166
  end
165
167
 
166
- # Write cron files
168
+ # Write cron files. They are installed as root, so they get installed from a
169
+ # root-owned copy rather than from the app directory, which the app user
170
+ # can write to.
167
171
  def setup_crons
168
172
  crons_dir = File.join("/", distribution.crons_dir)
173
+ config.crons_dir = crons_dir
169
174
 
170
175
  config.crons.map! do |cron_path|
171
- Cron.new(File.expand_path(cron_path, config.home), File.join(crons_dir, File.basename(cron_path)))
176
+ source = File.join("/", shared_dir, "crons", File.basename(cron_path))
177
+ FileUtils.mkdir_p File.dirname(File.join(build_dir, source))
178
+ FileUtils.cp File.join(build_dir, File.expand_path(cron_path, config.home)), File.join(build_dir, source)
179
+ Cron.new(source, File.join(crons_dir, File.basename(cron_path)))
172
180
  end
173
181
 
174
182
  config.crons.each do |cron|
@@ -259,8 +267,15 @@ module Pkgr
259
267
  File.join(vendor_dir, "processes")
260
268
  end
261
269
 
270
+ # Root-owned directory for files that are read as root at install time.
271
+ def shared_dir
272
+ File.join("usr", "share", config.name)
273
+ end
274
+
275
+ # Init templates are copied to system locations as root, so keep them out
276
+ # of the app directory.
262
277
  def scaling_dir
263
- File.join(vendor_dir, "scaling")
278
+ File.join(build_dir, shared_dir, "scaling")
264
279
  end
265
280
 
266
281
  # Returns the path to the app's (supposedly present) Procfile.
@@ -1,5 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'digest/sha1'
3
+ require 'shellwords'
3
4
 
4
5
  module Pkgr
5
6
  class Buildpack
@@ -24,7 +25,7 @@ module Pkgr
24
25
  def initialize(url, type = :builtin, env = nil)
25
26
  @uuid = Digest::SHA1.hexdigest(url)
26
27
  @url, @branch = url.split("#")
27
- @branch ||= "master"
28
+ @branch ||= "main"
28
29
  @type = type
29
30
  @env = env || Env.new
30
31
  end
@@ -85,7 +86,12 @@ module Pkgr
85
86
  def refresh(edge = true)
86
87
  return if !edge
87
88
  Dir.chdir(dir) do
88
- buildpack_refresh = Mixlib::ShellOut.new("git fetch origin && ( git reset --hard #{branch} || git reset --hard origin/#{branch} ) && chmod -f +x bin/detect && chmod -f +x bin/compile && chmod -f +x bin/release")
89
+ git_fetch = Mixlib::ShellOut.new("git fetch --tags origin")
90
+ git_fetch.logger = Pkgr.logger
91
+ git_fetch.run_command
92
+ git_fetch.error!
93
+
94
+ buildpack_refresh = Mixlib::ShellOut.new("git reset --hard #{Shellwords.shellescape(ref_for_checkout)} && chmod -f +x bin/detect && chmod -f +x bin/compile && chmod -f +x bin/release")
89
95
  buildpack_refresh.logger = Pkgr.logger
90
96
  buildpack_refresh.run_command
91
97
  buildpack_refresh.error!
@@ -117,6 +123,21 @@ module Pkgr
117
123
 
118
124
  private
119
125
 
126
+ def ref_for_checkout
127
+ [
128
+ "refs/remotes/origin/#{branch}",
129
+ "refs/tags/#{branch}",
130
+ "refs/heads/#{branch}"
131
+ ].find { |ref| git_ref_exists?(ref) } || branch
132
+ end
133
+
134
+ def git_ref_exists?(ref)
135
+ git_ref = Mixlib::ShellOut.new("git rev-parse --verify --quiet #{Shellwords.shellescape(ref)}")
136
+ git_ref.logger = Pkgr.logger
137
+ git_ref.run_command
138
+ git_ref.exitstatus == 0
139
+ end
140
+
120
141
  def compound_environment(path, local_env = Env.new)
121
142
  Env.new(['PATH=$PATH']).merge(local_env).merge(env).merge(exported_environment(File.join(path, "export")))
122
143
  end
data/lib/pkgr/config.rb CHANGED
@@ -27,6 +27,12 @@ module Pkgr
27
27
  end
28
28
  end
29
29
 
30
+ # Check if targets are defined but current target is not
31
+ if !targets.empty? && !targets.has_key?(distribution.to_s)
32
+ available_targets = targets.keys.join(", ")
33
+ raise Pkgr::Errors::TargetNotDefined, "Target '#{distribution}' is not defined in .pkgr.yml. Available targets: #{available_targets}"
34
+ end
35
+
30
36
  distro_config = targets[distribution.to_s]
31
37
  if distro_config.is_a?(Hash)
32
38
  distro_config.each do |k,v|
@@ -133,13 +139,18 @@ module Pkgr
133
139
  end
134
140
 
135
141
  def env
136
- @table[:env].is_a?(Pkgr::Env) ? @table[:env] : Pkgr::Env.new(@table[:env])
142
+ @env ||= @table[:env].is_a?(Pkgr::Env) ? @table[:env] : Pkgr::Env.new(@table[:env])
137
143
  end
138
144
 
139
145
  def buildpacks
140
146
  @table[:buildpack].is_a?(String) ? @table[:buildpack].split(",") : @table[:buildpack]
141
147
  end
142
148
 
149
+ def name
150
+ # handle GITHUB_REPOSITORY-like names
151
+ (@table[:name] || "").split("/").last
152
+ end
153
+
143
154
  def valid?
144
155
  @errors = []
145
156
  @errors.push("name can't be blank") if name.nil? || name.empty?
data/lib/pkgr/cron.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Pkgr
2
2
  class Cron
3
- # the source, in /opt/app-name/...
3
+ # the source, in /usr/share/app-name/crons/...
4
4
  attr_reader :source
5
5
  # the destination, most likely in /etc/cron.d/...
6
6
  attr_reader :destination
@@ -1,8 +1,9 @@
1
1
  module Pkgr
2
-
3
2
  module Distributions
4
-
5
3
  class Amazon < Base
4
+ def rpm?
5
+ true
6
+ end
6
7
 
7
8
  def release
8
9
  @release[/^[0-9]+/]
@@ -35,9 +36,6 @@ module Pkgr
35
36
  list
36
37
  end
37
38
  end
38
-
39
39
  end
40
-
41
40
  end
42
-
43
41
  end
@@ -22,17 +22,21 @@ module Pkgr
22
22
  self.class.name.split("::")[-1].downcase
23
23
  end # def os
24
24
 
25
+ def rpm?
26
+ false
27
+ end
28
+
29
+ def deb?
30
+ false
31
+ end
32
+
25
33
  # e.g. ubuntu-12.04
26
34
  def slug
27
35
  [os, release].join("-")
28
36
  end # def slug
29
37
 
30
38
  def target
31
- {
32
- "centos-6" => "el:6",
33
- "centos-7" => "el:7",
34
- "centos-8" => "el:8"
35
- }.fetch(slug, slug.sub("-", ":"))
39
+ slug.sub("-", ":").sub("centos", "el")
36
40
  end
37
41
 
38
42
  def package_test_command(package)
@@ -123,6 +127,13 @@ module Pkgr
123
127
  list
124
128
  end
125
129
 
130
+ def config_files
131
+ templates
132
+ .filter { |template| template.is_a?(Templates::FileTemplate) }
133
+ .map(&:target)
134
+ .filter { |target| target.start_with?("etc/") }
135
+ end
136
+
126
137
  # Returns a list of <Process, FileTemplate> tuples.
127
138
  def initializers_for(app_name, procfile_entries)
128
139
  list = []
@@ -7,6 +7,10 @@ module Pkgr
7
7
  module Distributions
8
8
  # Contains the various components required to make a packaged app integrate well with a Debian system.
9
9
  class Debian < Base
10
+ def deb?
11
+ true
12
+ end
13
+
10
14
  # Only keep major digits
11
15
  def release
12
16
  @release[/^[0-9]+/]
@@ -14,10 +18,10 @@ module Pkgr
14
18
 
15
19
  def runner
16
20
  @runner ||= case release
17
- when /^8/, /^9/, /^10/
18
- Runner.new("systemd", "default", "systemctl")
19
- else
21
+ when /^6/, /^7/
20
22
  Runner.new("sysv", "lsb-3.1", "update-rc.d")
23
+ else
24
+ Runner.new("systemd", "default", "systemctl")
21
25
  end
22
26
  end
23
27
 
@@ -41,7 +45,7 @@ module Pkgr
41
45
  Dir.glob(File.join(output_dir, "*deb")).each do |package|
42
46
  puts "-----> Verifying package #{File.basename(package)}"
43
47
  Dir.mktmpdir do |dir|
44
- verify_package = Mixlib::ShellOut.new %{dpkg-deb -x #{package} #{dir}}
48
+ verify_package = Mixlib::ShellOut.new %{dpkg-deb -x "#{package}" "#{dir}"}
45
49
  verify_package.logger = Pkgr.logger
46
50
  verify_package.run_command
47
51
  verify_package.error!
@@ -7,6 +7,10 @@ module Pkgr
7
7
  module Distributions
8
8
  # Contains the various components required to make a packaged app integrate well with a Debian system.
9
9
  class Fedora < Base
10
+ def rpm?
11
+ true
12
+ end
13
+
10
14
  # Only keep major digits
11
15
  def release
12
16
  @release[/^[0-9]+/]
@@ -20,7 +20,6 @@ module Pkgr
20
20
  super
21
21
  end
22
22
  end
23
-
24
23
  end
25
24
  end
26
25
  end
@@ -6,13 +6,21 @@ require 'pkgr/fpm_command'
6
6
  module Pkgr
7
7
  module Distributions
8
8
  class Sles < Base
9
+ def rpm?
10
+ true
11
+ end
12
+
9
13
  # Only keep major digits
10
14
  def release
11
15
  @release[/^[0-9]+/]
12
16
  end
13
17
 
14
18
  def runner
15
- @runner ||= Runner.new("sysv", "lsb-3.1", "chkconfig")
19
+ @runner ||= if release.to_i > 12
20
+ Runner.new("systemd", "default", "systemctl")
21
+ else
22
+ Runner.new("sysv", "lsb-3.1", "chkconfig")
23
+ end
16
24
  end
17
25
 
18
26
  def package_test_command(package)
@@ -20,7 +28,12 @@ module Pkgr
20
28
  end
21
29
 
22
30
  def package_install_command(packages)
23
- "sudo zypper refresh ; sudo zypper install -y #{packages.map{|package| "\"#{package}\""}.join(" ")}"
31
+ # --no-gpg-checks helps with outdated repos for SLES
32
+ zypper_flags = []
33
+ if release.to_i <= 12
34
+ zypper_flags.push("--no-gpg-checks")
35
+ end
36
+ "sudo zypper refresh ; sudo zypper #{zypper_flags.join(" ")} install -y #{packages.map{|package| "\"#{package}\""}.join(" ")}"
24
37
  end
25
38
 
26
39
  def installer_dependencies
data/lib/pkgr/env.rb CHANGED
@@ -9,8 +9,7 @@ module Pkgr
9
9
  end
10
10
 
11
11
  def initialize(variables = nil)
12
- @variables = variables || []
13
- @variables.compact!
12
+ @variables = (variables || []).map{|v| v && v.split("\n")}.flatten.select{|v| v && v.length > 0}
14
13
  end
15
14
 
16
15
  def to_s
@@ -35,7 +34,9 @@ module Pkgr
35
34
 
36
35
  variables.inject({}) do |h, var|
37
36
  name, value = var.split('=', 2)
38
- h[name.strip] = EnvValue.new(value || "").strip.unquote
37
+ unless name.nil?
38
+ h[name.strip] = EnvValue.new(value || "").strip.unquote
39
+ end
39
40
  h
40
41
  end
41
42
  end
@@ -37,6 +37,10 @@ class EnvValue < String
37
37
  "#{f}#{self}#{b}"
38
38
  end
39
39
 
40
+ def strip
41
+ self.class.new(super)
42
+ end
43
+
40
44
  def unquote
41
45
  s = self.dup
42
46
 
@@ -38,7 +38,9 @@ module Pkgr
38
38
  list << "--before-remove" << distribution.preuninstall_file
39
39
  list << "--after-remove" << distribution.postuninstall_file
40
40
  list << "--directories" << config.directories unless config.directories.nil?
41
+ list << "--rpm-digest" << "sha256" if distribution.rpm?
41
42
  distribution.dependencies(config.dependencies).each{|d| list << "-d" << d}
43
+ distribution.config_files.each{|f| list << "--config-files" << f}
42
44
  list.compact
43
45
  end
44
46
  end
data/lib/pkgr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pkgr
2
- VERSION = "1.8.0"
2
+ VERSION = "1.9.1"
3
3
  end
data/lib/pkgr.rb CHANGED
@@ -2,6 +2,14 @@ require 'pkgr/version'
2
2
  require 'pkgr/cli'
3
3
  require 'pkgr/dispatcher'
4
4
  require 'mixlib/log'
5
+ require 'yaml'
6
+
7
+ # https://stackoverflow.com/questions/71191685/visit-psych-nodes-alias-unknown-alias-default-psychbadalias/71192990#71192990
8
+ module YAML
9
+ class << self
10
+ alias_method :load, :unsafe_load if YAML.respond_to? :unsafe_load
11
+ end
12
+ end
5
13
 
6
14
  module Pkgr
7
15
  extend Mixlib::Log
@@ -11,6 +19,7 @@ module Pkgr
11
19
  class UnknownAppType < Base; end
12
20
  class UnknownDistribution < Base; end
13
21
  class ConfigurationInvalid < Base; end
22
+ class TargetNotDefined < Base; end
14
23
  end
15
24
 
16
25
  def data_dir=(path)