Add support for APT preferences through autoinstall in Subiquity

The autoinstall schema for "apt" now supports the "preferences"
configuration. Each preference element should contain the properties
described below, that 1:1 map with the keywords from apt_preferences(5):

  * package      <-> Package:
  * pin          <-> Pin:
  * pin-priority <-> Pin-Priority:

These preferences are forwarded to curtin through
subiquity-curtin-apt.conf. Support for these rules must be added to
curtin as well.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2022-01-05 16:54:11 +01:00
parent 5ae52c000b
commit 9e7bc5053b
4 changed files with 52 additions and 1 deletions

View File

@ -306,6 +306,28 @@
"non-free"
]
}
},
"preferences": {
"type": "array",
"items": {
"type": "object",
"properties": {
"package": {
"type": "string"
},
"pin": {
"type": "string"
},
"pin-priority": {
"type": "integer"
}
},
"required": [
"package",
"pin",
"pin-priority"
]
}
}
}
},

View File

@ -22,6 +22,9 @@ apt:
disable_components:
- non-free
- restricted
preferences:
- {package: "python3-*", pin: "origin *ubuntu.com*", pin-priority: 200}
- {package: "python-*", pin: "origin *ubuntu.com*", pin-priority: -1}
packages:
- package1
- package2

View File

@ -168,7 +168,11 @@ timeout --foreground 60 sh -c "LANG=C.UTF-8 python3 -m subiquity.cmd.tui --autoi
--source-catalog=examples/install-sources.yaml"
validate
python3 scripts/check-yaml-fields.py .subiquity/var/log/installer/subiquity-curtin-apt.conf \
apt.disable_components='[non-free, restricted]'
apt.disable_components='[non-free, restricted]' \
apt.preferences[0].pin-priority=200 \
apt.preferences[0].pin='"origin *ubuntu.com*"' \
apt.preferences[1].package='"python-*"' \
apt.preferences[1].pin-priority=-1
python3 scripts/check-yaml-fields.py .subiquity/var/log/installer/subiquity-curtin-install.conf \
debconf_selections.subiquity='"eek"' \
storage.config[-1].options='"errors=remount-ro"'

View File

@ -50,6 +50,28 @@ class MirrorController(SubiquityController):
'enum': ['universe', 'multiverse', 'restricted',
'contrib', 'non-free']
}
},
"preferences": {
"type": "array",
"items": {
"type": "object",
"properties": {
"package": {
"type": "string",
},
"pin": {
"type": "string",
},
"pin-priority": {
"type": "integer",
},
},
"required": [
"package",
"pin",
"pin-priority",
],
}
}
}
}