commit 7b62928270b8c45636013a7f357cfe86a50629c6 Author: Jelle van der Waa Date: Tue May 30 21:44:03 2023 +0200 upgpkg: 0.9.0-1 diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..56b4b96 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,119 @@ +# Maintainer: George Rawlinson +# Contributor: malacology +# Contributor: Stefan Husmann + +pkgname=gotosocial +pkgver=0.9.0 +pkgrel=1 +pkgdesc='ActivityPub social network server written in Golang' +arch=('x86_64') +url='https://gotosocial.org' +license=('AGPL3') +depends=('glibc') +makedepends=('git' 'go' 'yarn' 'nodejs' 'go-swagger') +options=('!lto') +backup=( + 'etc/gotosocial/config.yaml' + 'etc/gotosocial/template/404.tmpl' + 'etc/gotosocial/template/about.tmpl' + 'etc/gotosocial/template/authorize.tmpl' + 'etc/gotosocial/template/confirmed.tmpl' + 'etc/gotosocial/template/domain-blocklist.tmpl' + 'etc/gotosocial/template/email_confirm.tmpl' + 'etc/gotosocial/template/email_new_report.tmpl' + 'etc/gotosocial/template/email_report_closed.tmpl' + 'etc/gotosocial/template/email_reset.tmpl' + 'etc/gotosocial/template/email_test.tmpl' + 'etc/gotosocial/template/error.tmpl' + 'etc/gotosocial/template/finalize.tmpl' + 'etc/gotosocial/template/footer.tmpl' + 'etc/gotosocial/template/frontend.tmpl' + 'etc/gotosocial/template/header.tmpl' + 'etc/gotosocial/template/index.tmpl' + 'etc/gotosocial/template/oob.tmpl' + 'etc/gotosocial/template/profile.tmpl' + 'etc/gotosocial/template/sign-in.tmpl' + 'etc/gotosocial/template/status.tmpl' + 'etc/gotosocial/template/thread.tmpl' +) +_commit='282be6f26dd4dfb57c3a21b92b756c40c05b2e6c' +source=( + "$pkgname::git+https://github.com/superseriousbusiness/gotosocial#commit=$_commit" + 'sysusers.conf' + 'tmpfiles.conf' + 'use-fhs-directories.patch' +) +sha512sums=('SKIP' + '68890539a1285a819d5a2cd755aeabd59a9872926d9c32e5d54faaf2771414f006e568f2f813f3c6fcd9dbeda7b6e57c924d7490521880cb65632e02fabcbd63' + 'b89fad3073e140f17167515b38942e5b5e2bc2aee03c484e1bb7cf6444f86cb1e2a13a60b101e04d22633d348be073ca26cd309da4746e5062c12b4f3ce4b38a' + '913a5209487aba06bf1d8ac7c02506a05d01a8e12f172666c84bf6870d6237640d4745617b0f07ea8c9dcf665f4e0d24a0aabef31611909f7e9384ed6e7b7e77') +b2sums=('SKIP' + '0a5be7ac18af882c0c89d8e930eb76c2e60bc2c1d5a375ab04e987c7de9a7a3175319c4e5fbc818261141daf5f70d583aebcc2dc197fe3a88047fbfe488ccb94' + '4f65af952441c0f54bb32049a149675e207f8993678423d369c4095c57476464614ac720eccc64d7a93a81268ad7ca41cae75ca7211bd7b78f9035f6e5341f04' + '9edd4520fb99856feb82d01935588add7f805aa180f2ed0fe169cb26576bc2e1d2c1e6ab11604d977cec6a4ad8f1d5be1413e1a366de59b89c5b869136538f8c') + +pkgver() { + cd "$pkgname" + + git describe --tags | sed 's/^v//' +} + +prepare() { + cd "$pkgname" + + # create directory for build output + mkdir build + + # download dependencies + go mod download + + # use FHS directories + patch -p1 -i "$srcdir/use-fhs-directories.patch" +} + +build() { + cd "$pkgname" + + # set Go flags + export CGO_CPPFLAGS="${CPPFLAGS}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_CXXFLAGS="${CXXFLAGS}" + + # generate up-to-date swagger.yaml + swagger generate spec --scan-models --exclude-deps -o web/assets/swagger.yaml + sed -e "s/REPLACE_ME/$pkgver/" -i web/assets/swagger.yaml + + go build -v \ + -trimpath \ + -buildmode=pie \ + -mod=readonly \ + -modcacherw \ + -ldflags "-linkmode external -extldflags ${LDFLAGS} \ + -X main.Version=$pkgver" \ + -o build \ + ./cmd/... + + # generate web assets + yarn install --cwd web/source + BUDO_BUILD=1 node web/source +} + +package() { + # systemd integration + install -vDm644 sysusers.conf "$pkgdir/usr/lib/sysusers.d/$pkgname.conf" + install -vDm644 tmpfiles.conf "$pkgdir/usr/lib/tmpfiles.d/$pkgname.conf" + install -vDm644 "$pkgname/example/$pkgname.service" -t "$pkgdir/usr/lib/systemd/system" + + cd "$pkgname" + + # binary + install -vDm755 -t "$pkgdir/usr/bin" "build/$pkgname" + + # configuration + install -vDm640 -t "$pkgdir/etc/$pkgname" example/config.yaml + + # web frontend + install -vd "$pkgdir/usr/share/$pkgname" + cp -vr web/assets/* "$pkgdir/usr/share/$pkgname" + cp -vr web/template "$pkgdir/etc/$pkgname" +} diff --git a/sysusers.conf b/sysusers.conf new file mode 100644 index 0000000..f726751 --- /dev/null +++ b/sysusers.conf @@ -0,0 +1 @@ +u gotosocial - "gotosocial daemon user" /var/lib/gotosocial diff --git a/tmpfiles.conf b/tmpfiles.conf new file mode 100644 index 0000000..7fe8b0f --- /dev/null +++ b/tmpfiles.conf @@ -0,0 +1,5 @@ +d /var/lib/gotosocial 0750 gotosocial gotosocial +d /var/lib/gotosocial/storage 0750 gotosocial gotosocial +d /var/lib/gotosocial/storage/certs 0750 gotosocial gotosocial +d /var/log/gotosocial 0750 gotosocial gotosocial +Z /etc/gotosocial 0750 gotosocial gotosocial diff --git a/use-fhs-directories.patch b/use-fhs-directories.patch new file mode 100644 index 0000000..e629fe9 --- /dev/null +++ b/use-fhs-directories.patch @@ -0,0 +1,66 @@ +--- a/example/config.yaml ++++ b/example/config.yaml +@@ -97,7 +97,7 @@ trusted-proxies: + # String. Database type. + # Options: ["postgres","sqlite"] + # Default: "postgres" +-db-type: "postgres" ++db-type: "sqlite" + + # String. Database address or parameters. + # +@@ -112,7 +112,7 @@ db-type: "postgres" + # + # Examples: ["localhost","my.db.host","127.0.0.1","192.111.39.110",":memory:", "sqlite.db"] + # Default: "" +-db-address: "" ++db-address: "/var/lib/gotosocial/sqlite.db" + + # Int. Port for database connection. + # Examples: [5432, 1234, 6969] +@@ -158,12 +158,12 @@ db-tls-ca-cert: "" + # String. Directory from which gotosocial will attempt to load html templates (.tmpl files). + # Examples: ["/some/absolute/path/", "./relative/path/", "../../some/weird/path/"] + # Default: "./web/template/" +-web-template-base-dir: "./web/template/" ++web-template-base-dir: "/etc/gotosocial/template" + + # String. Directory from which gotosocial will attempt to serve static web assets (images, scripts). + # Examples: ["/some/absolute/path/", "./relative/path/", "../../some/weird/path/"] + # Default: "./web/assets/" +-web-asset-base-dir: "./web/assets/" ++web-asset-base-dir: "/usr/share/gotosocial" + + ########################### + ##### INSTANCE CONFIG ##### +@@ -261,7 +261,7 @@ storage-backend: "local" + # Only required when running with the local storage backend. + # Examples: ["/home/gotosocial/storage", "/opt/gotosocial/datastorage"] + # Default: "/gotosocial/storage" +-storage-local-base-path: "/gotosocial/storage" ++storage-local-base-path: "/var/lib/gotosocial/storage" + + # String. API endpoint of the S3 compatible service. + # Only required when running with the s3 storage backend. +@@ -357,7 +357,7 @@ letsencrypt-port: 80 + # In any case, make sure GoToSocial has permissions to write to / read from this directory. + # Examples: ["/home/gotosocial/storage/certs", "/acmecerts"] + # Default: "/gotosocial/storage/certs" +-letsencrypt-cert-dir: "/gotosocial/storage/certs" ++letsencrypt-cert-dir: "/var/lib/gotosocial/storage/certs" + + # String. Email address to use when registering LetsEncrypt certs. + # Most likely, this will be the email address of the instance administrator. +--- a/example/gotosocial.service ++++ b/example/gotosocial.service +@@ -14,8 +14,8 @@ Type=exec + Restart=on-failure + + # change if your path to the GoToSocial binary is different +-ExecStart=/gotosocial/gotosocial --config-path config.yaml server start +-WorkingDirectory=/gotosocial ++ExecStart=/usr/bin/gotosocial --config-path /etc/gotosocial/config.yaml server start ++WorkingDirectory=/var/lib/gotosocial + + StandardOutput=append:/var/log/gotosocial/gotosocial.log + StandardError=inherit