[Reproducible-commits] [blog] 01/01: add scripts for guessing tags for a post and for publishing

Holger Levsen holger at layer-acht.org
Sat Apr 30 16:57:53 UTC 2016


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository blog.

commit 5c686f7c010d0ec33b25c5d971abc3556d3c94df
Author: Holger Levsen <holger at layer-acht.org>
Date:   Sat Apr 30 18:57:22 2016 +0200

    add scripts for guessing tags for a post and for publishing
---
 TODO              | 16 ++++++++--------
 bin/guess_tags.sh | 32 ++++++++++++++++++++++++++++++++
 bin/publish.sh    | 41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 8 deletions(-)

diff --git a/TODO b/TODO
index beca208..1972c29 100644
--- a/TODO
+++ b/TODO
@@ -1,13 +1,13 @@
 #53 needs to be written and finished
-	set date header on publish
-	set tags on publish: [[!tag reproducible_builds]]
+	should be published with bin/publish.sh to get the meta headers right
 
-minor things which need to go into README eventually:
-	write a publish script to:
-		set meta date header automatically
-		set tags semi-automatically
-		fill out "This weeks edition was written by" automatically
-		run "ikiwiki-calendar -f /home/groups/reproducible/blog/blog.setup 'posts/*'" as holger on alioth to update the archive
+to be documented:
+	bin/guess_tags.sh
+	bin/publish.sh
+
+TODO for bin/publish.sh:
+	should try to detect if committers are not listed in "This weeks edition was written by"…
+	run "ikiwiki-calendar -f /home/groups/reproducible/blog/blog.setup 'posts/*'" as holger on alioth to update the archive
 
 ikiwiki polishing:
 	use nicer css than current one
diff --git a/bin/guess_tags.sh b/bin/guess_tags.sh
new file mode 100755
index 0000000..ac207ea
--- /dev/null
+++ b/bin/guess_tags.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+if [ "$1" = "" ] ; then
+	echo "need a post number to act on, eg 53"
+	exit 1
+fi
+WEEK=$1
+DRAFT=./drafts/$WEEK.mdwn
+
+if [ ! -f $DRAFT ] ; then
+	echo "$DRAFT does not exist, exiting."
+	exit 1
+elif [ -f ./drafts/$WEEK.tags ] ; then
+	echo "./drafts/$WEEK.tags exists, not doing anything, please edit manually."
+	exit 1
+fi
+
+KNOWN_TAGS="ArchLinux build_kernel_architecture build_locale clang coreboot diffoscope dpkg Fedora GCC GSoC installation live_media NetBSD OpenWrt Outreachy source_date_epoch SOURCE_DATE_EPOCH sphinx tails tar disorderfs strip-determinism"
+
+MY_TAGS="reproducible_builds"
+
+for TAG in $KNOWN_TAGS ; do
+	if [ -n "$(grep $TAG $DRAFT 2>/dev/null)" ] ; then
+		MY_TAGS="$MY_TAGS $TAG"
+	fi
+done
+
+if [ ! -f ./drafts/$WEEK.tags ] ; then
+	echo "Creating $WEEK.tags, please review detected tags:"
+	echo "  $MY_TAGS"
+	echo $MY_TAGS > ./drafts/$WEEK.tags
+fi
diff --git a/bin/publish.sh b/bin/publish.sh
new file mode 100755
index 0000000..4370df8
--- /dev/null
+++ b/bin/publish.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+if [ "$1" = "" ] ; then
+	echo "need a post number to act on, eg 53"
+	exit 1
+fi
+WEEK=$1
+DRAFT=./drafts/$WEEK.mdwn
+POST=./posts/$WEEK.mdwn
+
+if [ -f $POST ] ; then
+	echo "$POST already exists, doing nothing."
+	exit 0
+elif [ ! -f $DRAFT ] ; then
+	echo "$DRAFT does not exist, exiting."
+	exit 1
+elif [ ! -f ./drafts/$WEEK.tags ] ; then
+	echo "./drafts/$WEEK.tags does not exist, please run ./bin/guess_tags.sh $WEEK."
+	exit 1
+elif [ -z "$(grep 'meta title=' $DRAFT 2>/dev/null)" ] ; then
+	echo "$DRAFT has no title, exiting."
+	exit 1
+fi
+
+META_TAGS='[[!tag '$(cat ./drafts/$WEEK.tags)']]'
+META_DATE='[[!meta date="'$(TZ=UTC LANG=C date +'%a %b %d %H:%M:%S %Y %z')'"]]'
+
+TMPFILE=$(mktemp)
+grep "meta title=" $DRAFT > $TMPFILE
+echo $META_DATE >> $TMPFILE
+echo $META_TAGS >> $TMPFILE
+grep -v "meta title=" $DRAFT >> $TMPFILE
+cp $TMPFILE $DRAFT
+rm $TMPFILE
+
+git rm ./drafts/$WEEK.tags 2>/dev/null|| rm ./drafts/$WEEK.tags
+git mv $DRAFT $POST
+echo "Now verify the result, then run git commit and git push."
+git status
+
+echo dont forget the fixme here

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/blog.git



More information about the Reproducible-commits mailing list