rbt 0.16.12 → 0.16.13

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rbt might be problematic. Click here for more details.

@@ -12,6 +12,338 @@ class Action
12
12
 
13
13
  class SoftwareManager < RBT::Action # === RBT::Action::SoftwareManager
14
14
 
15
+ # ========================================================================= #
16
+ # === set_these_env_variables
17
+ #
18
+ # This method can be used to modify ENV variables.
19
+ #
20
+ # The first input argument to this method should be the Hash, consisting
21
+ # of the key-value pairs in the form of key being the NAME of the shell
22
+ # variable that is to be modified; and the corresponding value being
23
+ # the new VALUE that you wish to set this variable to.
24
+ #
25
+ # The third argument to this method determines whether we will output
26
+ # what we do to the user. By default this is true, but sometimes we
27
+ # may want to be able to quietly set these environment variables,
28
+ # such as when we attempt to use clang.
29
+ #
30
+ # Legitimate usage examples for this method, in ruby, would be:
31
+ #
32
+ # set_this_env_variable 'CFLAGS = -gcc'
33
+ # set_this_env_variable 'LIBS: -lpthread'
34
+ #
35
+ # ========================================================================= #
36
+ def set_these_env_variables(
37
+ hash_or_string, # We allow Hash and String as input. But String must be in a special format.
38
+ do_which_action = :report_only,
39
+ be_verbose = true,
40
+ &block
41
+ )
42
+ if block_given?
43
+ yielded = yield
44
+ if yielded.is_a? Symbol
45
+ do_which_action = yielded
46
+ end
47
+ end
48
+ unless @internal_hash[:do_not_use_special_flags]
49
+ case do_which_action
50
+ # ===================================================================== #
51
+ # === :be_quiet
52
+ # ===================================================================== #
53
+ when :be_quiet,
54
+ :be_silent
55
+ be_verbose = false
56
+ # =================================================================== #
57
+ # Also change the do_which_action variable.
58
+ # =================================================================== #
59
+ do_which_action = :do_set_these_variables
60
+ end
61
+ case be_verbose
62
+ # ===================================================================== #
63
+ # === :be_verbose
64
+ # ===================================================================== #
65
+ when :be_verbose
66
+ be_verbose = true
67
+ # ===================================================================== #
68
+ # === :be_quiet
69
+ # ===================================================================== #
70
+ when :be_quiet,
71
+ :be_silent
72
+ be_verbose = false
73
+ end
74
+ # ===================================================================== #
75
+ # === Next, handle Strings
76
+ # ===================================================================== #
77
+ if hash_or_string.is_a? String
78
+ if hash_or_string.include?('=') or
79
+ hash_or_string.include?(':')
80
+ if hash_or_string.include?('=')
81
+ use_this_as_split_token = '='
82
+ elsif hash_or_string.include?(':')
83
+ use_this_as_split_token = ':'
84
+ end
85
+ splitted = hash_or_string.sub(/^export /,'').split(use_this_as_split_token)
86
+ this_key = splitted.first
87
+ this_value = splitted.last
88
+ hash_or_string = { this_key => this_value }
89
+ end
90
+ end
91
+ # ===================================================================== #
92
+ # === Next, handle Hashes
93
+ # ===================================================================== #
94
+ hash_or_string.each_pair {|key, value|
95
+ value.strip! if value.is_a? String
96
+ # =================================================================== #
97
+ # Make some exceptions, e. g. for gems.
98
+ # =================================================================== #
99
+ return if cookbook_dataset_has_been_initialized? and is_a_gem?
100
+ if be_verbose and is_compiled? and !extract_only? and not value.to_s.empty?
101
+ # ================================================================== #
102
+ # Notify the user as to the env-value modification. Since as of
103
+ # November 2018 we will no longer use opnn() here.
104
+ # ================================================================== #
105
+ e " #{sfancy(key)} #{rev}will be set to the "\
106
+ "value(s): #{lightblue(value.to_s)}#{rev}"
107
+ end
108
+ if value.is_a? FalseClass or
109
+ value.is_a? TrueClass or
110
+ value.is_a? Integer
111
+ value = value.to_s
112
+ end
113
+ case do_which_action
114
+ when :do_set_these_variables
115
+ # ================================================================== #
116
+ # Next set the value to the environment variable.
117
+ # ================================================================== #
118
+ ENV[key] = value
119
+ end
120
+ }
121
+ end
122
+ end; alias set_this_env_variable set_these_env_variables # === set_this_env_variable
123
+
124
+ # ========================================================================= #
125
+ # === set_extracted_base_directory
126
+ # ========================================================================= #
127
+ def set_extracted_base_directory(i)
128
+ @internal_hash[:extracted_base_directory] = i
129
+ end
130
+
131
+ # ========================================================================= #
132
+ # === set_really_compile_this_program
133
+ # ========================================================================= #
134
+ def set_really_compile_this_program(i = :qt)
135
+ set_compile_this_program(i)
136
+ set_compile_these_programs(i) if compile_these_programs?.empty?
137
+ initialize_cookbook_dataset
138
+ end
139
+
140
+ # ========================================================================= #
141
+ # === set_user_prefix (set_prefix tag, set prefix tag)
142
+ #
143
+ # This method can be used by the user, to designate another prefix in
144
+ # use for the given program. This will be the target directory into
145
+ # which the program will be installed into.
146
+ #
147
+ # A specialized class, called RBT::Prefix, will handle the prefix.
148
+ # ========================================================================= #
149
+ def set_user_prefix(
150
+ i = :appdir_prefix
151
+ )
152
+ # ======================================================================= #
153
+ # We must rewrite the program version in the following case.
154
+ #
155
+ # The input may look like this:
156
+ #
157
+ # "/Programs/Gobjectintrospection/1.53.4/"
158
+ #
159
+ # ======================================================================= #
160
+ if i and use_this_specific_program_version?
161
+ if i.is_a?(String) and i.include?(programs_directory?)
162
+ use_this_regex = /(\d{1,2}\.?\d{1,2}\.?\d{1,2}\/)$/ # See: http://rubular.com/r/PPb2Y96XfF
163
+ i.sub!(use_this_regex, use_this_specific_program_version?)
164
+ i << '/' unless i.end_with? '/'
165
+ elsif i.is_a?(Symbol)
166
+ i = use_this_specific_program_version?
167
+ end
168
+ end
169
+ if i.is_a? Symbol
170
+ # ===================================================================== #
171
+ # Next, perform some sanitize operations.
172
+ #
173
+ # This clause will handle Symbols such as :app_dir_like or
174
+ # :use_ntrad_prefix_at_a_later_time.
175
+ # ===================================================================== #
176
+ case i.to_s # case tag
177
+ # ===================================================================== #
178
+ # === ULOCAL
179
+ #
180
+ # This refers to the commonly used /usr/local/ directory.
181
+ # ===================================================================== #
182
+ when 'ULOCAL'
183
+ i = '/usr/local/'
184
+ # ===================================================================== #
185
+ # === trad
186
+ # ===================================================================== #
187
+ when /^trad$/
188
+ i = '/usr/'
189
+ # ===================================================================== #
190
+ # === --opt_prefix
191
+ # ===================================================================== #
192
+ when /^-?-?opt(_|-)?prefix$/,
193
+ :opt
194
+ i = '/opt/'
195
+ # ===================================================================== #
196
+ # === non_traditional
197
+ #
198
+ # This entry point has various aliases such as :ntrad.
199
+ # ===================================================================== #
200
+ when /^app(_|-)?dir$/,
201
+ /^app(_|-)?dir(_|-)?like$/,
202
+ /^use(_|-)?appdir(_|-)?prefix$/i,
203
+ /^use(_|-)?ntrad(_|-)?prefix(_|-)?at(_|-)?a(_|-)?later(_|-)?time$/i,
204
+ 'non_traditional',
205
+ 'gobolinux',
206
+ 'ntrad',
207
+ 'default',
208
+ 'app_dir_like',
209
+ 'appdir',
210
+ 'return_appdir_path',
211
+ 'false',
212
+ 'f',
213
+ 'appdir_prefix',
214
+ ''
215
+ prefix?.clear_program # Clear it initially.
216
+ prefix?.do_use_appdir_prefix
217
+ if handle_which_program?
218
+ i = return_non_traditional_prefix(handle_which_program?)
219
+ end
220
+ # =================================================================== #
221
+ # Since as of May 2014 we get rid of all '-'
222
+ # =================================================================== #
223
+ i.delete!('-') if i.respond_to?(:include?) and i.include? '-'
224
+ end
225
+ # ===================================================================== #
226
+ # === Convert environment variables, if given, and unfreeze frozen
227
+ # Strings
228
+ # ===================================================================== #
229
+ if i.is_a?(String)
230
+ # =================================================================== #
231
+ # Unfreeze frozen Strings.
232
+ # =================================================================== #
233
+ if i.is_a? String and i.frozen?
234
+ i = i.dup # "unfreeze" it.
235
+ end
236
+ # =================================================================== #
237
+ # === Handle Strings that start with the ':' character
238
+ #
239
+ # Handle the situation when we input a String that starts with
240
+ # the character ':'. This will be assumed to be a shortcut to
241
+ # an environment variable.
242
+ # =================================================================== #
243
+ if i.start_with?(':')
244
+ # ================================================================== #
245
+ # Next, we must add the proper program_version. This is either the
246
+ # program_version at hand - or it is an ENV variable if it exists.
247
+ # We check for the ENV variable first.
248
+ # ================================================================== #
249
+ this_key = (i.delete(':').upcase+'_PREFIX').dup
250
+ if ENV.has_key? this_key
251
+ # =============================================================== #
252
+ # The environment variables must be UPCASED and have appended
253
+ # the string '_PREFIX'.
254
+ # =============================================================== #
255
+ i = ENV[this_key].dup.to_s
256
+ else
257
+ # =============================================================== #
258
+ # Assume a special prefix variant targetting the /Programs/
259
+ # hierarchy.
260
+ # =============================================================== #
261
+ i = programs_directory?+i.to_s.delete(':').capitalize+'/'
262
+ i << program_version?.dup.to_s
263
+ end
264
+ end
265
+ if i.include?('$')
266
+ i = convert_env_variable(i) # Replace ENV variables here.
267
+ i << '/' unless i.end_with? '/'
268
+ end
269
+ if i.include? '--'
270
+ if i.include? '--prefix=' # Input is assumed to be like '--prefix=/Depot/j'
271
+ i = i.split('=').last # ← Obtain just the last part in this case.
272
+ end
273
+ end
274
+ end
275
+ # ===================================================================== #
276
+ # === Ensure a trailing '/' for directories.
277
+ # ===================================================================== #
278
+ unless i.to_s.end_with? '/' # .to_s to protect against Symbols given.
279
+ i << '/' if File.directory?(i.to_s)
280
+ end
281
+ end
282
+ # ======================================================================= #
283
+ # Next, we must check for post-install actions and modify these,
284
+ # if they exist. We only do so if we have an AppDir-prefix.
285
+ # ======================================================================= #
286
+ if is_an_appdir_prefix?(i.to_s)
287
+ consider_modifying_postinstall
288
+ end
289
+ prefix_object?.use_this_as_the_new_prefix = i
290
+ end; alias set_use_this_prefix set_user_prefix # === set_use_this_prefix
291
+ alias prefix= set_user_prefix # === prefix=
292
+ alias set_prefix set_user_prefix # === set_prefix
293
+ alias set_prefix_to_use set_user_prefix # === set_prefix_to_use
294
+
295
+ # ========================================================================= #
296
+ # === set_cflags (cflags tag)
297
+ #
298
+ # This method will enable you to set i.e. new cflags. This then also
299
+ # allows you to compile some programs in a different manner, such as
300
+ # if you wish to compile that particular program statically.
301
+ #
302
+ # The default argument to this method will be a copy of ENV['CFLAGS'].
303
+ #
304
+ # You can overrule this via a shortcut, if you want to, by passing
305
+ # true as argument, or even better, a Symol such as :static. This
306
+ # will then allow you to perform the static build, if the program
307
+ # at hand allows for this.
308
+ #
309
+ # -static-libgcc may also be an option here.
310
+ #
311
+ # The variable LDFLAGS may be important as well.
312
+ #
313
+ # For instance:
314
+ #
315
+ # make LDFLAGS=-all-static
316
+ #
317
+ # ========================================================================= #
318
+ def set_cflags(
319
+ i = default_cflags?,
320
+ &block
321
+ )
322
+ case i # case tag
323
+ # ======================================================================= #
324
+ # === :clear
325
+ # ======================================================================= #
326
+ when :clear
327
+ i = ''
328
+ # ======================================================================= #
329
+ # Enable static builds for the CFLAGS at hand
330
+ # ======================================================================= #
331
+ when :overrule_static_build,
332
+ :static,
333
+ :build_static,
334
+ true
335
+ i = "#{old_cflags?} -static -g"
336
+ end
337
+ # ======================================================================= #
338
+ # Do the actual assignment next.
339
+ # ======================================================================= #
340
+ set_this_env_variable(
341
+ "CFLAGS: #{i}",
342
+ :do_set_these_variables,
343
+ &block
344
+ )
345
+ end
346
+
15
347
  # ========================================================================= #
16
348
  # === set_use_this_prefix
17
349
  #
@@ -64,6 +64,7 @@ class SoftwareManager < RBT::Action # === RBT::Action::SoftwareManager
64
64
  rescue LoadError; end
65
65
  end
66
66
 
67
+ require 'rbt/actions/individual_actions/software_manager/actions.rb'
67
68
  require 'rbt/actions/individual_actions/software_manager/initialize.rb'
68
69
  require 'rbt/actions/individual_actions/software_manager/extract_related_code.rb'
69
70
  require 'rbt/actions/individual_actions/software_manager/logic_related_code.rb'