!/usr/bin/python3 import argparse import getopt import os import pprint import sys import yaml from pathlib import Path

sys.path.append(

os.path.abspath("/home/x/programming/ruby/src/rbt/lib/rbt/python/")

)

from help import * from e import * from misc import * from constants import *

# =========================================================================== # # === EXTRACT_INTO_THIS_DIRECTORY # =========================================================================== # EXTRACT_INTO_THIS_DIRECTORY = os.getenv(“MY_TEMP”)+“/”

# =========================================================================== # # === run_make # =========================================================================== # def run_make():

system('make')

# =========================================================================== # # === run_make_install # =========================================================================== # def run_make_install():

system('make install')

# =========================================================================== # # === aquamarine # =========================================================================== # def aquamarine(i):

newline();
e(aquamarine1_on_black_background+i+rev1)
newline();

# =========================================================================== # # === main_colour() # =========================================================================== # def main_colour(i):

aquamarine(i)

# =========================================================================== # # === extract_this_archive # =========================================================================== # def extract_this_archive(i):

if i.endswith('.tar.xz'):
  main_colour(
    rev1+"Now extracting "+sfancy+i+rev1+
    " into "+EXTRACT_INTO_THIS_DIRECTORY+
    rev1
  )
  cd(EXTRACT_INTO_THIS_DIRECTORY)
  # ======================================================================= #
  # Extract it next via "tar".
  # ======================================================================= #
  system('tar -xvf '+i)
  # ======================================================================= #
  # Obtain the real name of the directory next:
  # ======================================================================= #
  raw_name_of_the_directory = absolute_path(i)
  e(
    rev1+"Changing into the directory "+raw_name_of_the_directory
  )
  os.chdir(raw_name_of_the_directory)
  e("The current directory is: "+os.getcwd())
  aquamarine("./configure --prefix=/usr")
  system('./configure --prefix=/usr')
  main_colour("make")
  run_make()
  main_colour("make_install")
  run_make_install()
else:
  e(rev1+"Unhandled archive: "+sfancy+extract_this_archive+rev1)

# =========================================================================== # # The main logic starts here: # =========================================================================== # dataset = None

# pretty_print(sys.argv) # Use all but the first entry. menu(sys.argv)

this_yaml_file = COOKBOOKS_DIRECTORY+FIRST_ARGUMENT+‘.yml’

path = Path(this_yaml_file)

if path.is_file():

with open(this_yaml_file) as this_file:
  # The FullLoader parameter handles the conversion from YAML
  # scalar values to Python the dictionary format
  dataset = yaml.load(this_file, Loader = yaml.FullLoader)

# pp = pprint.PrettyPrinter(indent=4)
# pp.pprint(dataset)
# exit()

program_path = dataset[':program_path']

if Path(program_path).is_file():
  e(
    rev1+
    "The file exists at "+
    sfancy+
    program_path+rev1+'.'
  )
  # ======================================================================= #
  # Try to extract the archive here:
  # ======================================================================= #
  extract_this_archive(program_path)
else:
  e("No file exists at "+program_path)
# print(dataset) # For debugging.
# print(dataset['zlib']['blfs'][0])

else:

print("No file exists at "+this_yaml_file)

# compilepy zlib