class RBT::Linux::Slackware::CreateSlackwarePackage

Constants

ALSO_INSTALL_THE_PACKAGE
#

ALSO_INSTALL_THE_PACKAGE

#
BASIC_CONFIGURE_COMMAND
#

BASIC_CONFIGURE_COMMAND

#

Private Class Methods

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

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

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 492
def self.[](i = ARGV)
  new(i)
end
new( name_of_the_program = return_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 66
def initialize(
    name_of_the_program = return_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
  )
  # ======================================================================= #
  # === Handle blocks given to this class next:
  # ======================================================================= #
  if block_given?
    yielded = yielded
    case yielded
    # ===================================================================== #
    # === :do_not_autoinstall
    # ===================================================================== #
    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 263
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 362
def assign_default_dataset(
    i = input?
  )
  if @use_cookbook_dataset
    @cookbook_dataset = RBT::Cookbooks::SanitizeCookbook.new(i) { :fast }
    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 223
def base_directory?
  @internal_hash[: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 188
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 377
def check_against_menu_and_chop_away_double_hyphens(i)
  case i # case tag
  # ======================================================================= #
  # === islackware --use-directory
  # ======================================================================= #
  when /^-?-?use(-|_)?directory$/i
    i = File.basename(return_pwd)
    @use_cookbook_dataset = false
    @use_directory = true
    set_program_name(ProgramInformation.return_name(i))
    use_this_version = program_information_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 = return_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 427
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 216
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 195
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 151
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 232
def determine_base_directory
  opne "Now determining the #{orange(':base_directory')} variable."
  @internal_hash[: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 284
def do_install_the_package
  _ = @location_of_the_package
  if File.exist? _
    cd base_dir?
    opne 'We will next install the package, from the path'
    opne "  #{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 277
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 172
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 179
def generate_slack_desc_file_into_the_current_directory(
    i = input?
  )
  RBT::Linux::SlackwareGenerateSlackDescFile.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 143
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 253
def notify_the_user_how_to_install_this_package
  opne '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 270
def notify_the_user_what_we_will_install_next
  opne "We will install the program `#{slateblue(input?)}`."
end
prefix?() click to toggle source
#

prefix?

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 434
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 165
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 319
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 93
def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === :base_directory
  # ======================================================================= #
  @internal_hash[:base_directory] = nil
  # ======================================================================= #
  # === @also_install_the_package
  # ======================================================================= #
  @also_install_the_package = ALSO_INSTALL_THE_PACKAGE
  # ======================================================================= #
  # === @program_name
  # ======================================================================= #
  @program_name = nil
  # ======================================================================= #
  # === @program_version
  # ======================================================================= #
  @program_version = nil
  # ======================================================================= #
  # === @use_cookbook_dataset
  # ======================================================================= #
  @use_cookbook_dataset = true
  # ======================================================================= #
  # === @use_directory
  # ======================================================================= #
  @use_directory = false
end
run() click to toggle source
#

run

#
# File lib/rbt/linux/slackware/create_slackware_package.rb, line 462
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 410
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 158
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 208
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 449
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 326
def set_name_of_the_program(i)
  if i.is_a? Array
    if i.empty? # Handle empty Arrays first.
      i = File.basename(return_pwd)
    else
      i = i.join(' ').strip.squeeze(' ')
    end
  end
  i = return_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 305
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 298
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 132
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 242
def strip_binaries
  _ = "strip -s #{base_dir?}usr/lib/* #{base_dir?}usr/bin/*"
  esystem_gold _
end