Debian Codegraph @

snap/snapcraft.yaml

raw
1 name: hugo
2 base: core24
3 adopt-info: hugo
4 confinement: strict
5 title: Hugo
6 icon: snap/local/logo.png
7 summary: Fast and Flexible Static Site Generator
8 description: |
9 Hugo is a static site generator written in Go, optimized for speed and
10 designed for flexibility. With its advanced templating system and fast asset
11 pipelines, Hugo renders a complete site in seconds, often less.
12
13 Due to its flexible framework, multilingual support, and powerful taxonomy
14 system, Hugo is widely used to create:
15 * Corporate, government, nonprofit, education, news, event, and project sites
16 * Documentation sites
17 * Image portfolios
18 * Landing pages
19 * Business, professional, and personal blogs
20 * Resumes and CVs
21
22 # Project links
23 issues: https://github.com/gohugoio/hugo/issues
24 license: "Apache-2.0"
25 source-code: https://github.com/gohugoio/hugo.git
26 website: https://gohugo.io/
27
28 platforms:
29 amd64:
30 arm64:
31
32 lint:
33 ignore:
34 - library:
35 - usr/lib/**/libform.so.*
36 - usr/lib/**/liblua*.so.*
37 - usr/lib/**/libmenu.so.*
38 - usr/lib/**/libpanel.so.*
39 - usr/lib/**/libperl.so.*
40
41 # Interfaces
42 plugs:
43 dot-aws:
44 interface: personal-files
45 read:
46 - $HOME/.aws
47 dot-azure:
48 interface: personal-files
49 read:
50 - $HOME/.azure
51 dot-cache-hugo:
52 interface: personal-files
53 write:
54 - $HOME/.cache/hugo_cache
55 dot-config-gcloud:
56 interface: personal-files
57 read:
58 - $HOME/.config/gcloud
59 etc-gitconfig:
60 interface: system-files
61 read:
62 - /etc/gitconfig
63 gitconfig:
64 interface: personal-files
65 read:
66 - $HOME/.config/git
67 - $HOME/.gitconfig
68 - $HOME/.gitconfig.local
69 ssh-keys:
70 interface: ssh-keys
71
72 # Runtime environment
73 environment:
74 # Home
75 HOME: $SNAP_REAL_HOME
76
77 # Ruby
78 GEM_HOME: $SNAP_USER_DATA/gems
79 GEM_PATH: $SNAP/usr/share/rubygems-integration/all:$SNAP/usr/lib/ruby/gems/3.2.0:$SNAP/var/lib/gems/3.2.0
80 RUBYLIB: $SNAP/usr/lib/ruby/vendor_ruby/3.2.0:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/ruby/vendor_ruby/3.2.0:$SNAP/usr/lib/ruby/vendor_ruby:$SNAP/usr/lib/ruby/3.2.0:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/ruby/3.2.0
81
82 # Node
83 npm_config_cache: $SNAP_USER_DATA/.npm
84 npm_config_init_module: $SNAP_USER_DATA/.npm-init.js
85 npm_config_userconfig: $SNAP_USER_DATA/.npmrc
86
87 # Other
88 PYTHONHOME: /usr:$SNAP/usr
89 pandoc_datadir: $SNAP/usr/share/pandoc
90 GIT_EXEC_PATH: $SNAP/usr/lib/git-core
91 GOCACHE: $SNAP_USER_DATA/.cache/go-build
92
93 # Allowlist for environment variables
94 # Default: (?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|GO\w+|(XDG_CONFIG_)?HOME|USERPROFILE|SSH_AUTH_SOCK|DISPLAY|LANG|SYSTEMDRIVE|PROGRAMDATA)$
95 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|SYSTEMDRIVE|PROGRAMDATA|GIT_EXEC_PATH|LD_LIBRARY_PATH|npm_config_(cache|init_module|userconfig)|pandoc_datadir|PYTHONHOME|SNAP|GEM_HOME|GEM_PATH|RUBYLIB)$
96
97 # App definition
98 apps:
99 hugo:
100 command: bin/hugo
101 completer: hugo-completion
102 plugs:
103 - desktop
104 - dot-aws
105 - dot-azure
106 - dot-cache-hugo
107 - dot-config-gcloud
108 - etc-gitconfig
109 - gitconfig
110 - home
111 - network-bind
112 - removable-media
113 - ssh-keys
114
115 # Build parts
116 parts:
117 asciidoctor:
118 plugin: nil
119 stage-packages:
120 - asciidoctor
121 - ruby-asciidoctor
122 - rubygems-integration
123 override-build: |
124 set -ex
125 craftctl default
126 # Use env ruby to ensure the snap's ruby interpreter is used
127 sed -i '1s|#!/usr/bin/ruby|#!/usr/bin/env ruby|' $CRAFT_PART_INSTALL/usr/bin/asciidoctor
128 # Patch rubygems to avoid flock() errors in strict confinement
129 sed -i 's|!solaris_platform|win_platform|' $CRAFT_PART_INSTALL/usr/lib/ruby/vendor_ruby/rubygems.rb
130
131 dart-sass:
132 plugin: nil
133 build-packages:
134 - curl
135 override-build: |
136 set -ex
137 craftctl default
138 case "$CRAFT_ARCH_BUILD_FOR" in
139 amd64) arch=x64 ;;
140 arm64) arch=arm64 ;;
141 *) arch="" ;;
142 esac
143 if [[ -n $arch ]]; then
144 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)}")
145 curl -LO --retry-connrefused --retry 10 "${url}"
146 tar xf dart-sass-*-linux-${arch}.tar.gz
147 install -d $CRAFT_PART_INSTALL/bin
148 cp -av dart-sass/* $CRAFT_PART_INSTALL/bin/
149 fi
150
151 git:
152 plugin: nil
153 stage-packages:
154 - git
155 prime:
156 - usr/bin/git
157 - usr/lib
158
159 go:
160 plugin: nil
161 stage-snaps:
162 - go/latest/stable
163 prime:
164 - bin/go
165 - pkg/tool
166 - -pkg/tool/*
167
168 node:
169 plugin: nil
170 stage-snaps:
171 - node/24/stable
172 organize:
173 "LICENSE": "LICENSE_NODE"
174 "README.md": "README_NODE.md"
175
176 pandoc:
177 plugin: nil
178 stage-packages:
179 - pandoc
180
181 rst2html:
182 plugin: nil
183 stage-packages:
184 - python3-docutils
185 override-build: |
186 set -ex
187 craftctl default
188 sed -i "s|'/usr/share/docutils/'|os.path.expandvars('\$SNAP/usr/share/docutils/')|" $CRAFT_PART_INSTALL/usr/lib/python3/dist-packages/docutils/__init__.py
189 organize:
190 usr/share/docutils/scripts/python3: usr/bin
191
192 hugo:
193 plugin: nil
194 source: .
195 after:
196 - git
197 - go
198 build-packages:
199 - git
200 override-pull: |
201 craftctl default
202 craftctl set version=$(git describe --tags --always --match 'v[0-9]*' | sed 's/^v//; s/-/+git/; s/-g/./')
203 if grep -q 'Suffix:\s*""' common/hugo/version_current.go; then
204 craftctl set grade=stable
205 else
206 craftctl set grade=devel
207 fi
208 override-build: |
209 set -ex
210 export GOPATH=$(realpath ../go)
211 export PATH=$GOPATH/bin:$PATH
212 HUGO_BUILD_TAGS="extended"
213
214 echo "Building Hugo (extended)..."
215 go build -v -ldflags "-s -w -X github.com/gohugoio/hugo/common/hugo.vendorInfo=snap:$(craftctl get version)" -tags "$HUGO_BUILD_TAGS"
216
217 echo "Generating Shell Completion..."
218 ./hugo completion bash > hugo-completion
219
220 echo "Installing Binaries..."
221 install -d $CRAFT_PART_INSTALL/bin
222 cp -av hugo $CRAFT_PART_INSTALL/bin/
223 mv -v hugo-completion $CRAFT_PART_INSTALL/
224
225 echo "Stripping Binary..."
226 strip --remove-section=.comment --remove-section=.note $CRAFT_PART_INSTALL/bin/hugo