mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-10-07 17:40:30 +00:00
Merge pull request #305 from KellerFuchs/apt.conf
Enable setting `apt.conf(5)` options
This commit is contained in:
commit
042b881a14
5 changed files with 220 additions and 173 deletions
|
@ -32,3 +32,14 @@ def validate_manifest(data, validator, error):
|
|||
|
||||
if release == squeeze:
|
||||
error('Grub installation on squeeze is not supported', ['system', 'bootloader'])
|
||||
|
||||
# Check the provided apt.conf(5) options
|
||||
if 'packages' in data:
|
||||
for name, val in data['packages'].get('apt.conf.d', {}).iteritems():
|
||||
from bootstrapvz.common.tools import log_call
|
||||
|
||||
status, _, _ = log_call(['apt-config', '-c=/dev/stdin', 'dump'],
|
||||
stdin=val + '\n')
|
||||
|
||||
if status != 0:
|
||||
error('apt.conf(5) syntax error', ['packages', 'apt.conf.d', name])
|
||||
|
|
|
@ -98,7 +98,14 @@ properties:
|
|||
required: [pin, package, pin-priority]
|
||||
additionalProperties: false
|
||||
minItems: 1
|
||||
minItems: 1
|
||||
minProperties: 1
|
||||
additionalProperties: false
|
||||
apt.conf.d:
|
||||
type: object
|
||||
patternProperties:
|
||||
^[0-9A-Za-z][0-9A-Za-z-_.]+$:
|
||||
type: string
|
||||
minProperties: 1
|
||||
additionalProperties: false
|
||||
sources:
|
||||
type: object
|
||||
|
@ -109,7 +116,7 @@ properties:
|
|||
pattern: ^(deb|deb-src)\s+(\[\s*(.+\S)?\s*\]\s+)?\S+\s+\S+(\s+(.+\S))?\s*$
|
||||
minItems: 1
|
||||
type: array
|
||||
minItems: 1
|
||||
minProperties: 1
|
||||
additionalProperties: false
|
||||
trusted-keys:
|
||||
type: array
|
||||
|
|
|
@ -125,6 +125,8 @@ def get_apt_group(manifest):
|
|||
if 'preferences' in manifest.packages:
|
||||
group.append(apt.AddManifestPreferences)
|
||||
group.append(apt.WritePreferences)
|
||||
if 'apt.conf.d' in manifest.packages:
|
||||
group.append(apt.WriteConfiguration)
|
||||
if 'install' in manifest.packages:
|
||||
group.append(packages.AddManifestPackages)
|
||||
if manifest.packages.get('install_standard', False):
|
||||
|
|
|
@ -80,6 +80,22 @@ class InstallTrustedKeys(Task):
|
|||
copy(key_path, destination)
|
||||
|
||||
|
||||
class WriteConfiguration(Task):
|
||||
decription = 'Write configuration to apt.conf.d from the manifest'
|
||||
phase = phases.package_installation
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
for name, val in info.manifest.packages.get('apt.conf.d', {}).iteritems():
|
||||
if name == 'main':
|
||||
path = os.path.join(info.root, 'etc/apt/apt.conf')
|
||||
else:
|
||||
path = os.path.join(info.root, 'etc/apt/apt.conf.d', name)
|
||||
|
||||
with open(path, 'w') as conf_file:
|
||||
conf_file.write(val + '\n')
|
||||
|
||||
|
||||
class WriteSources(Task):
|
||||
description = 'Writing aptitude sources to disk'
|
||||
phase = phases.package_installation
|
||||
|
@ -138,7 +154,7 @@ class DisableDaemonAutostart(Task):
|
|||
class AptUpdate(Task):
|
||||
description = 'Updating the package cache'
|
||||
phase = phases.package_installation
|
||||
predecessors = [locale.GenerateLocale, WriteSources, WritePreferences]
|
||||
predecessors = [locale.GenerateLocale, WriteConfiguration, WriteSources, WritePreferences]
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
|
|
|
@ -198,8 +198,9 @@ variety of sources.
|
|||
Default: ``http://httpredir.debian.org/debian/``
|
||||
- ``sources``: A map of additional sources that should be added to
|
||||
the aptitude sources list. The key becomes the filename in
|
||||
``/etc/apt/sources.list.d/`` (with ``.list`` appended to it), while
|
||||
the value is an array with each entry being a line.
|
||||
``/etc/apt/sources.list.d/`` (with ``.list`` appended to it), except
|
||||
for ``main``, which designates ``/etc/apt/sources.list``.
|
||||
The value is an array with each entry being a line.
|
||||
``optional``
|
||||
- ``components``: A list of components that should be added to the
|
||||
default apt sources. For example ``contrib`` or ``non-free``
|
||||
|
@ -209,6 +210,11 @@ variety of sources.
|
|||
be added to the aptitude keyring of trusted signatures for
|
||||
repositories.
|
||||
``optional``
|
||||
- ``apt.conf.d``: A map of ``apt.conf(5)`` configuration snippets.
|
||||
The key become the filename in ``/etc/apt/apt.conf.d``, except
|
||||
``main`` which designates ``/etc/apt/apt.conf``.
|
||||
The value is a string in the ``apt.conf(5)`` syntax.
|
||||
``optional``
|
||||
- ``preferences``: Allows you to pin packages through `apt
|
||||
preferences <https://wiki.debian.org/AptPreferences>`__. The setting
|
||||
is an object where the key is the preference filename in
|
||||
|
@ -241,6 +247,11 @@ Example:
|
|||
- non-free
|
||||
trusted-keys:
|
||||
- /root/keys/puppet.gpg
|
||||
apt.conf.d:
|
||||
00InstallRecommends: >-
|
||||
APT::Install-Recommends "false";
|
||||
APT::Install-Suggests "false";
|
||||
00IPv4: 'Acquire::ForceIPv4 "false";'
|
||||
preferences:
|
||||
main:
|
||||
- package: *
|
||||
|
|
Loading…
Add table
Reference in a new issue