summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Papakostas2021-06-17 23:15:54 +0200
committerJason Papakostas2021-06-17 23:26:40 +0200
commit934a20715969621d691c6bbdb56dc633c50c05fe (patch)
tree0f811c278a7a2bdc765673d2ee302ed7d5562732
parent33fafed498f81402123eda6f9b5126d341c1ec74 (diff)
downloadaur-934a20715969621d691c6bbdb56dc633c50c05fe.tar.gz
prepare for package rename
-rw-r--r--.SRCINFO23
-rw-r--r--.gitignore2
-rw-r--r--PKGBUILD42
-rw-r--r--PKGNAME.service.erb15
-rw-r--r--PKGNAME.sysusers.erb1
-rw-r--r--PKGNAME.tmpfiles.erb3
-rwxr-xr-xcompile-templates50
-rw-r--r--install14
-rw-r--r--install.erb50
-rw-r--r--path.patch.erb51
10 files changed, 221 insertions, 30 deletions
diff --git a/.SRCINFO b/.SRCINFO
index f37f99265c38..3997abdff3b1 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = oragono
- pkgdesc = A modern IRC server written in Go.
+ pkgdesc = A modern IRC server written in Go
pkgver = 2.6.1
- pkgrel = 1
+ pkgrel = 2
url = https://github.com/oragono/oragono
install = install
arch = x86_64
@@ -11,15 +11,16 @@ pkgbase = oragono
depends = glibc
backup = etc/oragono.conf
source = git+https://github.com/oragono/oragono#tag=v2.6.1
- source = oragono.service
- source = oragono.sysusers
- source = path.patch
- source = oragono.tmpfiles
+ source = PKGNAME.service.erb
+ source = PKGNAME.sysusers.erb
+ source = path.patch.erb
+ source = PKGNAME.tmpfiles.erb
+ source = compile-templates
sha256sums = SKIP
- sha256sums = d35dd5205e3b607ee105a1252677d0607d0c35636ee3e6057275b5f13e555858
- sha256sums = 7e214caa8bee053adac26a00a17ed732970e86665cbe31553b1d3d609f0a49b4
- sha256sums = ce58277f778809df5f6bdaa5d6997f5d55157e367c0d4a0b6cae0a61fd293e51
- sha256sums = 8f6baaa89e9723ac3344a2af201a93f348975537bc748024c0a48b0773f42b1f
+ sha256sums = 5df46fc5cb324fa362f30baf550d06e3b9d80056c047e9fe7b3db698eddb7c24
+ sha256sums = db0d2e965a2afb352afdc6062db83b657ee61c30f90df37aaf1982426e985d08
+ sha256sums = 617b6d0ba9efd84b27fbca1c5532305518e53605e79e2e4fa28548ffdc0f06d9
+ sha256sums = 7e490cb211b013449041ac345175c7e540108c8149c196462f1c4bcf965d138a
+ sha256sums = 897383fce9fc75e4df1c0281495504d23d638b849d20c963f49eb7f8130f82b7
pkgname = oragono
-
diff --git a/.gitignore b/.gitignore
index a07e3deafc25..dedec2e95f57 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@
/oragono-vendor/
/pkg/
/src/
+
+/ergo/
diff --git a/PKGBUILD b/PKGBUILD
index 342ab527b8cc..6594668b29bf 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,8 +3,8 @@
pkgname=oragono
pkgver=2.6.1
-pkgrel=1
-pkgdesc="A modern IRC server written in Go."
+pkgrel=2
+pkgdesc="A modern IRC server written in Go"
arch=('x86_64')
url="https://github.com/oragono/oragono"
license=('MIT')
@@ -12,18 +12,22 @@ install=install
depends=('glibc')
makedepends=('go' 'git')
source=("git+$url#tag=v$pkgver"
- "oragono.service"
- "oragono.sysusers"
- "path.patch"
- "oragono.tmpfiles")
+ "PKGNAME.service.erb"
+ "PKGNAME.sysusers.erb"
+ "path.patch.erb"
+ "PKGNAME.tmpfiles.erb"
+ "compile-templates")
sha256sums=('SKIP'
- 'd35dd5205e3b607ee105a1252677d0607d0c35636ee3e6057275b5f13e555858'
- '7e214caa8bee053adac26a00a17ed732970e86665cbe31553b1d3d609f0a49b4'
- 'ce58277f778809df5f6bdaa5d6997f5d55157e367c0d4a0b6cae0a61fd293e51'
- '8f6baaa89e9723ac3344a2af201a93f348975537bc748024c0a48b0773f42b1f')
-backup=('etc/oragono.conf')
+ '5df46fc5cb324fa362f30baf550d06e3b9d80056c047e9fe7b3db698eddb7c24'
+ 'db0d2e965a2afb352afdc6062db83b657ee61c30f90df37aaf1982426e985d08'
+ '617b6d0ba9efd84b27fbca1c5532305518e53605e79e2e4fa28548ffdc0f06d9'
+ '7e490cb211b013449041ac345175c7e540108c8149c196462f1c4bcf965d138a'
+ '897383fce9fc75e4df1c0281495504d23d638b849d20c963f49eb7f8130f82b7')
+backup=("etc/$pkgname.conf")
prepare() {
+ cd "${srcdir}"
+ ./compile-templates --pkgname="$pkgname" --pkgdesc="$pkgdesc" ../install.erb PKGNAME.service.erb PKGNAME.sysusers.erb PKGNAME.tmpfiles.erb path.patch.erb
cd "${srcdir}/$pkgname"
patch < ../path.patch
}
@@ -36,8 +40,8 @@ build() {
# flags from https://wiki.archlinux.org/index.php/Go_package_guidelines
# to address issues namcap warns about:
- # oragono W: ELF file ('usr/bin/oragono') lacks FULL RELRO, check LDFLAGS.
- # oragono W: ELF file ('usr/bin/oragono') lacks PIE.
+ # ergo W: ELF file ('usr/bin/ergo') lacks FULL RELRO, check LDFLAGS.
+ # ergo W: ELF file ('usr/bin/ergo') lacks PIE.
# related: https://bugs.archlinux.org/task/60928
go build \
-trimpath \
@@ -58,15 +62,15 @@ check() {
}
package() {
- install -Dm644 oragono.service "$pkgdir/usr/lib/systemd/system/oragono.service"
- install -Dm644 "$srcdir/oragono.sysusers" "$pkgdir/usr/lib/sysusers.d/oragono.conf"
- install -Dm644 "$srcdir/oragono.tmpfiles" "${pkgdir}"/usr/lib/tmpfiles.d/oragono.conf
+ install -Dm644 $pkgname.service "$pkgdir/usr/lib/systemd/system/$pkgname.service"
+ install -Dm644 "$srcdir/$pkgname.sysusers" "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"
+ install -Dm644 "$srcdir/$pkgname.tmpfiles" "${pkgdir}"/usr/lib/tmpfiles.d/$pkgname.conf
cd "${srcdir}/$pkgname"
install -Dm755 -d "$pkgdir/usr/share/$pkgname/i18n"
cp languages/* "$pkgdir/usr/share/$pkgname/i18n/"
install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
- install -Dm755 oragono "$pkgdir/usr/bin/oragono"
- install -Dm644 default.yaml "$pkgdir/etc/oragono.conf"
- install -Dm644 oragono.motd "$pkgdir/usr/share/$pkgname/default.motd"
+ install -Dm755 $pkgname "$pkgdir/usr/bin/$pkgname"
+ install -Dm644 default.yaml "$pkgdir/etc/$pkgname.conf"
+ install -Dm644 $pkgname.motd "$pkgdir/usr/share/$pkgname/default.motd"
}
diff --git a/PKGNAME.service.erb b/PKGNAME.service.erb
new file mode 100644
index 000000000000..950e9af9d8d6
--- /dev/null
+++ b/PKGNAME.service.erb
@@ -0,0 +1,15 @@
+[Unit]
+Description=<%= pkgdesc %>
+After=network.target
+
+[Service]
+Type=simple
+User=<%= pkgname %>
+Group=<%= pkgname %>
+WorkingDirectory=/var/lib/<%= pkgname %>
+ExecStart=/usr/bin/<%= pkgname %> run --conf /etc/<%= pkgname %>.conf
+ExecReload=/bin/kill -HUP $MAINPID
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
diff --git a/PKGNAME.sysusers.erb b/PKGNAME.sysusers.erb
new file mode 100644
index 000000000000..5a4b7228a45f
--- /dev/null
+++ b/PKGNAME.sysusers.erb
@@ -0,0 +1 @@
+u <%= pkgname %> - "<%= pkgname %> IRC daemon" /var/lib/<%= pkgname %>
diff --git a/PKGNAME.tmpfiles.erb b/PKGNAME.tmpfiles.erb
new file mode 100644
index 000000000000..d1639c33c851
--- /dev/null
+++ b/PKGNAME.tmpfiles.erb
@@ -0,0 +1,3 @@
+#Type Path Mode User Group Age Argument
+d /var/lib/<%= pkgname %> 0755 <%= pkgname %> <%= pkgname %> - -
+C /var/lib/<%= pkgname %>/ircd.motd 0644 <%= pkgname %> <%= pkgname %> - /usr/share/<%= pkgname %>/default.motd
diff --git a/compile-templates b/compile-templates
new file mode 100755
index 000000000000..e10247e6821c
--- /dev/null
+++ b/compile-templates
@@ -0,0 +1,50 @@
+#!/usr/bin/env ruby
+require 'optparse'
+require 'erb'
+
+options = {}
+OptionParser.new do |parser|
+ parser.banner = "Usage: compile-templates.rb [options] <template-files...>"
+
+ parser.on("--pkgname=PKGNAME", "Name of package") do |v|
+ options[:pkgname] = v
+ end
+
+ parser.on("--pkgdesc=PKGDESC", "Description of package") do |v|
+ options[:pkgdesc] = v
+ end
+end.parse!
+
+raise 'pkgname not provided' unless options.has_key?(:pkgname)
+raise 'pkgdesc not provided' unless options.has_key?(:pkgdesc)
+
+templates = ARGV
+
+raise 'templates not provided' unless templates.length > 0
+
+class TemplateVariables
+ attr_reader :pkgname, :pkgdesc
+
+ def initialize(pkgname, pkgdesc)
+ @pkgname = pkgname
+ @pkgdesc = pkgdesc
+ end
+
+ def get_binding
+ binding()
+ end
+end
+
+templateVariables = TemplateVariables.new(options[:pkgname], options[:pkgdesc])
+
+templates.each do |templateFilename|
+ template = File.read(templateFilename)
+ renderer = ERB.new(template)
+ rendered = renderer.result(templateVariables.get_binding)
+
+ templateFilenameWithoutSuffix = templateFilename.delete_suffix('.erb')
+ outputFilename = templateFilenameWithoutSuffix.sub 'PKGNAME', templateVariables.pkgname
+ output = File.new(outputFilename, 'w')
+ output.puts(rendered)
+ output.close
+end
diff --git a/install b/install
index de78ad3882b8..c0e841bf3723 100644
--- a/install
+++ b/install
@@ -3,6 +3,7 @@
# The tabs are for block indentation in the source code.
# The spaces following the tabs are for indentation of the printed output.
+## arg 1: the new package version
post_install() {
if [[ ! -e /var/lib/oragono/ircd.db ]]; then
cat <<-EOF
@@ -13,6 +14,8 @@ post_install() {
fi
}
+## arg 1: the new package version
+## arg 2: the old package version
post_upgrade() {
if (( "$(vercmp "$2" 2.1.0)" < 0 )); then
cat <<-EOF
@@ -25,6 +28,17 @@ post_upgrade() {
EOF
mkcert_howto
fi
+
+ if (( "$(vercmp "$2" 2.7.0)" < 0 )); then
+ cat <<-EOF
+ ==> The package name, filenames, paths, and system service user have changed.
+ /etc/oragono.conf -> /etc/oragono.conf
+ /var/lib/oragono/ -> /var/lib/oragono/
+ sysuser oragono -> oragono
+
+ Please take care to migrate your config and data.
+ EOF
+ fi
}
mkcert_howto() {
diff --git a/install.erb b/install.erb
new file mode 100644
index 000000000000..cb0770285cfc
--- /dev/null
+++ b/install.erb
@@ -0,0 +1,50 @@
+# Warning: This file has syntactically significant, mixed whitespace.
+# The heredoc bodies are indented with tabs up to the block level.
+# The tabs are for block indentation in the source code.
+# The spaces following the tabs are for indentation of the printed output.
+
+## arg 1: the new package version
+post_install() {
+ if [[ ! -e /var/lib/<%= pkgname %>/ircd.db ]]; then
+ cat <<-EOF
+ ==> <%= pkgname %> needs to initialize the database and have
+ certificates made available prior to use.
+ EOF
+ mkcert_howto
+ fi
+}
+
+## arg 1: the new package version
+## arg 2: the old package version
+post_upgrade() {
+ if (( "$(vercmp "$2" 2.1.0)" < 0 )); then
+ cat <<-EOF
+ ==> The tls certificate filenames in the default config have changed.
+ In /var/lib/<%= pkgname %>/:
+ tls.crt -> fullchain.pem
+ tls.key -> privkey.pem
+
+ To generate new self-signed certificates:
+ EOF
+ mkcert_howto
+ fi
+
+ if (( "$(vercmp "$2" 2.7.0)" < 0 )); then
+ cat <<-EOF
+ ==> The package name, filenames, paths, and system service user have changed.
+ /etc/oragono.conf -> /etc/<%= pkgname %>.conf
+ /var/lib/oragono/ -> /var/lib/<%= pkgname %>/
+ sysuser oragono -> <%= pkgname %>
+
+ Please take care to migrate your config and data.
+ EOF
+ fi
+}
+
+mkcert_howto() {
+ cat <<-EOF
+ cd /var/lib/<%= pkgname %>
+ sudo -u <%= pkgname %> /usr/bin/<%= pkgname %> mkcerts --conf /etc/<%= pkgname %>.conf
+ sudo -u <%= pkgname %> /usr/bin/<%= pkgname %> initdb --conf /etc/<%= pkgname %>.conf
+ EOF
+}
diff --git a/path.patch.erb b/path.patch.erb
new file mode 100644
index 000000000000..e98df52cc14d
--- /dev/null
+++ b/path.patch.erb
@@ -0,0 +1,51 @@
+--- default.yaml.orig 2021-02-01 15:50:27.556589528 +0000
++++ default.yaml 2021-02-01 15:52:59.786583877 +0000
+@@ -50,8 +50,8 @@
+ # The standard SSL/TLS port for IRC is 6697. This will listen on all interfaces:
+ ":6697":
+ tls:
+- cert: fullchain.pem
+- key: privkey.pem
++ cert: /var/lib/<%= pkgname %>/fullchain.pem
++ key: /var/lib/<%= pkgname %>/privkey.pem
+ # 'proxy' should typically be false. It's for cloud load balancers that
+ # always send a PROXY protocol header ahead of the connection. See the
+ # manual ("Reverse proxies") for more details.
+@@ -70,8 +70,8 @@
+ # ":8097":
+ # websocket: true
+ # tls:
+- # cert: fullchain.pem
+- # key: privkey.pem
++ # cert: /var/lib/<%= pkgname %>/fullchain.pem
++ # key: /var/lib/<%= pkgname %>/privkey.pem
+
+ # sets the permissions for Unix listen sockets. on a typical Linux system,
+ # the default is 0775 or 0755, which prevents other users/groups from connecting
+@@ -166,7 +166,7 @@
+
+ # motd filename
+ # if you change the motd, you should move it to ircd.motd
+- motd: oragono.motd
++ motd: /var/lib/<%= pkgname %>/ircd.motd
+
+ # motd formatting codes
+ # if this is true, the motd is escaped using formatting codes like $c, $b, and $i
+@@ -714,7 +714,7 @@
+ # datastore configuration
+ datastore:
+ # path to the datastore
+- path: ircd.db
++ path: /var/lib/<%= pkgname %>/ircd.db
+
+ # if the database schema requires an upgrade, `autoupgrade` will attempt to
+ # perform it automatically on startup. the database will be backed
+@@ -743,7 +743,7 @@
+ default: en
+
+ # which directory contains our language files
+- path: languages
++ path: /usr/share/<%= pkgname %>/i18n/
+
+ # limits - these need to be the same across the network
+ limits: