setup-cockpit/notes.md

2.2 KiB

TODO:

Add condition management to put in yml file and to be passed to the relevant function. If condition is True, the function is allowed to run, otherwise the function is skipped.

requirements.txt

  • cli-ui -> build user interface in the terminal
  • colorama -> dependency of cli-ui
  • unidecode -> dependency of cli-ui
  • ruamel.yaml -> load and dump yaml with python
  • path -> create path objects (alternative to os.path)

bootstrap.sh

configs.yml

  • holds the symlinks, git clones and config writes

install.py

main()

  • parses args: undefined number of programs as a list
  • has a flag to overwrite (--force)
  • Installer is a class, --force flag is passed to constructor
  • runs Installer.install with the programs list

class Installer(force=False)

  • self.conf -> load configs.yml
  • self.this_dir = getcwd()
  • self.home = ~ (expanduser)
  • self.force = force
  • install():
    • if no program in list, programs are found in self.conf
    • for each program, run install_program(program)
  • install_program(program)
    • print program name
    • look up program conf and assign to todo variable
    • for each action in todo, call corresponding method
  • do_clone(url, dest, branch='master'):
    • create dirs for dest recursively
    • use subprocess to issue git clone command
  • do_copy(src, dest):
    • create dirs for dest recursively
    • copy a config file to dest
  • do_download(*, url, dest, executable=False):
    • create dirs for dest recursively
    • fetch url to dest
    • if it should be executable, chmod it to 755
  • do_run(args):
    • args is a list
    • from that list, create a command
    • subprocess.check_call(command)
  • do_symlink(src, dest):
    • if is_dir make tree from parent.parent
    • if not is_dir make tree from parent
    • if dest is a link, remove it
    • create the symlink
  • do_write(src, contents):
    • create path to src
    • format the content with self.this_dir and self.home
    • add newline at end
    • write to file