snap: Transition base snap from core20 to core22 (#11101)

- Syntax changes
- Bump Go from 1.19 to 1.20
- Remove unused build tag logic (we only build the extended version)
This commit is contained in:
Joe Mooring 2023-06-13 14:52:19 -07:00 committed by GitHub
parent a0009e070a
commit 35e9b3ed1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,7 @@ description: |
optimized for speed, easy use and configurability. Hugo takes a directory optimized for speed, easy use and configurability. Hugo takes a directory
with content and templates and renders them into a full HTML website. with content and templates and renders them into a full HTML website.
license: "Apache-2.0" license: "Apache-2.0"
base: core20 base: core22
confinement: strict confinement: strict
adopt-info: hugo adopt-info: hugo
@ -40,7 +40,7 @@ environment:
npm_config_userconfig: $SNAP_USER_DATA/.npmrc npm_config_userconfig: $SNAP_USER_DATA/.npmrc
pandoc_datadir: $SNAP/usr/share/pandoc pandoc_datadir: $SNAP/usr/share/pandoc
PYTHONHOME: /usr:$SNAP/usr PYTHONHOME: /usr:$SNAP/usr
RUBYLIB: $SNAP/usr/lib/ruby/vendor_ruby/2.7.0:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/ruby/vendor_ruby/2.7.0:$SNAP/usr/lib/ruby/vendor_ruby:$SNAP/usr/lib/ruby/2.7.0:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/ruby/2.7.0 RUBYLIB: $SNAP/usr/lib/ruby/vendor_ruby/3.0.0:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/ruby/vendor_ruby/3.0.0:$SNAP/usr/lib/ruby/vendor_ruby:$SNAP/usr/lib/ruby/3.0.0:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/ruby/3.0.0
apps: apps:
hugo: hugo:
@ -65,7 +65,7 @@ parts:
go: go:
plugin: nil plugin: nil
stage-snaps: stage-snaps:
- go/1.19/stable - go/1.20/stable
prime: prime:
- bin/go - bin/go
- pkg/tool - pkg/tool
@ -78,12 +78,12 @@ parts:
- git - git
- go - go
override-pull: | override-pull: |
snapcraftctl pull craftctl default
snapcraftctl set-version "$(git describe --tags --always --match 'v[0-9]*' | sed 's/^v//; s/-/+git/; s/-g/./')" craftctl set version="$(git describe --tags --always --match 'v[0-9]*' | sed 's/^v//; s/-/+git/; s/-g/./')"
if grep -q 'Suffix:\s*""' common/hugo/version_current.go; then if grep -q 'Suffix:\s*""' common/hugo/version_current.go; then
snapcraftctl set-grade "stable" craftctl set grade=stable
else else
snapcraftctl set-grade "devel" craftctl set grade=devel
fi fi
override-build: | override-build: |
echo "\nStarting override-build:" echo "\nStarting override-build:"
@ -99,15 +99,9 @@ parts:
echo " - PYTHONHOME and SNAP to be passed to rst2html" echo " - PYTHONHOME and SNAP to be passed to rst2html"
echo " - RUBYLIB to be passed to asciidoctor" echo " - RUBYLIB to be passed to asciidoctor"
sed -i '/OsEnv: NewWhitelist/s/)\$/|GIT_EXEC_PATH|LD_LIBRARY_PATH|npm_config_(cache|init_module|userconfig)|pandoc_datadir|PYTHONHOME|RUBYLIB|SNAP&/' config/security/securityConfig.go sed -i '/OsEnv: NewWhitelist/s/)\$/|GIT_EXEC_PATH|LD_LIBRARY_PATH|npm_config_(cache|init_module|userconfig)|pandoc_datadir|PYTHONHOME|RUBYLIB|SNAP&/' config/security/securityConfig.go
git diff config/security/securityConfig.go git --no-pager diff config/security/securityConfig.go
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
HUGO_BUILD_TAGS="extended"
fi
export HUGO_BUILD_TAGS="extended"
echo " * Building hugo (HUGO_BUILD_TAGS=\"$HUGO_BUILD_TAGS\")..." echo " * Building hugo (HUGO_BUILD_TAGS=\"$HUGO_BUILD_TAGS\")..."
go build -v -ldflags "-X github.com/gohugoio/hugo/common/hugo.vendorInfo=snap:$(git describe --tags --always --match 'v[0-9]*' | sed 's/^v//; s/-/+git/; s/-g/./')" -tags "$HUGO_BUILD_TAGS" go build -v -ldflags "-X github.com/gohugoio/hugo/common/hugo.vendorInfo=snap:$(git describe --tags --always --match 'v[0-9]*' | sed 's/^v//; s/-/+git/; s/-g/./')" -tags "$HUGO_BUILD_TAGS"
./hugo version ./hugo version
@ -116,15 +110,15 @@ parts:
echo " * Building shell completion..." echo " * Building shell completion..."
./hugo completion bash > hugo-completion ./hugo completion bash > hugo-completion
echo " * Installing to ${SNAPCRAFT_PART_INSTALL}..." echo " * Installing to ${CRAFT_PART_INSTALL}..."
install -d $SNAPCRAFT_PART_INSTALL/bin install -d $CRAFT_PART_INSTALL/bin
cp -av hugo $SNAPCRAFT_PART_INSTALL/bin/ cp -av hugo $CRAFT_PART_INSTALL/bin/
mv -v hugo-completion $SNAPCRAFT_PART_INSTALL/ mv -v hugo-completion $CRAFT_PART_INSTALL/
echo " * Stripping binary..." echo " * Stripping binary..."
ls -l $SNAPCRAFT_PART_INSTALL/bin/hugo ls -l $CRAFT_PART_INSTALL/bin/hugo
strip --remove-section=.comment --remove-section=.note $SNAPCRAFT_PART_INSTALL/bin/hugo strip --remove-section=.comment --remove-section=.note $CRAFT_PART_INSTALL/bin/hugo
ls -l $SNAPCRAFT_PART_INSTALL/bin/hugo ls -l $CRAFT_PART_INSTALL/bin/hugo
asciidoctor: asciidoctor:
plugin: nil plugin: nil
@ -132,8 +126,8 @@ parts:
- asciidoctor - asciidoctor
override-build: | override-build: |
set -ex set -ex
snapcraftctl build craftctl default
sed -i '1s|#!/usr/bin/ruby|#!/usr/bin/env ruby|' $SNAPCRAFT_PART_INSTALL/usr/bin/asciidoctor sed -i '1s|#!/usr/bin/ruby|#!/usr/bin/env ruby|' $CRAFT_PART_INSTALL/usr/bin/asciidoctor
dart-sass-embedded: dart-sass-embedded:
plugin: nil plugin: nil
@ -141,8 +135,8 @@ parts:
- curl - curl
override-build: | override-build: |
set -ex set -ex
snapcraftctl build craftctl default
case "$SNAPCRAFT_TARGET_ARCH" in case "$CRAFT_TARGET_ARCH" in
amd64) arch=x64 ;; amd64) arch=x64 ;;
arm64) arch=arm64 ;; arm64) arch=arm64 ;;
armhf) arch=arm ;; armhf) arch=arm ;;
@ -153,8 +147,8 @@ parts:
url=$(curl -s https://api.github.com/repos/sass/dart-sass-embedded/releases/latest | awk -F\" "/browser_download_url.*-linux-${arch}.tar.gz/{print \$(NF-1)}") url=$(curl -s https://api.github.com/repos/sass/dart-sass-embedded/releases/latest | awk -F\" "/browser_download_url.*-linux-${arch}.tar.gz/{print \$(NF-1)}")
curl -LO --retry-connrefused --retry 10 "$url" curl -LO --retry-connrefused --retry 10 "$url"
tar xf sass_embedded-*-linux-$arch.tar.gz tar xf sass_embedded-*-linux-$arch.tar.gz
install -d $SNAPCRAFT_PART_INSTALL/bin install -d $CRAFT_PART_INSTALL/bin
cp -av sass_embedded/* $SNAPCRAFT_PART_INSTALL/bin/ cp -av sass_embedded/* $CRAFT_PART_INSTALL/bin/
fi fi
node: node:
@ -173,7 +167,7 @@ parts:
- python3-docutils - python3-docutils
override-build: | override-build: |
set -ex set -ex
snapcraftctl build craftctl default
sed -i "s|'/usr/share/docutils/'|os.path.expandvars('\$SNAP/usr/share/docutils/')|" $SNAPCRAFT_PART_INSTALL/usr/lib/python3/dist-packages/docutils/__init__.py sed -i "s|'/usr/share/docutils/'|os.path.expandvars('\$SNAP/usr/share/docutils/')|" $CRAFT_PART_INSTALL/usr/lib/python3/dist-packages/docutils/__init__.py
organize: organize:
usr/share/docutils/scripts/python3: usr/bin usr/share/docutils/scripts/python3: usr/bin