1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-19 20:57:53 +02:00
Ludovic Fernandez 377981ebd7
fix(aur): description with quotes (#5304)
Currently, the field `pkgdesc` is wrapped by simple quotes, but if the
description also contains simple quotes it breaks the package.

So it's not possible to publish a package that contains "Let's Encrypt"
inside the description.

This PR wraps the description with the right quotes depending on the
description content.

If there is a mix of quotes, it replaces, arbitrarily, double quotes
with single quotes.

Example with double quotes inside the description:
https://gitlab.archlinux.org/archlinux/packaging/packages/cargo-release/-/blob/main/PKGBUILD?ref_type=heads

Example with simple quotes inside the description:
https://gitlab.archlinux.org/archlinux/packaging/packages/cargo-modules/-/blob/main/PKGBUILD?ref_type=heads
2024-11-22 09:56:52 -03:00

103 lines
2.1 KiB
Go

package aur
type templateData struct {
Name string
Desc string
Homepage string
Version string
License string
ReleasePackages []releasePackage
Maintainers []string
Contributors []string
Provides []string
Conflicts []string
Backup []string
Depends []string
OptDepends []string
Arches []string
Rel string
Package string
}
type releasePackage struct {
DownloadURL string
SHA256 string
Arch string
Format string
}
const aurTemplateData = `# This file was generated by GoReleaser. DO NOT EDIT.
{{- range .Maintainers }}
# Maintainer: {{ . }}
{{- end }}
{{- range .Contributors }}
# Contributor: {{ . }}
{{- end }}
pkgname='{{ .Name }}'
pkgver={{ .Version }}
pkgrel={{ .Rel }}
pkgdesc={{ quoteField .Desc }}
url='{{ .Homepage }}'
arch=({{ pkgArray .Arches }})
license=('{{ .License }}')
{{- with .Provides }}
provides=({{ pkgArray . }})
{{- end }}
{{- with .Conflicts }}
conflicts=({{ pkgArray . }})
{{- end }}
{{- with .Depends }}
depends=({{ pkgArray . }})
{{- end }}
{{- with .OptDepends }}
optdepends=({{ pkgArray . }})
{{- end }}
{{- with .Backup }}
backup=({{ pkgArray . }})
{{- end }}
{{ range .ReleasePackages -}}
source_{{ .Arch }}=("${pkgname}_${pkgver}_{{ .Arch }}.{{ .Format }}::{{ .DownloadURL }}")
sha256sums_{{ .Arch }}=('{{ .SHA256 }}')
{{ printf "" }}
{{ end }}
{{- with .Package -}}
package() {
{{ fixLines . }}
}
{{ end }}`
const srcInfoTemplate = `pkgbase = {{ .Name }}
pkgdesc = {{ .Desc }}
pkgver = {{ .Version }}
pkgrel = {{ .Rel }}
{{ with .Homepage -}}
url = {{ . }}
{{ end -}}
{{ with .License -}}
license = {{ . }}
{{ end -}}
{{ range .OptDepends -}}
optdepends = {{ . }}
{{ end -}}
{{ range .Depends -}}
depends = {{ . }}
{{ end -}}
{{ range .Conflicts -}}
conflicts = {{ . }}
{{ end -}}
{{ range .Provides -}}
provides = {{ . }}
{{ end -}}
{{ range .ReleasePackages -}}
arch = {{ .Arch }}
source_{{ .Arch }} = {{ .DownloadURL }}
sha256sums_{{ .Arch }} = {{ .SHA256 }}
{{ end -}}
{{ printf "\n" -}}
pkgname = {{ .Name }}
`