Skip to content

Commit 7168b51

Browse files
committed
Problem: building extensions that require other extensions
This doesn't currently work because we try to install those other extensions in the last build and they are not available. Solution: build them together with the package The implementation is currently very, very hacky – that Proc refinement is just a massive hack. I've also fixed rebuild chaining but it is extremely brittle as well. But at least it works. I think.
1 parent 910dda8 commit 7168b51

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

exe/pgpm

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ module Pgpm
4141
option :path, type: :path, desc: "Override path to the source"
4242
argument :packages, type: :array, required: true, desc: "Package names"
4343

44+
module ExtendedProc
45+
refine Proc do
46+
def and_then(callable)
47+
lambda do |*args|
48+
res1 = call(*args)
49+
res2 = callable.call(*args)
50+
return res1 + res2 if res1.is_a?(Array) && res2.is_a?(Array)
51+
52+
res2
53+
end
54+
end
55+
end
56+
end
57+
58+
using ExtendedProc
59+
4460
# rubocop:disable Metrics/ParameterLists:
4561
def call(packages:, args: nil, os: nil, arch: nil, pgdist: nil, pgver: nil, pkgdir: nil, path: nil)
4662
_ = args
@@ -95,6 +111,10 @@ module Pgpm
95111
os.with_scope do
96112
arch.with_scope do
97113
selected_pgdist.with_scope do
114+
pkgs = pkgs.flat_map do |pkg|
115+
[pkg, *pkg.requires]
116+
end
117+
98118
b = pkgs.reduce(nil) do |c, p|
99119
if p.broken?
100120
puts "Can't build a broken package #{p.name}@#{p.version}"

lib/pgpm/rpm/mock/operation.rb

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,19 @@ def call
6868
def chain(op)
6969
raise ArgumentError, "can't chain non-rebuild operations" unless op.args.include?("--rebuild") && @args.include?("--rebuild")
7070

71-
args = @args.clone
72-
args.insert(@args.index("--localrepo") - 1, op.args[op.args.index("--localrepo") - 1])
73-
self.class.new(*args, cb: lambda {
74-
res1 = @cb&.call
75-
res2 = op.cb&.call
76-
return res1 + res2 if res1.is_a?(Array) && res2.is_a?(Array)
77-
78-
res2
79-
})
71+
self.args.insert(self.args.index("--localrepo"), *op.args[op.args.index("--recurse") + 1..op.args.index("--localrepo")-1])
72+
self
8073
end
8174

8275
def and_then(op)
8376
lambda do
8477
res1 = call
8578
res2 = op.call
86-
return res1 + res2 if res1.is_a?(Array) && res2.is_a?(Array)
87-
88-
[res1, res2]
79+
if res1.is_a?(Array) && res2.is_a?(Array)
80+
res1 + res2
81+
else
82+
[res1, res2]
83+
end
8984
end
9085
end
9186
end

0 commit comments

Comments
 (0)