aboutsummaryrefslogtreecommitdiffhomepage
path: root/snap/snapcraft.yaml
blob: c4c42a950c225ea0210932902740bd102ecc1b70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: hugo
base: core20
confinement: strict
adopt-info: hugo
title: Hugo
icon: snap/local/logo.png
summary: Fast and Flexible Static Site Generator
description: |
  Hugo is a static site generator written in Go, optimized for speed and
  designed for flexibility. With its advanced templating system and fast asset
  pipelines, Hugo renders a complete site in seconds, often less.

  Due to its flexible framework, multilingual support, and powerful taxonomy
  system, Hugo is widely used to create:

  * Corporate, government, nonprofit, education, news, event, and project sites
  * Documentation sites
  * Image portfolios
  * Landing pages
  * Business, professional, and personal blogs
  * Resumes and CVs

  Use Hugo's embedded web server during development to instantly see changes to
  content, structure, behavior, and presentation. Then deploy the site to your
  host, or push changes to your Git provider for automated builds and
  deployment.
issues: https://github.com/gohugoio/hugo/issues
license: "Apache-2.0"
source-code: https://github.com/gohugoio/hugo.git
website: https://gohugo.io/

package-repositories:
  - type: apt
    components: [main]
    suites: [focal]
    key-id: 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280
    url: https://deb.nodesource.com/node_16.x

plugs:
  etc-gitconfig:
    interface: system-files
    read:
      - /etc/gitconfig
  gitconfig:
    interface: personal-files
    read:
      - $HOME/.gitconfig
      - $HOME/.config/git
      - $HOME/.gitconfig.local
  dot-aws:
    interface: personal-files
    read:
      - $HOME/.aws
  dot-azure:
    interface: personal-files
    read:
      - $HOME/.azure
  dot-config-gcloud:
    interface: personal-files
    read:
      - $HOME/.config/gcloud
  dot-cache-hugo:
    interface: personal-files
    write:
      - $HOME/.cache/hugo_cache
  ssh-keys:
    interface: ssh-keys

environment:
  HOME: $SNAP_REAL_HOME
  GIT_EXEC_PATH: $SNAP/usr/lib/git-core
  GOCACHE: $SNAP_USER_DATA/.cache/go-build
  npm_config_cache: $SNAP_USER_DATA/.npm
  npm_config_init_module: $SNAP_USER_DATA/.npm-init.js
  npm_config_userconfig: $SNAP_USER_DATA/.npmrc
  pandoc_datadir: $SNAP/usr/share/pandoc
  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
  # HUGO_SECURITY_EXEC_OSENV
  #
  # Default value:
  #   (?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|GO\w+|(XDG_CONFIG_)?HOME|USERPROFILE|SSH_AUTH_SOCK|DISPLAY|LANG)$
  # Bundled applications require additional access:
  #   git:          GIT_EXEC_PATH and LD_LIBRARY_PATH
  #   npx:          npm_config_{cache,init_module,userconfig}
  #   pandoc:       pandoc_datadir
  #   rst2html:     PYTHONHOME and SNAP
  #   asciidoctor:  RUBYLIB
  HUGO_SECURITY_EXEC_OSENV: (?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|GO\w+|(XDG_CONFIG_)?HOME|USERPROFILE|SSH_AUTH_SOCK|DISPLAY|LANG|GIT_EXEC_PATH|LD_LIBRARY_PATH|npm_config_(cache|init_module|userconfig)|pandoc_datadir|PYTHONHOME|SNAP|RUBYLIB)$

apps:
  hugo:
    command: bin/hugo
    completer: hugo-completion
    plugs:
      - home
      - network-bind
      - removable-media
      - etc-gitconfig
      - gitconfig
      - dot-aws
      - dot-azure
      - dot-config-gcloud
      - dot-cache-hugo
      - ssh-keys

parts:
  git:
    plugin: nil
    stage-packages:
      - git
    prime:
      - usr/bin/git
      - usr/lib

  go:
    plugin: nil
    stage-snaps:
      - go/1.21/stable
    prime:
      - bin/go
      - pkg/tool
      - -pkg/tool/*

  hugo:
    plugin: nil
    source: .
    after:
      - git
      - go
    override-pull: |
      snapcraftctl pull
      snapcraftctl 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
        snapcraftctl set-grade "stable"
      else
        snapcraftctl set-grade "devel"
      fi
    override-build: |
      echo "\nStarting override-build:"
      set -ex

      export GOPATH=$(realpath ../go)
      export PATH=$GOPATH/bin:$PATH

      HUGO_BUILD_TAGS="extended"
      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"
      ./hugo version
      ldd hugo || :

      echo " * Building shell completion..."
      ./hugo completion bash > 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

  asciidoctor:
    plugin: nil
    stage-packages:
      - asciidoctor
    override-build: |
      set -ex
      snapcraftctl build
      sed -i '1s|#!/usr/bin/ruby|#!/usr/bin/env ruby|' $SNAPCRAFT_PART_INSTALL/usr/bin/asciidoctor

  dart-sass-embedded:
    plugin: nil
    build-packages:
      - curl
    override-build: |
      set -ex
      snapcraftctl build
      case "$SNAPCRAFT_TARGET_ARCH" in
        amd64)  arch=x64    ;;
        arm64)  arch=arm64  ;;
        armhf)  arch=arm    ;;
        i386)   arch=ia32   ;;
        *)      arch=""     ;;
      esac
      if [[ -n $arch ]]; then
        url=$(curl -s https://api.github.com/repos/sass/dart-sass/releases/latest | awk -F\" "/browser_download_url.*-linux-${arch}.tar.gz/{print \$(NF-1)}")
        curl -LO --retry-connrefused --retry 10 "${url}"
        tar xf dart-sass-*-linux-${arch}.tar.gz
        install -d $SNAPCRAFT_PART_INSTALL/bin
        cp -av dart-sass/* $SNAPCRAFT_PART_INSTALL/bin/
      fi

  node:
    plugin: nil
    stage-packages:
      - nodejs

  pandoc:
    plugin: nil
    stage-packages:
      - pandoc

  rst2html:
    plugin: nil
    stage-packages:
      - python3-docutils
    override-build: |
      set -ex
      snapcraftctl build
      sed -i "s|'/usr/share/docutils/'|os.path.expandvars('\$SNAP/usr/share/docutils/')|" $SNAPCRAFT_PART_INSTALL/usr/lib/python3/dist-packages/docutils/__init__.py
    organize:
      usr/share/docutils/scripts/python3: usr/bin