Skip to content

Commit

Permalink
snapcraft.yaml: Update to "base: core20"
Browse files Browse the repository at this point in the history
That is, switch to using Ubuntu 20.04 LTS as base,
leveraging new features in Snapcraft 4.x, etc.

It is far from complete, with npm temporarily disabled (hence no PostCSS)
and with Pandoc probably not working yet, but would hopefully get our
Hugo Snap build, which stopped working shortly after v0.80.0, working again.
  • Loading branch information
anthonyfok committed Apr 22, 2021
1 parent fe2ee02 commit 243951e
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
name: hugo
version: "0.83.0-DEV"
version: git
summary: Fast and Flexible Static Site Generator
description: |
Hugo is a static HTML and CSS website generator written in Go. It is
optimized for speed, easy use and configurability. Hugo takes a directory
with content and templates and renders them into a full HTML website.
license: "Apache-2.0"
base: core20
confinement: strict
grade: devel # "devel" or "stable"

apps:
hugo:
command: bin/hugo
completer: hugo-completion
plugs: [home, network-bind, removable-media]
plugs:
- home
- network-bind
- removable-media

parts:
git:
Expand All @@ -36,16 +41,16 @@ parts:
export PATH=$GOPATH/bin:$PATH
echo ' * Running "go get -v github.com/magefile/mage"...'
GO111MODULE=off go get -v github.com/magefile/mage
go get -v github.com/magefile/mage
echo ' * Running "mage -v test"...'
export GO111MODULE=on
mage -v test
#echo ' * Running "mage -v test"...'
#mage -v test
echo " * SNAPCRAFT_IMAGE_INFO=$SNAPCRAFT_IMAGE_INFO"
echo " * SNAPCRAFT_IMAGE_INFO=${SNAPCRAFT_IMAGE_INFO=}"
# Example: SNAPCRAFT_IMAGE_INFO='{"build_url": "https://launchpad.net/~gohugoio/+snap/hugo-extended-dev/+build/344022"}'
export HUGO_BUILD_TAGS=""
if echo $SNAPCRAFT_IMAGE_INFO | grep -q '/+snap/hugo-extended'; then
export HUGO_BUILD_TAGS="extended"
HUGO_BUILD_TAGS="extended"
fi
echo " * Building hugo (HUGO_BUILD_TAGS=\"$HUGO_BUILD_TAGS\")..."
[ "$SNAPCRAFT_PROJECT_GRADE" = "stable" ] && mage -v hugoNoGitInfo || mage -v hugo
Expand All @@ -65,27 +70,17 @@ parts:
strip --remove-section=.comment --remove-section=.note $SNAPCRAFT_PART_INSTALL/bin/hugo
ls -l $SNAPCRAFT_PART_INSTALL/bin/hugo
node:
plugin: x-nodejs
node-packages:
- "@babel/cli"
- "@babel/core"
- postcss
- postcss-cli
filesets:
node:
- bin/node
postcss:
- bin/postcss
- lib/node_modules/postcss/*
- lib/node_modules/postcss-cli/*
babel:
- bin/babel
- lib/node_modules/@babel/cli/*
pandoc:
plugin: nil
stage-packages:
- libatomic1
- pandoc
- pandoc-data
organize:
usr/bin/: bin/
usr/lib/: lib/
prime:
- $node
- $postcss
- $babel
- bin/pandoc

pygments:
plugin: python
Expand Down

4 comments on commit 243951e

@jmooring
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with npm temporarily disabled (hence no PostCSS) and with Pandoc probably not working

So, when my snap auto-updates these will stop working? If yes, this is a breaking change.

@jmooring
Copy link
Member

@jmooring jmooring commented on 243951e Apr 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just ran /snap/bin/hugo version and discovered that my snap has already been automatically updated:

hugo v0.83.0-DEV-243951EB+extended linux/amd64 BuildDate=2021-04-22T17:07:16Z

So I ran a rudimentary PostCSS test:

git clone --single-branch -b hugo-github-issue-7278 https://github.com/jmooring/hugo-testing hugo-github-issue-7278
cd hugo-github-issue-7278
npm ci
/snap/bin/hugo

And it's broken again:

Error: Error building site: failed to render pages: render of "page" failed: "/home/jmooring/temp/hugo-github-issue-7278/layouts/_default/baseof.html:9:14": execute of template failed: template: _default/single.html:9:14: executing "_default/single.html" at <$style.Content>: error calling Content: POSTCSS: failed to transform "sass/main.css" (text/css): /usr/bin/env: 'node': No such file or directory

I understand that we're trying to improve the snap, but we shouldn't be breaking installations. Users will have no warning.

/cc @bep

@anthonyfok
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmooring Thanks for letting me know!

Actually, it was not just "improving the snap", but rather, the existing Snap was broken, hence the Hugo Snap was stuck at 0.80.0 for over three months now, so my recent fix to snapcraft.yaml, though far from perfect was my first step at getting it to work again.

Sorry for disabling node/npm for my latest commit:

If it is feasible at all and not too much trouble, could you please revert to "extended/stable", i.e. the released 0.80.0 for the time being?
I'll try my best to get PostCSS in extended/edge over the weekend, and thank you for providing a sample repo https://github.com/jmooring/hugo-testing for me to test.

@anthonyfok
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jmooring,
This regression (no bin/node) is hopefully solved in commit 902535e.
Please allow for up to 6 hours for the Launchpad autobuilders to build and publish to extended/edge etc.
The snap size did increase from 33MB to 55MB with the addition of node 14.16.1 LTS binary.
Thank you again for reporting the issue and providing me with an easy way to test!

Please sign in to comment.