Skip to content

Commit 4ac7c0f

Browse files
author
qount25
committed
Specify default & custom dependencies in packages
1 parent 998546d commit 4ac7c0f

File tree

10 files changed

+82
-107
lines changed

10 files changed

+82
-107
lines changed

lib/pgpm/deb/builder.rb

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

1212
def build
13-
binding.break
1413
prepare
1514
generate_deb_src_files
1615
pull_image
@@ -23,7 +22,7 @@ def build
2322

2423
# Depends on postgres version and arch
2524
def image_name
26-
"quay.io/qount25/pgpm-debian-pg#{@spec.postgres_major_version}-#{@spec.arch}"
25+
"quay.io/qount25/pgpm-debian-pg#{@spec.package.postgres_major_version}-#{@spec.arch}"
2726
end
2827

2928
def prepare

lib/pgpm/deb/spec.rb

+3-25
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ class Spec
1010
attr_reader :package, :release, :postgres_version, :postgres_distribution
1111

1212
def initialize(package)
13+
@postgres_distribution = Pgpm::Postgres::Distribution.in_scope
1314
@package = package
15+
@package.postgres_major_version = @postgres_distribution.version.split(".")[0]
16+
@package.os = "debian"
1417
@release = 1
15-
16-
@postgres_distribution = Pgpm::Postgres::Distribution.in_scope
1718
end
1819

1920
def sources
@@ -27,24 +28,6 @@ def generate(template_name)
2728
erb.result(binding)
2829
end
2930

30-
def deps
31-
["postgresql-#{postgres_major_version}"]
32-
end
33-
34-
def build_deps
35-
[
36-
"postgresql-#{postgres_major_version}",
37-
"build-essential",
38-
"postgresql-#{postgres_major_version}",
39-
"postgresql-server-dev-#{postgres_major_version}",
40-
"postgresql-common"
41-
]
42-
end
43-
44-
def postgres_major_version
45-
self.postgres_distribution.version.split(".")[0]
46-
end
47-
4831
def source_version
4932
@package.version.to_s
5033
end
@@ -64,11 +47,6 @@ def arch
6447
end
6548
end
6649

67-
# Whatever is returned from this method gets added to the "rules" file.
68-
def rules_amendments
69-
"#"
70-
end
71-
7250
end
7351
end
7452
end

lib/pgpm/deb/templates/control.erb

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
Source: <%= self.package.name %>-<%= source_version %>
2+
Description: <%= self.package.description %>
23
Section: libs
34
Priority: optional
45
Maintainer: PGPM Debian maintainer <debian[email protected]>
56
Rules-Requires-Root: no
6-
Build-Depends: debhelper-compat (= 13), <%= build_deps.join(", ") %>
7+
Build-Depends: debhelper-compat (= 13), <%= self.package.build_dependencies.join(", ") %>
78
Standards-Version: 4.6.2
89

910
Package: <%= self.package.name %>-<%= source_version %>
10-
Depends: <%= deps.join(", ") %>
11+
Depends: <%= self.package.dependencies.join(", ") %>
1112
Section: libdevel
1213
Architecture: <%= arch %>
1314
Description: <%= self.package.description %>

lib/pgpm/deb/templates/copyright.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Upstream-Contact: <preferred name and address to reach the upstream project>
66
Files:
77
*
88
Copyright:
9-
<%= slef.package.licence %>
9+
<%= self.package.license %>

lib/pgpm/deb/templates/rules.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
%:
1919
dh $@
2020

21-
<%= self.rules_amendments %>
21+
<%= self.package.build_info[:rules] %>

lib/pgpm/package/building.rb

+7-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ def configure_steps
77
[]
88
end
99

10-
def build_steps
11-
[]
12-
end
13-
14-
def install_steps
15-
[]
10+
def build_info
11+
case @os
12+
when "debian", "ubuntu"
13+
{ rules: "" }
14+
when "rocky", "redhat", "fedora"
15+
{ build_steps: [], install_steps: [] }
16+
end
1617
end
1718

1819
def source_url_directory_name

lib/pgpm/package/dependencies.rb

+28-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,37 @@
33
module Pgpm
44
class Package
55
module Dependencies
6-
def build_dependencies
7-
return ["gcc"] if c_files_present?
86

9-
[]
7+
attr_accessor :postgres_major_version
8+
9+
def build_dependencies
10+
case @os
11+
when "debian", "ubuntu"
12+
[
13+
"postgresql-#{postgres_major_version}",
14+
"build-essential",
15+
"postgresql-#{postgres_major_version}",
16+
"postgresql-server-dev-#{postgres_major_version}",
17+
"postgresql-common"
18+
]
19+
when "rocky", "redhat", "fedora"
20+
[
21+
"postgresql-#{postgres_major_version}",
22+
"build-essential",
23+
"postgresql-#{postgres_major_version}",
24+
"postgresql-server-devel-#{postgres_major_version}",
25+
"postgresql-common"
26+
]
27+
end
1028
end
1129

1230
def dependencies
13-
[]
31+
case @os
32+
when "debian", "ubuntu"
33+
[ "postgresql-#{postgres_major_version}" ]
34+
when "rocky", "redhat", "fedora"
35+
[ "postgresql-#{postgres_major_version}" ]
36+
end
1437
end
1538

1639
def requires
@@ -20,6 +43,7 @@ def requires
2043
def c_files_present?
2144
Dir.glob("*.c", base: source).any?
2245
end
46+
2347
end
2448
end
2549
end

lib/pgpm/package/packaging.rb

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ module Pgpm
44
class Package
55
module Packaging
66

7+
attr_accessor :os
8+
79
def to_rpm_spec(**opts)
810
Pgpm::RPM::Spec.new(self, **opts)
911
end

packages/timescale/timescaledb.rb

+36-17
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,58 @@ def self.package_versions
1111
super.select { |v| v.to_s =~ /^(\d+\.\d+\.\d+)$/ }
1212
end
1313

14-
def summary
15-
"TimescaleDB is an open-source database designed to make SQL scalable for time-series data. It is engineered up from PostgreSQL and packaged as a PostgreSQL extension, providing automatic partitioning across time and space (partitioning key), as well as full SQL support."
16-
end
17-
1814
def description
19-
"An open-source time-series SQL database optimized for fast ingest and complex queries"
15+
"An open-source time-series SQL database optimized for fast ingest and " +
16+
"complex queries"
2017
end
2118

22-
def build_steps
23-
[
24-
"./bootstrap -DPG_CONFIG=$PG_CONFIG #{bootstrap_flags.map { |f| "-D#{f}" }.join(" ")}",
25-
"cmake --build build --parallel"
26-
]
19+
def summary
20+
"TimescaleDB is an open-source database designed to make SQL " +
21+
"scalable for time-series data. It is engineered up from PostgreSQL " +
22+
"and packaged as a PostgreSQL extension, providing automatic " +
23+
"partitioning across time and space (partitioning key), as well as " +
24+
"full SQL support."
2725
end
2826

29-
def install_steps
30-
[
31-
"DESTDIR=$PGPM_BUILDROOT cmake --build build --target install"
32-
]
27+
def dependencies
28+
super
3329
end
3430

3531
def build_dependencies
36-
super + %w[openssl-devel cmake]
32+
deps = case @os
33+
when "debian", "ubunut"
34+
["openssl-dev", "cmake"]
35+
when "rocky", "redhat", "fedora"
36+
["openssl-devel", "cmake"]
37+
end
38+
super + deps
3739
end
3840

39-
def dependencies
40-
super + %w[openssl]
41+
def build_info
42+
case @os
43+
when "debian", "ubuntu"
44+
{
45+
rules: "override_dh_auto_configure:\n" +
46+
" dh_auto_configure -- -DCMAKE_BUILD_TYPE=\"Release\""
47+
}
48+
when "rocky", "redhat", "fedora"
49+
{
50+
build_steps: [
51+
"./bootstrap -DPG_CONFIG=$PG_CONFIG #{bootstrap_flags.map { |f| "-D#{f}" }.join(" ")}",
52+
"cmake --build build --parallel"
53+
],
54+
install_steps: [
55+
"DESTDIR=$PGPM_BUILDROOT cmake --build build --target install"
56+
]
57+
}
58+
end
4159
end
4260

4361
protected
4462

4563
def bootstrap_flags
4664
[]
4765
end
66+
4867
end
4968
end

packages/timescaledb.rb

-49
This file was deleted.

0 commit comments

Comments
 (0)