[git] gnupg-doc - branch, master, updated. cbd32ab27da9d5841dcc4007fe6078024ce9446a

by Werner Koch cvs at cvs.gnupg.org
Fri Mar 17 21:14:04 CET 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GnuPG website and other docs".

The branch, master has been updated
       via  cbd32ab27da9d5841dcc4007fe6078024ce9446a (commit)
      from  0ef14cc5af1cdd690b77f98f2087e71ed44979a0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cbd32ab27da9d5841dcc4007fe6078024ce9446a
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Mar 17 21:10:26 2017 +0100

    tools: Update the web build tools.

diff --git a/tools/build-website.sh b/tools/build-website.sh
index 805970a..3bdaa7f 100755
--- a/tools/build-website.sh
+++ b/tools/build-website.sh
@@ -1,19 +1,84 @@
 #!/bin/sh
+# Build the gnupg.org website from a git working directory.
+# This script requires two users
+#   webbuilder - the user to run this script
+#   webbuild-x - the user used by this script to run emacs
+# A certain directory layout is required with permissions setup
+# so that the webbuild-x has only write access to the stage area
+# and to its own home directory.  The scripts checks the permissions.
+#
+# These cronjobs are required:
+# --8<---------------cut here---------------start------------->8---
+# # Pull the master branch of the web pages
+# */20  * * * * cd /home/webbuilder/gnupg-doc && git pull -q origin master
+#
+# # In case of race conditions we try to build every few ours again.
+# 35  */7 * * * /home/webbuilder/bin/build-website.sh --cron
+# --8<---------------cut here---------------end--------------->8---
+#
 
 set -e
 
 pgm=build-website.sh
-root_dir="$(pwd)/gnupg-doc/web"
-stage_dir="$(pwd)/gpgweb-stage"
+mainuser=webbuilder
+workuser=webbuild-x
 
-if [ ! -d "${root_dir}" ]; then
-   echo "$pgm: directory '${root_dir}' missing" >&2;
+# We use a fixed HOME so that this script can be run here from other
+# accounts.
+HOME=$(awk </etc/passwd -F: '$1=="'$mainuser'" {print $6;exit}')
+if [ ! -d "$HOME" ]; then
+   echo "$pgm: directory '${HOME}' missing" >&2;
    exit 1
 fi
-if [ ! -d "${stage_dir}" ]; then
-   echo "$pgm: directory '${stage_dir}' missing" >&2;
+
+reponame=gnupg-doc
+
+workuser_dir=$HOME/${workuser}
+log_dir="$HOME/log"
+root_dir="$HOME/${reponame}/web"
+stage_dir="$HOME/gpgweb-stage"
+LOCKFILE="${log_dir}/${reponame}.lock"
+
+if [ x"$1" = x"--git" ]; then
+  shift
+  exec  >>${log_dir}/"$reponame".log 2>&1
+  echo "$(date -u -Iseconds) gpgweb site build was git triggered"
+elif [ x"$1" = x"--cron" ]; then
+  shift
+  exec  >>${log_dir}/"$reponame".log 2>&1
+  echo "$(date -u -Iseconds) gpgweb site build was cron triggered"
+fi
+
+if ! id $workuser >/dev/null 2>&1 ; then
+   echo "$pgm: sudo user '${workuser}' not available" >&2;
    exit 1
 fi
+
+# Check directories
+for f in "${workuser_dir}" "${root_dir}" "${stage_dir}"; do
+  if [ ! -d "$f" ]; then
+     echo "$pgm: directory '$f' missing" >&2;
+     exit 1
+  fi
+done
+want="2775:${workuser}:${mainuser}"
+for f in "${workuser_dir}" "${stage_dir}"; do
+  x=$(stat -c '%a:%U:%G' "$f")
+  if [ x"$x" != x"$want" ]; then
+    echo "$pgm: directory '$f' has wrong permissions" >&2
+    echo "$pgm:   want: $want" >&2
+    echo "$pgm:   have: $x" >&2
+    exit 1
+  fi
+done
+
+# Take a lock
+if ! lockfile -l 7200 -r 2 $LOCKFILE; then
+    echo "$pgm: another instance is still running" >&2
+    exit 0
+fi
+trap "rm -f $LOCKFILE" 0
+
 cd "${root_dir}"
 
 rev="$(git rev-parse --verify HEAD)"
@@ -21,22 +86,20 @@ if [ -z "$rev" ]; then
    echo "$pgm: No git revision found" >&2;
    exit 1
 fi
-revlast="$(head -1 ${stage_dir}/.revlast 2>/dev/null || true)"
+revlast="$(head -1 ${log_dir}/${reponame}.revlast 2>/dev/null || true)"
 if [ x"$rev" = x"$revlast" ]; then
    echo "$pgm: No need to build" >&2;
    exit 0
 fi
 
 
-echo "========================================================"
-echo "gpgweb site building started on $(date -u -Iseconds)"
-echo "========================================================"
+echo "$(date -u -Iseconds) gpgweb site build started"
+echo "=================================================="
 
-emacs23 -q --batch  \
+sudo -u webbuild-x emacs24 -q --batch  \
   --eval "(require 'assoc)" \
   --eval "(require 'org)" \
   --eval "(setq make-backup-files nil)" \
-  --eval "(setq vc-handled-backends nil)" \
   --eval "(setq gpgweb-root-dir  \"${root_dir}/\")" \
   --eval "(setq gpgweb-stage-dir \"${stage_dir}/\")" \
   --eval "(require 'gpgweb (concat gpgweb-root-dir \"share/gpgweb.el\"))" \
@@ -45,11 +108,10 @@ emacs23 -q --batch  \
   --eval "(setq org-export-html-coding-system 'utf-8)" \
   --eval "(gpgweb-setup-project)" \
   --eval "(org-publish-initialize-cache \"gpgweb\")" \
-  --eval "(setq debug-on-error nil)" \
+  --eval "(message \"root=(%s)\" gpgweb-root-dir)" \
   --eval "(org-publish \"gpgweb\" t nil)"
 
-echo "$rev" > ${stage_dir}/.revlast
+echo "$rev" > ${log_dir}/${reponame}.revlast
 
-echo "========================================================="
-echo "gpgweb site building finished on $(date -u -Iseconds)"
-echo "========================================================="
+echo "==================================================="
+echo "$(date -u -Iseconds) gpgweb site build finished"
diff --git a/tools/trigger-website-build b/tools/trigger-website-build
new file mode 100644
index 0000000..b0c5ae2
--- /dev/null
+++ b/tools/trigger-website-build
@@ -0,0 +1,12 @@
+#!/bin/sh
+# This is a post-merge hook to trigger building
+# gnupg.org
+
+reponame=$(git rev-parse --show-toplevel | sed s,.*/,,)
+
+unset $(git rev-parse --local-env-vars)
+
+if [ x"$reponame" = x"gnupg-doc" ]; then
+   exec $HOME/bin/build-website.sh --git &
+fi
+exit 0

-----------------------------------------------------------------------

Summary of changes:
 tools/build-website.sh      | 96 +++++++++++++++++++++++++++++++++++++--------
 tools/trigger-website-build | 12 ++++++
 2 files changed, 91 insertions(+), 17 deletions(-)
 create mode 100644 tools/trigger-website-build


hooks/post-receive
-- 
The GnuPG website and other docs
http://git.gnupg.org




More information about the Gnupg-commits mailing list