From 4ecf7ccb4661054da1f9142552f83e4c4a73c82b Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 3 Apr 2022 08:04:16 +0200 Subject: [PATCH] bundles/matrix-media-repo: download prebuilt executable instead of building ourselves --- .../files/matrix-media-repo.service | 2 +- bundles/matrix-media-repo/items.py | 36 ++++--------------- bundles/matrix-media-repo/metadata.py | 1 - 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/bundles/matrix-media-repo/files/matrix-media-repo.service b/bundles/matrix-media-repo/files/matrix-media-repo.service index 178fafc..e118731 100644 --- a/bundles/matrix-media-repo/files/matrix-media-repo.service +++ b/bundles/matrix-media-repo/files/matrix-media-repo.service @@ -6,7 +6,7 @@ Requires=postgresql.service [Service] User=matrix-media-repo Group=matrix-media-repo -ExecStart=/opt/matrix-media-repo/src/bin/media_repo -config /opt/matrix-media-repo/config.yaml +ExecStart=/opt/matrix-media-repo/media_repo -config /opt/matrix-media-repo/config.yaml WorkingDirectory=/opt/matrix-media-repo/ Restart=always RestartSec=2 diff --git a/bundles/matrix-media-repo/items.py b/bundles/matrix-media-repo/items.py index b967209..ba2b2bb 100644 --- a/bundles/matrix-media-repo/items.py +++ b/bundles/matrix-media-repo/items.py @@ -3,10 +3,6 @@ directories = { 'owner': 'matrix-media-repo', 'group': 'matrix-media-repo', }, - '/opt/matrix-media-repo/src': { - 'owner': 'matrix-media-repo', - 'group': 'matrix-media-repo', - }, '/var/matrix/media': { 'owner': 'matrix-media-repo', 'group': 'matrix-media-repo', @@ -33,43 +29,23 @@ files = { 'svc_systemd:matrix-media-repo:restart', }, }, -} - -git_deploy = { - '/opt/matrix-media-repo/src': { - 'repo': 'https://github.com/turt2live/matrix-media-repo.git', - 'rev': node.metadata['matrix-media-repo']['version'], + '/opt/matrix-media-repo/media_repo': { + 'content_hash': node.metadata.get('matrix-media-repo/sha1', None), + 'content_type': 'download', + 'mode': '0755', + 'source': 'https://github.com/turt2live/matrix-media-repo/releases/download/{}/media_repo-linux-x64'.format(node.metadata.get('matrix-media-repo/version')), 'triggers': { - 'action:matrix-media-repo_build', 'svc_systemd:matrix-media-repo:restart', }, }, } -actions = { - 'matrix-media-repo_build': { - 'command': \ - 'chown -R matrix-media-repo:matrix-media-repo /opt/matrix-media-repo/src && ' + \ - 'sudo -u matrix-media-repo bash -c "cd /opt/matrix-media-repo/src && ' + \ - 'GOBIN=/opt/matrix-media-repo/src/bin go install -v ./cmd/compile_assets && ' + \ - '/opt/matrix-media-repo/src/bin/compile_assets && ' + \ - 'GOBIN=/opt/matrix-media-repo/src/bin go install -ldflags \\\"' + \ - '-X github.com/turt2live/matrix-media-repo/common/version.GitCommit=$(cat /opt/matrix-media-repo/src/.bundlewrap_git_deploy) ' + \ - '-X github.com/turt2live/matrix-media-repo/common/version.Version={}\\\" '.format(node.metadata['matrix-media-repo']['version']) + \ - '-v ./cmd/..."', - 'triggered': True, - 'needs': { - 'pkg_apt:', - }, - }, -} - svc_systemd = { 'matrix-media-repo': { 'needs': { - 'action:matrix-media-repo_build', 'file:/etc/systemd/system/matrix-media-repo.service', 'file:/opt/matrix-media-repo/config.yaml', + 'file:/opt/matrix-media-repo/media_repo', 'postgres_db:matrix-media-repo', }, }, diff --git a/bundles/matrix-media-repo/metadata.py b/bundles/matrix-media-repo/metadata.py index db3e0cf..b73fcda 100644 --- a/bundles/matrix-media-repo/metadata.py +++ b/bundles/matrix-media-repo/metadata.py @@ -1,7 +1,6 @@ defaults = { 'apt': { 'packages': { - 'golang-go': {}, 'imagemagick': {}, 'ffmpeg': {}, },