Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# For the next release

* ** Johannes Starosta**
* New parameter publish_children in mirrors config allows multi-component publishing

# Patch Release v1.1.2 (2026-01-28)
* **Johannes Starosta**
* Use keyring file instead of apt-key due to deprecation/removal of apt-key in recent Debian and Ubuntu releases
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,37 @@ aptly__mirrors:
- main
keys:
- url: ""
# Example for multi-component publishing.
# Note: Set only one component per repository see https://www.aptly.info/doc/feature/multi-component/
# Specifying multiple components is not expected to work
- name: openvox-noble
publish_prefix: openvox
no_block_mirror_task: true
origin: Vox Pupuli
label: openvox-ubuntu24.04
distribution: ubuntu24.04
publish_children: true
childrens:
- name: openvox7
distribution: ubuntu24.04
archive_url: https://apt.voxpupuli.org/
state: present
components:
- openvox7
architectures:
- amd64
keys:
- url: https://apt.voxpupuli.org/openvox-keyring.gpg
- name: openvox8
distribution: ubuntu24.04
archive_url: https://apt.voxpupuli.org/
state: present
components:
- openvox8
architectures:
- amd64
keys:
- url: https://apt.voxpupuli.org/openvox-keyring.gpg

aptly__repositories:
- name: jammy
Expand Down
35 changes: 33 additions & 2 deletions files/aptly-mirror-update.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,27 @@ def get_arguments():
return parser.parse_args()


def publish_multi(client, sources, mirror_config, async_run: bool):
publish = Publish(client)
distribution = mirror_config.get("mirror_distribution")
prefix = mirror_config.get("mirror_prefix")
if publish.check_if_exists(name=distribution, prefix=prefix):
publish.switch_snapshot(
snapshots=sources,
prefix=prefix,
distribution=distribution,
async_run=async_run,
)
else:
publish.create_from_snapshot(
sources=sources,
distribution=distribution,
origin=mirror_config.get("mirror_origin"),
label=mirror_config.get("mirror_label"),
prefix=prefix,
async_run=async_run,
)

def publish_mirror(client, mirror_name, mirror_config, current_day, async_run: bool):
publish = Publish(client)
distribution = mirror_config.get("mirror_distribution")
Expand All @@ -297,6 +318,7 @@ def publish_mirror(client, mirror_name, mirror_config, current_day, async_run: b
distribution=distribution,
async_run=async_run,
)

else:
publish.create_from_snapshot(
sources=[{"Name": f"{mirror_name}-{current_day}"}],
Expand All @@ -307,7 +329,6 @@ def publish_mirror(client, mirror_name, mirror_config, current_day, async_run: b
async_run=async_run,
)


def mirror_update_and_snapshot(client, mirror_name, current_day, async_run: bool):
mirror = Mirror(client=client, mirror=mirror_name)
mirror.update(async_run=async_run)
Expand Down Expand Up @@ -353,13 +374,20 @@ def main():
mirror_config = yaml.safe_load(stream)

if mirror_config.get("mirror_childrens"):
sources = []
for children_mirror_name in mirror_config.get("mirror_childrens"):
with open(f"/etc/aptly/mirror/{children_mirror_name}.conf.yaml") as stream:
children_mirror_config = yaml.safe_load(stream)
if children_mirror_config.get("mirror_parent") != mirror_name:
raise ValueError(
f"Children mirror {children_mirror_name} is not the parent of {mirror_name}"
)
components = ''
source = ''
if children_mirror_config.get("mirror_components"):
components = ','.join(children_mirror_config.get('mirror_components'))
source = { "Name": f"{children_mirror_name}-{current_day}", "Component": components }
sources.append(source)

mirror_update_and_snapshot(
client, children_mirror_name, current_day, mirror_async
Expand All @@ -383,7 +411,10 @@ def main():
parent_snapshot.merge(snapshots=snapshots, package_refs=packages)

print("Switch publish to new snapshot")
publish_mirror(client, mirror_name, mirror_config, current_day, mirror_async)
if mirror_config.get("publish_children"):
publish_multi(client, sources, mirror_config, mirror_async)
else:
publish_mirror(client, mirror_name, mirror_config, current_day, mirror_async)

print("Delete all old snapshots")
old_snapshot = Snapshot(client, f"{parent_snapshot_name}-old")
Expand Down
11 changes: 11 additions & 0 deletions templates/mirror.conf.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
{% if mirror_children is defined and mirror_children %}
mirror_parent: '{{ aptly__mirror_base.name }}'
{% endif %}
{% if aptly__mirror_base.publish_children is defined and publish_children is not defined %}
publish_children: true
{% endif %}
{% if aptly__mirror_base.childrens is defined and mirror_children is not defined %}
mirror_childrens:
{% for children in aptly__mirror.childrens %}
Expand All @@ -12,6 +15,14 @@ mirror_childrens:
{% endif %}
{% endfor %}
{% endif %}

{% if aptly__mirror.components is defined and mirror_components is not defined %}
mirror_components:
{% for component in aptly__mirror.components %}
- '{{ component }}'
{% endfor %}
{% endif %}

mirror_distribution: '{{ aptly__mirror.distribution }}'
{% if aptly__mirror_base.label is defined and aptly__mirror_base.label | length > 0 %}
mirror_label: '{{ aptly__mirror_base.label }}'
Expand Down
Loading