Skip to content

Commit 9b00b47

Browse files
committed
add support for rpm %attr
bernd/fpm-cookery#120
1 parent 0de5f8c commit 9b00b47

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

fpm-cookery.spec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
Summary: A tool for building software packages with fpm
66
Name: fpm-cookery
77
Version: 0.29.0
8-
Release: 0.2
8+
Release: 0.5
99
License: BSD
1010
Group: Development/Languages
1111
Source0: http://rubygems.org/downloads/%{name}-%{version}.gem
1212
# Source0-md5: bd210d6acb6a0519f8d940200917eefe
1313
Patch0: svn-ignore-externals.patch
14+
Patch1: rpm-attributes.patch
1415
URL: https://github.com/bernd/fpm-cookery
1516
BuildRequires: rpm-rubyprov
1617
BuildRequires: rpmbuild(macros) >= 1.656
@@ -40,6 +41,7 @@ A tool for building software packages with fpm.
4041
%prep
4142
%setup -q
4243
%patch0 -p1
44+
%patch1 -p1
4345
%{__sed} -i -e '1 s,#!.*ruby,#!%{__ruby},' bin/*
4446

4547
%build

rpm-attributes.patch

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
diff --git a/lib/fpm/cookery/package/package.rb b/lib/fpm/cookery/package/package.rb
2+
index 4d80344..38ec07a 100644
3+
--- a/lib/fpm/cookery/package/package.rb
4+
+++ b/lib/fpm/cookery/package/package.rb
5+
@@ -42,6 +42,9 @@ module FPM
6+
# overwrite the values from package_setup().
7+
@fpm.attributes.merge!(recipe.fpm_attributes)
8+
9+
+ # also merge fpm.attrs (for %attr flags, rpm specific)
10+
+ @fpm.attrs.merge!(recipe.rpm_attributes)
11+
+
12+
# The input for the FPM package will be set here.
13+
package_input
14+
15+
diff --git a/lib/fpm/cookery/recipe.rb b/lib/fpm/cookery/recipe.rb
16+
index ab23ca3..628b4a2 100644
17+
--- a/lib/fpm/cookery/recipe.rb
18+
+++ b/lib/fpm/cookery/recipe.rb
19+
@@ -42,6 +42,7 @@ module FPM
20+
# class variable.
21+
klass.instance_variable_set(:@fpm_attributes, self.fpm_attributes.dup)
22+
klass.instance_variable_set(:@environment, self.environment.dup)
23+
+ klass.instance_variable_set(:@rpm_attributes, self.rpm_attributes.dup)
24+
end
25+
26+
def self.platforms(valid_platforms)
27+
@@ -101,11 +102,23 @@ module FPM
28+
@fpm_attributes
29+
end
30+
31+
+ # record attributes[foo] = bar
32+
+ # Supports both hash and argument assignment
33+
+ # rpm_attributes[:attr1] = xxxx
34+
+ # rpm_attributes :xxxx=>1, :yyyy=>2
35+
+ def rpm_attributes(args=nil)
36+
+ if args.is_a?(Hash)
37+
+ @rpm_attributes.merge!(args)
38+
+ end
39+
+ @rpm_attributes
40+
+ end
41+
+
42+
def environment
43+
@environment
44+
end
45+
end
46+
@fpm_attributes = {}
47+
+ @rpm_attributes = {}
48+
@environment = FPM::Cookery::Environment.new
49+
50+
def initialize(filename, config)
51+
@@ -132,6 +145,7 @@ module FPM
52+
def pkgdir(path = nil) (@pkgdir || workdir('pkg'))/path end
53+
def cachedir(path = nil) (@cachedir || workdir('cache'))/path end
54+
def fpm_attributes() self.class.fpm_attributes end
55+
+ def rpm_attributes() self.class.rpm_attributes end
56+
def environment() self.class.environment end
57+
58+
# Resolve dependencies from omnibus package.

0 commit comments

Comments
 (0)