diff --git a/packages/git/pasty-git/DEBBUILD b/packages/git/pasty-git/DEBBUILD new file mode 100644 index 0000000..f47aad3 --- /dev/null +++ b/packages/git/pasty-git/DEBBUILD @@ -0,0 +1,53 @@ +#/usr/bin/env bash + +pkgname="pasty-git" +arch="amd64" +pkgrel=1 +pkgver=20240312172222-39b75df +pkgdesc="pasty is a fast and lightweight code pasting server" +url="https://github.com/leafee98/pasty" +maintainer="Leafee98 " + +source=( + "pasty::git+https://github.com/leafee98/pasty.git" + "pasty.service::materials/pasty.service" + "env::materials/env" +) + +function pkgver { + echo "$(date +%Y%m%d%H%M%S)-$(git rev-parse --short HEAD)" +} + +function build { + ( + cd ${srcdir}/pasty + go build -o pasty ./cmd/pasty/main.go + ) +} + +function package { + install -Dm755 ${srcdir}/pasty/pasty ${pkgdir}/usr/lib/pasty/pasty + install -Dm644 ${srcdir}/pasty/LICENSE ${pkgdir}/usr/share/licenses/pasty/LICENSE + + cp -r ${srcdir}/pasty/web ${pkgdir}/usr/lib/pasty/web + + install -Dm644 ${srcdir}/pasty.service ${pkgdir}/usr/lib/systemd/system/pasty.service + # We haven't implement the 'conffiles', so don't create this file in case override user's config + #install -Dm644 ${srcdir}/env ${pkgdir}/etc/pasty/env +} + +function debian_postinst { + cat << 'EOF' +#!/usr/bin/env bash +service_name="pasty.service" + +adduser --system --group pasty +chown -R pasty:pasty /usr/lib/pasty + +systemctl daemon-reload + +if systemctl is-active --quiet ${service_name} ; then + systemctl restart ${service_name} +fi +EOF +} diff --git a/packages/git/pasty-git/materials/env b/packages/git/pasty-git/materials/env new file mode 100644 index 0000000..be659e2 --- /dev/null +++ b/packages/git/pasty-git/materials/env @@ -0,0 +1 @@ +# See README on https://github.com/lus/pasty diff --git a/packages/git/pasty-git/materials/pasty.service b/packages/git/pasty-git/materials/pasty.service new file mode 100644 index 0000000..81d7c34 --- /dev/null +++ b/packages/git/pasty-git/materials/pasty.service @@ -0,0 +1,18 @@ +[Unit] +Description=Pasty is a fast and lightweight code pasting server +After=network.target + +[Service] +User=pasty + +# Here store the configs +EnvironmentFile=/etc/pasty/env + +# Start program here, the pasty read `./web` to find the front pages +WorkingDirectory=/usr/lib/pasty/ + +ExecStart=/usr/lib/pasty/pasty +Restart=on-failure + +[Install] +WantedBy=multi-user.target