qrpm 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example.yml +30 -0
- data/exe/qrpm +8 -5
- data/lib/qrpm/parser.rb +19 -0
- data/lib/qrpm/rpm.rb +15 -10
- data/lib/qrpm/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 884bb9257c9679db9a55e792de02fe716fc777e8903b1ed003fed768bba51129
|
4
|
+
data.tar.gz: eebed25d75b50ae9f738afebadec366ae22307245be691449cce0ca48f3bab6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a12688142eb50b64dbf59324d299f192421675279af2574be1fee9d6df5aba3b0272f9a4196d05dee64165be6ffc19f2769c7954a363e6c705b6b17849be5d93
|
7
|
+
data.tar.gz: bad940c0c5af97d5fa5ec5c809266765b0d3ecd5925a50c726544ea2cc15d7ba434926ba6c6e1b00918c002cfbcf2dd26f1409e93fa01b7bbfb7ffbfe0cac321
|
data/example.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# QRPM configuration file. See https://github.com/clrgit/qrpm
|
2
|
+
|
3
|
+
name: $pg_name-url_encode
|
4
|
+
summary: Adds the url_encode extension to postgres
|
5
|
+
description: RPM wrapper for the postgres url_encode extension (https://github.com/okbob/url_encode)
|
6
|
+
version: $(cd url_encode; git tag | tail -1 | sed 's/^v//')
|
7
|
+
|
8
|
+
requires:
|
9
|
+
- $pg_name-server
|
10
|
+
- $pg_name-libs
|
11
|
+
|
12
|
+
pg_name: $(rpm -q -qf '%{NAME}\n' -f $(readlink -f $(which pg_config)))
|
13
|
+
pg_version: $(pg_config --version | sed 's/^[^0-9]* \([0-9]\+\).*$/\1/')
|
14
|
+
pg_libdir: $(pg_config --libdir)
|
15
|
+
pg_extdir: $(pg_config --share)/extension
|
16
|
+
|
17
|
+
init:
|
18
|
+
- git submodule init
|
19
|
+
- git submodule update
|
20
|
+
|
21
|
+
make:
|
22
|
+
- cd url_encode; make
|
23
|
+
|
24
|
+
$pg_libdir:
|
25
|
+
- url_encode/src/url_encode.so
|
26
|
+
|
27
|
+
$pg_extdir:
|
28
|
+
- url_encode/url_encode.control
|
29
|
+
- url_encode/sql/url_encode--1.2.sql
|
30
|
+
|
data/exe/qrpm
CHANGED
@@ -45,14 +45,16 @@ begin
|
|
45
45
|
files
|
46
46
|
|
47
47
|
-C,directory=EDIR
|
48
|
-
Change to directory before doing anything else
|
48
|
+
Change to directory before doing anything else. Output files are still
|
49
|
+
created in the current directory, though
|
49
50
|
|
50
51
|
-d,dump
|
51
|
-
Dump internal data and exit
|
52
|
+
Dump internal data and exit. For debug
|
52
53
|
)
|
53
54
|
|
54
|
-
opts, args = ShellOpts.process(SPEC, ARGV)
|
55
|
+
opts, args = ShellOpts.process(SPEC, ARGV, verbose: true)
|
55
56
|
|
57
|
+
currdir = Dir.getwd
|
56
58
|
Dir.chdir(opts.directory) if opts.directory?
|
57
59
|
|
58
60
|
if opts.template?
|
@@ -61,7 +63,8 @@ begin
|
|
61
63
|
exit
|
62
64
|
end
|
63
65
|
|
64
|
-
# Collect var=val settings
|
66
|
+
# Collect var=val settings into the dict hash and sets the configuration file
|
67
|
+
# if present
|
65
68
|
dict = {}
|
66
69
|
while arg = args.extract(0..1)
|
67
70
|
if arg =~ /^(.*?)=(.*)$/
|
@@ -92,7 +95,7 @@ begin
|
|
92
95
|
opts.force? || `git status --porcelain 2>/dev/null` == "" or raise "Repository is dirty"
|
93
96
|
|
94
97
|
target = (opts.spec? ? :spec : (opts.source? ? :srpm : :rpm))
|
95
|
-
rpm.build(target: target, file: opts.spec)
|
98
|
+
rpm.build(target: target, file: opts.spec, verbose: opts.verbose?, destdir: currdir)
|
96
99
|
|
97
100
|
rescue RuntimeError => ex
|
98
101
|
ShellOpts.error ex.message
|
data/lib/qrpm/parser.rb
CHANGED
@@ -116,6 +116,25 @@ module Qrpm
|
|
116
116
|
"logdir" => "/var/log"
|
117
117
|
}
|
118
118
|
|
119
|
+
# TODO TODO TODO
|
120
|
+
|
121
|
+
# Expand shell expansions ($(shell command))
|
122
|
+
#
|
123
|
+
def expand_shell_commands(object)
|
124
|
+
case object
|
125
|
+
when Array; object.map { |e| expand_shell_commands(e) }
|
126
|
+
when Hash; object.map { |k,v| [k, expand_shell_commands(v)] }.to_h
|
127
|
+
when String;
|
128
|
+
puts object.scan(/\$\(([^\)]+)\)/)
|
129
|
+
object.scan(/\$\(([^\)]+)\)/)
|
130
|
+
|
131
|
+
when Integer, Float, true, false, nil; object
|
132
|
+
else
|
133
|
+
raise "Illegal object: #{object}"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
119
138
|
# Returns array of variables in the object. Variables can be either '$name' or
|
120
139
|
# '${name}'. The variables are returned in left-to-right order
|
121
140
|
#
|
data/lib/qrpm/rpm.rb
CHANGED
@@ -43,15 +43,20 @@ module Qrpm
|
|
43
43
|
def files() @files ||= nodes.select(&:file?) end
|
44
44
|
def links() @lines ||= nodes.select(&:link?) end
|
45
45
|
|
46
|
-
def
|
47
|
-
def has_make?() ::File.exist? "make" end
|
46
|
+
def verbose?() @verbose end
|
48
47
|
|
49
|
-
def initialize(fields, nodes, template: TEMPLATE)
|
48
|
+
def initialize(fields, nodes, template: TEMPLATE, verbose: false)
|
50
49
|
@fields, @nodes = fields, nodes
|
51
50
|
@template = template
|
51
|
+
@verbose = verbose
|
52
|
+
@verb = verbose ? "" : "&>/dev/null"
|
52
53
|
end
|
53
54
|
|
54
|
-
def
|
55
|
+
def has_configure?() ::File.exist? "configure" end
|
56
|
+
def has_make?() ::File.exist? "make" end
|
57
|
+
|
58
|
+
def build(target: :rpm, file: nil, verbose: false, destdir: ".")
|
59
|
+
verb = verbose ? "" : "&>/dev/null"
|
55
60
|
Dir.mktmpdir { |rootdir|
|
56
61
|
FileUtils.rm_rf(rootdir)
|
57
62
|
FileUtils.mkdir_p(rootdir)
|
@@ -73,7 +78,7 @@ module Qrpm
|
|
73
78
|
FileUtils.cp_r(".", tarroot, preserve: true)
|
74
79
|
|
75
80
|
# Roll tarball and put it in the SOURCES directory
|
76
|
-
system "tar zcf #{tar_path} -C #{rootdir}/tmp #{name}" or raise "Can't roll tarball"
|
81
|
+
system "tar zcf #{tar_path} -C #{rootdir}/tmp #{name} #{verb}" or raise "Can't roll tarball"
|
77
82
|
|
78
83
|
# Remove temporary tar dir
|
79
84
|
FileUtils.rm_rf tarroot
|
@@ -84,15 +89,15 @@ module Qrpm
|
|
84
89
|
|
85
90
|
# Emit spec or build RPM
|
86
91
|
if target == :spec
|
87
|
-
IO.write(spec_file, @spec)
|
92
|
+
IO.write("#{destdir}/#{spec_file}", @spec)
|
88
93
|
else
|
89
94
|
IO.write(spec_path, @spec)
|
90
|
-
system "rpmbuild -v -ba --define \"_topdir #{rootdir}\" #{rootdir}/SPECS/#{name}.spec" or
|
91
|
-
raise "Failed building RPM file"
|
95
|
+
system "rpmbuild -v -ba --define \"_topdir #{rootdir}\" #{rootdir}/SPECS/#{name}.spec #{verb}" or
|
96
|
+
raise "Failed building RPM file. Re-run with -v option to see errors"
|
92
97
|
if target == :srpm
|
93
|
-
system "cp #{rootdir}/SRPMS/*
|
98
|
+
system "cp #{rootdir}/SRPMS/* #{destdir}" or raise "Failed copying SRPM file"
|
94
99
|
elsif target == :rpm
|
95
|
-
system "cp #{rootdir}/RPMS/*/#{name}-[0-9]*
|
100
|
+
system "cp #{rootdir}/RPMS/*/#{name}-[0-9]* #{destdir}" or raise "Failed copying RPM file"
|
96
101
|
else
|
97
102
|
raise ArgumentError, "Not a valid value for :target - #{target.inspect}"
|
98
103
|
end
|
data/lib/qrpm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qrpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shellopts
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- bin/setup
|
56
56
|
- clean
|
57
57
|
- cmd
|
58
|
+
- example.yml
|
58
59
|
- example/bin/a_file
|
59
60
|
- example/bin/another_file
|
60
61
|
- example/qrpm.yml
|