-
Notifications
You must be signed in to change notification settings - Fork 3
/
package.rb
executable file
·37 lines (30 loc) · 949 Bytes
/
package.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
#!/usr/bin/env ruby
# This script uses package data in dub.json and the FPM utility to build DEB and
# RPM packages for trash-d so that users can install them
# It requires Ruby and FPM to work: https://fpm.readthedocs.io/en/latest/
require 'json'
require 'fileutils'
data = JSON.parse(File.read("dub.json"))
arch = `uname -m`.chomp
targets = ["deb", "rpm"]
outdir = ARGV.first
FileUtils.mkdir_p(outdir)
for target in targets do
file = outdir + "trash-d-#{data["version"]}-1-#{arch}.#{target}"
cmd = <<-sh
fpm -f -s dir \
-t #{target} \
-p '#{file}' \
--no-depends \
--name '#{data["name"]}' \
--license '#{data["license"]}' \
--version '#{data["version"]}' \
--architecture '#{arch}' \
--description '#{data["description"]}' \
--url '#{data["homepage"]}' \
--maintainer '#{data["authors"][0]}' \
#{outdir}/trash=/usr/bin/trash \
#{outdir}/trash.man=/usr/share/man/man1/trash.1
sh
exit(1) if not system(cmd)
end