example config done

This commit is contained in:
brent s. 2018-05-09 03:27:58 -04:00
parent 5182e8154b
commit 4dd03dea75
16 changed files with 183 additions and 6 deletions

10
TODO
View File

@ -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:

View File

@ -0,0 +1,3 @@
import jinja2
import os
import shutil

2
bdisk/GIT.py Normal file
View File

@ -0,0 +1,2 @@
import git
import os

View File

@ -0,0 +1 @@
import gpg

View File

@ -0,0 +1 @@
import OpenSSL

View File

@ -0,0 +1,3 @@
import os
import shutil
import subprocess

View File

@ -0,0 +1,3 @@
import os
import psutil
import subprocess

View File

@ -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

View File

@ -0,0 +1,3 @@
import copy
import importlib
import os

View File

@ -0,0 +1 @@
import GIT

1
bdisk/logger.py Normal file
View File

@ -0,0 +1 @@
import logging

View File

@ -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

View File

@ -0,0 +1,2 @@
import shutil
import subprocess

113
docs/examples/example.xml Normal file
View File

@ -0,0 +1,113 @@
<?xml version="1.0"?>
<bdisk>
<profile name="default" id="1" uuid="8cdd6bcb-c147-4a63-9779-b5433c510dbc">
<meta>
<names>
<name>BDisk</name>
<uxname>bdisk</uxname>
<pname><xpath-ref select="../name" /></pname>
</names>
<desc>A rescue/restore live environment.</desc>
<dev>
<author>A. Dev Eloper</author>
<email>dev@domain.tld</email>
<website>https://domain.tld/~dev</website>
</dev>
<uri>https://domain.tld/projname</uri>
<ver>1.0.0</ver>
<max_recurse>3</max_recurse>
</meta>
<accounts>
<!-- Salted/hashed password is "test" -->
<rootpass hashed="yes"
salt="sha512">
$6$7KfIdtHTcXwVrZAC$LZGNeMNz7v5o/cYuA48FAxtZynpIwO5B1CPGXnOW5kCTVpXVt4SypRqfM.AoKkFt/O7MZZ8ySXJmxpELKmdlF1
</rootpass>
<user sudo="yes">
<username>
<xpath-ref select="//meta/names/uxname" />
</username>
<!-- You can also use substitution from different profiles: -->
<!-- <username><xpath-ref select="//profile[@name='default']/meta/names/uxname" /></username> -->
<name>
<xpath-ref select="//meta/dev/author" />
</name>
<password hashed="no"
salt="none">
testpassword
</password>
</user>
</accounts>
<sources>
<source arch="x86_64">
<mirror>http://archlinux.mirror.domain.tld</mirror>
<webroot>/iso/latest</webroot>
<tarball flags="glob,latest">
<xpath-ref select="./mirror" />/<xpath-ref select="./webroot" />/archlinux-bootstrap-*-x86_64.tar.gz
</tarball>
<checksum hash="sha1">
<xpath-ref select="./mirror" />/<xpath-ref select="./webroot" />/sha1sums.txt
</checksum>
<sig keys="7F2D434B9741E8AC"
keyserver="hkp://pool.sks-keyservers.net">
<xpath-ref select="./tarball" />.sig
</sig>
</source>
<source arch="i686">
<mirror>http://archlinux32.mirror.domain.tld</mirror>
<webroot>/iso/latest</webroot>
<tarball flags="glob,latest">
<xpath-ref select="./mirror" />/<xpath-ref select="./webroot" />/archlinux-bootstrap-*-i686.tar.gz
</tarball>
<checksum hash="sha512">
<xpath-ref select="./mirror" />/<xpath-ref select="./webroot" />/sha512sums.txt
</checksum>
<sig keys="248BF41F9BDD61D41D060AE774EDA3C6B06D0506"
keyserver="hkp://pool.sks-keyservers.net">
<xpath-ref select="./tarball" />.sig
</sig>
</source>
</sources>
<build its_full_of_stars="yes">
<paths>
<cache>/var/tmp/<xpath-ref select="//meta/names/uxname" /></cache>
<chroot>/var/tmp/chroots/<xpath-ref select="//meta/names/uxname" /></chroot>
<templates>~/<xpath-ref select="//meta/names/uxname" />/templates</templates>
<mount>/mnt/<xpath-ref select="//meta/names/uxname" /></mount>
<distros>~/<xpath-ref select="//meta/names/uxname" />/distros</distros>
<dest>~/<xpath-ref select="//meta/names/uxname" />/results</dest>
<iso><xpath-ref select="./dest" />/iso</iso>
<http><xpath-ref select="./dest" />/http</http>
<tftp><xpath-ref select="./dest" />/tftp</tftp>
<ssl><xpath-ref select="./dest" />/pki</ssl>
</paths>
<basedistro>archlinux</basedistro>
<iso sign="yes" sync="yes" multiarch="yes" rsync="yes"/>
<ipxe sign="yes" sync="yes" iso="yes" rsync="yes">
<ssl>
<ca><xpath-ref select="build/paths/ssl" />/ca.crt</ca>
<ca_key><xpath-ref select="build/paths/ssl" />/ca.key</ca_key>
<crt>
<xpath-ref select="build/paths/ssl" />/<xpath-ref select="//meta/names/uxname" />.crt
</crt>
<key>
<xpath-ref select="build/paths/ssl" />/<xpath-ref select="//meta/names/uxname" />.key
</key>
</ssl>
<uri><xpath-ref select="meta/dev/website" />/ipxe</uri>
</ipxe>
<gpg keyid="none" gnupghome="none" publish="no" sync="yes" />
<sync>
<http enabled="yes" rsync="yes" />
<tftp enabled="yes" rsync="yes" />
<rsync enabled="yes">
<user>root</user>
<path>/srv/http/<xpath-ref select="//meta/names/uxname" /></path>
<host>mirror.domain.tld</host>
<port>22</port>
<pubkey>~/.ssh/id_ed25519</pubkey>
</rsync>
</sync>
</build>
</profile>
</bdisk>

View File

@ -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 '