- release-cycle.py captures a new snapshot only on the 1st and reuses the current one otherwise; the build is always bound to an immutable snapshot. - publish-hardware.py hardlinks immutable OSTree objects instead of copying 8.4 GB of small files onto ZFS. - release-schedule.py and the timer run on the 1st only; STATUS updated.
30 lines
1 KiB
Python
30 lines
1 KiB
Python
#!/usr/bin/env python3
|
|
"""Monthly snapshot cycle: ISO + OSTree build on the 1st of each month."""
|
|
import argparse
|
|
from datetime import datetime, timedelta, timezone
|
|
import subprocess
|
|
|
|
|
|
def mode(day):
|
|
# D-108: the monthly repository snapshot and the ISO+OSTree build run on the
|
|
# 1st; the snapshot is created by the cycle before it compiles anything.
|
|
if day.day == 1:
|
|
return 'iso'
|
|
return None
|
|
|
|
|
|
def next_release(now):
|
|
day = now.astimezone(timezone.utc).date() + timedelta(days=1)
|
|
while not mode(day):
|
|
day += timedelta(days=1)
|
|
return {'date': day.isoformat(), 'mode': mode(day), 'time': '00:00 UTC'}
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# A typo in a manual call must not silently start a release cycle.
|
|
argparse.ArgumentParser(description=__doc__).parse_args()
|
|
today = datetime.now(timezone.utc).date()
|
|
selected = mode(today)
|
|
print(f'{today}: {selected or "not scheduled"}', flush=True)
|
|
if selected:
|
|
subprocess.run(['systemctl', 'start', '--no-block', 'archipelago-release-cycle.service'], check=True)
|