class RBT::Linux::Slackware::CreateSlackwarePackage

Constants

ALSO_INSTALL_THE_PACKAGE
#

ALSO_INSTALL_THE_PACKAGE

#
BASIC_CONFIGURE_COMMAND
#

BASIC_CONFIGURE_COMMAND

#
NAMESPACE
#

NAMESPACE

#

Private Class Methods

[](i = '') click to toggle source
#

RBT::Linux::Slackware::CreateSlackwarePackage[]

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 463
def self.[](i = '')
  self.new(i)
end
new( name_of_the_program = Dir.pwd, run_already = true ) click to toggle source
#

initialize

The first argument is the name of the program.

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 65
def initialize(
    name_of_the_program = Dir.pwd, # By default we will obtain information from the current working directory.
    run_already         = true
  )
  reset
  set_name_of_the_program(
    name_of_the_program
  )
  if block_given?
    yielded = yielded
    case yielded
    when :do_not_autoinstall
      do_not_autoinstall
    end
  end
  run if run_already
end

Private Instance Methods

also_install_the_package?() click to toggle source
#

also_install_the_package?

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 241
def also_install_the_package?
  @also_install_the_package
end
assign_default_dataset( i = input? ) click to toggle source
#

assign_default_dataset

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 340
def assign_default_dataset(
    i = input?
  )
  if @use_cookbook_dataset
    @cookbook_dataset = RBT::Cookbooks::Cookbook.new(i) { :bypass_menu_check }
    set_program_version(@cookbook_dataset.program_version?)
  end
end
base_dir?()
Alias for: base_directory?
base_directory?() click to toggle source
#

base_directory?

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 194
def base_directory?
  @base_directory
end
Also aliased as: base_dir?
cd_into_install_subdirectory() click to toggle source
#

cd_into_install_subdirectory

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 161
def cd_into_install_subdirectory
  cd base_dir?+'install/'
end
check_against_menu_and_chop_away_double_hyphens(i) click to toggle source
#

check_against_menu_and_chop_away_double_hyphens (menu tag)

This is like a menu() call, but it also chops away some commandline instructions that include '–'.

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 355
def check_against_menu_and_chop_away_double_hyphens(i)
  case i # case tag
  # ======================================================================= #
  # === islackware --use-directory
  # ======================================================================= #
  when /^-?-?use(-|_)?directory$/i
    i = File.basename(Dir.pwd)
    @use_cookbook_dataset = false
    @use_directory = true
    set_program_name(ProgramInformation.return_name(i))
    use_this_version = ProgramInformation.return_version(i)
    set_program_version(use_this_version)
  # ======================================================================= #
  # === islackware --help
  # ======================================================================= #
  when /^-?-?help/
    show_help
    exit
  # ======================================================================= #
  # === islackware --do-not-install
  # ======================================================================= #
  when /(-?-?do-?not-?install)/,/(-?-?not?-?install)/
    _ = $1.to_s.dup
    i.gsub!(/#{_}/,'')
    do_not_autoinstall
    i = Dir.pwd # Must also overrule it in this case.
  end
  return i
end
configure_options?() click to toggle source
#

configure_options?

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 201
def configure_options?
  @cookbook_dataset.configure_options?
end
create_build_directory() click to toggle source
#

create_build_directory

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 187
def create_build_directory
  mkdir base_dir?
end
create_install_subdirectory() click to toggle source
#

create_install_subdirectory

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 168
def create_install_subdirectory
  _ = base_dir?+'install/'
  mkdir _
end
dataset?() click to toggle source
#

dataset?

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 126
def dataset?
  @cookbook_dataset
end
determine_base_directory() click to toggle source
#

determine_base_directory

The main base directory is at $MY_TEMP/build.

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 210
def determine_base_directory
  opnn; e 'Now determining the '+orange('@base_directory')+' variable.'
  @base_directory = convert_global_env(
    '$MY_TEMP/build/'+program_name_and_program_version+'/'
  ) # Should have a trailing '/' character.
end
do_install_the_package() click to toggle source
#

do_install_the_package

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 262
def do_install_the_package
  _ = @location_of_the_package
  if File.exist? _
    cd base_dir?
    opnn; e 'We will next install the package, from the path'
    opnn; e '  '+sfile(_)
    cmd = 'installpkg '+_
    esystem_gold(cmd)
  end
end
do_not_autoinstall() click to toggle source
#

do_not_autoinstall

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 255
def do_not_autoinstall
  @also_install_the_package = false
end
enter_base_directory() click to toggle source
#

enter_base_directory

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 147
def enter_base_directory
  cd @base_directory
end
generate_slack_desc_file_into_the_current_directory(i = input?) click to toggle source
#

generate_slack_desc_file_into_the_current_directory

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 154
def generate_slack_desc_file_into_the_current_directory(i = input?)
  RBT::GenerateSlackDescFile.new(i) { :use_short_name }
end
input?()
name_of_the_program?() click to toggle source
#

name_of_the_program?

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 118
def name_of_the_program?
  @name_of_the_program
end
Also aliased as: input?, program_name?
notify_the_user_how_to_install_this_package() click to toggle source
#

notify_the_user_how_to_install_this_package

Purpose of this method is to notify the user where the package can be found (and then installed via installpkg).

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 231
def notify_the_user_how_to_install_this_package
  opnn; e 'If you wish to install this package, you can use this command:'
  e
  e simp('  installpkg '+@location_of_the_package)
  e
end
notify_the_user_what_we_will_install_next() click to toggle source
#

notify_the_user_what_we_will_install_next

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 248
def notify_the_user_what_we_will_install_next
  opnn; e 'We will install the program `'+slateblue(input?)+'`.'
end
prefix?() click to toggle source
#

prefix?

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 405
def prefix?
  _ = @cookbook_dataset.prefix?.to_s if @use_cookbook_dataset
  # ======================================================================= #
  # The following condition is only true when we pass a certain
  # commandline flag to the class here.
  # ======================================================================= #
  if program_name?
    _ = programs_dir?+program_name?+'/'+program_version?
  end
  _
end
program_name?()
program_name_and_program_version() click to toggle source
#

program_name_and_program_version

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 140
def program_name_and_program_version
  program_name?+'-'+program_version?
end
program_version?() click to toggle source
#

program_version?

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 297
def program_version?
  @program_version
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 86
def reset
  super()
  @base_directory = nil
  @also_install_the_package = ALSO_INSTALL_THE_PACKAGE
  @program_name = nil
  @program_version = nil
  @use_cookbook_dataset = true
  @use_directory = false
  @namespace = NAMESPACE
end
run() click to toggle source
#

run

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 433
def run
  notify_the_user_what_we_will_install_next
  run_configure_command_into_the_inferred_prefix
  run_make_command # Run "make".
  determine_base_directory
  create_build_directory
  run_make_install_destdir_command
  # ======================================================================= #
  # Next we could run strip, but for now, we skip that.
  # ======================================================================= #
  strip_binaries
  create_install_subdirectory
  cd_into_install_subdirectory
  # ======================================================================= #
  # Next, we can generate the proper slack-desc file directly
  # into the current directory.
  # ======================================================================= #
  generate_slack_desc_file_into_the_current_directory
  enter_base_directory
  run_makepkg_command
  if also_install_the_package?
    do_install_the_package
  else
    notify_the_user_how_to_install_this_package
  end
end
run_configure_command_into_the_inferred_prefix() click to toggle source
#

run_configure_command_into_the_inferred_prefix

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 388
def run_configure_command_into_the_inferred_prefix
  if @use_directory or @use_cookbook_dataset
    _ = './configure --prefix='+prefix?
  else
    _ = './'+BASIC_CONFIGURE_COMMAND
  end
  _ = _.dup
  _.squeeze!(' ')
  if @use_cookbook_dataset
    _ << ' '+configure_options?
  end
  esystem_gold _
end
run_make_command() click to toggle source
#

run_make_command

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 133
def run_make_command
  RBT.colourized_make # Run "make" here.
end
run_make_install_destdir_command() click to toggle source
#

run_make_install_destdir_command

This will run a command such as:

make install DESTDIR=$MY_TEMP/build/grep-3.0
#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 179
def run_make_install_destdir_command
  _ = "make install DESTDIR=#{base_dir?}"
  esystem_gold _
end
run_makepkg_command() click to toggle source
#

run_makepkg_command

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 420
def run_makepkg_command
  # ======================================================================= #
  # The following code will essentially run slackware's "makepkg"
  # command.
  # ======================================================================= #
  @location_of_the_package = ::RBT.run_makepkg_command(
    program_name?, program_version?
  )
end
set_name_of_the_program(i) click to toggle source
#

set_name_of_the_program

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 304
def set_name_of_the_program(i)
  if i.is_a? Array
    if i.empty? # Handle empty Arrays first.
      i = File.basename(Dir.pwd)
    else
      i = i.join(' ').strip.squeeze(' ')
    end
  end
  i = Dir.pwd if i.nil? # Assign a safeguard here.
  i = i.to_s.dup
  # ========================================================================= #
  # Chop away on '--' parts.
  # ========================================================================= #
  if i.include? '--'
    # ======================================================================= #
    # === cpackage --do-not-install
    # ======================================================================= #
    i = check_against_menu_and_chop_away_double_hyphens(i)
  end
  if i.include? '/'
    i = File.basename(i)
  end
  if i.include? '-' # Then grab all but the last part, through ProgramInformation.
    # i = i.split('-').first
    i = ProgramInformation[i].first
  end
  @name_of_the_program = i
  if @use_cookbook_dataset
    @cookbook_dataset = ::RBT.cookbook(@name_of_the_program)
    assign_default_dataset
  end
end
set_program_name(i) click to toggle source
#

set_program_name

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 283
def set_program_name(i)
  @program_name = i.to_s.capitalize
end
set_program_version(i) click to toggle source
#

set_program_version

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 276
def set_program_version(i)
  @program_version = i
end
show_help() click to toggle source
#

show_help (help tag)

Show the help options for this class.

Invocation example:

islackware --help
#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 107
def show_help
  e
  e '  --do-not-install # Do not run the auto-installation part.'
  e '  --use-directory  # Use the current working directory as '\
    'base for input'
  e
end
strip_binaries() click to toggle source
#

strip_binaries

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 220
def strip_binaries
  _ = 'strip -s '+base_dir?+'usr/lib/* '+base_dir?+'usr/bin/*'
  esystem_gold _
end