6 from datetime import datetime, timedelta
10 def advisory_date() -> datetime:
11 changelog_entry_timestamp = subprocess.run(
12 ["dpkg-parsechangelog", "--show-field", "Timestamp"],
13 stdout=subprocess.PIPE,
14 universal_newlines=True,
15 check=True).stdout.rstrip()
16 return datetime.fromtimestamp(
17 float(changelog_entry_timestamp)) - timedelta(days=2)
20 def security_advisory_contents(args) -> str:
21 jinja2_env = jinja2.Environment(
22 loader=jinja2.FileSystemLoader('config/release_management/templates'))
24 return (jinja2_env.get_template('security_advisory.mdwn').render(
25 date=email.utils.format_datetime(advisory_date()),
26 previous_version=args.previous_version,
31 if __name__ == '__main__':
33 parser = argparse.ArgumentParser()
34 parser.add_argument('--previous-version', required=True)
35 parser.add_argument('--version', required=True)
36 parser.add_argument('--tag', required=True)
37 args = parser.parse_args()
39 print(security_advisory_contents(args))