class RBT::Cookbooks::CreateEbuild

Constants

DEFAULT_PROGRAM
#

DEFAULT_PROGRAM

#
DIRECTORY_FOR_EBUILDS
#

DIRECTORY_FOR_EBUILDS

Where to store the ebuilds.

#
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/rbt/linux/gentoo/create_ebuild.rb, line 65
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/rbt/linux/gentoo/create_ebuild.rb, line 107
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/rbt/linux/gentoo/create_ebuild.rb, line 146
  def do_create_the_ebuild
    license = ''.dup # empty at default
    license = licence? unless licence?.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="'+homepage?.to_s+'"
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.
    opne "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/rbt/linux/gentoo/create_ebuild.rb, line 237
def guess_program_name
  _ = data?.short_name?
  set_program_name(_)
end
homepage?() click to toggle source
#

homepage?

#
# File lib/rbt/linux/gentoo/create_ebuild.rb, line 217
def homepage?
  data?.homepage?
end
is_on_gentoo?() click to toggle source
#

is_on_gentoo?

#
# File lib/rbt/linux/gentoo/create_ebuild.rb, line 245
def is_on_gentoo?
  false # <- May have to be changed one day (Sep 2018).
end
licence?()
Alias for: license?
license?() click to toggle source
#

license?

#
# File lib/rbt/linux/gentoo/create_ebuild.rb, line 137
def license?
  data?.license?
end
Also aliased as: licence?
notify_the_user_what_we_are_about_to_do() click to toggle source
#

notify_the_user_what_we_are_about_to_do

#
# File lib/rbt/linux/gentoo/create_ebuild.rb, line 224
def notify_the_user_what_we_are_about_to_do
  e
  cliner {
    opne 'Now creating ebuild for '+sfancy(@program_name)+' in'
    opne "  `#{sfile(store_where?)}`."
  }; e
end
program?()
Alias for: program_name?
program_name?() click to toggle source
#

program_name?

#
# File lib/rbt/linux/gentoo/create_ebuild.rb, line 252
def program_name?
  @program_name
end
Also aliased as: program?
required_deps_on?() click to toggle source
#

required_deps_on?

#
# File lib/rbt/linux/gentoo/create_ebuild.rb, line 203
def required_deps_on?
  data?.required_deps_on?.to_s
end
reset() click to toggle source
#

reset

#
Calls superclass method RBT::Base#reset
# File lib/rbt/linux/gentoo/create_ebuild.rb, line 77
def reset
  super()
  infer_the_namespace
  set_program_name # Set to empty String.
end
run() click to toggle source
#

run

#
# File lib/rbt/linux/gentoo/create_ebuild.rb, line 259
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 -
  # or rather, it uses a "is_on_gentoo?" check, which currently will
  # always return false.
  # ======================================================================= #
  if is_on_gentoo?
    create_directory(PORTAGE_BASE_DIRECTORY) unless File.directory? PORTAGE_BASE_DIRECTORY
  end
  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/rbt/linux/gentoo/create_ebuild.rb, line 88
def set_data(i = nil)
  i = DEFAULT_PROGRAM if i.nil?
  i = RBT::Cookbooks::SanitizeCookbook.new(i).dataset? if i.is_a? String
  if i.is_a? Array
    if i.empty? # Empty Arrays will be treated differently.
      i = RBT::Cookbooks::SanitizeCookbook.new(DEFAULT_PROGRAM).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/rbt/linux/gentoo/create_ebuild.rb, line 114
def set_program_name(i = '')
  @program_name = i
end
short_name?() click to toggle source
#

short_name?

#
# File lib/rbt/linux/gentoo/create_ebuild.rb, line 130
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/rbt/linux/gentoo/create_ebuild.rb, line 123
def store_where?
  DIRECTORY_FOR_EBUILDS+program_name?+'.ebuild'
end
url1?() click to toggle source
#

url1?

#
# File lib/rbt/linux/gentoo/create_ebuild.rb, line 210
def url1?
  data?.url1?
end