From 4dd03dea75fd0fa28611ffdbf0697bdfbd2bacab Mon Sep 17 00:00:00 2001 From: r00t Date: Wed, 9 May 2018 03:27:58 -0400 Subject: [PATCH] example config done --- TODO | 10 +++- bdisk/BIOS.py | 3 + bdisk/GIT.py | 2 + bdisk/GPG.py | 1 + bdisk/SSL.py | 1 + bdisk/UEFI.py | 3 + bdisk/chroot.py | 3 + bdisk/confparse.py | 29 ++++++++++ bdisk/env_prep.py | 3 + bdisk/{git.py => fetch.py} | 0 bdisk/iPXE.py | 1 + bdisk/logger.py | 1 + bdisk/main.py | 13 ++++- bdisk/sync.py | 2 + docs/examples/example.xml | 113 +++++++++++++++++++++++++++++++++++++ setup.py | 4 -- 16 files changed, 183 insertions(+), 6 deletions(-) create mode 100644 bdisk/GIT.py rename bdisk/{git.py => fetch.py} (100%) create mode 100644 bdisk/logger.py create mode 100644 docs/examples/example.xml diff --git a/TODO b/TODO index 7f0e725..f4947e4 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,13 @@ - write classes/functions -- support XML and legacy build.ini (warn to STDERR for build.ini) +- XML-based config +- ensure we use docstrings in a Sphinx-compatible manner. + https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html + +- package for PyPI: +# https://packaging.python.org/tutorials/distributing-packages/ +# https://docs.python.org/3/distutils/apiref.html +# https://python-packaging.readthedocs.io/en/latest/minimal.html +# https://setuptools.readthedocs.io/en/latest/setuptools.html#new-and-changed-setup-keywords BUGS.SQUARE-R00T.NET bugs/tasks: diff --git a/bdisk/BIOS.py b/bdisk/BIOS.py index e69de29..012fb51 100644 --- a/bdisk/BIOS.py +++ b/bdisk/BIOS.py @@ -0,0 +1,3 @@ +import jinja2 +import os +import shutil diff --git a/bdisk/GIT.py b/bdisk/GIT.py new file mode 100644 index 0000000..2da5906 --- /dev/null +++ b/bdisk/GIT.py @@ -0,0 +1,2 @@ +import git +import os diff --git a/bdisk/GPG.py b/bdisk/GPG.py index e69de29..4c3cbfc 100644 --- a/bdisk/GPG.py +++ b/bdisk/GPG.py @@ -0,0 +1 @@ +import gpg diff --git a/bdisk/SSL.py b/bdisk/SSL.py index e69de29..df36961 100644 --- a/bdisk/SSL.py +++ b/bdisk/SSL.py @@ -0,0 +1 @@ +import OpenSSL diff --git a/bdisk/UEFI.py b/bdisk/UEFI.py index e69de29..b0039b0 100644 --- a/bdisk/UEFI.py +++ b/bdisk/UEFI.py @@ -0,0 +1,3 @@ +import os +import shutil +import subprocess diff --git a/bdisk/chroot.py b/bdisk/chroot.py index e69de29..d81f638 100644 --- a/bdisk/chroot.py +++ b/bdisk/chroot.py @@ -0,0 +1,3 @@ +import os +import psutil +import subprocess diff --git a/bdisk/confparse.py b/bdisk/confparse.py index e69de29..9f83931 100644 --- a/bdisk/confparse.py +++ b/bdisk/confparse.py @@ -0,0 +1,29 @@ +import validators +from urllib.parse import urlparse +try: + from lxml import etree + has_lxml = True +except ImportError: + import xml.etree.ElementTree as etree + has_lxml = False + +"""Read a configuration file, parse it, and make it available to the rest of +BDisk.""" + +class Conf(object): + def __init__(self, cfg, profile = None, id_type = 'name'): + """Conf classes accept the following parameters: + cfg - The configuration. Can be a filesystem path, a string, bytes, + or a stream + + profile (optional) - A sub-profile in the configuration. If None is + provided, we'll first look for a profile named + 'default'. If one isn't found, then the first + profile found will be used + id_type (optional) - The type of identifer to use for profile=. + Valid values are: + + id + name + uuid""" + pass diff --git a/bdisk/env_prep.py b/bdisk/env_prep.py index e69de29..5dcac35 100644 --- a/bdisk/env_prep.py +++ b/bdisk/env_prep.py @@ -0,0 +1,3 @@ +import copy +import importlib +import os diff --git a/bdisk/git.py b/bdisk/fetch.py similarity index 100% rename from bdisk/git.py rename to bdisk/fetch.py diff --git a/bdisk/iPXE.py b/bdisk/iPXE.py index e69de29..fc1c561 100644 --- a/bdisk/iPXE.py +++ b/bdisk/iPXE.py @@ -0,0 +1 @@ +import GIT diff --git a/bdisk/logger.py b/bdisk/logger.py new file mode 100644 index 0000000..ade1461 --- /dev/null +++ b/bdisk/logger.py @@ -0,0 +1 @@ +import logging diff --git a/bdisk/main.py b/bdisk/main.py index 29287f1..182dd28 100644 --- a/bdisk/main.py +++ b/bdisk/main.py @@ -1,4 +1,15 @@ #!/usr/bin/env python3.6 -def main(): +import argparse + +"""The primary user interface for BDisk. If we are running interactively, +parse arguments first, then initiate a BDisk session.""" + +def parseArgs(): + pass + +def run(): + pass + +def run_interactive(): pass diff --git a/bdisk/sync.py b/bdisk/sync.py index e69de29..eea520b 100644 --- a/bdisk/sync.py +++ b/bdisk/sync.py @@ -0,0 +1,2 @@ +import shutil +import subprocess diff --git a/docs/examples/example.xml b/docs/examples/example.xml new file mode 100644 index 0000000..9558d13 --- /dev/null +++ b/docs/examples/example.xml @@ -0,0 +1,113 @@ + + + + + + BDisk + bdisk + + + A rescue/restore live environment. + + A. Dev Eloper + dev@domain.tld + https://domain.tld/~dev + + https://domain.tld/projname + 1.0.0 + 3 + + + + + $6$7KfIdtHTcXwVrZAC$LZGNeMNz7v5o/cYuA48FAxtZynpIwO5B1CPGXnOW5kCTVpXVt4SypRqfM.AoKkFt/O7MZZ8ySXJmxpELKmdlF1 + + + + + + + + + + + + testpassword + + + + + + http://archlinux.mirror.domain.tld + /iso/latest + + //archlinux-bootstrap-*-x86_64.tar.gz + + + //sha1sums.txt + + + .sig + + + + http://archlinux32.mirror.domain.tld + /iso/latest + + //archlinux-bootstrap-*-i686.tar.gz + + + //sha512sums.txt + + + .sig + + + + + + /var/tmp/ + /var/tmp/chroots/ + ~//templates + /mnt/ + ~//distros + ~//results + /iso + /http + /tftp + /pki + + archlinux + + + + /ca.crt + /ca.key + + /.crt + + + /.key + + + /ipxe + + + + + + + root + /srv/http/ + mirror.domain.tld + 22 + ~/.ssh/id_ed25519 + + + + + diff --git a/setup.py b/setup.py index 791c90f..40e0f21 100644 --- a/setup.py +++ b/setup.py @@ -2,10 +2,6 @@ from setuptools import setup import version -# https://packaging.python.org/tutorials/distributing-packages/ -# https://docs.python.org/3/distutils/apiref.html -# https://python-packaging.readthedocs.io/en/latest/minimal.html -# https://setuptools.readthedocs.io/en/latest/setuptools.html#new-and-changed-setup-keywords setup(name = 'bdisk', version = version.BDISK_VERSION, description = ('An easy liveCD creator built in python. Supports hybrid '