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

by Werner Koch cvs at cvs.gnupg.org
Sat Mar 18 13:34:13 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  bff6c6ef52207b013e6966564f4845ffc31e4085 (commit)
      from  cbd32ab27da9d5841dcc4007fe6078024ce9446a (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 bff6c6ef52207b013e6966564f4845ffc31e4085
Author: Werner Koch <wk at gnupg.org>
Date:   Sat Mar 18 13:29:41 2017 +0100

    web: Let build-website.sh also update the blogs

diff --git a/misc/blog.gnupg.org/update-index.sh b/misc/blog.gnupg.org/update-index.sh
new file mode 100644
index 0000000..7e48dc6
--- /dev/null
+++ b/misc/blog.gnupg.org/update-index.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+# Insert the ctual index into index.html
+
+pgm=update-index.sh
+
+if [ ! -f index.html ]; then
+  echo "$pgm: blog.gnupg.org/index.html has not been build" >&2
+  exit 1
+fi
+
+# Find all rendered HTML files but skip possible translated versions.
+find . -maxdepth 1 -type f -name "20*.html" -print \
+    | grep -v '\.[a-z][a-z].html$' | sort -r >index.tmp
+newest=$(head -1 index.tmp)
+
+# Extract the head lines
+: >index.headlines.tmp
+cat index.tmp | while read fname; do
+  echo -n "${fname#./}|" >>index.headlines.tmp
+  sed  -n '/^<h2 id=/ {s,^<[^>]*>\(.*\)</h2>,\1,p;q}' \
+       $fname >>index.headlines.tmp
+done
+
+# Update the index file
+awk -F:  <index.html  >index.tmp \
+  -v newest=${newest#./} '
+   /<!--BEGIN-NEWEST-ENTRY-->/ {indon=1; print; insertnewest() }
+   /<!--END-NEWEST-ENTRY-->/ {indon=0}
+   /<!--BEGIN-BLOG-INDEX-->/ {indon=1; print; insertindex() }
+   /<!--END-BLOG-INDEX-->/   {indon=0}
+   !indon { print }
+
+   function insertnewest () {
+     inblog = 0
+     while (getline < newest) {
+       if (match ($0, /^<main>/))  { inblog = 1; continue; }
+       if (match ($0, /^<\/main>/)) { inblog = 0; break; }
+       if (! inblog) { continue }
+       if (match ($0, /^<div id="content">/)) { continue; }
+       if (match ($0, /^<\/div><!-- end content -->/)) { continue; }
+       print $0
+     }
+    close(newest)
+   }
+
+   function insertindex (tag) {
+     file = "index.headlines.tmp";
+     print "<ul>"
+     while (getline < file) {
+       split($0, a, "|")
+       printf "  <li><a href=\"%s\">%s</a>\n", a[1], a[2];
+     }
+     print "</ul>"
+     close (file)
+   }
+   '
+if ! mv index.tmp index.html ; then
+    echo "$pgm: error updating blog index" >&2
+    exit 1
+fi
+
+# FIXME: Create a feed file
+
+# Rename headlines file
+mv index.headlines.tmp headlines.txt
+
+exit 0
diff --git a/misc/blog.gnupg.org/upload b/misc/blog.gnupg.org/upload
deleted file mode 100755
index e72979f..0000000
--- a/misc/blog.gnupg.org/upload
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/bin/sh
-
-set -e
-
-opt_upload=yes
-if [ x"$1" = x"--no-upload" ]; then
-  opt_upload=no
-fi
-
-
-if [ "$(pwd  | awk -F/ '{print $NF}')" != "blog.gnupg.org" ]; then
-  echo "upload: not invoked from the blog.gnupg.org directory" >&2;
-  exit 1
-fi
-
-echo "upload: Rendering entries" >&2
-# We need to initialize that org cache to use our own publish function
-# despite that we do not use any org-publish feature
-emacs23 --batch \
-  --eval "(require 'assoc)" \
-  --eval "(require 'org)" \
-  --eval "(setq gpgweb-root-dir \"$(cd ../../web && pwd)/\")" \
-  --eval "(setq gpgweb-stage-dir \"$(cd ../../stage && pwd)/\")" \
-  --eval "(require 'gpgweb (concat gpgweb-root-dir \"share/gpgweb.el\"))" \
-  --eval "(setq org-publish-use-timestamps-flag nil)" \
-  --eval "(setq org-export-html-toplevel-hlevel 1)" \
-  --eval "(setq org-export-html-coding-system 'utf-8)" \
-  --eval "(gpgweb-setup-project)" \
-  --eval "(org-publish-initialize-cache \"gpgweb\")" \
-  --eval "(gpgweb-publish-blogs)"
-
-if [ ! -f index.html ]; then
-  echo "upload: index.html has not yet been build" >&2;
-  exit 1
-fi
-
-# Find all rendered HTML files but skip possible translated versions.
-find . -maxdepth 1 -type f -name "20*.html" -print \
-    | grep -v '\.[a-z][a-z].html$' | sort -r >index.tmp
-newest=$(head -1 index.tmp)
-
-# Extract the head lines
-: >index.headlines.tmp
-cat index.tmp | while read fname; do
-  echo -n "${fname#./}|" >>index.headlines.tmp
-  sed  -n '/^<h2 id=/ {s,^<[^>]*>\(.*\)</h2>,\1,p;q}' \
-       $fname >>index.headlines.tmp
-done
-
-# Update the index file
-echo "upload: Updating index.html" >&2
-awk -F:  <index.html  >index.tmp \
-    -v newest=${newest#./} '
-     /<!--BEGIN-NEWEST-ENTRY-->/ {indon=1; print; insertnewest() }
-     /<!--END-NEWEST-ENTRY-->/ {indon=0}
-     /<!--BEGIN-BLOG-INDEX-->/ {indon=1; print; insertindex() }
-     /<!--END-BLOG-INDEX-->/   {indon=0}
-     !indon { print }
-
-     function insertnewest () {
-       inblog = 0
-       while (getline < newest) {
-         if (match ($0, /^<main>/))  { inblog = 1; continue; }
-         if (match ($0, /^<\/main>/)) { inblog = 0; break; }
-         if (! inblog) { continue }
-         if (match ($0, /^<div id="content">/)) { continue; }
-         if (match ($0, /^<\/div><!-- end content -->/)) { continue; }
-         print $0
-       }
-      close(newest)
-     }
-
-     function insertindex (tag) {
-       file = "index.headlines.tmp";
-       print "<ul>"
-       while (getline < file) {
-         split($0, a, "|")
-         printf "  <li><a href=\"%s\">%s</a>\n", a[1], a[2];
-       }
-       print "</ul>"
-       close (file)
-     }
-     '
-mv index.tmp index.html || echo "upload: error updating index.html" >&2
-
-# Update the feed file
-echo "upload: Updating feed file" >&2
-
-
-
-# Rename headlines file
-mv index.headlines.tmp headlines.txt
-
-if [ $opt_upload = yes ]; then
-  echo "upload: Uploading files" >&2
-  rsync -vr --links --exclude '*~' --exclude upload --exclude '*tmp' \
-     --exclude '*.org' \
-     . werner at trithemius.gnupg.org:/var/www/www/www.gnupg.org/misc/blog/
-fi
-
-#eof
diff --git a/tools/build-website.sh b/tools/build-website.sh
index 3bdaa7f..521ae46 100755
--- a/tools/build-website.sh
+++ b/tools/build-website.sh
@@ -1,13 +1,19 @@
 #!/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.
+# and to its own home directory.  The script checks the permissions.
+#
+# The trigger-website-build scripts is expected to be installed
+# as git post-merge hook.
 #
-# These cronjobs are required:
+# These cronjobs are required for user webbuilder:
 # --8<---------------cut here---------------start------------->8---
 # # Pull the master branch of the web pages
 # */20  * * * * cd /home/webbuilder/gnupg-doc && git pull -q origin master
@@ -16,6 +22,12 @@
 # 35  */7 * * * /home/webbuilder/bin/build-website.sh --cron
 # --8<---------------cut here---------------end--------------->8---
 #
+# /etc/sudoers needs this:
+# --8<---------------cut here---------------start------------->8---
+# # Let webbuilder run any command as user webbuild-x
+# webbuilder         ALL = (webbuild-x) NOPASSWD: ALL
+# --8<---------------cut here---------------end--------------->8---
+#
 
 set -e
 
@@ -35,8 +47,8 @@ reponame=gnupg-doc
 
 workuser_dir=$HOME/${workuser}
 log_dir="$HOME/log"
-root_dir="$HOME/${reponame}/web"
-stage_dir="$HOME/gpgweb-stage"
+root_dir="$HOME/${reponame}"
+stage_dir="$HOME/${reponame}-stage"
 LOCKFILE="${log_dir}/${reponame}.lock"
 
 if [ x"$1" = x"--git" ]; then
@@ -72,36 +84,47 @@ for f in "${workuser_dir}" "${stage_dir}"; do
   fi
 done
 
-# Take a lock
+cd "${root_dir}"
+
+#
+# Take a lock so that only one instacne of this script runs.
+#
 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)"
+#
+# Build main part
+#
+subdir=web
+
+revlastfile="${log_dir}/${reponame}.$(echo $subdir | tr / _).revlast"
+buildlog="${log_dir}/${reponame}.$(echo $subdir | tr / _).log"
+rev="$(git rev-parse --verify HEAD:$subdir)"
 if [ -z "$rev" ]; then
    echo "$pgm: No git revision found" >&2;
    exit 1
 fi
-revlast="$(head -1 ${log_dir}/${reponame}.revlast 2>/dev/null || true)"
+revlast="$(head -1 ${revlastfile} 2>/dev/null || true)"
 if [ x"$rev" = x"$revlast" ]; then
-   echo "$pgm: No need to build" >&2;
-   exit 0
-fi
+   echo "$pgm: No need to build $subdir" >&2;
+else
 
+  echo "$(date -u -Iseconds) build started for $subdir" | tee ${buildlog}
 
-echo "$(date -u -Iseconds) gpgweb site build started"
-echo "=================================================="
+  if [ ! -d ${stage_dir}/${subdir} ]; then
+      sudo -u webbuild-x mkdir ${stage_dir}/${subdir}
+  fi
 
-sudo -u webbuild-x emacs24 -q --batch  \
+  sudo 2>>${buildlog} -u webbuild-x emacs24 -q --batch  \
   --eval "(require 'assoc)" \
   --eval "(require 'org)" \
   --eval "(setq make-backup-files nil)" \
-  --eval "(setq gpgweb-root-dir  \"${root_dir}/\")" \
-  --eval "(setq gpgweb-stage-dir \"${stage_dir}/\")" \
+  --eval "(setq gpgweb-root-dir  \"${root_dir}/${subdir}/\")" \
+  --eval "(setq gpgweb-stage-dir \"${stage_dir}/${subdir}/\")" \
   --eval "(require 'gpgweb (concat gpgweb-root-dir \"share/gpgweb.el\"))" \
   --eval "(setq org-publish-use-timestamps-flag nil)" \
   --eval "(setq org-export-html-toplevel-hlevel 1)" \
@@ -111,7 +134,83 @@ sudo -u webbuild-x emacs24 -q --batch  \
   --eval "(message \"root=(%s)\" gpgweb-root-dir)" \
   --eval "(org-publish \"gpgweb\" t nil)"
 
-echo "$rev" > ${log_dir}/${reponame}.revlast
+  echo "$rev" > ${revlastfile}
+
+  echo "$(date -u -Iseconds) build finished for $subdir" | tee -a ${buildlog}
+fi
+
+
+#
+# Build blogs
+#
+subdir=misc/blog.gnupg.org
+
+revlastfile="${log_dir}/${reponame}.$(echo $subdir | tr / _).revlast"
+buildlog="${log_dir}/${reponame}.$(echo $subdir | tr / _).log"
+rev="$(git rev-parse --verify HEAD:$subdir)"
+if [ -z "$rev" ]; then
+   echo "$pgm: No git revision found" >&2;
+   exit 1
+fi
+revlast="$(head -1 ${revlastfile} 2>/dev/null || true)"
+if [ x"$rev" = x"$revlast" ]; then
+   echo "$pgm: No need to build $subdir" >&2;
+else
+
+  echo "$(date -u -Iseconds) build started for $subdir" | tee ${buildlog}
+
+  if [ ! -d ${stage_dir}/${subdir} ]; then
+      sudo -u webbuild-x mkdir -p ${stage_dir}/${subdir}
+  fi
+  cd ${stage_dir}/${subdir}
+
+  # We need to initialize that org cache to use our own publish function
+  # despite that we do not use any org-publish feature
+  echo "$pgm: Rendering blogs" >&2
+  sudo 2>>${buildlog} -u webbuild-x emacs24 -q --batch \
+  --eval "(require 'assoc)" \
+  --eval "(require 'org)" \
+  --eval "(setq gpgweb-root-dir \"${root_dir}/web/\")" \
+  --eval "(setq gpgweb-blog-dir \"${root_dir}/${subdir}/\")" \
+  --eval "(setq gpgweb-stage-dir \"${stage_dir}/${subdir}/\")" \
+  --eval "(require 'gpgweb (concat gpgweb-root-dir \"share/gpgweb.el\"))" \
+  --eval "(setq org-publish-use-timestamps-flag nil)" \
+  --eval "(setq org-export-html-toplevel-hlevel 1)" \
+  --eval "(setq org-export-html-coding-system 'utf-8)" \
+  --eval "(gpgweb-setup-project)" \
+  --eval "(org-publish-initialize-cache \"gpgweb\")" \
+  --eval "(message \"root=(%s)\" gpgweb-root-dir)" \
+  --eval "(gpgweb-publish-blogs)"
+
+  echo "$pgm: Updating blog index" >&2
+  indexcreator="${root_dir}/${subdir}/update-index.sh"
+  if [ ! -f $indexcreator ]; then
+    echo "$pgm: $indexcreator not found" >&2
+    exit 1
+  fi
+  sudo -u webbuild-x ${indexcreator}
+
+  echo "$rev" > ${revlastfile}
+
+  echo "$(date -u -Iseconds) build finished for $subdir" | tee -a ${buildlog}
+
+fi
+
+
+#
+# Sync to the webspace
+#
+cd "${root_dir}"
+
+
+#
+# Print warnings when the scripts are out of date
+# (For security reasons the scripts need to be installed manually.)
+#
+for f in trigger-website-build build-website.sh ; do
+  if cmp -s tools/$f ${HOME}/bin/$f ; then
+    echo "$pgm: Warning: A newer version of $f is available" >&2;
+  fi
+done
 
-echo "==================================================="
-echo "$(date -u -Iseconds) gpgweb site build finished"
+exit 0
diff --git a/web/share/gpgweb.el b/web/share/gpgweb.el
index 03f9e8f..cd6163a 100644
--- a/web/share/gpgweb.el
+++ b/web/share/gpgweb.el
@@ -297,7 +297,7 @@ HTMLFILE is HTML file name and COMMITTED-AT is the commit date
 string of the source file or nil if not available."
   (let ((srcfile (concat "https://git.gnupg.org/cgi-bin/gitweb.cgi?"
                          "p=gnupg-doc.git;a=blob;f="
-                         (if blogmode "misc/blog.gnupg.org/" "web/")
+                         (if blogmode "misc/blog.gnupg.org" "web/")
                          ;; The replace below is a hack to cope with
                          ;; blogmode where HTMLFILE is like "./foo.html".
                          (replace-regexp-in-string
@@ -334,7 +334,7 @@ string of the source file or nil if not available."
       ><img alt=\"CC-BY-SA 3.0\" style=\"border: 0\"
             src=\"/share/cc-by-sa-3.0_80x15.png\"/></a> 
     These web pages are
-    Copyright 1998--2015 The GnuPG Project and licensed under a
+    Copyright 1998--2017 The GnuPG Project and licensed under a
     <a rel=\"license\" href=\"https://creativecommons.org/licenses/by-sa/3.0/\"
     >Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.  See
     <a href=\"/copying.html\">copying</a> for details.
@@ -387,11 +387,14 @@ to create the previous and Next links for an entry."
   (let* ((visitingp (find-buffer-visiting htmlfile))
 	 (work-buffer (or visitingp (find-file-noselect htmlfile)))
          (committed-at (shell-command-to-string
-                        (concat "git log -1 --format='%ci' -- " orgfile))))
+                        (concat "git"
+                                (if blogmode (concat " -C " gpgweb-blog-dir))
+                                " log -1 --format='%ci' -- " orgfile))))
     (prog1 (with-current-buffer work-buffer
              (let ((fname (file-name-nondirectory htmlfile))
                    (fname-2 (replace-regexp-in-string
-                              ".*/gpgweb-stage/\\(.*\\)$" "\\1" htmlfile t))
+                             ".*/gnupg-doc-stage/web/\\(.*\\)$" "\\1"
+                             htmlfile t))
                    (title (gpgweb-publish-find-title orgfile)))
                ;; Insert header, menu, and footer.
                (gpgweb-insert-header title committed-at)
@@ -457,11 +460,14 @@ rendered form and save it with the suffix .html."
 (defun gpgweb-publish-blogs ()
   "Publish all blog entries in the current directory"
   (interactive)
-  (let ((orgfiles (directory-files "." nil "^2[0-9]+-.*\.org$")))
+  (let ((orgfiles (directory-files gpgweb-blog-dir nil "^2[0-9]+-.*\.org$")))
     (dolist (file (cons "index.org" orgfiles))
-      (let* ((visitingp (find-buffer-visiting file))
-             (work-buffer (or visitingp (find-file-noselect file))))
+      (let* ((file2 (concat gpgweb-blog-dir file))
+             (visitingp (find-buffer-visiting file2))
+             (work-buffer (or visitingp (find-file-noselect file2))))
         (with-current-buffer work-buffer
+          (setq default-directory gpgweb-stage-dir)
+          (toggle-read-only 0)
           (gpgweb-render-blog orgfiles)
           (basic-save-buffer))
         (unless visitingp

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

Summary of changes:
 misc/blog.gnupg.org/update-index.sh |  67 ++++++++++++++++++
 misc/blog.gnupg.org/upload          | 101 --------------------------
 tools/build-website.sh              | 137 +++++++++++++++++++++++++++++++-----
 web/share/gpgweb.el                 |  20 ++++--
 4 files changed, 198 insertions(+), 127 deletions(-)
 create mode 100644 misc/blog.gnupg.org/update-index.sh
 delete mode 100755 misc/blog.gnupg.org/upload


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




More information about the Gnupg-commits mailing list