Make trusted-keys paths in manifest relative to manifest

This commit is contained in:
Anders Ingemann 2017-07-14 18:25:07 +02:00
parent 58c682818c
commit 85a0e6a191
No known key found for this signature in database
GPG key ID: 49C87973A14931A9
3 changed files with 10 additions and 7 deletions

View file

@ -121,7 +121,7 @@ properties:
trusted-keys: trusted-keys:
type: array type: array
items: items:
$ref: '#/definitions/absolute_path' $ref: '#/definitions/path'
minItems: 1 minItems: 1
include-source-type: {type: boolean} include-source-type: {type: boolean}
additionalProperties: false additionalProperties: false

View file

@ -1,6 +1,7 @@
from bootstrapvz.base import Task from bootstrapvz.base import Task
from bootstrapvz.common import phases from bootstrapvz.common import phases
from bootstrapvz.common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
from bootstrapvz.common.tools import rel_path
import locale import locale
import logging import logging
import os import os
@ -14,7 +15,8 @@ class ValidateTrustedKeys(Task):
def run(cls, info): def run(cls, info):
from bootstrapvz.common.tools import log_call from bootstrapvz.common.tools import log_call
for i, key_path in enumerate(info.manifest.packages.get('trusted-keys', {})): for i, rel_key_path in enumerate(info.manifest.packages.get('trusted-keys', {})):
key_path = rel_path(info.manifest.path, rel_key_path)
if not os.path.isfile(key_path): if not os.path.isfile(key_path):
info.manifest.validation_error('File not found: {}'.format(key_path), info.manifest.validation_error('File not found: {}'.format(key_path),
['packages', 'trusted-keys', i]) ['packages', 'trusted-keys', i])
@ -108,7 +110,8 @@ class InstallTrustedKeys(Task):
@classmethod @classmethod
def run(cls, info): def run(cls, info):
from shutil import copy from shutil import copy
for key_path in info.manifest.packages['trusted-keys']: for rel_key_path in info.manifest.packages['trusted-keys']:
key_path = rel_path(info.manifest.path, rel_key_path)
key_name = os.path.basename(key_path) key_name = os.path.basename(key_path)
destination = os.path.join(info.root, 'etc/apt/trusted.gpg.d', key_name) destination = os.path.join(info.root, 'etc/apt/trusted.gpg.d', key_name)
copy(key_path, destination) copy(key_path, destination)

View file

@ -206,8 +206,8 @@ variety of sources.
default apt sources. For example ``contrib`` or ``non-free`` default apt sources. For example ``contrib`` or ``non-free``
``optional`` ``optional``
Default: ``['main']`` Default: ``['main']``
- ``trusted-keys``: List of paths to ``.gpg`` keyrings that should - ``trusted-keys``: List of paths (relative to the manifest) to ``.gpg`` keyrings
be added to the aptitude keyring of trusted signatures for that should be added to the aptitude keyring of trusted signatures for
repositories. repositories.
``optional`` ``optional``
- ``apt.conf.d``: A map of ``apt.conf(5)`` configuration snippets. - ``apt.conf.d``: A map of ``apt.conf(5)`` configuration snippets.
@ -303,7 +303,7 @@ boot, root and swap.
- ``{device_path}``: The device path of the partition. - ``{device_path}``: The device path of the partition.
- ``{size}``: The size of the partition. - ``{size}``: The size of the partition.
- ``{mount_opts}``: Options to mount the partition with. This optional - ``{mount_opts}``: Options to mount the partition with. This optional
setting overwrites the default option list bootstrap-vz would setting overwrites the default option list bootstrap-vz would
normally use to mount the partiton (defaults). The List is specified normally use to mount the partiton (defaults). The List is specified
as a string array where each option/argument is an item in that array. as a string array where each option/argument is an item in that array.
``optional`` Here some examples: ``optional`` Here some examples:
@ -315,7 +315,7 @@ boot, root and swap.
The default command used by bootstrap-vz is The default command used by bootstrap-vz is
``['mkfs.{fs}', '{device_path}']``. ``['mkfs.{fs}', '{device_path}']``.
- ``boot``: Configuration of the boot partition. All settings equal - ``boot``: Configuration of the boot partition. All settings equal
those of the root partition. those of the root partition.
``optional`` ``optional``
- ``swap``: Configuration of the swap partition. Since the swap - ``swap``: Configuration of the swap partition. Since the swap