Skip to content

Commit

Permalink
Merge pull request #2065 from phillipp/main
Browse files Browse the repository at this point in the history
Add support for .timer units to --deb-systemd
  • Loading branch information
jordansissel authored Sep 12, 2024
2 parents 9d3d96a + 6957220 commit 18e04a7
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions lib/fpm/package/deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -517,14 +517,23 @@ def output(output_path)

attributes[:deb_systemd] = []
attributes.fetch(:deb_systemd_list, []).each do |systemd|
name = File.basename(systemd, ".service")
dest_systemd = staging_path("lib/systemd/system/#{name}.service")
name = File.basename(systemd)
extname = File.extname(name)

name_with_extension = if extname.empty?
"#{name}.service"
elsif [".service", ".timer"].include?(extname)
name
else
raise ArgumentError, "Invalid systemd unit file extension: #{extname}. Expected .service or .timer, or no extension."
end

dest_systemd = staging_path("lib/systemd/system/#{name_with_extension}")
mkdir_p(File.dirname(dest_systemd))
FileUtils.cp(systemd, dest_systemd)
File.chmod(0644, dest_systemd)

# add systemd service name to attribute
attributes[:deb_systemd] << name
attributes[:deb_systemd] << name_with_extension
end

if script?(:before_upgrade) or script?(:after_upgrade) or attributes[:deb_systemd].any?
Expand Down Expand Up @@ -627,8 +636,11 @@ def output(output_path)
end

attributes.fetch(:deb_systemd_list, []).each do |systemd|
name = File.basename(systemd, ".service")
dest_systemd = staging_path("lib/systemd/system/#{name}.service")
name = File.basename(systemd)
extname = File.extname(systemd)
name_with_extension = extname.empty? ? "#{name}.service" : name

dest_systemd = staging_path("lib/systemd/system/#{name_with_extension}")
mkdir_p(File.dirname(dest_systemd))
FileUtils.cp(systemd, dest_systemd)
File.chmod(0644, dest_systemd)
Expand Down

0 comments on commit 18e04a7

Please sign in to comment.