Skip to content

Add support for .timer units to --deb-systemd #2065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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