From 67b27d838e8ef0605ff07018af5804758897b732 Mon Sep 17 00:00:00 2001
From: Sergey Matveev <stargrave@stargrave.org>
Date: Fri, 11 Feb 2022 20:13:03 +0300
Subject: [PATCH 1/1] Initial commit

---
 releases.atom.zsh | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100755 releases.atom.zsh

diff --git a/releases.atom.zsh b/releases.atom.zsh
new file mode 100755
index 0000000..e8d039e
--- /dev/null
+++ b/releases.atom.zsh
@@ -0,0 +1,47 @@
+#!/usr/bin/env zsh
+# releases.atom.zsh -- releases.atom generator
+# Copyright (C) 2022 Sergey Matveev <stargrave@stargrave.org>
+
+set -e
+
+[[ -n "$ATOM_ID" ]]
+[[ -n "$NAME" ]]
+[[ -n "$BASE_URL" ]]
+[[ -n "$AUTHOR_EMAIL" ]]
+export TZ=UTC
+UPDATED=`date -Iseconds`
+ATOM=releases.atom
+tmp=`mktemp`
+trap "rm -f $tmp" HUP PIPE INT QUIT TERM EXIT
+
+cat > $tmp <<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+  <title>$NAME releases</title>
+  <id>urn:uuid:$ATOM_ID</id>
+  <link rel="self" href="$BASE_URL/$ATOM"></link>
+  <updated>$UPDATED</updated>
+  <author>
+    <email>$AUTHOR_EMAIL</email>
+  </author>
+EOF
+
+for meta (*.meta4(om)) {
+    fn=$meta:r
+    title=${meta%.tar.*}
+    updated=$(date -j -f %s -Iseconds $(stat -f %m $meta))
+    cat >> $tmp <<EOF
+  <entry>
+    <title>$title</title>
+    <id>$BASE_URL/$fn</id>
+    <link rel="alternate" type="application/metalink4+xml" href="$BASE_URL/$meta" />
+    <updated>$updated</updated>
+  </entry>
+EOF
+}
+
+echo "</feed>" >> $tmp
+
+size_our=`stat -f %z $tmp`
+size_their=`stat -f $ATOM`
+[[ $size_our = $size_their ]] || mv $tmp $ATOM
-- 
2.52.0