class RBT::Linux::Gobolinux::CreateRecipe

Constants

USE_THIS_GOBOLINUX_COMPILE_VERSION
#

USE_THIS_GOBOLINUX_COMPILE_VERSION

Which gobolinux-compile version to use. Currently this is hardcoded.

On GoboLinux, we could probably determine the “Compile –version”.

#

Public Class Methods

new( i = ARGV, run_already = true ) { || ... } click to toggle source
#

initialize

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 57
def initialize(
    i           = ARGV,
    run_already = true
  )
  reset
  set_this_program(i)
  # ======================================================================= #
  # === Handle blocks given to this method next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # The following entry point means that we will store e. g. 'gtk' into
    # the subdirectory 'g/gtk'.
    # ===================================================================== #
    when :store_in_alphanumeric_subdirectory
      use_this_first_character = @this_program[0,1].dup
      @store_in_this_base_directory << use_this_first_character+'/'
    end
  end
  run if run_already
end

Public Instance Methods

add(i = N) click to toggle source
#

add

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 266
def add(i = N)
  @main_string << i
end
configure_options?() click to toggle source
#

configure_options?

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 332
def configure_options?
  @dataset.configure_options? # This appears to be a String.
end
Also aliased as: coptions?
consider_appending_more_stuff() click to toggle source
#

consider_appending_more_stuff

Add some more exceptions and so forth.

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 321
def consider_appending_more_stuff
  if coptions?.include? '--enable-udev'
    add 'with_udev=('+N
    add '  --enable-udev'+N
    add ')'
  end
end
coptions?()
Alias for: configure_options?
create_directory_skeleton() click to toggle source
#

create_directory_skeleton

This method will create the required directories and files to accomodate a gobolinux recipe.

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 357
def create_directory_skeleton
  _ = "#{temporary_base_dir?}#{name_of_the_program}-#{version?}/"
  mkdir _
  opnn; touch rds(_+'/Recipe'), :be_verbose
  mkdir rds(_+'/Resources/')
  opnn; touch rds(_+'/Resources/BuildDependencies'), :be_verbose
  opnn; touch rds(_+'/Resources/BuildInformation'), :be_verbose
  opnn; touch rds(_+'/Resources/Dependencies'), :be_verbose
  opnn; touch rds(_+'/Resources/Description'), :be_verbose
  opnn; touch rds(_+'/Resources/Environment'), :be_verbose # This one is rarely needed.
  populate_description_file
  populate_dependencies_file
  populate_recipe_file # Need to fill up the file "Recipe" here.
end
dataset?() click to toggle source
#

dataset?

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 191
def dataset?
  @dataset
end
dependencies?() click to toggle source
#

dependencies?

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 239
def dependencies?
  @dataset.required_deps_on? # This is assumed to return an Array.
end
description?() click to toggle source
#

description?

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 421
def description?
  _ = @dataset.description?.delete(N)
  _ = word_wrap(_, 68) # Condense the description a bit.
  return _
end
has_a_homepage_url?() click to toggle source
#

has_a_homepage_url?

Query whether the program has a registered homepage url.

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 407
def has_a_homepage_url?
  homepage_url?
end
homepage_url?() click to toggle source
#

homepage_url?

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 414
def homepage_url?
  @dataset.homepage?
end
licence?() click to toggle source
#

licence?

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 212
def licence?
  _ = @dataset.licence?.to_s
  # ======================================================================= #
  # GoboLinux uses a slightly different scheme, hence the following
  # line which acts as a corrective.
  # ======================================================================= #
  _ = 'GNU GPL 2' if _ == 'GPLv2'
  return _
end
Also aliased as: license?
license?()
Alias for: licence?
name_of_the_program()
Alias for: this_program?
notify_the_user_what_we_will_do() click to toggle source
#

notify_the_user_what_we_will_do

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 159
def notify_the_user_what_we_will_do
  _ = program?
  orev "We will next create a gobolinux-recipe for the "\
       "program #{simp(_)}#{rev}."
end
pad_with_quotes(i) click to toggle source
#

pad_with_quotes

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 246
def pad_with_quotes(i)
  unless i.include? '"'
    i = '"'+i+'"'
  end
  return i
end
path()
Alias for: path?
path?() click to toggle source
#

path?

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 198
def path?
  dataset?.program_path?
end
Also aliased as: path
populate_dependencies_file() click to toggle source
#

populate_dependencies_file

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 430
def populate_dependencies_file
  _ = ''.dup
  dependencies = dependencies?
  if dependencies
    dependencies.each {|dep|
      _ << dep+N
    }
    into = @store_in_this_base_directory+program_name_and_version+'/Resources/Dependencies'
    write_what_into(_, into)
  end
end
populate_description_file( i = program_name? ) click to toggle source
#

populate_description_file

This method will generate a (hopefully) valid GoboLinux Recipe description file. This file resides in the subdirectory Resources/ hierarchy.

For examples of such a file in use by GoboLinux, have a look at:

http://recipes.gobolinux.org/r/?list=LibDRM&ver=2.4.80-r1&file=Resources/Description
http://recipes.gobolinux.org/r/?list=ZzipLib&ver=0.13.58-r1&file=Resources/Description
#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 385
def populate_description_file(
    i = program_name?
  )
  _ = ''.dup
  _ << '[Name] '+return_gobolinux_name_for_this_program(i)+N # Unsure whether this line is needed - htop 2.0.x does not have it.
  _ << '[Summary] '+short_desc?+N
  _ << '[Description] '+description?.rstrip+N # .split(N).join(NEW_LINE_SEPARATOR+N)
  _ << '[License] '+license?+N
  if has_a_homepage_url?
    _ << '[Homepage] '+homepage_url?+N
  else # else we will simply use url2 instead
    _ << '[Homepage] '+url2+N
  end
  into = @store_in_this_base_directory+program_name_and_version+'/Resources/Description'
  write_what_into(_, into)
end
populate_recipe_file() click to toggle source
#

populate_recipe_file (recipe tag)

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 273
def populate_recipe_file
  add ''.dup
  # ======================================================================= #
  # First add the header to that particular recipe:
  # ======================================================================= #
  add '# Recipe for version '+return_version+', author email: '+email?+N
  add '# (autogenerated via the file create_recipe.rb)'+N
  add '# Recipe (MakeRecipe) for '+return_gobolinux_name+N+N
  add "compile_version=#{USE_THIS_GOBOLINUX_COMPILE_VERSION}#{N}"
  add 'url='+pad_with_quotes(url1)+N
  add 'file_size='+return_file_size.to_s+N
  add 'file_md5='+return_md5sum.to_s+N
  add 'recipe_type=configure'+N
  add return_symlink_options
  # ======================================================================= #
  # Next, if the configure options for the given program in question exist,
  # then we will batch-add them to the recipe file.
  # ======================================================================= #
  coptions = configure_options?
  unless coptions.empty? # Only when it is NOT empty, will we append it.
    add 'configure_options=('+N
    coptions.squeeze(' ').split(' ').each {|inner_coption|
      unless inner_coption.include? '--enable-udev'
        unless inner_coption.start_with? '--'
          inner_coption.prepend('--')
        end
        # ================================================================= #
        # Use udev-options a bit differently - see GoboLinux recipes
        # such as libdrm.
        # ================================================================= #
        add '  '+inner_coption+N
      end
    }
    add ')'+N
  end
  consider_appending_more_stuff
  into = @store_in_this_base_directory+program_name_and_version+'/Recipe'
  # ======================================================================= #
  # The main String was built up there.
  # ======================================================================= #
  write_what_into(@main_string, into)
end
program?()
Alias for: this_program?
program_name?()
Alias for: this_program?
program_name_and_version() click to toggle source
#

program_name_and_version

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 205
def program_name_and_version
  "#{name_of_the_program}-#{version?}"
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 84
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === @main_string
  # ======================================================================= #
  @main_string = ''.dup
  set_store_in_this_base_directory
end
return_file_size() click to toggle source
#

return_file_size

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 168
def return_file_size
  @dataset.file_size?
end
return_gobolinux_name(i = @this_program) click to toggle source
#

return_gobolinux_name

This method will return the GoboLinux name. It will make use of the class GobolinuxNamingConvention.

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 152
def return_gobolinux_name(i = @this_program)
  ::RBT.return_gobolinux_name(i)
end
return_gobolinux_name_for_this_program(i = @this_program)
return_md5sum(i = path) click to toggle source
#

return_md5sum

Here we need to keep in mind that the target path may not exist.

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 177
def return_md5sum(i = path)
  if File.exist? i
    result = `md5sum #{i}`.split(' ').first
    result.chomp
  else
    orev swarn('No target file at `')+sfile(i)+
         swarn('`. We will continue nonetheless.')
    '0' # Return 0 in this case.
  end
end
return_version()
Alias for: version?
run() click to toggle source
#

run

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 445
def run
  notify_the_user_what_we_will_do
  create_directory_skeleton
end
set_dataset(i = @this_program) click to toggle source
#

set_dataset

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 132
def set_dataset(i = @this_program)
  @dataset = action(:SanitizeCookbook, i) { :fast }
end
set_store_in_this_base_directory(i = Dir.pwd) click to toggle source
#

set_store_in_this_base_directory

This method will keep track as to where to store the recipe - the base directory.

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 107
def set_store_in_this_base_directory(i = Dir.pwd)
  i = i.dup if i.frozen?
  i << '/' unless i.end_with? '/'
  @store_in_this_base_directory = i
end
set_this_program(i) click to toggle source
#

set_this_program

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 116
def set_this_program(i)
  i = i.first if i.is_a? Array
  @this_program = i
  set_dataset
end
short_desc?() click to toggle source
#

short_desc?

Wrapper over the short_description of a program.

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 341
def short_desc?
  _ = @dataset.short_description?.to_s
  if _.size > 68
    _ = word_wrap(_, 68)
  end
  _.chomp!
  _.strip!
  return _
end
temporary_base_dir?() click to toggle source
#

temporary_base_dir?

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 97
def temporary_base_dir?
  @store_in_this_base_directory
end
this_program()
Alias for: this_program?
this_program?() click to toggle source
#

this_program?

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 139
def this_program?
  @this_program
end
url1() click to toggle source
#

url1

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 225
def url1
  @dataset.url1?.to_s
end
url2() click to toggle source
#

url2

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 232
def url2
  @dataset.url2?.to_s
end
version?() click to toggle source
#

version?

#
# File lib/rbt/linux/gobolinux/create_recipe.rb, line 125
def version?
  @dataset.program_version?
end
Also aliased as: return_version