shithub: hugo

Download patch

ref: 3033a9a37eb66c08e60f9fe977f29d22bd646857
parent: 27d4211187d4617f4b3afa970f91349567886748
author: Anthony Fok <[email protected]>
date: Tue Sep 25 03:05:55 EDT 2018

snap: Fix go plugin build failure by renaming go.mod

as a temporary workaround.

See https://forum.snapcraft.io/t/go-plugin-go1-11-fails-if-go-mod-exists-in-the-top-level-directory/7546
and https://discourse.gohugo.io/t/hugo-0-48-released/13908/12

--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -15,45 +15,63 @@
     plugs: [home, network-bind, removable-media]
 
 parts:
+  git:
+    plugin: nil
+    stage-packages:
+      - git
+    organize:
+      usr/bin/: bin/
+    prime:
+      - bin/git
+
+  go:
+    # Hugo's go.mod would interfere with the build of Go 1.11 in the
+    # parts/go/build/ subdirectory.  Move go.mod out of the way
+    # as a workaround.  (Note: 'override-build' does not work here,
+    # hence the use of the deprecated 'prepare' keyword.)
+    # See https://forum.snapcraft.io/t/go-plugin-go1-11-fails-if-go-mod-exists-in-the-top-level-directory/7546
+    prepare: |
+      set -x
+      ( cd ../../.. && mv -v go.mod go.mod~ )
+    source-tag: go1.11
+
   hugo:
     source: .
+    after: [go]
     plugin: go
     go-importpath: github.com/gohugoio/hugo
-    build-packages:
-      - git
     override-build: |
+      set -ex
+
       echo "\nStarting override-build:"
+      ( cd ../../.. && mv -v go.mod~ go.mod || : )
       export GO111MODULE=on
       export GOPATH=$(dirname $SNAPCRAFT_PART_INSTALL)/go
       export PATH=$GOPATH/bin:$PATH
+
       cd $GOPATH/src/github.com/gohugoio/hugo
       echo ' * Running "go get -v github.com/magefile/mage"...'
       go get -v github.com/magefile/mage
       echo ' * Running "mage -v test"...'
       mage -v test
+
       echo " * Building hugo (build tag: none)..."
       [ "$SNAPCRAFT_PROJECT_GRADE" = "stable" ] && mage -v hugoNoGitInfo || mage -v hugo
       ./hugo version
       ldd hugo || :
+
       echo " * Building shell completion..."
       ./hugo gen autocomplete --completionfile=hugo-completion
+
       echo " * Installing to ${SNAPCRAFT_PART_INSTALL}..."
       install -d $SNAPCRAFT_PART_INSTALL/bin
       cp -av hugo $SNAPCRAFT_PART_INSTALL/bin/
       mv -v hugo-completion $SNAPCRAFT_PART_INSTALL/
+
       echo " * Stripping binary..."
       ls -l $SNAPCRAFT_PART_INSTALL/bin/hugo
       strip --remove-section=.comment --remove-section=.note $SNAPCRAFT_PART_INSTALL/bin/hugo
       ls -l $SNAPCRAFT_PART_INSTALL/bin/hugo
-    after: [go]
-
-  go:
-    source-tag: go1.11
-
-  git:
-    plugin: nil
-    stage-packages: [git]
-    prime: [usr/bin/git]
 
   node:
     plugin: nodejs