Skip to content

Commit 3165c10

Browse files
author
qount25
committed
Add Package#licence which attempts to read LICENCE file in pkg root and return its contents
1 parent 1f8b9b2 commit 3165c10

File tree

6 files changed

+18
-60
lines changed

6 files changed

+18
-60
lines changed

lib/pgpm/deb/builder.rb

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def initialize(spec)
1010
end
1111

1212
def build
13+
binding.break
1314
prepare
1415
generate_deb_src_files
1516
pull_image

lib/pgpm/deb/templates/copyright.erb

+1-40
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,4 @@ Upstream-Contact: <preferred name and address to reach the upstream project>
66
Files:
77
*
88
Copyright:
9-
<years> <put author's name and email here>
10-
<years> <likewise for another author>
11-
License: <special license>
12-
<Put the license of the package here indented by 1 space>
13-
<This follows the format of Description: lines in control file>
14-
.
15-
<Including paragraphs>
16-
17-
# If you want to use GPL v2 or later for the /debian/* files use
18-
# the following clauses, or change it to suit. Delete these two lines
19-
Files:
20-
debian/*
21-
Copyright:
22-
2025 PGPM Debian maintainer <debian[email protected]>
23-
License: GPL-2+
24-
This package is free software; you can redistribute it and/or modify
25-
it under the terms of the GNU General Public License as published by
26-
the Free Software Foundation; either version 2 of the License, or
27-
(at your option) any later version.
28-
.
29-
This package is distributed in the hope that it will be useful,
30-
but WITHOUT ANY WARRANTY; without even the implied warranty of
31-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32-
GNU General Public License for more details.
33-
.
34-
You should have received a copy of the GNU General Public License
35-
along with this program. If not, see <https://www.gnu.org/licenses/>
36-
Comment:
37-
On Debian systems, the complete text of the GNU General
38-
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
39-
40-
# Please also look if there are files or directories which have a
41-
# different copyright/license attached and list them here.
42-
# Please avoid picking licenses with terms that are more restrictive than the
43-
# packaged work, as it may make Debian's contributions unacceptable upstream.
44-
#
45-
# If you need, there are some extra license texts available in two places:
46-
# /usr/share/debhelper/dh_make/licenses/
47-
# /usr/share/common-licenses/
48-
9+
<%= slef.package.licence %>

lib/pgpm/package/metadata.rb

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ def broken?
2525
requires.any?(&:broken?)
2626
end
2727

28+
def license
29+
path = "#{self.source.to_s}"
30+
["LICENSE", "license", "License"].each do |fn|
31+
if File.exist?("#{path}/#{fn}")
32+
return File.read("#{path}/#{fn}")
33+
end
34+
end
35+
nil
36+
end
37+
2838
module ClassMethods
2939
def extension_name
3040
self[:latest]&.extension_name

lib/pgpm/package/pgxn.rb

+6-11
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,15 @@ def description
4242
end
4343

4444
def license
45-
if provides_pgxn_meta_json?
46-
lic = pgxn_meta_json["license"]
47-
case lic
48-
when Hash
49-
lic.keys.join(" or ")
50-
when Array
51-
lic.join(" or ")
52-
when String
53-
lic
45+
path = "#{self.source.to_s}"
46+
["LICENSE", "license", "License"].each do |fn|
47+
if File.exist?("#{path}/#{fn}")
48+
return File.read("#{path}/#{fn}")
5449
end
55-
else
56-
super
5750
end
51+
nil
5852
end
53+
5954
end
6055
end
6156
end

packages/timescale/timescaledb.rb

-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ def description
1919
"An open-source time-series SQL database optimized for fast ingest and complex queries"
2020
end
2121

22-
def license
23-
"Timescale License"
24-
end
25-
2622
def build_steps
2723
[
2824
"./bootstrap -DPG_CONFIG=$PG_CONFIG #{bootstrap_flags.map { |f| "-D#{f}" }.join(" ")}",

packages/timescaledb.rb

-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ def description
88
"complex queries"
99
end
1010

11-
def licence
12-
"Timescale License"
13-
end
14-
1511
def summary
1612
"TimescaleDB is an open-source database designed to make SQL " +
1713
"scalable for time-series data. It is engineered up from PostgreSQL " +
@@ -41,7 +37,6 @@ def build_info_for(os)
4137
"DESTDIR=$PGPM_BUILDROOT cmake --build build --target install"
4238
]
4339
}
44-
}
4540
end
4641
end
4742

0 commit comments

Comments
 (0)