fpm-scriptable 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +201 -0
- data/bin/fpm-script +37 -0
- data/lib/fpm/scriptable/app.rb +102 -0
- data/lib/fpm/scriptable/config.rb +58 -0
- data/lib/fpm/scriptable/constants.rb +52 -0
- data/lib/fpm/scriptable/log.rb +186 -0
- data/lib/fpm/scriptable/plugin/rpm.rb +93 -0
- data/lib/fpm/scriptable/script.rb +222 -0
- data/lib/fpm/scriptable/util.rb +92 -0
- data/lib/fpm/scriptable/version.rb +23 -0
- data/lib/fpm/scriptable.rb +36 -0
- metadata +88 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 462abaa26e46eef0c790fd3817797f0fd773a68f
|
|
4
|
+
data.tar.gz: c5f38036216be412ec63e8db0359b7988403eb37
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ec2237f35dcd887378dd5546940cf4a55577820ec04ce95c21d8bbb94e9b927eea144cf05c080d3246043acecb33cfe1074c5f08e41470c052cc382cfd870e84
|
|
7
|
+
data.tar.gz: 3d9e535434ae2d547c07312732c06b5fa552c4ea1093abbf697946e5ab3ebcbfcb99f9c842b20ea23f013adbabec2af2f0b3d58aab26eb2e1fa86d81284aba49
|
data/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
data/bin/fpm-script
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# Copyright 2014 Ted Elwartowski <xelwarto.pub@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
bin_path = String.new
|
|
17
|
+
bin_dir = String.new
|
|
18
|
+
app_dir = String.new
|
|
19
|
+
|
|
20
|
+
bin_path = File.expand_path($0)
|
|
21
|
+
if bin_path && bin_path != ""
|
|
22
|
+
bin_dir = File.dirname(bin_path)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
if bin_dir && bin_dir != ''
|
|
26
|
+
app_dir = "#{bin_dir}/.."
|
|
27
|
+
$:.push "#{app_dir}/lib"
|
|
28
|
+
else
|
|
29
|
+
puts 'Error: unable to locate bin directory'
|
|
30
|
+
exit 1
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Dir.chdir(app_dir) do
|
|
34
|
+
require 'fpm/scriptable'
|
|
35
|
+
end
|
|
36
|
+
FPM::Scriptable::App.run(app_dir)
|
|
37
|
+
exit 0
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Copyright 2014 Ted Elwartowski <xelwarto.pub@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module FPM
|
|
16
|
+
module Scriptable
|
|
17
|
+
class App
|
|
18
|
+
|
|
19
|
+
def self.run(app_dir)
|
|
20
|
+
@log = FPM::Scriptable::Log.instance
|
|
21
|
+
args = FPM::Scriptable::Util.get_args
|
|
22
|
+
|
|
23
|
+
@log.color = false if args[:nocolor]
|
|
24
|
+
@log.quiet = true if args[:quiet] && ( !args[:help] && !args[:h] )
|
|
25
|
+
@log.quiet = true if args[:q] && ( !args[:help] && !args[:h] )
|
|
26
|
+
|
|
27
|
+
if !@log.quiet
|
|
28
|
+
level = FPM::Scriptable::Constants.instance.log_level
|
|
29
|
+
level = args[:log_level] if args[:log_level]
|
|
30
|
+
@log.add(level.to_sym, @log.color, STDOUT)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
@log.show FPM::Scriptable::Util.banner, @log.quiet, true
|
|
34
|
+
|
|
35
|
+
if args[:help] || args[:h]
|
|
36
|
+
@log.show FPM::Scriptable::Util.usage, false, false
|
|
37
|
+
exit 0
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
cfg = FPM::Scriptable::Config.instance
|
|
41
|
+
@config = cfg.config
|
|
42
|
+
@config.app_dir = app_dir
|
|
43
|
+
@config.working_dir = Dir.getwd
|
|
44
|
+
|
|
45
|
+
script = args[:script]
|
|
46
|
+
if script.nil?
|
|
47
|
+
@log.fatal 'FPM::Scriptable::App - No script file was specified'
|
|
48
|
+
@log.show FPM::Scriptable::Util.usage, @log.quiet, false
|
|
49
|
+
exit 1
|
|
50
|
+
else
|
|
51
|
+
if script !~ /^\//
|
|
52
|
+
script = "#{@config.app_dir}/#{script}"
|
|
53
|
+
|
|
54
|
+
if !File.exists? script
|
|
55
|
+
script = args[:script]
|
|
56
|
+
script = "#{@config.working_dir}/#{script}"
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
@log.debug "FPM::Scriptable::App - Script file path set to: #{script}"
|
|
61
|
+
if File.file? script
|
|
62
|
+
if File.readable? script
|
|
63
|
+
@script_lines = nil
|
|
64
|
+
begin
|
|
65
|
+
@log.debug 'FPM::Scriptable::App - Reading script file'
|
|
66
|
+
s_lines = nil
|
|
67
|
+
File.open(script) do |f|
|
|
68
|
+
s_lines = f.readlines
|
|
69
|
+
end
|
|
70
|
+
@script_lines = s_lines.join
|
|
71
|
+
rescue Exception => e
|
|
72
|
+
@log.error "FPM::Scriptable::App - #{e}"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
if @script_lines.nil?
|
|
76
|
+
@log.error "FPM::Scriptable::App - Unable to read script file: #{script}"
|
|
77
|
+
else
|
|
78
|
+
|
|
79
|
+
@log.debug 'FPM::Scriptable::App - Staring new thread to execute script'
|
|
80
|
+
begin
|
|
81
|
+
Thread.start {
|
|
82
|
+
eval(@script_lines)
|
|
83
|
+
}.join
|
|
84
|
+
rescue Exception => e
|
|
85
|
+
@log.error "FPM::Scriptable::App - #{e}"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
else
|
|
90
|
+
@log.error "FPM::Scriptable::App - Unable to read script file: #{script}"
|
|
91
|
+
end
|
|
92
|
+
else
|
|
93
|
+
@log.error "FPM::Scriptable::App - Unable to locate script file: #{script}"
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
exit 0
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Copyright 2014 Ted Elwartowski <xelwarto.pub@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module FPM
|
|
16
|
+
module Scriptable
|
|
17
|
+
class Config
|
|
18
|
+
include Singleton
|
|
19
|
+
|
|
20
|
+
def initialize
|
|
21
|
+
@log = FPM::Scriptable::Log.instance
|
|
22
|
+
@log.debug 'FPM::Scriptable::Config - Initializing Application Configuration'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def config
|
|
26
|
+
@config ||= GeneralConfig.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
protected
|
|
30
|
+
|
|
31
|
+
class GeneralConfig
|
|
32
|
+
attr_accessor :app_dir
|
|
33
|
+
|
|
34
|
+
def initialize
|
|
35
|
+
@app_dir = nil
|
|
36
|
+
|
|
37
|
+
@u_defined = {}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def udefine(name, *opts)
|
|
41
|
+
if !name.nil?
|
|
42
|
+
name = name.to_s
|
|
43
|
+
if name =~ /\=\z/
|
|
44
|
+
name.gsub! /\=/, ''
|
|
45
|
+
if opts.size == 1
|
|
46
|
+
@u_defined[name.to_sym] = opts.first
|
|
47
|
+
end
|
|
48
|
+
else
|
|
49
|
+
@u_defined[name.to_sym]
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
alias method_missing udefine
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Copyright 2014 Ted Elwartowski <xelwarto.pub@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module FPM
|
|
16
|
+
module Scriptable
|
|
17
|
+
class Constants
|
|
18
|
+
include Singleton
|
|
19
|
+
|
|
20
|
+
attr_accessor :version,
|
|
21
|
+
:author,
|
|
22
|
+
:cfg_file,
|
|
23
|
+
:name,
|
|
24
|
+
:log_level,
|
|
25
|
+
:script,
|
|
26
|
+
:website
|
|
27
|
+
|
|
28
|
+
def initialize
|
|
29
|
+
@name = FPM::Scriptable::NAME
|
|
30
|
+
@version = FPM::Scriptable::VERSION
|
|
31
|
+
@author = "#{FPM::Scriptable::AUTHOR} #{FPM::Scriptable::EMAIL}"
|
|
32
|
+
@website = FPM::Scriptable::WEBSITE
|
|
33
|
+
@log_level = :info
|
|
34
|
+
|
|
35
|
+
@script = ScriptConstants.new
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
class ScriptConstants
|
|
41
|
+
attr_accessor :version, :iteration, :description, :dstdir
|
|
42
|
+
|
|
43
|
+
def initialize
|
|
44
|
+
@version = '1.0'
|
|
45
|
+
@iteration = '1'
|
|
46
|
+
@description = "Packages built using #{@name} v#{@version}"
|
|
47
|
+
@dstdir = '.'
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Copyright 2014 Ted Elwartowski <xelwarto.pub@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module FPM
|
|
16
|
+
module Scriptable
|
|
17
|
+
class Log
|
|
18
|
+
include Singleton
|
|
19
|
+
attr_accessor :quiet, :color
|
|
20
|
+
|
|
21
|
+
def initialize
|
|
22
|
+
@quiet = false
|
|
23
|
+
@color = true
|
|
24
|
+
|
|
25
|
+
@logger = nil
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def show(msg,quiet=@is_quiet,in_color=false)
|
|
29
|
+
if msg
|
|
30
|
+
if @color && in_color
|
|
31
|
+
msg = "\e[33m#{msg}\e[0m"
|
|
32
|
+
else
|
|
33
|
+
msg = "\e[0m#{msg}\e[0m"
|
|
34
|
+
end
|
|
35
|
+
puts msg unless quiet
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def add(level=:info, color=true, *args)
|
|
40
|
+
l = LogHandler.new(*args)
|
|
41
|
+
l.level = LogHandler.level level
|
|
42
|
+
l.color = color
|
|
43
|
+
|
|
44
|
+
if @logger.nil?
|
|
45
|
+
@logger = l
|
|
46
|
+
else
|
|
47
|
+
@logger.extend(LogHandler.broadcast(l))
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def info(msg)
|
|
52
|
+
if msg
|
|
53
|
+
if !@logger.nil?
|
|
54
|
+
@logger.info msg
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def warn(msg)
|
|
60
|
+
if msg
|
|
61
|
+
if !@logger.nil?
|
|
62
|
+
@logger.warn msg
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def debug(msg)
|
|
68
|
+
if msg
|
|
69
|
+
if !@logger.nil?
|
|
70
|
+
@logger.debug msg
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def error(msg)
|
|
76
|
+
if msg
|
|
77
|
+
if !@logger.nil?
|
|
78
|
+
@logger.error msg
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def fatal(msg)
|
|
84
|
+
if msg
|
|
85
|
+
if !@logger.nil?
|
|
86
|
+
@logger.fatal msg
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
class LogHandler < Logger
|
|
92
|
+
def initialize(*args)
|
|
93
|
+
super
|
|
94
|
+
@formatter = LogFormatter.new
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def color=(c=true)
|
|
98
|
+
@formatter.color = c
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def self.broadcast(logger)
|
|
102
|
+
Module.new do
|
|
103
|
+
define_method(:add) do |*args, &block|
|
|
104
|
+
logger.add(*args, &block)
|
|
105
|
+
super(*args, &block)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
define_method(:<<) do |x|
|
|
109
|
+
logger << x
|
|
110
|
+
super(x)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
define_method(:close) do
|
|
114
|
+
logger.close
|
|
115
|
+
super()
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
define_method(:progname=) do |name|
|
|
119
|
+
logger.progname = name
|
|
120
|
+
super(name)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
define_method(:formatter=) do |formatter|
|
|
124
|
+
logger.formatter = formatter
|
|
125
|
+
super(formatter)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
define_method(:level=) do |level|
|
|
129
|
+
logger.level = level
|
|
130
|
+
super(level)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def self.level(lvl)
|
|
136
|
+
case lvl
|
|
137
|
+
when :info
|
|
138
|
+
Logger::INFO
|
|
139
|
+
when :warn
|
|
140
|
+
Logger::WARN
|
|
141
|
+
when :debug
|
|
142
|
+
Logger::DEBUG
|
|
143
|
+
when :error
|
|
144
|
+
Logger::ERROR
|
|
145
|
+
when :fatal
|
|
146
|
+
Logger::FATAL
|
|
147
|
+
else
|
|
148
|
+
Logger::UNKNOWN
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
class LogFormatter < Logger::Formatter
|
|
153
|
+
attr_accessor :color
|
|
154
|
+
|
|
155
|
+
def call(severity, timestamp, progname, msg)
|
|
156
|
+
c = get_color severity
|
|
157
|
+
|
|
158
|
+
f_severity = sprintf("%-5s", severity.to_s)
|
|
159
|
+
f_time = timestamp.strftime("%Y-%m-%d %H:%M:%S")
|
|
160
|
+
|
|
161
|
+
if !@color.nil? && @color
|
|
162
|
+
"\e[#{c}\e[30m[#{f_severity} #{f_time}] #{msg.to_s.strip}\e[0m\n"
|
|
163
|
+
else
|
|
164
|
+
"[#{f_severity} #{f_time}] #{msg.to_s.strip}\n"
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def get_color(c)
|
|
169
|
+
case c
|
|
170
|
+
when 'DEBUG'
|
|
171
|
+
'46m'
|
|
172
|
+
when 'WARN'
|
|
173
|
+
'43m'
|
|
174
|
+
when 'ERROR'
|
|
175
|
+
'41m'
|
|
176
|
+
when 'FATAL'
|
|
177
|
+
'41m'
|
|
178
|
+
else
|
|
179
|
+
'42m'
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Copyright 2014 Ted Elwartowski <xelwarto.pub@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module FPM
|
|
16
|
+
module Scriptable
|
|
17
|
+
|
|
18
|
+
class RPM < FPM::Scriptable::Script
|
|
19
|
+
TYPE = 'rpm'
|
|
20
|
+
|
|
21
|
+
attr_handler :compression, :digest, :user, :group
|
|
22
|
+
|
|
23
|
+
attr_list_handler :srcrpm
|
|
24
|
+
|
|
25
|
+
def fpm_obj
|
|
26
|
+
FPM::Package::Dir.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def fpm_convert
|
|
30
|
+
obj = FPM::Package.types[TYPE]
|
|
31
|
+
@fpm.convert(obj)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def plugin_init
|
|
35
|
+
@compression = 'gzip'
|
|
36
|
+
@digest = 'md5'
|
|
37
|
+
@user = 'root'
|
|
38
|
+
@group = 'root'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def plugin_setup
|
|
42
|
+
@fpm.attributes[:rpm_compression] = compression
|
|
43
|
+
@fpm.attributes[:rpm_digest] = digest
|
|
44
|
+
@fpm.attributes[:rpm_user] = user
|
|
45
|
+
@fpm.attributes[:rpm_group] = group
|
|
46
|
+
|
|
47
|
+
# TODO
|
|
48
|
+
#@fpm.attributes[:rpm_defattrfile] = '-'
|
|
49
|
+
#@fpm.attributes[:rpm_defattrdir] = '-'
|
|
50
|
+
#@fpm.scripts[:rpm_verifyscript] =
|
|
51
|
+
#@fpm.scripts[:rpm_posttrans] =
|
|
52
|
+
#@fpm.scripts[:rpm_pretrans] =
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def build_inputs
|
|
56
|
+
srcdir.each do |src|
|
|
57
|
+
@fpm.attributes[:chdir] = src
|
|
58
|
+
@fpm.input '.'
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
if !srcrpm.nil? && srcrpm.size > 0
|
|
62
|
+
t = Time.now.to_i
|
|
63
|
+
tmp_dir = "/tmp/#{@name}_rpm_#{t.to_s}"
|
|
64
|
+
Dir.mkdir tmp_dir
|
|
65
|
+
|
|
66
|
+
srcrpm.each do |rpm|
|
|
67
|
+
rpm_data = rpm.split(/\//)
|
|
68
|
+
rpm_name = rpm_data.last
|
|
69
|
+
|
|
70
|
+
Dir.chdir(tmp_dir) do
|
|
71
|
+
open(rpm_name, "w") do |f|
|
|
72
|
+
c = Curl.get rpm
|
|
73
|
+
f.write c.body_str
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
fpm_rpm = FPM::Package::RPM.new
|
|
77
|
+
fpm_rpm.input rpm_name
|
|
78
|
+
|
|
79
|
+
@fpm.attributes[:chdir] = fpm_rpm.staging_path
|
|
80
|
+
@fpm.input '.'
|
|
81
|
+
|
|
82
|
+
File.delete rpm_name
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
Dir.delete tmp_dir
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# Copyright 2014 Ted Elwartowski <xelwarto.pub@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module FPM
|
|
16
|
+
module Scriptable
|
|
17
|
+
class Script
|
|
18
|
+
|
|
19
|
+
def self.attr_handler(*opts)
|
|
20
|
+
opts.each do |opt|
|
|
21
|
+
class_eval %Q{
|
|
22
|
+
def #{opt.to_s}(value=nil)
|
|
23
|
+
value.nil? ? @#{opt.to_s} : @#{opt.to_s} = value
|
|
24
|
+
end
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.attr_list_handler(*opts)
|
|
30
|
+
opts.each do |opt|
|
|
31
|
+
class_eval %Q{
|
|
32
|
+
def #{opt.to_s}(*list)
|
|
33
|
+
@#{opt.to_s} ||= []
|
|
34
|
+
@#{opt.to_s} << list
|
|
35
|
+
@#{opt.to_s}.flatten!
|
|
36
|
+
@#{opt.to_s}.uniq!
|
|
37
|
+
@#{opt.to_s}
|
|
38
|
+
end
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
attr_handler :name, :url, :version, :iteration, :description, :dstdir,
|
|
44
|
+
:category, :arch, :license, :epoch, :maintainer, :vendor,
|
|
45
|
+
:before_install, :after_install, :before_remove, :after_remove,
|
|
46
|
+
:overwrite, :workdir
|
|
47
|
+
|
|
48
|
+
attr_list_handler :depends, :conflicts, :provides, :replaces, :excludes, :srcdir
|
|
49
|
+
|
|
50
|
+
def initialize
|
|
51
|
+
@log = FPM::Scriptable::Log.instance
|
|
52
|
+
@config = FPM::Scriptable::Config.instance.config
|
|
53
|
+
c = FPM::Scriptable::Constants.instance
|
|
54
|
+
|
|
55
|
+
@log.debug 'FPM::Scriptable::RPM - initializing Script'
|
|
56
|
+
|
|
57
|
+
@version = c.script.version
|
|
58
|
+
@iteration = c.script.iteration
|
|
59
|
+
@description = c.script.description
|
|
60
|
+
@dstdir = c.script.dstdir
|
|
61
|
+
|
|
62
|
+
plugin_init
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def fpm_obj
|
|
66
|
+
@log.error 'fpm_obj method not implemented in plugin'
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def fpm_convert
|
|
70
|
+
@log.error 'fpm_convert method not implemented in plugin'
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def plugin_init
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def plugin_setup
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def build_inputs
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def create
|
|
83
|
+
begin
|
|
84
|
+
ENV['TMP'] = workdir if !workdir.nil?
|
|
85
|
+
|
|
86
|
+
@fpm = fpm_obj
|
|
87
|
+
|
|
88
|
+
@fpm.name = name
|
|
89
|
+
@fpm.url = url if !url.nil?
|
|
90
|
+
@fpm.version = version
|
|
91
|
+
@fpm.iteration = iteration
|
|
92
|
+
@fpm.category = category if !category.nil?
|
|
93
|
+
@fpm.description = description if !description.nil?
|
|
94
|
+
@fpm.architecture = arch if !arch.nil?
|
|
95
|
+
@fpm.license = license if !license.nil?
|
|
96
|
+
@fpm.epoch = epoch if !epoch.nil?
|
|
97
|
+
@fpm.maintainer = maintainer if !maintainer.nil?
|
|
98
|
+
@fpm.vendor = vendor if !vendor.nil?
|
|
99
|
+
|
|
100
|
+
@fpm.dependencies += depends
|
|
101
|
+
@fpm.conflicts += conflicts
|
|
102
|
+
@fpm.provides += provides
|
|
103
|
+
@fpm.replaces += replaces
|
|
104
|
+
|
|
105
|
+
@fpm.attributes[:excludes] = excludes
|
|
106
|
+
|
|
107
|
+
if !before_install.nil?
|
|
108
|
+
@fpm.scripts[:before_install] = expand_script(before_install)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if !after_install.nil?
|
|
112
|
+
@fpm.scripts[:after_install] = expand_script(after_install)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
if !before_remove.nil?
|
|
116
|
+
@fpm.scripts[:before_remove] = expand_script(before_remove)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
if !after_remove.nil?
|
|
120
|
+
@fpm.scripts[:after_remove] = expand_script(after_remove)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
plugin_setup
|
|
124
|
+
build_inputs
|
|
125
|
+
|
|
126
|
+
# TODO
|
|
127
|
+
#@fpm.config_files +=
|
|
128
|
+
#@fpm.directories +=
|
|
129
|
+
#@fom.attributes[:excludes]
|
|
130
|
+
rescue Exception => e
|
|
131
|
+
log.error "#{e}"
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
package = nil
|
|
135
|
+
begin
|
|
136
|
+
package = fpm_convert
|
|
137
|
+
|
|
138
|
+
if !package.nil?
|
|
139
|
+
Dir.chdir(@dstdir) do
|
|
140
|
+
if File.exists? package.to_s
|
|
141
|
+
if !overwrite.nil?
|
|
142
|
+
force = overwrite.to_s.downcase
|
|
143
|
+
if force == 'true'
|
|
144
|
+
@log.info "Overwrite enabled - Removing package: #{package.to_s}"
|
|
145
|
+
FileUtils.rm_f(package.to_s)
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
@log.info "Building package: #{package.to_s}"
|
|
151
|
+
package.output(package.to_s)
|
|
152
|
+
end
|
|
153
|
+
else
|
|
154
|
+
@log.error 'Failed to convert - Packaging object is invalid'
|
|
155
|
+
end
|
|
156
|
+
rescue Exception => e
|
|
157
|
+
log.error "#{e}"
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def env
|
|
163
|
+
@env ||= EnvHandler.new
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def log
|
|
167
|
+
@log
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def config
|
|
171
|
+
@config
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def self.build(&block)
|
|
175
|
+
self.new.instance_eval(&block)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def get_binding
|
|
179
|
+
binding
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
private
|
|
183
|
+
|
|
184
|
+
def expand_script(file=nil)
|
|
185
|
+
if !file.nil?
|
|
186
|
+
if File.exists? file
|
|
187
|
+
File.read file
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
class EnvHandler
|
|
194
|
+
|
|
195
|
+
def handler(name, *opts)
|
|
196
|
+
if !name.nil?
|
|
197
|
+
name = name.to_s
|
|
198
|
+
|
|
199
|
+
if name =~ /\=\z/
|
|
200
|
+
name.gsub! /\=/, ''
|
|
201
|
+
if opts.size == 1
|
|
202
|
+
name.upcase!
|
|
203
|
+
ENV[name] = opts.first
|
|
204
|
+
end
|
|
205
|
+
else
|
|
206
|
+
if ENV.has_key? name
|
|
207
|
+
ENV[name]
|
|
208
|
+
else
|
|
209
|
+
name.upcase!
|
|
210
|
+
if ENV.has_key? name
|
|
211
|
+
ENV[name]
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
alias method_missing handler
|
|
219
|
+
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Copyright 2014 Ted Elwartowski <xelwarto.pub@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module FPM
|
|
16
|
+
module Scriptable
|
|
17
|
+
class Util
|
|
18
|
+
|
|
19
|
+
def self.get_args
|
|
20
|
+
args = Hash.new
|
|
21
|
+
cur_argv = String.new
|
|
22
|
+
|
|
23
|
+
if ARGV.length > 0
|
|
24
|
+
ARGV.each do |x|
|
|
25
|
+
if x =~ /^-/
|
|
26
|
+
cur_argv = x.sub(/^-+/,'')
|
|
27
|
+
if cur_argv != ''
|
|
28
|
+
args[cur_argv.to_sym] = ''
|
|
29
|
+
end
|
|
30
|
+
else
|
|
31
|
+
if cur_argv != ''
|
|
32
|
+
if args[cur_argv.to_sym].instance_of? Array
|
|
33
|
+
args[cur_argv.to_sym].push x
|
|
34
|
+
else
|
|
35
|
+
if args[cur_argv.to_sym] != ''
|
|
36
|
+
cur_value = args[cur_argv.to_sym]
|
|
37
|
+
args[cur_argv.to_sym] = Array.new
|
|
38
|
+
args[cur_argv.to_sym].push cur_value
|
|
39
|
+
args[cur_argv.to_sym].push x
|
|
40
|
+
else
|
|
41
|
+
args[cur_argv.to_sym] = x
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
args
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.usage
|
|
53
|
+
usage = <<EOF
|
|
54
|
+
|
|
55
|
+
Usage:
|
|
56
|
+
#{$0} OPTIONS
|
|
57
|
+
|
|
58
|
+
Options:
|
|
59
|
+
--help Display this help screen
|
|
60
|
+
--quiet Messages are not displayed to the console
|
|
61
|
+
--nocolor Turn off colors in console output
|
|
62
|
+
--log_level <lvl> STDOUT log level (info, debug, error)
|
|
63
|
+
|
|
64
|
+
--script <file> Script to build
|
|
65
|
+
|
|
66
|
+
EOF
|
|
67
|
+
usage
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.banner
|
|
71
|
+
c = FPM::Scriptable::Constants.instance
|
|
72
|
+
banner = <<EOF
|
|
73
|
+
|
|
74
|
+
__ _ _ _ _
|
|
75
|
+
/ _|_ __ _ __ ___ ___ ___ _ __(_)_ __ | |_ __ _| |__ | | ___
|
|
76
|
+
| |_| '_ \\| '_ ` _ \\ _____/ __|/ __| '__| | '_ \\| __/ _` | '_ \\| |/ _ \\
|
|
77
|
+
| _| |_) | | | | | |_____\\__ \\ (__| | | | |_) | || (_| | |_) | | __/
|
|
78
|
+
|_| | .__/|_| |_| |_| |___/\\___|_| |_| .__/ \\__\\__,_|_.__/|_|\\___|
|
|
79
|
+
|_| |_|
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
#{c.name}
|
|
83
|
+
Version: #{c.version}
|
|
84
|
+
Author: #{c.author}
|
|
85
|
+
Website: #{c.website}
|
|
86
|
+
EOF
|
|
87
|
+
banner
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Copyright 2014 Ted Elwartowski <xelwarto.pub@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
module FPM
|
|
16
|
+
module Scriptable
|
|
17
|
+
NAME = 'fpm-scriptable'
|
|
18
|
+
VERSION = '1.0'
|
|
19
|
+
AUTHOR = 'Ted Elwartowski'
|
|
20
|
+
EMAIL = '<xelwarto.pub@gmail.com>'
|
|
21
|
+
WEBSITE = 'https://github.com/xelwarto/fpm-scriptable'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright 2014 Ted Elwartowski <xelwarto.pub@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
require 'rubygems'
|
|
16
|
+
require 'singleton'
|
|
17
|
+
require 'logger'
|
|
18
|
+
require 'fpm'
|
|
19
|
+
require 'curb'
|
|
20
|
+
|
|
21
|
+
require 'fpm/scriptable/version'
|
|
22
|
+
|
|
23
|
+
module FPM
|
|
24
|
+
module Scriptable
|
|
25
|
+
# Core classes
|
|
26
|
+
autoload :App, "fpm/scriptable/app"
|
|
27
|
+
autoload :Config, "fpm/scriptable/config"
|
|
28
|
+
autoload :Log, "fpm/scriptable/log"
|
|
29
|
+
autoload :Util, "fpm/scriptable/util"
|
|
30
|
+
autoload :Constants, "fpm/scriptable/constants"
|
|
31
|
+
autoload :Script, "fpm/scriptable/script"
|
|
32
|
+
|
|
33
|
+
# Package type plugins
|
|
34
|
+
autoload :RPM, "fpm/scriptable/plugin/rpm"
|
|
35
|
+
end
|
|
36
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: fpm-scriptable
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '1.0'
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ted Elwartowski
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-11-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: curb
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.8'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.8'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: fpm
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.3'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.3'
|
|
41
|
+
description: fpm-scriptable provides a simple and easy to use scripting interface
|
|
42
|
+
for creating software packages with fpm (https://github.com/jordansissel/fpm). Software
|
|
43
|
+
packages are created using easy to read scripts written in a simple DSL. Scripts
|
|
44
|
+
can easily be added to source code to ensure they are properly versioned.
|
|
45
|
+
email:
|
|
46
|
+
- "<xelwarto.pub@gmail.com>"
|
|
47
|
+
executables:
|
|
48
|
+
- fpm-script
|
|
49
|
+
extensions: []
|
|
50
|
+
extra_rdoc_files: []
|
|
51
|
+
files:
|
|
52
|
+
- LICENSE
|
|
53
|
+
- bin/fpm-script
|
|
54
|
+
- lib/fpm/scriptable.rb
|
|
55
|
+
- lib/fpm/scriptable/app.rb
|
|
56
|
+
- lib/fpm/scriptable/config.rb
|
|
57
|
+
- lib/fpm/scriptable/constants.rb
|
|
58
|
+
- lib/fpm/scriptable/log.rb
|
|
59
|
+
- lib/fpm/scriptable/plugin/rpm.rb
|
|
60
|
+
- lib/fpm/scriptable/script.rb
|
|
61
|
+
- lib/fpm/scriptable/util.rb
|
|
62
|
+
- lib/fpm/scriptable/version.rb
|
|
63
|
+
homepage: https://github.com/xelwarto/fpm-scriptable
|
|
64
|
+
licenses:
|
|
65
|
+
- Apache-2.0
|
|
66
|
+
metadata: {}
|
|
67
|
+
post_install_message:
|
|
68
|
+
rdoc_options: []
|
|
69
|
+
require_paths:
|
|
70
|
+
- lib
|
|
71
|
+
- lib
|
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0'
|
|
82
|
+
requirements: []
|
|
83
|
+
rubyforge_project:
|
|
84
|
+
rubygems_version: 2.2.2
|
|
85
|
+
signing_key:
|
|
86
|
+
specification_version: 4
|
|
87
|
+
summary: Scriptable software packaging using FPM
|
|
88
|
+
test_files: []
|