class RBT::Cookbooks::IncrementProgramVersion
Constants
- DEFAULT_PROGRAM
#¶ ↑
DEFAULT_PROGRAM
¶ ↑#¶ ↑
- TRY_TO_REPACKAGE_INTO_TAR_XZ_FORMAT
#¶ ↑
TRY_TO_REPACKAGE_INTO_TAR_XZ_FORMAT
¶ ↑If the following constant is true then incremented programs will be repackaged into .tar.xz, unless they are already in this format.
This constant is thus mostly a convenience setting, if you wish to keep archives in .tar.xz, which I do.
#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
Public Instance Methods
assign_url_to_dataset_url(use_this_dataset)
click to toggle source
check_for_incremented_remote_versions( i = url? )
click to toggle source
#¶ ↑
check_for_incremented_remote_versions
¶ ↑
This is the method that will check for the remote versions.
#¶ ↑
# File lib/rbt/utility_scripts/increment_program_version/increment_program_version.rb, line 101 def check_for_incremented_remote_versions( i = url? ) if i.nil? or i.empty? e rev+'No '+steelblue('url1')+rev+' entry could be found. '+ lightblue('Is the .yml file correct?') return end original_version = ProgramInformation.return_version(i) e "#{rev}The input-version was `#{sfancy(original_version)}#{rev}`." original_split = original_version.split('.') splitted = original_split # ======================================================================= # # === Minor Version Check # # First check for minor-version part. We must be careful here because # some programs use a version scheme such as "009", such as usbutils. # ======================================================================= # splitted_last_part = splitted.last if splitted_last_part if splitted_last_part.start_with? '0' new_number = splitted_last_part.to_i + 1 last_part = new_number.to_s.rjust(splitted_last_part.to_s.size,'0') else last_part = splitted_last_part.to_i + 1 # Increment the last part here. end else e "A #{steelblue('nil value')} occurred so something must have went wrong." pp splitted end splitted[-1] = last_part.to_s minor_increment = splitted.join('.') url_for_minor_version = i.gsub(/#{original_version}/, minor_increment) try_this_URL(url_for_minor_version) # ======================================================================= # # === Next query whether the remote file exists # # Up until November 2020, we always relied on "wget" for this, but # since as of the 09.11.2020, we will also allow the use of curl # instead of wget. The reason for this was that "wget --spider" does # not always seem to work reliably well. In fact, that was the # reason why support for "curl" was added. # # Wget will query whether the remote file exists or whether it does # not. # ======================================================================= # case @use_this_program_to_query_whether_the_remote_URL_exists # ======================================================================= # # === :wget # ======================================================================= # when :wget if Object.const_defined? :Wget does_it_exist = Wget.check_if_remote_file_exists(url_for_minor_version) if does_it_exist # Minor increment exist, download it. register_and_install_this_program(url_for_minor_version) else e rev+'There was '+seagreen('no minor release')+rev+ ' for `'+ sfancy(url_for_minor_version)+rev+ '`.' end else report_that_wget_is_missing_then_exit end # ======================================================================= # # === :curl # ======================================================================= # when :curl cmd = "curl -Is #{url_for_minor_version}" result = `#{cmd}` does_it_exist = false if result.include? "302 Found\r\n" does_it_exist = true end if does_it_exist # Minor increment exist, download it. register_and_install_this_program(url_for_minor_version) else e rev+'There was '+seagreen('no minor release')+rev+ ' for `'+ sfancy(url_for_minor_version)+rev+'`.' end end # ======================================================================= # # === Check the subversion next, which is simply a '.1' added. # # Since as of April 2023 this comes before the increment of the # outer version. The reason was to first test e. g. tumbler-4.18.1 # rather than tumbler-4.19.0 # ======================================================================= # splitted = (original_version+'.1').split('.') url_for_subversion = splitted.join('.') url_for_subversion = i.gsub(/#{original_version}/, url_for_subversion) try_this_URL(url_for_subversion) subversion_version_exists = Wget.check_if_remote_file_exists(url_for_subversion) if subversion_version_exists register_and_install_this_program(url_for_subversion) else e rev+'There was '+seagreen('no subversion release')+ rev+' release for '+sfancy(url_for_subversion)+rev+'.' end # ======================================================================= # # Check for another minor-version again. # ======================================================================= # last_part = splitted.last.to_i + 1 # Increment the last part here again. splitted[-1] = last_part.to_s minor_increment = splitted.join('.') url_for_minor_version = i.gsub(/#{original_version}/, minor_increment) try_this_URL(url_for_minor_version) # ======================================================================= # # === Query via Wget whether a remote file exists # ======================================================================= # if Object.const_defined? :Wget does_it_exist = Wget.check_if_remote_file_exists(url_for_minor_version) if does_it_exist # Minor increment exist, download it. register_and_install_this_program(url_for_minor_version) else e "#{rev}There was #{seagreen('no minor release')} #{rev}for `"\ "#{sfancy(url_for_minor_version)}#{rev}`." end else report_that_wget_is_missing_then_exit end # ======================================================================= # # === Middle Version Check # # Next check for the middle version part. # ======================================================================= # splitted = original_version.split('.') splitted[1] = (splitted[1].to_i + 1).to_s splitted[-1] = '0' # Last bit is 0. middle_increment = splitted.join('.') url_for_middle_version = i.gsub(/#{original_version}/, middle_increment) _ = "/#{original_split[0]}.#{original_split[1]}/" if url_for_middle_version.include? _ # Then apply a .gsub() url_for_middle_version.gsub!(/#{_}/,"/#{splitted[0]}.#{splitted[1]}/") end try_this_URL(url_for_middle_version) middle_version_exists = Wget.check_if_remote_file_exists(url_for_middle_version) if middle_version_exists register_and_install_this_program(url_for_middle_version) else e rev+'There was '+seagreen('no middle release')+ rev+' release for '+sfancy(url_for_middle_version)+rev+ '.' end # ======================================================================= # # === Major Version Check # # Next check for the middle version part. # ======================================================================= # splitted = original_version.split('.') splitted[0] = splitted[0].to_i + 1 splitted[1] = '0' # Middle bit is now 0 as well. splitted[-1] = '0' # Last bit is 0. major_increment = splitted.join('.') url_for_major_version = i.gsub(/#{original_version}/, major_increment) _ = "/#{original_split[0]}.#{original_split[1]}/" if url_for_major_version.include? _ # Then apply a .gsub() url_for_major_version.gsub!(/#{_}/,"/#{splitted[0]}.#{splitted[1]}/") end try_this_URL(url_for_major_version) major_version_exists = Wget.check_if_remote_file_exists(url_for_major_version) if major_version_exists register_and_install_this_program(url_for_major_version) else e "#{rev}There was #{seagreen('no major release')} #{rev}for "\ "#{sfancy(url_for_major_version)}#{rev}." end end
check_for_missing_homepage_entry()
click to toggle source
#¶ ↑
check_for_missing_homepage_entry
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/increment_program_version/increment_program_version.rb, line 306 def check_for_missing_homepage_entry homepage = @dataset.homepage?.to_s if homepage.empty? if is_on_roebe? # =================================================================== # # Only roebe-systems get the following extra notifications. # =================================================================== # e "#{rev}The program `#{sfancy(short_name?)}` #{rev}has no "\ "#{orange('homepage: entry')}#{rev}. Consider adding one." end end end
dataset?()
click to toggle source
determine_dataset( i = input? )
click to toggle source
determine_whether_the_program_exists_or_not()
click to toggle source
#¶ ↑
determine_whether_the_program_exists_or_not
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/increment_program_version/increment_program_version.rb, line 336 def determine_whether_the_program_exists_or_not _ = program_name? # ======================================================================= # # === try_to_update_this_program binutils # ======================================================================= # if RBT.does_include? _ e rev+'The program '+sfancy(_)+rev+ ' is included. '+ steelblue('This class can thus proceed. ')+ gold( cheering_ascii_person ) determine_dataset(_) assign_url_to_dataset_url(dataset?) check_for_incremented_remote_versions # Here we check for different remote versions. else e "The program #{sfancy(_)} is #{swarn('NOT')} included. "\ "Can not proceed." end end
exit_program()
click to toggle source
input?()
click to toggle source
#¶ ↑
input?¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/increment_program_version/increment_program_version.rb, line 92 def input? @input end
Also aliased as: program_name?
register_and_install_this_program( i, shall_we_exit = true )
click to toggle source
#¶ ↑
register_and_install_this_program
¶ ↑
This method will delegate into class RBT::UpdateEntry
for updating the specific program at hand.
#¶ ↑
# File lib/rbt/utility_scripts/increment_program_version/increment_program_version.rb, line 390 def register_and_install_this_program( i, shall_we_exit = true ) e "#{rev}We found a match towards the URL `#{simp(i)}#{rev}`." # ======================================================================= # # Delegate towards class Cookbooks::UpdateEntry in this case. # ======================================================================= # RBT::UpdateEntry.new(i) {{ repackage_into_tar_xz_format: @try_to_repackage_into_tar_xz_format }} exit_program if shall_we_exit end
report_that_wget_is_missing_then_exit()
click to toggle source
report_the_main_namespace()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
RBT::LeanPrototype#reset
# File lib/rbt/utility_scripts/increment_program_version/increment_program_version.rb, line 46 def reset super() infer_the_namespace # ======================================================================= # # === try_to_repackage_into_tar_xz_format # ======================================================================= # @try_to_repackage_into_tar_xz_format = TRY_TO_REPACKAGE_INTO_TAR_XZ_FORMAT # ======================================================================= # # === @use_this_program_to_query_whether_the_remote_URL_exists # # The following variable can be either :wget or :curl. Since as of # November 2020, the default is :curl. # ======================================================================= # @use_this_program_to_query_whether_the_remote_URL_exists = :curl try_to_require_wget end
run()
click to toggle source
set_input( i = DEFAULT_PROGRAM )
click to toggle source
#¶ ↑
set_input
¶ ↑
#¶ ↑
# File lib/rbt/utility_scripts/increment_program_version/increment_program_version.rb, line 66 def set_input( i = DEFAULT_PROGRAM ) i = i.first if i.is_a? Array if i.nil? # If the user did not provide any input-argument here. if return_pwd.include? archive_dir? i = Dir['*'].first # Just pick the first entry in this case. if i if i.include? '-' i = ProgramInformation.return_name(i) end else e 'There does not appear to be any file in that directory.' i = nil end else i = DEFAULT_PROGRAM end end i = i.to_s.dup.delete('-_').downcase @input = i end
short_name?()
click to toggle source
try_this_URL(this_URL)
click to toggle source