class Cookbooks::CreateEbuild

Constants

DEFAULT_PROGRAM
#

DEFAULT_PROGRAM

#
DIRECTORY_FOR_EBUILDS
#

DIRECTORY_FOR_EBUILDS

Where to store the ebuilds.

#
NAMESPACE
#

NAMESPACE

#
PORTAGE_BASE_DIRECTORY
#

PORTAGE_BASE_DIRECTORY

Where portage normally keeps an .ebuild file.

#

Public Class Methods

new( i = nil, run_already = true ) click to toggle source
#

initialize

The first argument should contain the dataset.

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 68
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_data(i)
  run if run_already
end

Public Instance Methods

data?() click to toggle source
#

data?

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 109
def data?
  @data
end
do_create_the_ebuild() click to toggle source
#

#do_create_the_ebuild

This method will create the specific .ebuild file in question.

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 141
  def do_create_the_ebuild
    license = ''.dup # empty at default
    license = data?.license? unless data?.license?.empty?
    # ======================================================================= #
    # Generate the main string next.
    # ======================================================================= #
    string = ''.dup
    string << 
'EAPI="5"

PYTHON_COMPAT=( python2_7 )

AUTOTOOLS_AUTORECONF=true

inherit autotools-utils linux-info python-any-r1

ARTS_REQUIRED="never"

MY_P="'+short_name?+'"

DESCRIPTION="'+data?.description?+'"

HOMEPAGE="'+url1?+'"
SRC_URI="'+url1?+'"
LICENSE="'+license+'"

SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="debug doc"
need-kde 3.5
S="${WORKDIR}/${MY_P}"

DEPEND="'+required_deps_on?+'"

RDEPEND="${DEPEND}
  x11-libs/qt-svg:4[debug?]"

src_compile () {
  mkdir build
  cd build
  cmake ..
  emake || die "emake failed"
}

src_install () {
  cd build
  emake DESTDIR=${D} install || die "emake install failed"
  dodoc ChangeLog README TODO
}
'
    write_what_into(string, store_where?) # Overwrite.
    opnn; e 'Created ebuild for '+program?+' at `'+sfile(store_where?)+'`.'
  end
guess_program_name() click to toggle source
#

#guess_program_name

This method will try to guess the program name.

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 232
def guess_program_name
  _ = data?.real_short_name?
  set_program_name(_)
end
notify_the_user_what_we_are_about_to_do() click to toggle source
#

#notify_the_user_what_we_are_about_to_do

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 219
def notify_the_user_what_we_are_about_to_do
  e
  cliner {
    opnn; e 'Now creating ebuild for '+sfancy(@program_name)+' in'
    opnn; e "  `#{sfile(store_where?)}`."
  }; e
end
opnn() click to toggle source
#

opnn

#
Calls superclass method Cookbooks::Base#opnn
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 240
def opnn
  super(NAMESPACE)
end
program?()
Alias for: program_name?
program_name?() click to toggle source
#

program_name?

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 212
def program_name?
  @program_name
end
Also aliased as: program?
required_deps_on?() click to toggle source
#

required_deps_on?

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 198
def required_deps_on?
  data?.required_deps_on?.to_s
end
reset() click to toggle source
#

reset

#
Calls superclass method Cookbooks::Base#reset
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 80
def reset
  super()
  set_program_name # Set to empty String.
end
run() click to toggle source
#

run

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 247
def run
  create_directory(DIRECTORY_FOR_EBUILDS)  # Create the basic ebuild directory.
  # ======================================================================= #
  # Next, consider creating the portage base directory.
  # Not everyone wants this though, so I have uncommented it for now.
  # ======================================================================= #
  # create_directory(PORTAGE_BASE_DIRECTORY)
  guess_program_name if program_name?.empty?
  notify_the_user_what_we_are_about_to_do
  do_create_the_ebuild
end
set_data(i = nil) click to toggle source
#

#set_data

The input should be a Hash.

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 90
def set_data(i = nil)
  i = DEFAULT_PROGRAM if i.nil?
  i = Cookbooks::Cookbook.new(i) { :bypass_menu }.dataset? if i.is_a? String
  if i.is_a? Array
    if i.empty? # Empty Arrays will be treated differently.
      i = Cookbooks::Cookbook.new(DEFAULT_PROGRAM) { :bypass_menu }.dataset?
    else
      i = i.join(' ')
    end
  end
  @data = i
  if @data.is_a? Hash
    set_program_name(@data['short_name'])
  end
end
set_program_name(i = '') click to toggle source
#

#set_program_name

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 116
def set_program_name(i = '')
  @program_name = i
end
short_name?() click to toggle source
#

short_name?

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 132
def short_name?
  data?.short_name?
end
store_where?() click to toggle source
#

store_where?

We could also store in the directory PORTAGE_BASE_DIRECTORY.

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 125
def store_where?
  DIRECTORY_FOR_EBUILDS+program_name?+'.ebuild'
end
url1?() click to toggle source
#

url1?

#
# File lib/cookbooks/utility_scripts/create_ebuild.rb, line 205
def url1?
  data?.url1?
end