├── setup.py ├── autoinstall_generator ├── version.py ├── tests │ ├── __init__.py │ ├── data │ │ ├── simple.txt │ │ ├── identity.yaml │ │ ├── preseed2autoinstall.yaml │ │ ├── autoinstall.yaml │ │ ├── preseed2autoinstall_debug.yaml │ │ ├── example-preseed.txt │ │ └── preseed.txt │ ├── test_util.py │ ├── test_yaml.py │ ├── test_reader.py │ ├── test_merge.py │ └── test_basic.py ├── __init__.py ├── cmd │ ├── autoinstall-generator.py │ └── tests │ │ └── test_invoke.py ├── merging.py ├── convert.py └── autoinstall-schema.json ├── MANIFEST.in ├── pyproject.toml ├── renovate.json ├── .gitignore ├── test ├── lp-1926292-unicode.cfg └── identity-no-hostname.cfg ├── tox.ini ├── scripts └── integration-test.sh ├── setup.cfg ├── .github └── workflows │ └── python-package.yml ├── README.md ├── Makefile ├── snapcraft.yaml └── LICENSE /setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | setuptools.setup() 3 | -------------------------------------------------------------------------------- /autoinstall_generator/version.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.1.2' 2 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include autoinstall_generator/autoinstall-schema.json 2 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/__init__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.append('../convert') 3 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/data/simple.txt: -------------------------------------------------------------------------------- 1 | d-i debian-installer/locale string en_US 2 | -------------------------------------------------------------------------------- /autoinstall_generator/__init__.py: -------------------------------------------------------------------------------- 1 | from .version import __version__ # noqa: F401 # flake8 false positive unused 2 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools", "wheel"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .tox 2 | .pytest_cache 3 | __pycache__ 4 | *.pyc 5 | *.egg-info 6 | build 7 | dist 8 | .coverage 9 | .tags 10 | *.snap 11 | README.html 12 | -------------------------------------------------------------------------------- /test/lp-1926292-unicode.cfg: -------------------------------------------------------------------------------- 1 | # The following line contains a non-ascii apostrophe, which requires 2 | # utf-8 input reader encoding. 3 | # if you don’t want it, you can set this to "false" to turn it off. 4 | -------------------------------------------------------------------------------- /test/identity-no-hostname.cfg: -------------------------------------------------------------------------------- 1 | d-i passwd/user-fullname string Ubuntu User 2 | d-i passwd/username string ubuntu 3 | # d-i passwd/user-password password ubuntu 4 | d-i passwd/user-password-crypted password [crypt(3) hash] 5 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/data/identity.yaml: -------------------------------------------------------------------------------- 1 | identity: 2 | hostname: ubuntu 3 | password: $6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1 4 | realname: '' 5 | username: ubuntu 6 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = lint, test 3 | isolated_build = True 4 | 5 | [testenv:lint] 6 | deps = flake8 7 | commands = flake8 8 | 9 | [testenv:test] 10 | basepython = python3 11 | deps = 12 | jsonschema 13 | pytest 14 | pytest-cov 15 | pyyaml 16 | commands = pytest --cov autoinstall_generator --cov-report term-missing -vv autoinstall_generator 17 | -------------------------------------------------------------------------------- /scripts/integration-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | make readme 6 | diff -u README.md README.md.tmp 7 | 8 | make build 9 | [ -f build/lib/autoinstall_generator/autoinstall-schema.json ] 10 | 11 | invoke() { 12 | PYTHONPATH=$(realpath .) \ 13 | autoinstall_generator/cmd/autoinstall-generator.py "$@" 14 | } 15 | 16 | for cfg in test/* ; do 17 | invoke -cd $cfg 18 | invoke -cd - < $cfg 19 | done 20 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/data/preseed2autoinstall.yaml: -------------------------------------------------------------------------------- 1 | apt: 2 | primary: 3 | - arches: 4 | - default 5 | uri: http://http.us.debian.org/debian 6 | debconf-selections: | 7 | pkg-a pkg-a/my-q boolean false 8 | pkg-b pkg-a/my-other-q boolean true 9 | keyboard: 10 | layout: us 11 | locale: en_GB.UTF-8 12 | network: 13 | ethernets: 14 | any: 15 | addresses: 16 | - 192.168.1.42/24 17 | gateway4: 192.168.1.1 18 | match: 19 | name: en* 20 | nameservers: 21 | addresses: 22 | - 192.168.1.1 23 | version: 2 24 | storage: 25 | layout: 26 | name: lvm 27 | version: 1 28 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = autoinstall_generator 3 | license = AGPL3+ 4 | classifiers = 5 | Programming Language :: Python :: 3 6 | License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+) 7 | Operating System :: OS Independent 8 | author = Canonical Engineering 9 | author_email = ubuntu-dev@lists.ubuntu.com 10 | version = attr: autoinstall_generator.__version__ 11 | 12 | [options] 13 | packages = autoinstall_generator 14 | include_package_data = True 15 | install_requires = 16 | jsonschema 17 | pyyaml 18 | scripts = 19 | autoinstall_generator/cmd/autoinstall-generator.py 20 | 21 | [options.package_data] 22 | autoinstall_generator = 23 | autoinstall-schema.json 24 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/test_util.py: -------------------------------------------------------------------------------- 1 | 2 | from autoinstall_generator.convert import is_multiline, prefixify 3 | 4 | 5 | def test_is_multiline(): 6 | assert is_multiline('a\nb\nc\n') 7 | assert is_multiline('a\nb\n') 8 | assert not is_multiline('a\n') 9 | 10 | 11 | def test_commentize(): 12 | data = 'a\nb\nc\n' 13 | expected = '# a\n# b\n# c\n' 14 | assert expected == prefixify(data) 15 | 16 | 17 | def test_prefixify(): 18 | data = 'a\nb\nc\n' 19 | expected = '//a\n//b\n//c\n' 20 | assert expected == prefixify(data, '//') 21 | 22 | 23 | def test_first_prefixify(): 24 | data = 'a\nb\nc\n' 25 | expected = '// a\n b\n c\n' 26 | assert expected == prefixify(data, ' ', '// ') 27 | -------------------------------------------------------------------------------- /.github/workflows/python-package.yml: -------------------------------------------------------------------------------- 1 | # This workflow will install Python dependencies, run tests and lint with a 2 | # variety of Python versions For more information see: 3 | # https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 4 | 5 | name: Python package 6 | 7 | on: 8 | push: 9 | branches: [ main ] 10 | pull_request: 11 | branches: [ main ] 12 | 13 | jobs: 14 | build: 15 | 16 | runs-on: ubuntu-18.04 17 | strategy: 18 | matrix: 19 | python-version: [3.6, 3.7, 3.8, 3.9] 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | - name: Set up Python ${{ matrix.python-version }} 24 | uses: actions/setup-python@v2 25 | with: 26 | python-version: ${{ matrix.python-version }} 27 | - name: Install Tox and any other packages 28 | run: pip install tox pyyaml jsonschema setuptools wheel 29 | - name: Run linter 30 | run: tox -e lint 31 | - name: Run tests 32 | run: tox -e test 33 | - name: Run integration 34 | run: ./scripts/integration-test.sh 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # autoinstall-generator 3 | 4 | [![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/autoinstall-generator) 5 | 6 | Objective: Ingest Debian preseed format file(s), and provide compatible 7 | Subiquity autoinstall in response. 8 | 9 | Project Status: First public release. Some basic support is present but there 10 | is room for improvement. Several directive types have only partial support, 11 | including network. Partition handling is very basic and only identifies 'lvm' 12 | or 'normal' types. Pre/post command support not yet handled. Multiline 13 | directives not yet supported. Input files must be utf-8. 14 | 15 | ## Usage 16 | 17 | usage: autoinstall-generator.py [-h] [-c] [-d] [-V] infile [outfile] 18 | 19 | positional arguments: 20 | infile Debian install preseed file, or a dash to read stdin 21 | outfile Subiquity autoinstall yaml 22 | 23 | optional arguments: 24 | -h, --help show this help message and exit 25 | -c, --cloud output in cloud-config format 26 | -d, --debug include commented out debug output explaining the conversions 27 | performed 28 | -V, --version show version and exit 29 | 30 | ## Feedback 31 | 32 | Please direct bugs and feature requests to the project on 33 | [Launchpad](https://bugs.launchpad.net/autoinstall-generator/+filebug). 34 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: all 3 | 4 | all: check build 5 | 6 | new: clean all 7 | 8 | install_deps: 9 | sudo apt install tox python3-testresources python3-setuptools 10 | 11 | clean: 12 | rm -fr *.egg-info build dist README.html *.tmp 13 | 14 | distclean: clean 15 | -find . -type d -name __pycache__ | xargs rm -fr 16 | rm -fr .tox .coverage .pytest_cache *.snap 17 | 18 | build: 19 | python3 setup.py bdist_wheel 20 | 21 | lint: 22 | tox -e lint 23 | 24 | test: 25 | tox -e test 26 | 27 | check: 28 | tox 29 | 30 | integration: 31 | scripts/integration-test.sh 32 | 33 | snap: 34 | snapcraft snap --use-lxd --debug 35 | 36 | snap-clean: 37 | snapcraft clean --use-lxd autoinstall-generator metadata 38 | 39 | snap-install: 40 | sudo snap install *.snap --dangerous 41 | 42 | snap-uninstall: 43 | sudo snap remove autoinstall-generator 44 | 45 | html: 46 | markdown README.md > README.html 47 | 48 | readme: 49 | cat README.md | sed -ne '0,/^## Usage/p' > 1.tmp 50 | echo > 2.tmp 51 | @PYTHONPATH=$(shell realpath .) \ 52 | autoinstall_generator/cmd/autoinstall-generator.py --help | \ 53 | sed -ne 's/^\(.\+\)$$/ \1/;p' \ 54 | > 3.tmp 55 | echo > 4.tmp 56 | cat README.md | sed -ne '/^## Feedback/,$$p' > 5.tmp 57 | cat ?.tmp > README.md.tmp 58 | 59 | invoke: 60 | @PYTHONPATH=$(shell realpath .) \ 61 | autoinstall_generator/cmd/autoinstall-generator.py \ 62 | autoinstall_generator/tests/data/preseed.txt --debug 63 | 64 | .PHONY: default all new install_deps clean distclean build lint test check 65 | .PHONY: snap invoke snap-clean snap-install html 66 | -------------------------------------------------------------------------------- /autoinstall_generator/cmd/autoinstall-generator.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from autoinstall_generator.merging import convert_file 4 | from autoinstall_generator.version import __version__ 5 | 6 | from argparse import ArgumentParser, FileType 7 | import sys 8 | 9 | 10 | helptext = { 11 | 'inpath': 'Debian install preseed file, or a dash to read stdin', 12 | 'outfile': 'Subiquity autoinstall yaml', 13 | 'debug': 'include commented out debug output explaining the conversions' 14 | + ' performed', 15 | 'cloud': 'output in cloud-config format', 16 | 'version': 'show version and exit', 17 | } 18 | 19 | 20 | def add(parser, name, *args, **kwargs): 21 | if len(args) > 0: 22 | parser.add_argument(*args, help=helptext[name], **kwargs) 23 | else: 24 | parser.add_argument(name, help=helptext[name], **kwargs) 25 | 26 | 27 | ver_output = f'Version: {__version__}' 28 | 29 | 30 | def main(): 31 | parser = ArgumentParser() 32 | add(parser, 'inpath', metavar='infile') 33 | add(parser, 'outfile', nargs='?', type=FileType('w'), default=sys.stdout) 34 | add(parser, 'cloud', '-c', '--cloud', action='store_true') 35 | add(parser, 'debug', '-d', '--debug', action='store_true') 36 | add(parser, 'version', '-V', '--version', action='version', 37 | version=ver_output) 38 | args = parser.parse_args() 39 | 40 | if args.inpath == "-": 41 | infile_needs_close = False 42 | infile = sys.stdin 43 | else: 44 | infile_needs_close = True 45 | infile = open(args.inpath, 'r', encoding='utf-8') 46 | 47 | out = convert_file(infile, args) 48 | args.outfile.write(out) 49 | if infile_needs_close and infile: 50 | infile.close() 51 | 52 | return 0 53 | 54 | 55 | if __name__ == '__main__': 56 | sys.exit(main()) 57 | -------------------------------------------------------------------------------- /snapcraft.yaml: -------------------------------------------------------------------------------- 1 | name: autoinstall-generator 2 | summary: Utility to convert Debian Installer preseed to Subiquity answers 3 | description: | 4 | Ingest Debian preseed format file(s), and provide compatible Subiquity 5 | autoinstall in response. 6 | confinement: strict 7 | base: core18 8 | grade: stable 9 | adopt-info: metadata 10 | 11 | parts: 12 | metadata: 13 | plugin: dump 14 | source: . 15 | # source: https://github.com/canonical/autoinstall-generator.git 16 | override-pull: | 17 | cat "$SNAPCRAFT_PROJECT_DIR/autoinstall_generator/version.py" | \ 18 | awk '{print $3}' | \ 19 | xargs snapcraftctl set-version 20 | 21 | autoinstall-generator: 22 | plugin: python 23 | python-version: python3 24 | source: . 25 | # source: https://github.com/canonical/autoinstall-generator.git 26 | # requirements: [requirements.txt] 27 | organize: 28 | 'bin/autoinstall-generator.py': usr/bin/autoinstall-generator 29 | build-packages: 30 | - python3-pip 31 | - python3-setuptools 32 | - python3-wheel 33 | stage-packages: 34 | - python3.6-minimal 35 | - python3-jsonschema 36 | - python3-yaml 37 | 38 | # More info: https://forum.snapcraft.io/t/reducing-the-size-of-desktop-snaps/17280#heading--cleanup-part 39 | # Temporarily disabled - if this is allowed to run, the resulting snap is 40 | # unable to find the autoinstall_generator package 41 | # cleanup: 42 | # after: 43 | # - autoinstall-generator 44 | # plugin: nil 45 | # build-snaps: 46 | # - core18 47 | # override-prime: | 48 | # set -eux 49 | # for snap in "core18"; do 50 | # cd "/snap/$snap/current" 51 | # find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \; 52 | # done 53 | 54 | apps: 55 | autoinstall-generator: 56 | command: usr/bin/autoinstall-generator 57 | plugs: 58 | - home 59 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/data/autoinstall.yaml: -------------------------------------------------------------------------------- 1 | version: 1 2 | early-commands: 3 | - echo a 4 | - sleep 1 5 | - echo a 6 | locale: en_GB.UTF-8 7 | refresh-installer: 8 | update: yes 9 | channel: edge 10 | network: 11 | version: 2 12 | ethernets: 13 | all-eth: 14 | match: 15 | name: "en*" 16 | dhcp6: yes 17 | debconf-selections: eek 18 | apt: 19 | primary: 20 | - arches: [default] 21 | uri: "http://mymirror.local/repository/Apt/ubuntu/" 22 | packages: 23 | - package1 24 | - package2 25 | late-commands: 26 | - echo late 27 | - sleep 1 28 | - echo late 29 | error-commands: 30 | - echo OH NOES 31 | - sleep 5 32 | - echo OH WELL 33 | keyboard: 34 | layout: gb 35 | identity: 36 | realname: '' 37 | username: ubuntu 38 | password: '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1' 39 | hostname: ubuntu 40 | storage: 41 | config: 42 | - {type: disk, ptable: gpt, path: /dev/vdb, wipe: superblock, preserve: false, grub_device: true, id: disk-1} 43 | - {type: disk, ptable: gpt, path: /dev/vdc, wipe: superblock, preserve: false, grub_device: true, id: disk-2} 44 | - {type: partition, device: disk-1, size: 1M, wipe: superblock, flag: bios_grub, number: 1, preserve: false, id: partition-grub-1} 45 | - {type: partition, device: disk-2, size: 1M, wipe: superblock, flag: bios_grub, number: 1, preserve: false, id: partition-grub-2} 46 | - {type: partition, device: disk-1, size: 1G, wipe: superblock, number: 2, preserve: false, id: partition-boot-1} 47 | - {type: partition, device: disk-2, size: 1G, wipe: superblock, number: 2, preserve: false, id: partition-boot-2} 48 | - {type: partition, device: disk-1, size: 17%, wipe: superblock, number: 3, preserve: false, id: partition-system-1} 49 | - {type: partition, device: disk-2, size: 17%, wipe: superblock, number: 3, preserve: false, id: partition-system-2} 50 | - {type: raid, name: md0, raidlevel: raid1, devices: [partition-boot-1, partition-boot-2], preserve: false, id: raid-boot} 51 | - {type: raid, name: md1, raidlevel: raid1, devices: [partition-system-1, partition-system-2], preserve: false, id: raid-system} 52 | - {type: format, fstype: ext4, volume: raid-boot, preserve: false, id: format-boot} 53 | - {type: format, fstype: ext4, volume: raid-system, preserve: false, id: format-system} 54 | - {type: mount, device: format-boot, path: /boot, id: mount-boot} 55 | - {type: mount, device: format-system, path: /, id: mount-system} 56 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/test_yaml.py: -------------------------------------------------------------------------------- 1 | 2 | from autoinstall_generator.convert import Directive, ConversionType 3 | from autoinstall_generator.merging import merge 4 | import yaml 5 | 6 | 7 | password = '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRD'\ 8 | 'YK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1' 9 | identity = { 10 | 'identity': { 11 | 'hostname': 'ubuntu', 12 | 'password': password, 13 | 'realname': '', 14 | 'username': 'ubuntu', 15 | } 16 | } 17 | 18 | 19 | def test_roundtrip(): 20 | expected_text = '''\ 21 | a: 1 22 | b: 23 | c: 3 24 | d: 4 25 | ''' 26 | 27 | actual_yaml = yaml.safe_load(expected_text) 28 | expected_yaml = {'a': 1, 'b': {'c': 3, 'd': 4}} 29 | assert expected_yaml == actual_yaml 30 | 31 | actual_text = yaml.dump(actual_yaml, default_flow_style=False) 32 | assert expected_text == actual_text 33 | 34 | 35 | def test_ai_identity_fullquote(): 36 | expected_text = f'''\ 37 | 'identity': 38 | 'hostname': 'ubuntu' 39 | 'password': '{password}' 40 | 'realname': '' 41 | 'username': 'ubuntu' 42 | ''' 43 | actual_text = yaml.dump(identity, default_flow_style=False, 44 | default_style="'") 45 | assert expected_text == actual_text 46 | 47 | 48 | def test_ai_identity(): 49 | expected_text = f'''\ 50 | identity: 51 | hostname: ubuntu 52 | password: {password} 53 | realname: '' 54 | username: ubuntu 55 | ''' 56 | actual_text = yaml.dump(identity, default_flow_style=False) 57 | assert expected_text == actual_text 58 | 59 | 60 | def test_to_file(tmpdir): 61 | dest = tmpdir.join('out.yaml') 62 | 63 | with open(dest.strpath, 'w') as out: 64 | yaml.dump(identity, out, default_flow_style=False) 65 | 66 | expected_yaml_path = 'autoinstall_generator/tests/data/identity.yaml' 67 | 68 | with open(expected_yaml_path, 'r') as expected_yaml_file: 69 | expected_yaml = expected_yaml_file.read() 70 | assert expected_yaml == dest.read() 71 | 72 | 73 | def test_merge(): 74 | trees = [ 75 | {'identity': {'hostname': 'ubuntu'}}, 76 | {'identity': {'password': password}}, 77 | {'identity': {'realname': ''}}, 78 | {'identity': {'username': 'ubuntu'}}, 79 | ] 80 | 81 | directives = [] 82 | for tree in trees: 83 | directives.append(Directive(tree, '', ConversionType.UnknownError)) 84 | 85 | assert identity == merge(directives) 86 | 87 | 88 | def test_array(): 89 | a = 'a: [b, c, d]' 90 | 91 | actual = yaml.safe_load(a) 92 | expected = {'a': ['b', 'c', 'd']} 93 | assert expected == actual 94 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/test_reader.py: -------------------------------------------------------------------------------- 1 | 2 | from autoinstall_generator.convert import convert, ConversionType, Directive 3 | from autoinstall_generator.merging import convert_file, validate_yaml 4 | import json 5 | import jsonschema 6 | import pytest 7 | import yaml 8 | 9 | 10 | @pytest.fixture(autouse=True) 11 | def reset_largest_lineno(): 12 | Directive.largest_linenumber = 0 13 | 14 | 15 | class MockArgs: 16 | debug = False 17 | cloud = False 18 | 19 | 20 | expected_lines = '''\ 21 | d-i debian-installer/locale string en_US 22 | d-i debian-installer/language string en 23 | d-i debian-installer/country string NL 24 | d-i debian-installer/locale string en_GB.UTF-8''' 25 | 26 | data = 'autoinstall_generator/tests/data' 27 | preseed_path = f'{data}/preseed.txt' 28 | simple_path = f'{data}/simple.txt' 29 | autoinstall_path = f'{data}/preseed2autoinstall.yaml' 30 | 31 | 32 | def test_reader(): 33 | converted = [] 34 | 35 | with open(preseed_path, 'r') as preseed_file: 36 | for line in preseed_file.readlines(): 37 | directive = convert(line) 38 | if directive.convert_type != ConversionType.PassThru: 39 | converted.append(directive.orig_input.strip()) 40 | 41 | expected = expected_lines.split('\n') 42 | assert expected == converted[:4] 43 | 44 | 45 | def test_convert_file(): 46 | args = MockArgs() 47 | with open(preseed_path, 'r') as preseed: 48 | actual = convert_file(preseed, args) 49 | with open(autoinstall_path, 'r') as autoinstall: 50 | expected = autoinstall.read() 51 | assert expected == actual 52 | 53 | 54 | def test_is_valid(): 55 | with open(autoinstall_path, 'r') as fp: 56 | ai = yaml.safe_load(fp.read()) 57 | 58 | validate_yaml(ai) 59 | 60 | 61 | def test_is_not_valid(): 62 | with open(autoinstall_path, 'r') as fp: 63 | ai = yaml.safe_load(fp.read()) 64 | 65 | del ai['version'] 66 | 67 | with pytest.raises(jsonschema.exceptions.ValidationError): 68 | validate_yaml(ai) 69 | 70 | 71 | def test_validate(): 72 | with open(autoinstall_path, 'r') as fp: 73 | ai = yaml.safe_load(fp.read()) 74 | 75 | with open('autoinstall_generator/autoinstall-schema.json', 'r') as fp: 76 | schema_data = fp.read() 77 | schema = json.loads(schema_data) 78 | 79 | jsonschema.validate(ai, schema) 80 | 81 | 82 | def test_convert_simple_debug(): 83 | args = MockArgs() 84 | args.debug = True 85 | with open(simple_path, 'r') as simple: 86 | actual = convert_file(simple, args) 87 | expected = '''\ 88 | locale: en_US 89 | version: 1 90 | # 1: Directive: d-i debian-installer/locale string en_US 91 | # Mapped to: locale: en_US 92 | ''' 93 | assert expected == actual 94 | 95 | 96 | def test_convert_simple_cloud(): 97 | args = MockArgs() 98 | args.cloud = True 99 | with open(simple_path, 'r') as simple: 100 | actual = convert_file(simple, args) 101 | expected = '''\ 102 | #cloud-config 103 | autoinstall: 104 | locale: en_US 105 | version: 1 106 | ''' 107 | assert expected == actual 108 | -------------------------------------------------------------------------------- /autoinstall_generator/cmd/tests/test_invoke.py: -------------------------------------------------------------------------------- 1 | 2 | import subprocess 3 | from subprocess import PIPE 4 | import tempfile 5 | 6 | cmd = './autoinstall_generator/cmd/autoinstall-generator.py' 7 | # FIXME redundant file paths with reader 8 | data = 'autoinstall_generator/tests/data' 9 | preseed_path = f'{data}/preseed.txt' 10 | autoinstall_path = f'{data}/preseed2autoinstall.yaml' 11 | autoinstall_debug_path = f'{data}/preseed2autoinstall_debug.yaml' 12 | 13 | simple_path = f'{data}/simple.txt' 14 | 15 | 16 | def run(args, **kwargs): 17 | return subprocess.run(args, universal_newlines=True, 18 | stdout=PIPE, stderr=PIPE, **kwargs) 19 | 20 | 21 | def file_contents(path): 22 | with open(path, 'r') as f: 23 | return f.read() 24 | 25 | 26 | def test_invoke(): 27 | process = run([cmd]) 28 | assert 2 == process.returncode 29 | 30 | 31 | def test_convert(): 32 | out = tempfile.NamedTemporaryFile() 33 | process = run([cmd, preseed_path, out.name]) 34 | assert 0 == process.returncode 35 | expected = file_contents(autoinstall_path) 36 | actual = file_contents(out.name) 37 | assert expected == actual 38 | 39 | 40 | def test_convert_debug(): 41 | out = tempfile.NamedTemporaryFile() 42 | process = run([cmd, preseed_path, out.name, '--debug']) 43 | assert 0 == process.returncode 44 | expected = file_contents(autoinstall_debug_path) 45 | actual = file_contents(out.name) 46 | assert expected == actual 47 | 48 | 49 | def test_stdout(): 50 | process = run([cmd, preseed_path]) 51 | assert 0 == process.returncode 52 | expected = file_contents(autoinstall_path) 53 | assert expected == str(process.stdout) 54 | 55 | 56 | def test_pipe(): 57 | process = run([cmd, '-'], input=file_contents(preseed_path)) 58 | assert 0 == process.returncode 59 | expected = file_contents(autoinstall_path) 60 | assert expected == str(process.stdout) 61 | 62 | 63 | def test_help(): 64 | process = run([cmd, '--help']) 65 | actual = process.stdout.split('\n')[0] 66 | expected = 'usage: autoinstall-generator' 67 | assert actual.startswith(expected) 68 | assert 0 == process.returncode 69 | 70 | 71 | def test_bad_infile(): 72 | process = run([cmd, '/does/not/exist']) 73 | found_exception = False 74 | for line in process.stderr.split('\n'): 75 | if line.startswith('FileNotFound'): 76 | found_exception = True 77 | break 78 | 79 | assert found_exception 80 | assert 0 != process.returncode 81 | 82 | 83 | def test_simple_debug(): 84 | process = run([cmd, simple_path, '--debug']) 85 | assert 0 == process.returncode 86 | expected = '''\ 87 | locale: en_US 88 | version: 1 89 | # 1: Directive: d-i debian-installer/locale string en_US 90 | # Mapped to: locale: en_US 91 | ''' 92 | assert expected == str(process.stdout) 93 | 94 | 95 | def test_simple_cloud_config(): 96 | for arg in ['-c', '--cloud']: 97 | process = run([cmd, simple_path, arg]) 98 | assert 0 == process.returncode 99 | expected = '''\ 100 | #cloud-config 101 | autoinstall: 102 | locale: en_US 103 | version: 1 104 | ''' 105 | assert expected == str(process.stdout) 106 | 107 | 108 | def test_version(): 109 | process = run([cmd, '--version']) 110 | assert 0 == process.returncode 111 | assert str(process.stdout).startswith('Version: ') 112 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/data/preseed2autoinstall_debug.yaml: -------------------------------------------------------------------------------- 1 | apt: 2 | primary: 3 | - arches: 4 | - default 5 | uri: http://http.us.debian.org/debian 6 | debconf-selections: | 7 | pkg-a pkg-a/my-q boolean false 8 | pkg-b pkg-a/my-other-q boolean true 9 | keyboard: 10 | layout: us 11 | locale: en_GB.UTF-8 12 | network: 13 | ethernets: 14 | any: 15 | addresses: 16 | - 192.168.1.42/24 17 | gateway4: 192.168.1.1 18 | match: 19 | name: en* 20 | nameservers: 21 | addresses: 22 | - 192.168.1.1 23 | version: 2 24 | storage: 25 | layout: 26 | name: lvm 27 | version: 1 28 | # 4: Directive: d-i debian-installer/locale string en_US 29 | # Mapped to: locale: en_US 30 | # 7: Unsupported: d-i debian-installer/language string en 31 | # 8: Unsupported: d-i debian-installer/country string NL 32 | # 9: Directive: d-i debian-installer/locale string en_GB.UTF-8 33 | # Mapped to: locale: en_GB.UTF-8 34 | # 11: Unsupported: d-i localechooser/supported-locales multiselect en_US.UTF-8, nl_NL.UTF-8 35 | # 14: Directive: d-i keyboard-configuration/xkb-keymap select us 36 | # Mapped to: keyboard: 37 | # layout: us 38 | # 15: Unsupported: d-i keyboard-configuration/toggle select No toggling 39 | # 25: Directive: d-i netcfg/choose_interface select auto 40 | # 52: And: d-i netcfg/get_ipaddress string 192.168.1.42 41 | # 53: And: d-i netcfg/get_netmask string 255.255.255.0 42 | # 54: And: d-i netcfg/get_gateway string 192.168.1.1 43 | # 55: And: d-i netcfg/get_nameservers string 192.168.1.1 44 | # Mapped to: network: 45 | # ethernets: 46 | # any: 47 | # addresses: 48 | # - 192.168.1.42/24 49 | # gateway4: 192.168.1.1 50 | # match: 51 | # name: en* 52 | # nameservers: 53 | # addresses: 54 | # - 192.168.1.1 55 | # version: 2 56 | # 56: Unsupported: d-i netcfg/confirm_static boolean true 57 | # 68: Unsupported: d-i netcfg/get_hostname string unassigned-hostname 58 | # 69: Unsupported: d-i netcfg/get_domain string unassigned-domain 59 | # 77: Unsupported: d-i netcfg/wireless_wep string 60 | # 98: Unsupported: d-i mirror/country string manual 61 | # 99: Directive: d-i mirror/http/hostname string http.us.debian.org 62 | # 100: And: d-i mirror/http/directory string /debian 63 | # Mapped to: apt: 64 | # primary: 65 | # - arches: 66 | # - default 67 | # uri: http://http.us.debian.org/debian 68 | # 101: Unsupported: d-i mirror/http/proxy string 69 | # 138: Unsupported: d-i clock-setup/utc boolean true 70 | # 142: Unsupported: d-i time/zone string US/Eastern 71 | # 145: Unsupported: d-i clock-setup/ntp boolean true 72 | # 160: Unsupported: d-i partman-auto/disk string /dev/sda 73 | # 166: Directive: d-i partman-auto/method string lvm 74 | # Mapped to: storage: 75 | # layout: 76 | # name: lvm 77 | # 171: Unsupported: d-i partman-auto-lvm/guided_size string max 78 | # 176: Unsupported: d-i partman-lvm/device_remove_lvm boolean true 79 | # 178: Unsupported: d-i partman-md/device_remove_md boolean true 80 | # 180: Unsupported: d-i partman-lvm/confirm boolean true 81 | # 181: Unsupported: d-i partman-lvm/confirm_nooverwrite boolean true 82 | # 187: Unsupported: d-i partman-auto/choose_recipe select atomic 83 | # 222: Unsupported: d-i partman-partitioning/confirm_write_new_label boolean true 84 | # 223: Unsupported: d-i partman/choose_partition select finish 85 | # 224: Unsupported: d-i partman/confirm boolean true 86 | # 225: Unsupported: d-i partman/confirm_nooverwrite boolean true 87 | # 274: Unsupported: d-i partman-md/confirm boolean true 88 | # 275: Unsupported: d-i partman-partitioning/confirm_write_new_label boolean true 89 | # 276: Unsupported: d-i partman/choose_partition select finish 90 | # 277: Unsupported: d-i partman/confirm boolean true 91 | # 278: Unsupported: d-i partman/confirm_nooverwrite boolean true 92 | # 353: Unsupported: d-i grub-installer/only_debian boolean true 93 | # 357: Unsupported: d-i grub-installer/with_other_os boolean true 94 | # 391: Unsupported: d-i finish-install/reboot_in_progress note 95 | # 436: Directive: pkg-a pkg-a/my-q boolean false 96 | # 437: And: pkg-b pkg-a/my-other-q boolean true 97 | # Mapped to: debconf-selections: | 98 | # pkg-a pkg-a/my-q boolean false 99 | # pkg-b pkg-a/my-other-q boolean true 100 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/test_merge.py: -------------------------------------------------------------------------------- 1 | 2 | from autoinstall_generator.convert import convert, Directive, ConversionType 3 | from autoinstall_generator.merging import (merge, do_merge, coalesce, 4 | bucketize, Bucket) 5 | import copy 6 | 7 | 8 | def test_basic(): 9 | a = {'a': 1} 10 | b = {'b': 2} 11 | expected = { 12 | 'a': 1, 13 | 'b': 2, 14 | } 15 | actual = do_merge(a, b) 16 | assert expected == actual 17 | 18 | 19 | def test_firstlevel(): 20 | b = {'a': {'b': 1}} 21 | c = {'a': {'c': 2}} 22 | 23 | expected = { 24 | 'a': { 25 | 'b': 1, 26 | 'c': 2, 27 | } 28 | } 29 | 30 | actual = do_merge(b, c) 31 | assert expected == actual 32 | 33 | 34 | def test_secondlevel(): 35 | c = {'a': {'b': {'c': 1}}} 36 | d = {'a': {'b': {'d': 2}}} 37 | expected = { 38 | 'a': { 39 | 'b': { 40 | 'c': 1, 41 | 'd': 2, 42 | } 43 | } 44 | } 45 | 46 | actual = do_merge(c, d) 47 | assert expected == actual 48 | 49 | 50 | def test_redundant(): 51 | a = {'a': 1} 52 | expected = { 53 | 'a': 1, 54 | } 55 | actual = do_merge(a, a) 56 | assert expected == actual 57 | 58 | 59 | def test_redundant_array(): 60 | a = {'a': [1]} 61 | expected = { 62 | 'a': [1], 63 | } 64 | actual = do_merge(a, a) 65 | assert expected == actual 66 | 67 | 68 | def test_duplicate_int(): 69 | one = {'a': 1} 70 | two = {'a': 2} 71 | expected = {'a': 2} 72 | assert expected == do_merge(one, two) 73 | 74 | 75 | def test_duplicate_array(): 76 | one = {'a': [1]} 77 | two = {'a': [2]} 78 | expected = {'a': [2]} 79 | assert expected == do_merge(one, two) 80 | 81 | 82 | def test_empty(): 83 | one = {'a': [1]} 84 | two = {} 85 | expected = {'a': [1]} 86 | assert expected == do_merge(one, two) 87 | 88 | 89 | def test_list(): 90 | a = Directive({'a': 1}, '', ConversionType.UnknownError) 91 | b = Directive({'b': 2}, '', ConversionType.UnknownError) 92 | c = Directive({'c': 3}, '', ConversionType.UnknownError) 93 | expected = { 94 | 'a': 1, 95 | 'b': 2, 96 | 'c': 3, 97 | } 98 | 99 | actual = merge([a, b, c]) 100 | assert expected == actual 101 | 102 | 103 | def test_coalesce(): 104 | hostname = 'asdf' 105 | directory = '/qwerty' 106 | lines = [ 107 | f'd-i mirror/http/hostname string {hostname}', 108 | f'd-i mirror/http/directory string {directory}', 109 | ] 110 | 111 | directives = [] 112 | for line in lines: 113 | directives.append(convert(line)) 114 | 115 | actual = coalesce(directives) 116 | expected_tree = { 117 | 'apt': { 118 | 'primary': [{ 119 | 'arches': ['default'], 120 | 'uri': f'http://{hostname}{directory}', 121 | }] 122 | } 123 | } 124 | expected_fragments = { 125 | 'mirror/http': { 126 | 'hostname': hostname, 127 | 'directory': directory, 128 | } 129 | } 130 | assert ConversionType.Coalesced == actual.convert_type 131 | assert directives == actual.children 132 | assert expected_fragments == actual.fragments 133 | assert expected_tree == actual.tree 134 | 135 | 136 | def test_bucketize(): 137 | # bucketization is the process by which directives are processed to 138 | # determine if they are standalone or if they require coalescing. 139 | lines = [ 140 | 'd-i mirror/http/hostname string a', 141 | 'd-i mirror/http/directory string /b', 142 | 'd-i debian-installer/locale string en_US', 143 | ] 144 | key = 'mirror/http' 145 | 146 | directives = [convert(line) for line in lines] 147 | buckets = bucketize(directives) 148 | assert 1 == len(buckets.independent) 149 | assert ConversionType.OneToOne == buckets.independent[0].convert_type 150 | assert 1 == len(buckets.dependent) 151 | assert key in buckets.dependent 152 | assert 2 == len(buckets.dependent[key]) 153 | for d in buckets.dependent[key]: 154 | assert ConversionType.Dependent == d.convert_type 155 | 156 | 157 | def test_coalesce_buckets(): 158 | buckets = Bucket() 159 | lines = [ 160 | 'd-i mirror/http/hostname string a', 161 | 'd-i mirror/http/directory string /b', 162 | ] 163 | key = 'mirror/http' 164 | directives = [convert(line) for line in lines] 165 | buckets.dependent[key] = directives 166 | 167 | coalesced = buckets.coalesce() 168 | 169 | assert 1 == len(coalesced) 170 | assert ConversionType.Dependent != coalesced[0].convert_type 171 | 172 | 173 | def test_coalesce_directives(): 174 | # the fragments section was being modified as a side effect of the do_merge 175 | hostname = 'http.us.debian.org' 176 | directory = '/debian' 177 | 178 | directives = [convert(x) for x in [ 179 | f'd-i mirror/http/hostname string {hostname}', 180 | f'd-i mirror/http/directory string {directory}' 181 | ] 182 | ] 183 | 184 | before = [copy.deepcopy(d) for d in directives] 185 | coalesce(directives) 186 | after = directives 187 | 188 | for i in range(len(directives)): 189 | assert before[i].fragments == after[i].fragments 190 | -------------------------------------------------------------------------------- /autoinstall_generator/merging.py: -------------------------------------------------------------------------------- 1 | 2 | from autoinstall_generator.convert import convert, Directive, ConversionType 3 | import copy 4 | import json 5 | import jsonschema 6 | import pkg_resources 7 | import yaml 8 | 9 | 10 | def do_merge(a, b): 11 | '''Take a pair of dictionaries, and provide the merged result. 12 | Assumes that any key conflicts have values that are themselves 13 | dictionaries and raises TypeError if found otherwise.''' 14 | result = copy.deepcopy(a) 15 | 16 | for key in b: 17 | if key in result: 18 | left = result[key] 19 | right = b[key] 20 | if type(left) is not dict or type(right) is not dict: 21 | result[key] = right 22 | else: 23 | result[key] = do_merge(left, right) 24 | else: 25 | result[key] = b[key] 26 | 27 | return result 28 | 29 | 30 | def merge(directives): 31 | '''Take a list of directives, and do_merge() their trees.''' 32 | 33 | result = {} 34 | for d in directives: 35 | result = do_merge(result, d.tree) 36 | 37 | return result 38 | 39 | 40 | def mirror_http(parent_directive): 41 | hostname = parent_directive.fragments['mirror/http']['hostname'] 42 | directory = parent_directive.fragments['mirror/http']['directory'] 43 | parent_directive.tree = { 44 | 'apt': { 45 | 'primary': [ 46 | { 47 | 'arches': ['default'], 48 | 'uri': f'http://{hostname}{directory}' 49 | } 50 | ] 51 | } 52 | } 53 | 54 | 55 | def netcfg(parent_directive): 56 | netcfg = parent_directive.fragments['netcfg'] 57 | interface = netcfg.get('interface', 'any') 58 | parent_directive.tree = { 59 | 'network': { 60 | 'version': 2, 61 | 'ethernets': {interface: {}} 62 | } 63 | } 64 | 65 | iface_subtree = parent_directive.tree['network']['ethernets'][interface] 66 | if interface == 'any': 67 | val = {'name': 'en*'} 68 | iface_subtree['match'] = val 69 | 70 | gateway = netcfg.get('gateway', None) 71 | if gateway: 72 | iface_subtree['gateway4'] = gateway 73 | 74 | ipaddress = netcfg.get('ipaddress', None) 75 | netmask_bits = netcfg.get('netmask_bits', 24) 76 | if ipaddress: 77 | iface_subtree['addresses'] = [f'{ipaddress}/{netmask_bits}'] 78 | 79 | nameservers = netcfg.get('nameservers', None) 80 | if nameservers: 81 | iface_subtree['nameservers'] = {'addresses': [nameservers]} 82 | 83 | 84 | def debconf_selections(parent_directive): 85 | fragments = parent_directive.fragments['debconf-selections'] 86 | values = [fragments[key] for key in fragments] 87 | value = '\n'.join(values) + '\n' 88 | parent_directive.tree = {'debconf-selections': value} 89 | 90 | 91 | coalesce_map = { 92 | 'mirror/http': mirror_http, 93 | 'netcfg': netcfg, 94 | 'debconf-selections': debconf_selections, 95 | } 96 | 97 | 98 | def coalesce(directives): 99 | '''Take a list of co-dependent directives, and output a coalesced 100 | Directive that represents resolution of all the dependent values.''' 101 | result = Directive({}, '', ConversionType.Coalesced) 102 | result.children = directives 103 | 104 | result.fragments = {} 105 | for d in directives: 106 | result.fragments = do_merge(result.fragments, d.fragments) 107 | if result.linenumber is None: 108 | result.linenumber = d.linenumber 109 | 110 | key = list(result.fragments)[0] 111 | coalesce_map[key](result) 112 | 113 | return result 114 | 115 | 116 | class Bucket: 117 | def __init__(self): 118 | self.independent = [] 119 | self.dependent = {} 120 | 121 | def coalesce(self): 122 | def keyfn(d): 123 | if d.linenumber is None: 124 | return -1 125 | return d.linenumber 126 | 127 | result = copy.copy(self.independent) 128 | for key in self.dependent: 129 | cur = self.dependent[key] 130 | result.append(coalesce(cur)) 131 | 132 | list.sort(result, key=keyfn) 133 | return result 134 | 135 | 136 | def bucketize(directives): 137 | '''Categorize Directives into independent and dependent. Dependent 138 | type directives are grouped into a list in the dependent dict and 139 | grouped on their fragment toplevel key. Non-Dependent type 140 | directives are placed into the independent list.''' 141 | 142 | bucket = Bucket() 143 | 144 | for cur in directives: 145 | if cur.convert_type != ConversionType.Dependent: 146 | bucket.independent.append(cur) 147 | continue 148 | 149 | key = list(cur.fragments)[0] 150 | if key not in bucket.dependent: 151 | bucket.dependent[key] = [cur] 152 | else: 153 | bucket.dependent[key].append(cur) 154 | 155 | return bucket 156 | 157 | 158 | def validate_yaml(tree): 159 | pkg = 'autoinstall_generator' 160 | schema_file = 'autoinstall-schema.json' 161 | schema_path = pkg_resources.resource_filename(pkg, schema_file) 162 | 163 | with open(schema_path, 'r') as fp: 164 | schema_data = fp.read() 165 | schema = json.loads(schema_data) 166 | 167 | jsonschema.validate(tree, schema) 168 | 169 | 170 | def implied_directives(): 171 | return [Directive({'version': 1}, None, ConversionType.Implied)] 172 | 173 | 174 | def debug_output(directives): 175 | trailer = [] 176 | for cur in directives: 177 | out = cur.debug() 178 | if out: 179 | trailer.append(out) 180 | return ''.join(trailer) 181 | 182 | 183 | def str_presenter(dumper, data): 184 | '''https://github.com/yaml/pyyaml/issues/240''' 185 | def rep(val, **kwargs): 186 | return dumper.represent_scalar('tag:yaml.org,2002:str', val, **kwargs) 187 | 188 | try: 189 | dlen = len(data.splitlines()) 190 | if (dlen > 1): 191 | return rep(data, style='|') 192 | except TypeError: 193 | pass 194 | return rep(data.strip()) 195 | 196 | 197 | def dump_yaml(tree): 198 | yaml.add_representer(str, str_presenter) 199 | return yaml.dump(tree, default_flow_style=False) 200 | 201 | 202 | def convert_file(preseed_file, args): 203 | directives = implied_directives() 204 | 205 | fullDirective = None 206 | for idx, line in enumerate(preseed_file.readlines()): 207 | line = line.strip('\n') 208 | cleanedLine = line.rstrip('\\').strip(' ') 209 | 210 | if fullDirective is None: 211 | fullDirective = cleanedLine 212 | startIdx = idx 213 | else: 214 | fullDirective = ' '.join([fullDirective, cleanedLine]) 215 | 216 | if not line.endswith('\\'): 217 | directives.append(convert(fullDirective, startIdx + 1)) 218 | fullDirective = None 219 | 220 | buckets = bucketize(directives) 221 | coalesced = buckets.coalesce() 222 | result_dict = merge(coalesced) 223 | 224 | try: 225 | validate_yaml(result_dict) 226 | except jsonschema.exceptions.ValidationError as ve: 227 | print('# Warning: resulting autoinstall is missing required data') 228 | print('# ' + ve.message) 229 | 230 | result = '' 231 | if args.cloud: 232 | result_dict = {'autoinstall': result_dict} 233 | result = '#cloud-config\n' 234 | 235 | result += dump_yaml(result_dict) 236 | 237 | if args.debug: 238 | result += debug_output(coalesced) 239 | 240 | return result 241 | -------------------------------------------------------------------------------- /autoinstall_generator/convert.py: -------------------------------------------------------------------------------- 1 | 2 | import copy 3 | from enum import Enum 4 | import yaml 5 | 6 | 7 | class ConversionType(Enum): 8 | # generic error 9 | UnknownError = 0 10 | # input lines that get passed thru - comments and what not 11 | PassThru = 1 12 | # a single d-i directive that has a 1:1 mapping with an autoinstall 13 | OneToOne = 2 14 | # a d-i directive that, when paired with matching Dependent 15 | # directives, can output autoinstall directive(s) 16 | Dependent = 3 17 | # the result of two or more Dependent directives being grouped into 18 | # a single, resolved, directive 19 | Coalesced = 4 20 | # a d-i directive that is recognized as being relevant to the 21 | # installer, but does not yet have a supported autoinstaller 22 | # mapping. 23 | Unsupported = 5 24 | # an autoinstall directive that has no match in d-i, and is required 25 | Implied = 6 26 | 27 | 28 | class Directive: 29 | ''' 30 | A structure of values corresponding to how the conversion handled a given 31 | input line. 32 | 33 | Attributes 34 | ---------- 35 | tree : dict 36 | the output data generated from the orig_input line in the form 37 | of a hierarchy of dictionaries 38 | orig_input : str 39 | the input that was used to generate this Directive 40 | convert_type : ConversionType 41 | the type of conversion performed 42 | fragments : dict 43 | partial data derived from Dependent preseed directives that, 44 | when coallased with all other Dependent directives, will yield a 45 | useable output 46 | children : list of Directive 47 | a list of child Directive objects that were the source of this 48 | Directive 49 | linenumber : int 50 | line number in original file 51 | ''' 52 | largest_linenumber = 0 53 | longest_label = 'Unsupported' 54 | 55 | def __init__(self, tree, orig_input, convert_type, linenumber=None): 56 | self.tree = tree 57 | self.orig_input = orig_input 58 | self.convert_type = convert_type 59 | self.fragments = {} 60 | self.children = [] 61 | self.linenumber = linenumber 62 | if linenumber and linenumber > Directive.largest_linenumber: 63 | Directive.largest_linenumber = linenumber 64 | 65 | def __repr__(self): 66 | show_orig = [ 67 | ConversionType.UnknownError, 68 | ConversionType.PassThru, 69 | ConversionType.Unsupported, 70 | ] 71 | if self.convert_type in show_orig: 72 | return f'{self.convert_type.name}:"{self.orig_input}"' 73 | 74 | if self.convert_type == ConversionType.Dependent: 75 | return f'{self.convert_type.name}:{self.fragments}' 76 | 77 | return f'{self.convert_type.name}:{self.tree}' 78 | 79 | def debug_directive(self, isfirst=True): 80 | linenumber = self.linenumber if self.linenumber else 0 81 | # space pad linenumbers to match the largest line number seen 82 | linenolen = len(str(Directive.largest_linenumber)) 83 | linenostr = str(linenumber).rjust(linenolen) 84 | prefix = f'{linenostr}: ' 85 | if self.convert_type == ConversionType.Unsupported: 86 | label = 'Unsupported' 87 | elif self.convert_type == ConversionType.UnknownError: 88 | label = 'Error' 89 | elif isfirst: 90 | label = 'Directive' 91 | else: 92 | label = 'And' 93 | label = label.rjust(len(Directive.longest_label)) 94 | return (f'# {prefix}{label}: {self.orig_input}\n', linenolen) 95 | 96 | def debug(self): 97 | first, linenolen, rest = None, None, '' 98 | if self.convert_type == ConversionType.OneToOne or \ 99 | self.convert_type == ConversionType.Unsupported or \ 100 | self.convert_type == ConversionType.UnknownError: 101 | first, linenolen = self.debug_directive() 102 | if self.convert_type == ConversionType.Coalesced: 103 | # similar handling to OneToOne, except we iterate over the 104 | # child directives to get the orig_input lines 105 | first, linenolen = self.children[0].debug_directive() 106 | other_children = [ 107 | cur.debug_directive(False)[0] for cur in self.children[1:]] 108 | rest = ''.join(other_children) 109 | if not first: 110 | return None 111 | spacer = ' ' * (linenolen + 2) 112 | label = 'Mapped to'.rjust(len(Directive.longest_label)) 113 | mapped_prefix = f'# {spacer}{label}: ' 114 | mapped_spacer = '#' + ((len(mapped_prefix)-1) * ' ') 115 | mapped = yaml.dump(self.tree) if len(self.tree) else '' 116 | # prefix the dumped yaml with spaces (excluding the first line) 117 | # so that the yaml is indented over to match the first line. 118 | # result looks like: 119 | # 14: Directive: d-i keyboard-configuration/xkb-keymap select us 120 | # Mapped to: keyboard: 121 | # layout: us 122 | return first + rest + prefixify(mapped, mapped_spacer, mapped_prefix) 123 | 124 | 125 | def is_multiline(data): 126 | return data.count('\n') > 1 127 | 128 | 129 | def prefixify_lines(lines, prefix='# ', first=None): 130 | if not first: 131 | first = prefix 132 | prefixed = [] 133 | for i, line in enumerate(lines): 134 | if i == 0: 135 | prefixed.append(f'{first}{line}\n') 136 | else: 137 | prefixed.append(f'{prefix}{line}\n') 138 | return ''.join(prefixed) 139 | 140 | 141 | def prefixify(data, prefix='# ', first=None): 142 | return prefixify_lines(data.splitlines(), prefix, first) 143 | 144 | 145 | def netmask_bits(value): 146 | # FIXME actually calculate it 147 | bits = '0' 148 | if value == '255.255.255.0': 149 | bits = '24' 150 | elif value == '255.255.0.0': 151 | bits = '16' 152 | return bits 153 | 154 | 155 | def fragment(frag, line, lineno): 156 | directive = Directive({}, line, ConversionType.Dependent, lineno) 157 | directive.fragments = frag 158 | return directive 159 | 160 | 161 | def debconf_fragment(value, line, lineno): 162 | chunks = line.split(' ') 163 | key = f'{chunks[0]} {chunks[1]}' 164 | return fragment({'debconf-selections': {key: line}}, line, lineno) 165 | 166 | 167 | def netmask(value, line, lineno): 168 | bits = netmask_bits(value) 169 | return fragment({'netcfg': {'netmask_bits': bits}}, line, lineno) 170 | 171 | 172 | def ipaddress(value, line, lineno): 173 | return fragment({'netcfg': {'ipaddress': value}}, line, lineno) 174 | 175 | 176 | def netcfg_gateway(value, line, lineno): 177 | return fragment({'netcfg': {'gateway': value}}, line, lineno) 178 | 179 | 180 | def netcfg_interface(value, line, lineno): 181 | if value == 'auto': 182 | value = 'any' 183 | return fragment({'netcfg': {'interface': value}}, line, lineno) 184 | 185 | 186 | def netcfg_nameservers(value, line, lineno): 187 | return fragment({'netcfg': {'nameservers': value}}, line, lineno) 188 | 189 | 190 | def mirror_http_hostname(value, line, lineno): 191 | return fragment({'mirror/http': {'hostname': value}}, line, lineno) 192 | 193 | 194 | def mirror_http_directory(value, line, lineno): 195 | return fragment({'mirror/http': {'directory': value}}, line, lineno) 196 | 197 | 198 | def partman_method(value, line, lineno): 199 | template = {'storage': {'layout': {'name': None}}} 200 | layout_name = '' 201 | if value == 'lvm': 202 | layout_name = value 203 | elif value == 'regular': 204 | layout_name = 'direct' 205 | else: 206 | return Directive({}, line, ConversionType.UnknownError, lineno) 207 | 208 | output = insert_at_none(template, layout_name) 209 | return Directive(output, line, ConversionType.OneToOne, lineno) 210 | 211 | 212 | # Translation table to map from preseed values to autoinstall ones. 213 | # key: d-i style directive key 214 | # value: dictionary for simple mapping, function for more exciting one 215 | preseed_map = { 216 | 'keyboard-configuration/xkb-keymap': {'keyboard': {'layout': None}}, 217 | 'debian-installer/locale': {'locale': None}, 218 | 'passwd/user-fullname': {'identity': {'realname': None}}, 219 | 'passwd/username': {'identity': {'username': None}}, 220 | 'passwd/user-password-crypted': {'identity': {'password': None}}, 221 | 'netcfg/hostname': {'identity': {'hostname': None}}, 222 | 'netcfg/get_netmask': netmask, 223 | 'netcfg/get_ipaddress': ipaddress, 224 | 'netcfg/get_nameservers': netcfg_nameservers, 225 | 'netcfg/choose_interface': netcfg_interface, 226 | 'netcfg/get_gateway': netcfg_gateway, 227 | 'mirror/http/hostname': mirror_http_hostname, 228 | 'mirror/http/directory': mirror_http_directory, 229 | 'partman-auto/method': partman_method, 230 | } 231 | 232 | 233 | def dispatch(line, pkg, key, value, linenumber): 234 | output = {} 235 | 236 | if key in preseed_map: 237 | # do we know how to convert this item? 238 | mapped_key = preseed_map[key] 239 | if callable(mapped_key): 240 | return mapped_key(value, line, linenumber) 241 | else: 242 | output = insert_at_none(copy.deepcopy(mapped_key), value) 243 | convert_type = ConversionType.OneToOne 244 | return Directive(output, line, convert_type, linenumber) 245 | else: 246 | # is this an installer item we don't support? 247 | if pkg == 'd-i': 248 | return Directive({}, line, ConversionType.Unsupported, 249 | linenumber) 250 | 251 | return debconf_fragment(value, line, linenumber) 252 | 253 | 254 | def convert(line, linenumber=None): 255 | '''Convert Debian install preseed line to Subiquity directive equivalent. 256 | 257 | Returns 258 | ------- 259 | directive 260 | Directive object 261 | ''' 262 | # assumptions: 263 | # can process one line at a time 264 | # whitespace-only lines and comments should pass thru 265 | 266 | trimmed = line.strip() 267 | tokens = trimmed.split(' ') 268 | pkg = tokens[0] 269 | if pkg.startswith('#') or not pkg: 270 | return Directive({}, line, ConversionType.PassThru, linenumber) 271 | 272 | value = '' 273 | if len(tokens) > 3: 274 | value = ' '.join(tokens[3:]) 275 | 276 | key = '' 277 | if len(tokens) > 1: 278 | key = tokens[1] 279 | 280 | return dispatch(line, pkg, key, value, linenumber) 281 | 282 | 283 | def insert_at_none(tree, value): 284 | '''Walk tree looking for None or empty array, then insert value.''' 285 | for key in tree: 286 | cur = tree[key] 287 | if type(cur) is dict: 288 | tree[key] = insert_at_none(cur, value) 289 | elif type(cur) is list and len(cur) == 0: 290 | tree[key] = [value] 291 | elif cur is None: 292 | tree[key] = value 293 | return tree 294 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/test_basic.py: -------------------------------------------------------------------------------- 1 | 2 | from autoinstall_generator.convert import (convert, Directive, ConversionType, 3 | netmask_bits, insert_at_none) 4 | from autoinstall_generator.merging import merge, bucketize, dump_yaml 5 | 6 | 7 | def full_flow(start, expected, convert_type): 8 | directives = [] 9 | 10 | if type(start) == str: 11 | start = [start] 12 | 13 | for item in start: 14 | cur = convert(item) 15 | assert convert_type == cur.convert_type 16 | assert isinstance(cur.tree, dict) 17 | directives.append(cur) 18 | 19 | buckets = bucketize(directives) 20 | coalesced = buckets.coalesce() 21 | 22 | assert expected == merge(coalesced) 23 | 24 | 25 | def one_to_one(start, expected): 26 | full_flow(start, expected, ConversionType.OneToOne) 27 | 28 | 29 | def dependent(start, expected): 30 | full_flow(start, expected, ConversionType.Dependent) 31 | 32 | 33 | def unsupported(start, expected): 34 | full_flow(start, expected, ConversionType.Unsupported) 35 | 36 | 37 | def unknown_error(start): 38 | full_flow(start, {}, ConversionType.UnknownError) 39 | 40 | 41 | def test_directive(): 42 | orig = 'my input' 43 | output = 'my output' 44 | convert_type = ConversionType.PassThru 45 | directive = Directive(output, orig, convert_type) 46 | assert output == directive.tree 47 | assert orig == directive.orig_input 48 | assert convert_type == directive.convert_type 49 | 50 | 51 | def test_di_locale(): 52 | # FIXME needs .UTF-8 at the end in all cases? 53 | for locale in ['en_US', 'en_GB']: 54 | one_to_one(f'd-i debian-installer/locale string {locale}', 55 | {'locale': locale}) 56 | 57 | 58 | def test_di_locale_extra_stuff(): 59 | locale = 'zz_ZZ' 60 | one_to_one(f' d-i debian-installer/locale string {locale} ', 61 | {'locale': locale}) 62 | 63 | 64 | def test_comment(): 65 | lines = [ 66 | '#### Contents of the preconfiguration file (for buster)', 67 | '### Localization', 68 | '# Preseeding only locale sets language, country and locale.', 69 | '', 70 | ' ' * 4, 71 | ] 72 | for line in lines: 73 | directive = convert(line) 74 | assert line == directive.orig_input 75 | assert ConversionType.PassThru == directive.convert_type 76 | 77 | 78 | def test_di_keymap(): 79 | # d-i keyboard-configuration/xkb-keymap select us 80 | # keyboard: 81 | # layout: us 82 | for keymap in ['us', 'zz']: 83 | one_to_one(f'd-i keyboard-configuration/xkb-keymap select {keymap}', 84 | {'keyboard': {'layout': keymap}}) 85 | 86 | 87 | def test_di_debconf_selections(): 88 | line = 'stuff stuff/things string asdf' 89 | dependent(line, {'debconf-selections': f'{line}\n'}) 90 | 91 | 92 | def test_di_user_fullname(): 93 | value = 'Debian User' 94 | # identity: 95 | # realname: value 96 | one_to_one(f'd-i passwd/user-fullname string {value}', 97 | {'identity': {'realname': value}}) 98 | 99 | 100 | def test_di_username(): 101 | value = 'debian' 102 | # username: value 103 | one_to_one(f'd-i passwd/username string {value}', 104 | {'identity': {'username': value}}) 105 | 106 | 107 | def test_di_user_password_crypted(): 108 | value = '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4' \ 109 | 'QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1' 110 | # password: value 111 | one_to_one(f'd-i passwd/user-password-crypted string {value}', 112 | {'identity': {'password': value}}) 113 | 114 | 115 | def test_di_hostname(): 116 | value = 'somehost' 117 | # hostname: value 118 | one_to_one(f'd-i netcfg/hostname string {value}', 119 | {'identity': {'hostname': value}}) 120 | 121 | 122 | def test_netmask_bits(): 123 | table = { 124 | '255.255.255.0': '24', 125 | '255.255.0.0': '16', 126 | } 127 | for key in table: 128 | expected = table[key] 129 | assert expected == netmask_bits(key) 130 | 131 | 132 | def test_di_gateway(): 133 | value = '192.168.1.1' 134 | dependent(f'd-i netcfg/get_gateway string {value}', 135 | {'network': { 136 | 'version': 2, 137 | 'ethernets': {'any': { 138 | 'match': {'name': 'en*'}, 139 | 'gateway4': value} 140 | } 141 | }}) 142 | 143 | 144 | def test_di_address_netmask(): 145 | address = '192.168.1.42' 146 | mask = '255.255.255.0' 147 | mask_bits = '24' 148 | expected = {'network': { 149 | 'version': 2, 150 | 'ethernets': {'any': { 151 | 'match': {'name': 'en*'}, 152 | 'addresses': [f'{address}/{mask_bits}'], 153 | }}} 154 | } 155 | dependent([f'd-i netcfg/get_ipaddress string {address}', 156 | f'd-i netcfg/get_netmask string {mask}'], 157 | expected) 158 | 159 | 160 | def test_di_mirror(): 161 | # d-i mirror/http/hostname string http.us.debian.org 162 | # d-i mirror/http/directory string /debian 163 | hostname = 'http.us.debian.org' 164 | directory = '/debian' 165 | 166 | expected = {'apt': { 167 | 'primary': [{ 168 | 'arches': ['default'], 169 | 'uri': f'http://{hostname}{directory}'}]}} 170 | dependent([f'd-i mirror/http/hostname string {hostname}', 171 | f'd-i mirror/http/directory string {directory}'], 172 | expected) 173 | 174 | 175 | def test_di_partman_method(): 176 | # lvm -> lvm 177 | # regular -> direct 178 | maps = [('lvm', 'lvm'), ('regular', 'direct')] 179 | for pair in maps: 180 | expected = {'storage': {'layout': {'name': pair[1]}}} 181 | one_to_one(f'd-i partman-auto/method string {pair[0]}', expected) 182 | 183 | unknown_error('d-i partman-auto/method string asdf') 184 | 185 | 186 | def test_dependent(): 187 | value = 'asdf' 188 | for key in ['hostname', 'directory']: 189 | orig = f'd-i mirror/http/{key} string {value}' 190 | directive = convert(orig) 191 | 192 | assert ConversionType.Dependent == directive.convert_type 193 | assert orig == directive.orig_input 194 | assert {'mirror/http': {key: value}} == directive.fragments 195 | 196 | 197 | def test_insert_at_none(): 198 | a = {'a': None} 199 | 200 | actual = insert_at_none(a, 1) 201 | expected = {'a': 1} 202 | assert expected == actual 203 | 204 | 205 | def test_insert_at_none_second(): 206 | b = {'a': {'b': None}} 207 | 208 | actual = insert_at_none(b, 1) 209 | expected = {'a': {'b': 1}} 210 | assert expected == actual 211 | 212 | 213 | def test_insert_at_array(): 214 | a = {'a': []} 215 | 216 | actual = insert_at_none(a, 1) 217 | expected = {'a': [1]} 218 | assert expected == actual 219 | 220 | 221 | def test_unsupported(): 222 | lines = [ 223 | 'd-i localechooser/supported-locales multiselect en_US.UTF-8', 224 | 'd-i debian-installer/language string en', 225 | 'd-i debian-installer/country string NL', 226 | 'd-i keyboard-configuration/toggle select No toggling', 227 | 'd-i partman-auto/disk string /dev/sda', 228 | ] 229 | for line in lines: 230 | unsupported(line, {}) 231 | 232 | 233 | def test_duplicate(): 234 | directives = [] 235 | for locale in ['en_US', 'en_GB']: 236 | line = f'd-i debian-installer/locale string {locale}' 237 | directives.append(convert(line)) 238 | actual = merge(directives) 239 | expected = {'locale': 'en_GB'} 240 | assert expected == actual 241 | 242 | 243 | def test_directive_repr(): 244 | dependent = Directive({}, 'netmask', ConversionType.Dependent) 245 | dependent.fragments = {'stuff': 'things'} 246 | onetoone = Directive({}, '1:1', ConversionType.OneToOne) 247 | onetoone.tree = {'first': {'second': 3}} 248 | directives = [ 249 | (Directive({}, 'asdf', ConversionType.UnknownError), 250 | 'UnknownError:"asdf"'), 251 | (Directive({}, 'pass', ConversionType.PassThru), 252 | 'PassThru:"pass"'), 253 | (Directive({}, 'nope', ConversionType.Unsupported), 254 | 'Unsupported:"nope"'), 255 | (dependent, f'Dependent:{dependent.fragments}'), 256 | (onetoone, f'OneToOne:{onetoone.tree}'), 257 | ] 258 | 259 | for d in directives: 260 | assert d[1] == repr(d[0]) 261 | 262 | 263 | def test_debug_directive(): 264 | one = Directive({'stuff': 'things'}, 'my orig input', 265 | ConversionType.OneToOne, 1) 266 | expected = '# 1: Directive: my orig input\n' 267 | actual, linenolen = one.debug_directive() 268 | assert expected == actual 269 | assert 1 == linenolen 270 | 271 | 272 | def test_debug(): 273 | one = Directive({'stuff': 'things'}, 'my orig input', 274 | ConversionType.OneToOne, 1) 275 | expected = '''\ 276 | # 1: Directive: my orig input 277 | # Mapped to: stuff: things 278 | ''' 279 | assert expected == one.debug() 280 | 281 | 282 | def test_debug_coallesce(): 283 | coalesced = Directive({'a': 'b'}, 'asdf', ConversionType.Coalesced, 1) 284 | coalesced.children = [ 285 | Directive({}, 'c', ConversionType.Dependent, 2), 286 | Directive({}, 'd', ConversionType.Dependent, 3), 287 | ] 288 | expected = '''\ 289 | # 2: Directive: c 290 | # 3: And: d 291 | # Mapped to: a: b 292 | ''' 293 | assert expected == coalesced.debug() 294 | 295 | 296 | def test_debug_unsupported(): 297 | unsupported = Directive({}, 'qwerty', ConversionType.Unsupported, 7) 298 | expected = '# 7: Unsupported: qwerty\n' 299 | assert expected == unsupported.debug_directive()[0] 300 | 301 | 302 | def test_debug_error(): 303 | error = Directive({}, 'oiqwueriower', ConversionType.UnknownError, 6) 304 | expected = '# 6: Error: oiqwueriower\n' 305 | assert expected == error.debug_directive()[0] 306 | 307 | 308 | def test_di_multiple_debconf_selections(): 309 | selections = [ 310 | 'stuff stuff/things string asdf', 311 | 'stuff a/b boolean false', 312 | ] 313 | directives = [convert(sel) for sel in selections] 314 | buckets = bucketize(directives) 315 | coalesced = buckets.coalesce() 316 | actual = merge(coalesced) 317 | expected_vals = '''\ 318 | stuff stuff/things string asdf 319 | stuff a/b boolean false 320 | ''' 321 | expected = {'debconf-selections': expected_vals} 322 | assert expected == actual 323 | 324 | 325 | def test_dump_yaml_single(): 326 | tree = {'a': 'b'} 327 | actual = dump_yaml(tree) 328 | expected = 'a: b\n' 329 | assert expected == actual 330 | 331 | 332 | def test_dump_yaml_single_line(): 333 | tree = {'a': 'b\n'} 334 | actual = dump_yaml(tree) 335 | expected = 'a: b\n' 336 | assert expected == actual 337 | 338 | 339 | def test_dump_yaml_multiline(): 340 | tree = {'a': 'b\nc\nd\n'} 341 | actual = dump_yaml(tree) 342 | expected = '''\ 343 | a: | 344 | b 345 | c 346 | d 347 | ''' 348 | assert expected == actual 349 | 350 | 351 | def test_choose_interface_eth1(): 352 | gw = '192.168.1.1' 353 | iface = 'eth1' 354 | dependent([f'd-i netcfg/get_gateway string {gw}', 355 | f'd-i netcfg/choose_interface select {iface}'], 356 | {'network': { 357 | 'version': 2, 358 | 'ethernets': {iface: { 359 | 'gateway4': gw} 360 | } 361 | }}) 362 | -------------------------------------------------------------------------------- /autoinstall_generator/autoinstall-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "version": { 5 | "type": "integer", 6 | "minimum": 1, 7 | "maximum": 1 8 | }, 9 | "early-commands": { 10 | "type": "array", 11 | "items": { 12 | "type": [ 13 | "string", 14 | "array" 15 | ], 16 | "items": { 17 | "type": "string" 18 | } 19 | } 20 | }, 21 | "reporting": { 22 | "type": "object", 23 | "additionalProperties": { 24 | "type": "object", 25 | "properties": { 26 | "type": { 27 | "type": "string" 28 | } 29 | }, 30 | "required": [ 31 | "type" 32 | ], 33 | "additionalProperties": true 34 | } 35 | }, 36 | "error-commands": { 37 | "type": "array", 38 | "items": { 39 | "type": [ 40 | "string", 41 | "array" 42 | ], 43 | "items": { 44 | "type": "string" 45 | } 46 | } 47 | }, 48 | "user-data": { 49 | "type": "object" 50 | }, 51 | "packages": { 52 | "type": "array", 53 | "items": { 54 | "type": "string" 55 | } 56 | }, 57 | "debconf-selections": { 58 | "type": "string" 59 | }, 60 | "locale": { 61 | "type": "string" 62 | }, 63 | "refresh-installer": { 64 | "type": "object", 65 | "properties": { 66 | "update": { 67 | "type": "boolean" 68 | }, 69 | "channel": { 70 | "type": "string" 71 | } 72 | }, 73 | "additionalProperties": false 74 | }, 75 | "keyboard": { 76 | "type": "object", 77 | "properties": { 78 | "layout": { 79 | "type": "string" 80 | }, 81 | "variant": { 82 | "type": "string" 83 | }, 84 | "toggle": { 85 | "type": [ 86 | "string", 87 | "null" 88 | ] 89 | } 90 | }, 91 | "required": [ 92 | "layout" 93 | ], 94 | "additionalProperties": false 95 | }, 96 | "network": { 97 | "oneOf": [ 98 | { 99 | "type": "object", 100 | "properties": { 101 | "version": { 102 | "type": "integer", 103 | "minimum": 2, 104 | "maximum": 2 105 | }, 106 | "ethernets": { 107 | "type": "object", 108 | "properties": { 109 | "match": { 110 | "type": "object", 111 | "properties": { 112 | "name": { 113 | "type": "string" 114 | }, 115 | "macaddress": { 116 | "type": "string" 117 | }, 118 | "driver": { 119 | "type": "string" 120 | } 121 | }, 122 | "additionalProperties": false 123 | } 124 | } 125 | }, 126 | "wifis": { 127 | "type": "object", 128 | "properties": { 129 | "match": { 130 | "type": "object", 131 | "properties": { 132 | "name": { 133 | "type": "string" 134 | }, 135 | "macaddress": { 136 | "type": "string" 137 | }, 138 | "driver": { 139 | "type": "string" 140 | } 141 | }, 142 | "additionalProperties": false 143 | } 144 | } 145 | }, 146 | "bridges": { 147 | "type": "object" 148 | }, 149 | "bonds": { 150 | "type": "object" 151 | }, 152 | "tunnels": { 153 | "type": "object" 154 | }, 155 | "vlans": { 156 | "type": "object" 157 | } 158 | }, 159 | "required": [ 160 | "version" 161 | ] 162 | }, 163 | { 164 | "type": "object", 165 | "properties": { 166 | "network": { 167 | "type": "object", 168 | "properties": { 169 | "version": { 170 | "type": "integer", 171 | "minimum": 2, 172 | "maximum": 2 173 | }, 174 | "ethernets": { 175 | "type": "object", 176 | "properties": { 177 | "match": { 178 | "type": "object", 179 | "properties": { 180 | "name": { 181 | "type": "string" 182 | }, 183 | "macaddress": { 184 | "type": "string" 185 | }, 186 | "driver": { 187 | "type": "string" 188 | } 189 | }, 190 | "additionalProperties": false 191 | } 192 | } 193 | }, 194 | "wifis": { 195 | "type": "object", 196 | "properties": { 197 | "match": { 198 | "type": "object", 199 | "properties": { 200 | "name": { 201 | "type": "string" 202 | }, 203 | "macaddress": { 204 | "type": "string" 205 | }, 206 | "driver": { 207 | "type": "string" 208 | } 209 | }, 210 | "additionalProperties": false 211 | } 212 | } 213 | }, 214 | "bridges": { 215 | "type": "object" 216 | }, 217 | "bonds": { 218 | "type": "object" 219 | }, 220 | "tunnels": { 221 | "type": "object" 222 | }, 223 | "vlans": { 224 | "type": "object" 225 | } 226 | }, 227 | "required": [ 228 | "version" 229 | ] 230 | } 231 | }, 232 | "required": [ 233 | "network" 234 | ] 235 | } 236 | ] 237 | }, 238 | "proxy": { 239 | "type": [ 240 | "string", 241 | "null" 242 | ], 243 | "format": "uri" 244 | }, 245 | "apt": { 246 | "type": "object", 247 | "properties": { 248 | "preserve_sources_list": { 249 | "type": "boolean" 250 | }, 251 | "primary": { 252 | "type": "array" 253 | }, 254 | "geoip": { 255 | "type": "boolean" 256 | }, 257 | "sources": { 258 | "type": "object" 259 | } 260 | } 261 | }, 262 | "storage": { 263 | "type": "object" 264 | }, 265 | "identity": { 266 | "type": "object", 267 | "properties": { 268 | "realname": { 269 | "type": "string" 270 | }, 271 | "username": { 272 | "type": "string" 273 | }, 274 | "hostname": { 275 | "type": "string" 276 | }, 277 | "password": { 278 | "type": "string" 279 | } 280 | }, 281 | "required": [ 282 | "username", 283 | "hostname", 284 | "password" 285 | ], 286 | "additionalProperties": false 287 | }, 288 | "ssh": { 289 | "type": "object", 290 | "properties": { 291 | "install-server": { 292 | "type": "boolean" 293 | }, 294 | "authorized-keys": { 295 | "type": "array", 296 | "items": { 297 | "type": "string" 298 | } 299 | }, 300 | "allow-pw": { 301 | "type": "boolean" 302 | } 303 | } 304 | }, 305 | "snaps": { 306 | "type": "array", 307 | "items": { 308 | "type": "object", 309 | "properties": { 310 | "name": { 311 | "type": "string" 312 | }, 313 | "channel": { 314 | "type": "string" 315 | }, 316 | "classic": { 317 | "type": "boolean" 318 | } 319 | }, 320 | "required": [ 321 | "name" 322 | ], 323 | "additionalProperties": false 324 | } 325 | }, 326 | "late-commands": { 327 | "type": "array", 328 | "items": { 329 | "type": [ 330 | "string", 331 | "array" 332 | ], 333 | "items": { 334 | "type": "string" 335 | } 336 | } 337 | } 338 | }, 339 | "required": [ 340 | "version" 341 | ], 342 | "additionalProperties": true 343 | } 344 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/data/example-preseed.txt: -------------------------------------------------------------------------------- 1 | #### Contents of the preconfiguration file (for buster) 2 | ### Localization 3 | # Preseeding only locale sets language, country and locale. 4 | d-i debian-installer/locale string en_US 5 | 6 | # The values can also be preseeded individually for greater flexibility. 7 | #d-i debian-installer/language string en 8 | #d-i debian-installer/country string NL 9 | #d-i debian-installer/locale string en_GB.UTF-8 10 | # Optionally specify additional locales to be generated. 11 | #d-i localechooser/supported-locales multiselect en_US.UTF-8, nl_NL.UTF-8 12 | 13 | # Keyboard selection. 14 | d-i keyboard-configuration/xkb-keymap select us 15 | # d-i keyboard-configuration/toggle select No toggling 16 | 17 | ### Network configuration 18 | # Disable network configuration entirely. This is useful for cdrom 19 | # installations on non-networked devices where the network questions, 20 | # warning and long timeouts are a nuisance. 21 | #d-i netcfg/enable boolean false 22 | 23 | # netcfg will choose an interface that has link if possible. This makes it 24 | # skip displaying a list if there is more than one interface. 25 | d-i netcfg/choose_interface select auto 26 | 27 | # To pick a particular interface instead: 28 | #d-i netcfg/choose_interface select eth1 29 | 30 | # To set a different link detection timeout (default is 3 seconds). 31 | # Values are interpreted as seconds. 32 | #d-i netcfg/link_wait_timeout string 10 33 | 34 | # If you have a slow dhcp server and the installer times out waiting for 35 | # it, this might be useful. 36 | #d-i netcfg/dhcp_timeout string 60 37 | #d-i netcfg/dhcpv6_timeout string 60 38 | 39 | # If you prefer to configure the network manually, uncomment this line and 40 | # the static network configuration below. 41 | #d-i netcfg/disable_autoconfig boolean true 42 | 43 | # If you want the preconfiguration file to work on systems both with and 44 | # without a dhcp server, uncomment these lines and the static network 45 | # configuration below. 46 | #d-i netcfg/dhcp_failed note 47 | #d-i netcfg/dhcp_options select Configure network manually 48 | 49 | # Static network configuration. 50 | # 51 | # IPv4 example 52 | #d-i netcfg/get_ipaddress string 192.168.1.42 53 | #d-i netcfg/get_netmask string 255.255.255.0 54 | #d-i netcfg/get_gateway string 192.168.1.1 55 | #d-i netcfg/get_nameservers string 192.168.1.1 56 | #d-i netcfg/confirm_static boolean true 57 | # 58 | # IPv6 example 59 | #d-i netcfg/get_ipaddress string fc00::2 60 | #d-i netcfg/get_netmask string ffff:ffff:ffff:ffff:: 61 | #d-i netcfg/get_gateway string fc00::1 62 | #d-i netcfg/get_nameservers string fc00::1 63 | #d-i netcfg/confirm_static boolean true 64 | 65 | # Any hostname and domain names assigned from dhcp take precedence over 66 | # values set here. However, setting the values still prevents the questions 67 | # from being shown, even if values come from dhcp. 68 | d-i netcfg/get_hostname string unassigned-hostname 69 | d-i netcfg/get_domain string unassigned-domain 70 | 71 | # If you want to force a hostname, regardless of what either the DHCP 72 | # server returns or what the reverse DNS entry for the IP is, uncomment 73 | # and adjust the following line. 74 | #d-i netcfg/hostname string somehost 75 | 76 | # Disable that annoying WEP key dialog. 77 | d-i netcfg/wireless_wep string 78 | # The wacky dhcp hostname that some ISPs use as a password of sorts. 79 | #d-i netcfg/dhcp_hostname string radish 80 | 81 | # If non-free firmware is needed for the network or other hardware, you can 82 | # configure the installer to always try to load it, without prompting. Or 83 | # change to false to disable asking. 84 | #d-i hw-detect/load_firmware boolean true 85 | 86 | ### Network console 87 | # Use the following settings if you wish to make use of the network-console 88 | # component for remote installation over SSH. This only makes sense if you 89 | # intend to perform the remainder of the installation manually. 90 | #d-i anna/choose_modules string network-console 91 | #d-i network-console/authorized_keys_url string http://10.0.0.1/openssh-key 92 | #d-i network-console/password password r00tme 93 | #d-i network-console/password-again password r00tme 94 | 95 | ### Mirror settings 96 | # If you select ftp, the mirror/country string does not need to be set. 97 | #d-i mirror/protocol string ftp 98 | d-i mirror/country string manual 99 | d-i mirror/http/hostname string http.us.debian.org 100 | d-i mirror/http/directory string /debian 101 | d-i mirror/http/proxy string 102 | 103 | # Suite to install. 104 | #d-i mirror/suite string testing 105 | # Suite to use for loading installer components (optional). 106 | #d-i mirror/udeb/suite string testing 107 | 108 | ### Account setup 109 | # Skip creation of a root account (normal user account will be able to 110 | # use sudo). 111 | #d-i passwd/root-login boolean false 112 | # Alternatively, to skip creation of a normal user account. 113 | #d-i passwd/make-user boolean false 114 | 115 | # Root password, either in clear text 116 | #d-i passwd/root-password password r00tme 117 | #d-i passwd/root-password-again password r00tme 118 | # or encrypted using a crypt(3) hash. 119 | #d-i passwd/root-password-crypted password [crypt(3) hash] 120 | 121 | # To create a normal user account. 122 | #d-i passwd/user-fullname string Debian User 123 | #d-i passwd/username string debian 124 | # Normal user's password, either in clear text 125 | #d-i passwd/user-password password insecure 126 | #d-i passwd/user-password-again password insecure 127 | # or encrypted using a crypt(3) hash. 128 | #d-i passwd/user-password-crypted password [crypt(3) hash] 129 | # Create the first user with the specified UID instead of the default. 130 | #d-i passwd/user-uid string 1010 131 | 132 | # The user account will be added to some standard initial groups. To 133 | # override that, use this. 134 | #d-i passwd/user-default-groups string audio cdrom video 135 | 136 | ### Clock and time zone setup 137 | # Controls whether or not the hardware clock is set to UTC. 138 | d-i clock-setup/utc boolean true 139 | 140 | # You may set this to any valid setting for $TZ; see the contents of 141 | # /usr/share/zoneinfo/ for valid values. 142 | d-i time/zone string US/Eastern 143 | 144 | # Controls whether to use NTP to set the clock during the install 145 | d-i clock-setup/ntp boolean true 146 | # NTP server to use. The default is almost always fine here. 147 | #d-i clock-setup/ntp-server string ntp.example.com 148 | 149 | ### Partitioning 150 | ## Partitioning example 151 | # If the system has free space you can choose to only partition that space. 152 | # This is only honoured if partman-auto/method (below) is not set. 153 | #d-i partman-auto/init_automatically_partition select biggest_free 154 | 155 | # Alternatively, you may specify a disk to partition. If the system has only 156 | # one disk the installer will default to using that, but otherwise the device 157 | # name must be given in traditional, non-devfs format (so e.g. /dev/sda 158 | # and not e.g. /dev/discs/disc0/disc). 159 | # For example, to use the first SCSI/SATA hard disk: 160 | #d-i partman-auto/disk string /dev/sda 161 | # In addition, you'll need to specify the method to use. 162 | # The presently available methods are: 163 | # - regular: use the usual partition types for your architecture 164 | # - lvm: use LVM to partition the disk 165 | # - crypto: use LVM within an encrypted partition 166 | d-i partman-auto/method string lvm 167 | 168 | # You can define the amount of space that will be used for the LVM volume 169 | # group. It can either be a size with its unit (eg. 20 GB), a percentage of 170 | # free space or the 'max' keyword. 171 | d-i partman-auto-lvm/guided_size string max 172 | 173 | # If one of the disks that are going to be automatically partitioned 174 | # contains an old LVM configuration, the user will normally receive a 175 | # warning. This can be preseeded away... 176 | d-i partman-lvm/device_remove_lvm boolean true 177 | # The same applies to pre-existing software RAID array: 178 | d-i partman-md/device_remove_md boolean true 179 | # And the same goes for the confirmation to write the lvm partitions. 180 | d-i partman-lvm/confirm boolean true 181 | d-i partman-lvm/confirm_nooverwrite boolean true 182 | 183 | # You can choose one of the three predefined partitioning recipes: 184 | # - atomic: all files in one partition 185 | # - home: separate /home partition 186 | # - multi: separate /home, /var, and /tmp partitions 187 | d-i partman-auto/choose_recipe select atomic 188 | 189 | # Or provide a recipe of your own... 190 | # If you have a way to get a recipe file into the d-i environment, you can 191 | # just point at it. 192 | #d-i partman-auto/expert_recipe_file string /hd-media/recipe 193 | 194 | # If not, you can put an entire recipe into the preconfiguration file in one 195 | # (logical) line. This example creates a small /boot partition, suitable 196 | # swap, and uses the rest of the space for the root partition: 197 | #d-i partman-auto/expert_recipe string \ 198 | # boot-root :: \ 199 | # 40 50 100 ext3 \ 200 | # $primary{ } $bootable{ } \ 201 | # method{ format } format{ } \ 202 | # use_filesystem{ } filesystem{ ext3 } \ 203 | # mountpoint{ /boot } \ 204 | # . \ 205 | # 500 10000 1000000000 ext3 \ 206 | # method{ format } format{ } \ 207 | # use_filesystem{ } filesystem{ ext3 } \ 208 | # mountpoint{ / } \ 209 | # . \ 210 | # 64 512 300% linux-swap \ 211 | # method{ swap } format{ } \ 212 | # . 213 | 214 | # The full recipe format is documented in the file partman-auto-recipe.txt 215 | # included in the 'debian-installer' package or available from D-I source 216 | # repository. This also documents how to specify settings such as file 217 | # system labels, volume group names and which physical devices to include 218 | # in a volume group. 219 | 220 | # This makes partman automatically partition without confirmation, provided 221 | # that you told it what to do using one of the methods above. 222 | d-i partman-partitioning/confirm_write_new_label boolean true 223 | d-i partman/choose_partition select finish 224 | d-i partman/confirm boolean true 225 | d-i partman/confirm_nooverwrite boolean true 226 | 227 | # When disk encryption is enabled, skip wiping the partitions beforehand. 228 | #d-i partman-auto-crypto/erase_disks boolean false 229 | 230 | ## Partitioning using RAID 231 | # The method should be set to "raid". 232 | #d-i partman-auto/method string raid 233 | # Specify the disks to be partitioned. They will all get the same layout, 234 | # so this will only work if the disks are the same size. 235 | #d-i partman-auto/disk string /dev/sda /dev/sdb 236 | 237 | # Next you need to specify the physical partitions that will be used. 238 | #d-i partman-auto/expert_recipe string \ 239 | # multiraid :: \ 240 | # 1000 5000 4000 raid \ 241 | # $primary{ } method{ raid } \ 242 | # . \ 243 | # 64 512 300% raid \ 244 | # method{ raid } \ 245 | # . \ 246 | # 500 10000 1000000000 raid \ 247 | # method{ raid } \ 248 | # . 249 | 250 | # Last you need to specify how the previously defined partitions will be 251 | # used in the RAID setup. Remember to use the correct partition numbers 252 | # for logical partitions. RAID levels 0, 1, 5, 6 and 10 are supported; 253 | # devices are separated using "#". 254 | # Parameters are: 255 | # \ 256 | # 257 | 258 | #d-i partman-auto-raid/recipe string \ 259 | # 1 2 0 ext3 / \ 260 | # /dev/sda1#/dev/sdb1 \ 261 | # . \ 262 | # 1 2 0 swap - \ 263 | # /dev/sda5#/dev/sdb5 \ 264 | # . \ 265 | # 0 2 0 ext3 /home \ 266 | # /dev/sda6#/dev/sdb6 \ 267 | # . 268 | 269 | # For additional information see the file partman-auto-raid-recipe.txt 270 | # included in the 'debian-installer' package or available from D-I source 271 | # repository. 272 | 273 | # This makes partman automatically partition without confirmation. 274 | d-i partman-md/confirm boolean true 275 | d-i partman-partitioning/confirm_write_new_label boolean true 276 | d-i partman/choose_partition select finish 277 | d-i partman/confirm boolean true 278 | d-i partman/confirm_nooverwrite boolean true 279 | 280 | ## Controlling how partitions are mounted 281 | # The default is to mount by UUID, but you can also choose "traditional" to 282 | # use traditional device names, or "label" to try filesystem labels before 283 | # falling back to UUIDs. 284 | #d-i partman/mount_style select uuid 285 | 286 | ### Base system installation 287 | # Configure APT to not install recommended packages by default. Use of this 288 | # option can result in an incomplete system and should only be used by very 289 | # experienced users. 290 | #d-i base-installer/install-recommends boolean false 291 | 292 | # The kernel image (meta) package to be installed; "none" can be used if no 293 | # kernel is to be installed. 294 | #d-i base-installer/kernel/image string linux-image-686 295 | 296 | ### Apt setup 297 | # You can choose to install non-free and contrib software. 298 | #d-i apt-setup/non-free boolean true 299 | #d-i apt-setup/contrib boolean true 300 | # Uncomment this if you don't want to use a network mirror. 301 | #d-i apt-setup/use_mirror boolean false 302 | # Select which update services to use; define the mirrors to be used. 303 | # Values shown below are the normal defaults. 304 | #d-i apt-setup/services-select multiselect security, updates 305 | #d-i apt-setup/security_host string security.debian.org 306 | 307 | # Additional repositories, local[0-9] available 308 | #d-i apt-setup/local0/repository string \ 309 | # http://local.server/debian stable main 310 | #d-i apt-setup/local0/comment string local server 311 | # Enable deb-src lines 312 | #d-i apt-setup/local0/source boolean true 313 | # URL to the public key of the local repository; you must provide a key or 314 | # apt will complain about the unauthenticated repository and so the 315 | # sources.list line will be left commented out 316 | #d-i apt-setup/local0/key string http://local.server/key 317 | 318 | # By default the installer requires that repositories be authenticated 319 | # using a known gpg key. This setting can be used to disable that 320 | # authentication. Warning: Insecure, not recommended. 321 | #d-i debian-installer/allow_unauthenticated boolean true 322 | 323 | # Uncomment this to add multiarch configuration for i386 324 | #d-i apt-setup/multiarch string i386 325 | 326 | 327 | ### Package selection 328 | #tasksel tasksel/first multiselect standard, web-server, kde-desktop 329 | 330 | # Individual additional packages to install 331 | #d-i pkgsel/include string openssh-server build-essential 332 | # Whether to upgrade packages after debootstrap. 333 | # Allowed values: none, safe-upgrade, full-upgrade 334 | #d-i pkgsel/upgrade select none 335 | 336 | # Some versions of the installer can report back on what software you have 337 | # installed, and what software you use. The default is not to report back, 338 | # but sending reports helps the project determine what software is most 339 | # popular and include it on CDs. 340 | #popularity-contest popularity-contest/participate boolean false 341 | 342 | ### Boot loader installation 343 | # Grub is the default boot loader (for x86). If you want lilo installed 344 | # instead, uncomment this: 345 | #d-i grub-installer/skip boolean true 346 | # To also skip installing lilo, and install no bootloader, uncomment this 347 | # too: 348 | #d-i lilo-installer/skip boolean true 349 | 350 | 351 | # This is fairly safe to set, it makes grub install automatically to the MBR 352 | # if no other operating system is detected on the machine. 353 | d-i grub-installer/only_debian boolean true 354 | 355 | # This one makes grub-installer install to the MBR if it also finds some other 356 | # OS, which is less safe as it might not be able to boot that other OS. 357 | d-i grub-installer/with_other_os boolean true 358 | 359 | # Due notably to potential USB sticks, the location of the MBR can not be 360 | # determined safely in general, so this needs to be specified: 361 | #d-i grub-installer/bootdev string /dev/sda 362 | # To install to the first device (assuming it is not a USB stick): 363 | #d-i grub-installer/bootdev string default 364 | 365 | # Alternatively, if you want to install to a location other than the mbr, 366 | # uncomment and edit these lines: 367 | #d-i grub-installer/only_debian boolean false 368 | #d-i grub-installer/with_other_os boolean false 369 | #d-i grub-installer/bootdev string (hd0,1) 370 | # To install grub to multiple disks: 371 | #d-i grub-installer/bootdev string (hd0,1) (hd1,1) (hd2,1) 372 | 373 | # Optional password for grub, either in clear text 374 | #d-i grub-installer/password password r00tme 375 | #d-i grub-installer/password-again password r00tme 376 | # or encrypted using an MD5 hash, see grub-md5-crypt(8). 377 | #d-i grub-installer/password-crypted password [MD5 hash] 378 | 379 | # Use the following option to add additional boot parameters for the 380 | # installed system (if supported by the bootloader installer). 381 | # Note: options passed to the installer will be added automatically. 382 | #d-i debian-installer/add-kernel-opts string nousb 383 | 384 | ### Finishing up the installation 385 | # During installations from serial console, the regular virtual consoles 386 | # (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next 387 | # line to prevent this. 388 | #d-i finish-install/keep-consoles boolean true 389 | 390 | # Avoid that last message about the install being complete. 391 | d-i finish-install/reboot_in_progress note 392 | 393 | # This will prevent the installer from ejecting the CD during the reboot, 394 | # which is useful in some situations. 395 | #d-i cdrom-detect/eject boolean false 396 | 397 | # This is how to make the installer shutdown when finished, but not 398 | # reboot into the installed system. 399 | #d-i debian-installer/exit/halt boolean true 400 | # This will power off the machine instead of just halting it. 401 | #d-i debian-installer/exit/poweroff boolean true 402 | 403 | ### Preseeding other packages 404 | # Depending on what software you choose to install, or if things go wrong 405 | # during the installation process, it's possible that other questions may 406 | # be asked. You can preseed those too, of course. To get a list of every 407 | # possible question that could be asked during an install, do an 408 | # installation, and then run these commands: 409 | # debconf-get-selections --installer > file 410 | # debconf-get-selections >> file 411 | 412 | 413 | #### Advanced options 414 | ### Running custom commands during the installation 415 | # d-i preseeding is inherently not secure. Nothing in the installer checks 416 | # for attempts at buffer overflows or other exploits of the values of a 417 | # preconfiguration file like this one. Only use preconfiguration files from 418 | # trusted locations! To drive that home, and because it's generally useful, 419 | # here's a way to run any shell command you'd like inside the installer, 420 | # automatically. 421 | 422 | # This first command is run as early as possible, just after 423 | # preseeding is read. 424 | #d-i preseed/early_command string anna-install some-udeb 425 | # This command is run immediately before the partitioner starts. It may be 426 | # useful to apply dynamic partitioner preseeding that depends on the state 427 | # of the disks (which may not be visible when preseed/early_command runs). 428 | #d-i partman/early_command \ 429 | # string debconf-set partman-auto/disk "$(list-devices disk | head -n1)" 430 | # This command is run just before the install finishes, but when there is 431 | # still a usable /target directory. You can chroot to /target and use it 432 | # directly, or use the apt-install and in-target commands to easily install 433 | # packages and run commands in the target system. 434 | #d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh 435 | 436 | -------------------------------------------------------------------------------- /autoinstall_generator/tests/data/preseed.txt: -------------------------------------------------------------------------------- 1 | #### Contents of the preconfiguration file (for buster) 2 | ### Localization 3 | # Preseeding only locale sets language, country and locale. 4 | d-i debian-installer/locale string en_US 5 | 6 | # The values can also be preseeded individually for greater flexibility. 7 | d-i debian-installer/language string en 8 | d-i debian-installer/country string NL 9 | d-i debian-installer/locale string en_GB.UTF-8 10 | # Optionally specify additional locales to be generated. 11 | d-i localechooser/supported-locales multiselect en_US.UTF-8, nl_NL.UTF-8 12 | 13 | # Keyboard selection. 14 | d-i keyboard-configuration/xkb-keymap select us 15 | d-i keyboard-configuration/toggle select No toggling 16 | 17 | ### Network configuration 18 | # Disable network configuration entirely. This is useful for cdrom 19 | # installations on non-networked devices where the network questions, 20 | # warning and long timeouts are a nuisance. 21 | #d-i netcfg/enable boolean false 22 | 23 | # netcfg will choose an interface that has link if possible. This makes it 24 | # skip displaying a list if there is more than one interface. 25 | d-i netcfg/choose_interface select auto 26 | 27 | # To pick a particular interface instead: 28 | #d-i netcfg/choose_interface select eth1 29 | 30 | # To set a different link detection timeout (default is 3 seconds). 31 | # Values are interpreted as seconds. 32 | #d-i netcfg/link_wait_timeout string 10 33 | 34 | # If you have a slow dhcp server and the installer times out waiting for 35 | # it, this might be useful. 36 | #d-i netcfg/dhcp_timeout string 60 37 | #d-i netcfg/dhcpv6_timeout string 60 38 | 39 | # If you prefer to configure the network manually, uncomment this line and 40 | # the static network configuration below. 41 | #d-i netcfg/disable_autoconfig boolean true 42 | 43 | # If you want the preconfiguration file to work on systems both with and 44 | # without a dhcp server, uncomment these lines and the static network 45 | # configuration below. 46 | #d-i netcfg/dhcp_failed note 47 | #d-i netcfg/dhcp_options select Configure network manually 48 | 49 | # Static network configuration. 50 | # 51 | # IPv4 example 52 | d-i netcfg/get_ipaddress string 192.168.1.42 53 | d-i netcfg/get_netmask string 255.255.255.0 54 | d-i netcfg/get_gateway string 192.168.1.1 55 | d-i netcfg/get_nameservers string 192.168.1.1 56 | d-i netcfg/confirm_static boolean true 57 | # 58 | # IPv6 example 59 | #d-i netcfg/get_ipaddress string fc00::2 60 | #d-i netcfg/get_netmask string ffff:ffff:ffff:ffff:: 61 | #d-i netcfg/get_gateway string fc00::1 62 | #d-i netcfg/get_nameservers string fc00::1 63 | #d-i netcfg/confirm_static boolean true 64 | 65 | # Any hostname and domain names assigned from dhcp take precedence over 66 | # values set here. However, setting the values still prevents the questions 67 | # from being shown, even if values come from dhcp. 68 | d-i netcfg/get_hostname string unassigned-hostname 69 | d-i netcfg/get_domain string unassigned-domain 70 | 71 | # If you want to force a hostname, regardless of what either the DHCP 72 | # server returns or what the reverse DNS entry for the IP is, uncomment 73 | # and adjust the following line. 74 | #d-i netcfg/hostname string somehost 75 | 76 | # Disable that annoying WEP key dialog. 77 | d-i netcfg/wireless_wep string 78 | # The wacky dhcp hostname that some ISPs use as a password of sorts. 79 | #d-i netcfg/dhcp_hostname string radish 80 | 81 | # If non-free firmware is needed for the network or other hardware, you can 82 | # configure the installer to always try to load it, without prompting. Or 83 | # change to false to disable asking. 84 | #d-i hw-detect/load_firmware boolean true 85 | 86 | ### Network console 87 | # Use the following settings if you wish to make use of the network-console 88 | # component for remote installation over SSH. This only makes sense if you 89 | # intend to perform the remainder of the installation manually. 90 | #d-i anna/choose_modules string network-console 91 | #d-i network-console/authorized_keys_url string http://10.0.0.1/openssh-key 92 | #d-i network-console/password password r00tme 93 | #d-i network-console/password-again password r00tme 94 | 95 | ### Mirror settings 96 | # If you select ftp, the mirror/country string does not need to be set. 97 | #d-i mirror/protocol string ftp 98 | d-i mirror/country string manual 99 | d-i mirror/http/hostname string http.us.debian.org 100 | d-i mirror/http/directory string /debian 101 | d-i mirror/http/proxy string 102 | 103 | # Suite to install. 104 | #d-i mirror/suite string testing 105 | # Suite to use for loading installer components (optional). 106 | #d-i mirror/udeb/suite string testing 107 | 108 | ### Account setup 109 | # Skip creation of a root account (normal user account will be able to 110 | # use sudo). 111 | #d-i passwd/root-login boolean false 112 | # Alternatively, to skip creation of a normal user account. 113 | #d-i passwd/make-user boolean false 114 | 115 | # Root password, either in clear text 116 | #d-i passwd/root-password password r00tme 117 | #d-i passwd/root-password-again password r00tme 118 | # or encrypted using a crypt(3) hash. 119 | #d-i passwd/root-password-crypted password [crypt(3) hash] 120 | 121 | # To create a normal user account. 122 | #d-i passwd/user-fullname string Debian User 123 | #d-i passwd/username string debian 124 | # Normal user's password, either in clear text 125 | #d-i passwd/user-password password insecure 126 | #d-i passwd/user-password-again password insecure 127 | # or encrypted using a crypt(3) hash. 128 | #d-i passwd/user-password-crypted password [crypt(3) hash] 129 | # Create the first user with the specified UID instead of the default. 130 | #d-i passwd/user-uid string 1010 131 | 132 | # The user account will be added to some standard initial groups. To 133 | # override that, use this. 134 | #d-i passwd/user-default-groups string audio cdrom video 135 | 136 | ### Clock and time zone setup 137 | # Controls whether or not the hardware clock is set to UTC. 138 | d-i clock-setup/utc boolean true 139 | 140 | # You may set this to any valid setting for $TZ; see the contents of 141 | # /usr/share/zoneinfo/ for valid values. 142 | d-i time/zone string US/Eastern 143 | 144 | # Controls whether to use NTP to set the clock during the install 145 | d-i clock-setup/ntp boolean true 146 | # NTP server to use. The default is almost always fine here. 147 | #d-i clock-setup/ntp-server string ntp.example.com 148 | 149 | ### Partitioning 150 | ## Partitioning example 151 | # If the system has free space you can choose to only partition that space. 152 | # This is only honoured if partman-auto/method (below) is not set. 153 | #d-i partman-auto/init_automatically_partition select biggest_free 154 | 155 | # Alternatively, you may specify a disk to partition. If the system has only 156 | # one disk the installer will default to using that, but otherwise the device 157 | # name must be given in traditional, non-devfs format (so e.g. /dev/sda 158 | # and not e.g. /dev/discs/disc0/disc). 159 | # For example, to use the first SCSI/SATA hard disk: 160 | d-i partman-auto/disk string /dev/sda 161 | # In addition, you'll need to specify the method to use. 162 | # The presently available methods are: 163 | # - regular: use the usual partition types for your architecture 164 | # - lvm: use LVM to partition the disk 165 | # - crypto: use LVM within an encrypted partition 166 | d-i partman-auto/method string lvm 167 | 168 | # You can define the amount of space that will be used for the LVM volume 169 | # group. It can either be a size with its unit (eg. 20 GB), a percentage of 170 | # free space or the 'max' keyword. 171 | d-i partman-auto-lvm/guided_size string max 172 | 173 | # If one of the disks that are going to be automatically partitioned 174 | # contains an old LVM configuration, the user will normally receive a 175 | # warning. This can be preseeded away... 176 | d-i partman-lvm/device_remove_lvm boolean true 177 | # The same applies to pre-existing software RAID array: 178 | d-i partman-md/device_remove_md boolean true 179 | # And the same goes for the confirmation to write the lvm partitions. 180 | d-i partman-lvm/confirm boolean true 181 | d-i partman-lvm/confirm_nooverwrite boolean true 182 | 183 | # You can choose one of the three predefined partitioning recipes: 184 | # - atomic: all files in one partition 185 | # - home: separate /home partition 186 | # - multi: separate /home, /var, and /tmp partitions 187 | d-i partman-auto/choose_recipe select atomic 188 | 189 | # Or provide a recipe of your own... 190 | # If you have a way to get a recipe file into the d-i environment, you can 191 | # just point at it. 192 | #d-i partman-auto/expert_recipe_file string /hd-media/recipe 193 | 194 | # If not, you can put an entire recipe into the preconfiguration file in one 195 | # (logical) line. This example creates a small /boot partition, suitable 196 | # swap, and uses the rest of the space for the root partition: 197 | #d-i partman-auto/expert_recipe string \ 198 | # boot-root :: \ 199 | # 40 50 100 ext3 \ 200 | # $primary{ } $bootable{ } \ 201 | # method{ format } format{ } \ 202 | # use_filesystem{ } filesystem{ ext3 } \ 203 | # mountpoint{ /boot } \ 204 | # . \ 205 | # 500 10000 1000000000 ext3 \ 206 | # method{ format } format{ } \ 207 | # use_filesystem{ } filesystem{ ext3 } \ 208 | # mountpoint{ / } \ 209 | # . \ 210 | # 64 512 300% linux-swap \ 211 | # method{ swap } format{ } \ 212 | # . 213 | 214 | # The full recipe format is documented in the file partman-auto-recipe.txt 215 | # included in the 'debian-installer' package or available from D-I source 216 | # repository. This also documents how to specify settings such as file 217 | # system labels, volume group names and which physical devices to include 218 | # in a volume group. 219 | 220 | # This makes partman automatically partition without confirmation, provided 221 | # that you told it what to do using one of the methods above. 222 | d-i partman-partitioning/confirm_write_new_label boolean true 223 | d-i partman/choose_partition select finish 224 | d-i partman/confirm boolean true 225 | d-i partman/confirm_nooverwrite boolean true 226 | 227 | # When disk encryption is enabled, skip wiping the partitions beforehand. 228 | #d-i partman-auto-crypto/erase_disks boolean false 229 | 230 | ## Partitioning using RAID 231 | # The method should be set to "raid". 232 | #d-i partman-auto/method string raid 233 | # Specify the disks to be partitioned. They will all get the same layout, 234 | # so this will only work if the disks are the same size. 235 | #d-i partman-auto/disk string /dev/sda /dev/sdb 236 | 237 | # Next you need to specify the physical partitions that will be used. 238 | #d-i partman-auto/expert_recipe string \ 239 | # multiraid :: \ 240 | # 1000 5000 4000 raid \ 241 | # $primary{ } method{ raid } \ 242 | # . \ 243 | # 64 512 300% raid \ 244 | # method{ raid } \ 245 | # . \ 246 | # 500 10000 1000000000 raid \ 247 | # method{ raid } \ 248 | # . 249 | 250 | # Last you need to specify how the previously defined partitions will be 251 | # used in the RAID setup. Remember to use the correct partition numbers 252 | # for logical partitions. RAID levels 0, 1, 5, 6 and 10 are supported; 253 | # devices are separated using "#". 254 | # Parameters are: 255 | # \ 256 | # 257 | 258 | #d-i partman-auto-raid/recipe string \ 259 | # 1 2 0 ext3 / \ 260 | # /dev/sda1#/dev/sdb1 \ 261 | # . \ 262 | # 1 2 0 swap - \ 263 | # /dev/sda5#/dev/sdb5 \ 264 | # . \ 265 | # 0 2 0 ext3 /home \ 266 | # /dev/sda6#/dev/sdb6 \ 267 | # . 268 | 269 | # For additional information see the file partman-auto-raid-recipe.txt 270 | # included in the 'debian-installer' package or available from D-I source 271 | # repository. 272 | 273 | # This makes partman automatically partition without confirmation. 274 | d-i partman-md/confirm boolean true 275 | d-i partman-partitioning/confirm_write_new_label boolean true 276 | d-i partman/choose_partition select finish 277 | d-i partman/confirm boolean true 278 | d-i partman/confirm_nooverwrite boolean true 279 | 280 | ## Controlling how partitions are mounted 281 | # The default is to mount by UUID, but you can also choose "traditional" to 282 | # use traditional device names, or "label" to try filesystem labels before 283 | # falling back to UUIDs. 284 | #d-i partman/mount_style select uuid 285 | 286 | ### Base system installation 287 | # Configure APT to not install recommended packages by default. Use of this 288 | # option can result in an incomplete system and should only be used by very 289 | # experienced users. 290 | #d-i base-installer/install-recommends boolean false 291 | 292 | # The kernel image (meta) package to be installed; "none" can be used if no 293 | # kernel is to be installed. 294 | #d-i base-installer/kernel/image string linux-image-686 295 | 296 | ### Apt setup 297 | # You can choose to install non-free and contrib software. 298 | #d-i apt-setup/non-free boolean true 299 | #d-i apt-setup/contrib boolean true 300 | # Uncomment this if you don't want to use a network mirror. 301 | #d-i apt-setup/use_mirror boolean false 302 | # Select which update services to use; define the mirrors to be used. 303 | # Values shown below are the normal defaults. 304 | #d-i apt-setup/services-select multiselect security, updates 305 | #d-i apt-setup/security_host string security.debian.org 306 | 307 | # Additional repositories, local[0-9] available 308 | #d-i apt-setup/local0/repository string \ 309 | # http://local.server/debian stable main 310 | #d-i apt-setup/local0/comment string local server 311 | # Enable deb-src lines 312 | #d-i apt-setup/local0/source boolean true 313 | # URL to the public key of the local repository; you must provide a key or 314 | # apt will complain about the unauthenticated repository and so the 315 | # sources.list line will be left commented out 316 | #d-i apt-setup/local0/key string http://local.server/key 317 | 318 | # By default the installer requires that repositories be authenticated 319 | # using a known gpg key. This setting can be used to disable that 320 | # authentication. Warning: Insecure, not recommended. 321 | #d-i debian-installer/allow_unauthenticated boolean true 322 | 323 | # Uncomment this to add multiarch configuration for i386 324 | #d-i apt-setup/multiarch string i386 325 | 326 | 327 | ### Package selection 328 | #tasksel tasksel/first multiselect standard, web-server, kde-desktop 329 | 330 | # Individual additional packages to install 331 | #d-i pkgsel/include string openssh-server build-essential 332 | # Whether to upgrade packages after debootstrap. 333 | # Allowed values: none, safe-upgrade, full-upgrade 334 | #d-i pkgsel/upgrade select none 335 | 336 | # Some versions of the installer can report back on what software you have 337 | # installed, and what software you use. The default is not to report back, 338 | # but sending reports helps the project determine what software is most 339 | # popular and include it on CDs. 340 | #popularity-contest popularity-contest/participate boolean false 341 | 342 | ### Boot loader installation 343 | # Grub is the default boot loader (for x86). If you want lilo installed 344 | # instead, uncomment this: 345 | #d-i grub-installer/skip boolean true 346 | # To also skip installing lilo, and install no bootloader, uncomment this 347 | # too: 348 | #d-i lilo-installer/skip boolean true 349 | 350 | 351 | # This is fairly safe to set, it makes grub install automatically to the MBR 352 | # if no other operating system is detected on the machine. 353 | d-i grub-installer/only_debian boolean true 354 | 355 | # This one makes grub-installer install to the MBR if it also finds some other 356 | # OS, which is less safe as it might not be able to boot that other OS. 357 | d-i grub-installer/with_other_os boolean true 358 | 359 | # Due notably to potential USB sticks, the location of the MBR can not be 360 | # determined safely in general, so this needs to be specified: 361 | #d-i grub-installer/bootdev string /dev/sda 362 | # To install to the first device (assuming it is not a USB stick): 363 | #d-i grub-installer/bootdev string default 364 | 365 | # Alternatively, if you want to install to a location other than the mbr, 366 | # uncomment and edit these lines: 367 | #d-i grub-installer/only_debian boolean false 368 | #d-i grub-installer/with_other_os boolean false 369 | #d-i grub-installer/bootdev string (hd0,1) 370 | # To install grub to multiple disks: 371 | #d-i grub-installer/bootdev string (hd0,1) (hd1,1) (hd2,1) 372 | 373 | # Optional password for grub, either in clear text 374 | #d-i grub-installer/password password r00tme 375 | #d-i grub-installer/password-again password r00tme 376 | # or encrypted using an MD5 hash, see grub-md5-crypt(8). 377 | #d-i grub-installer/password-crypted password [MD5 hash] 378 | 379 | # Use the following option to add additional boot parameters for the 380 | # installed system (if supported by the bootloader installer). 381 | # Note: options passed to the installer will be added automatically. 382 | #d-i debian-installer/add-kernel-opts string nousb 383 | 384 | ### Finishing up the installation 385 | # During installations from serial console, the regular virtual consoles 386 | # (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next 387 | # line to prevent this. 388 | #d-i finish-install/keep-consoles boolean true 389 | 390 | # Avoid that last message about the install being complete. 391 | d-i finish-install/reboot_in_progress note 392 | 393 | # This will prevent the installer from ejecting the CD during the reboot, 394 | # which is useful in some situations. 395 | #d-i cdrom-detect/eject boolean false 396 | 397 | # This is how to make the installer shutdown when finished, but not 398 | # reboot into the installed system. 399 | #d-i debian-installer/exit/halt boolean true 400 | # This will power off the machine instead of just halting it. 401 | #d-i debian-installer/exit/poweroff boolean true 402 | 403 | ### Preseeding other packages 404 | # Depending on what software you choose to install, or if things go wrong 405 | # during the installation process, it's possible that other questions may 406 | # be asked. You can preseed those too, of course. To get a list of every 407 | # possible question that could be asked during an install, do an 408 | # installation, and then run these commands: 409 | # debconf-get-selections --installer > file 410 | # debconf-get-selections >> file 411 | 412 | 413 | #### Advanced options 414 | ### Running custom commands during the installation 415 | # d-i preseeding is inherently not secure. Nothing in the installer checks 416 | # for attempts at buffer overflows or other exploits of the values of a 417 | # preconfiguration file like this one. Only use preconfiguration files from 418 | # trusted locations! To drive that home, and because it's generally useful, 419 | # here's a way to run any shell command you'd like inside the installer, 420 | # automatically. 421 | 422 | # This first command is run as early as possible, just after 423 | # preseeding is read. 424 | #d-i preseed/early_command string anna-install some-udeb 425 | # This command is run immediately before the partitioner starts. It may be 426 | # useful to apply dynamic partitioner preseeding that depends on the state 427 | # of the disks (which may not be visible when preseed/early_command runs). 428 | #d-i partman/early_command \ 429 | # string debconf-set partman-auto/disk "$(list-devices disk | head -n1)" 430 | # This command is run just before the install finishes, but when there is 431 | # still a usable /target directory. You can chroot to /target and use it 432 | # directly, or use the apt-install and in-target commands to easily install 433 | # packages and run commands in the target system. 434 | #d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh 435 | 436 | pkg-a pkg-a/my-q boolean false 437 | pkg-b pkg-a/my-other-q boolean true 438 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | 663 | --------------------------------------------------------------------------------