From df6f398efc0ae3d12fdde4a23390c2ad323eb709 Mon Sep 17 00:00:00 2001 From: Christopher James Halse Rogers Date: Sat, 16 Nov 2019 22:19:46 +1000 Subject: [PATCH] Various snap fixes (#698) * snap: Store media in the proper directory * snap/set-environment: Exit successfully when not enabled. This lets us unconditionally run things under `set-environment` and let it handle the case where the necessary configuration hasn't yet been set. * snap: Set the version based on git tags This will make the version something like `0.3.0-alpha-2-65-g29178aa` at the moment, as that was the most recent tag, but the commit tagged as `0.4.0` will get *that* as the version * snap: Force-install cargo-web This makes building the *second* time work; otherwise there might be an existing cargo-web install, and cargo will refuse to overwrite it. --- snap/hooks/configure | 5 +++++ snap/hooks/post-refresh | 7 ------- snap/local/set-environment | 3 ++- snap/snapcraft.yaml | 5 +++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/snap/hooks/configure b/snap/hooks/configure index cb493943..a4656540 100644 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -38,6 +38,11 @@ then with 'snap restart plume'" fi +if [ ! -d ${SNAP_DATA}/media ] +then + mkdir ${SNAP_DATA}/media +fi + if [ "${enabled}" = "true" -a ! -e ${SNAP_COMMON}/initial-migrations-run ] then cd ${SNAP} diff --git a/snap/hooks/post-refresh b/snap/hooks/post-refresh index da50b21b..4be65e5b 100644 --- a/snap/hooks/post-refresh +++ b/snap/hooks/post-refresh @@ -1,11 +1,4 @@ #!/bin/sh -db_type=$(snapctl get db.type) - -if [ -z "${db_type}" ] -then - exit 0 -fi - cd ${SNAP} exec ./set-environment bin/plm migration run --path ${SNAP_DATA} diff --git a/snap/local/set-environment b/snap/local/set-environment index 8579f4d0..06dc1b0e 100755 --- a/snap/local/set-environment +++ b/snap/local/set-environment @@ -4,7 +4,7 @@ enabled="$(snapctl get enabled)" if [ -z "${enabled}" -o "${enabled}" != "true" ] then echo "Plume not yet enabled" - exit 1 + exit 0 fi export BASE_URL="$(snapctl get base-url)" @@ -24,6 +24,7 @@ ROCKET_ADDRESS="$(snapctl get listen.address)" ROCKET_PORT="$(snapctl get listen.port)" export ROCKET_SECRET_KEY="$(cat ${SNAP_COMMON}/rocket-secret-key)" export SEARCH_INDEX="${SNAP_DATA}/search_index" +export MEDIA_UPLOAD_DIRECTORY="${SNAP_DATA}/media" cd ${SNAP} exec $@ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index f224104b..fbd8c406 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: plume base: core18 -version: '0.3.0' # just for humans, typically '1.2+git' or '1.3.2' +adopt-info: plume summary: Multi-user blogging platform, federated over ActivityPub description: | Plume is a federated blogging platform, featuring: @@ -34,9 +34,10 @@ parts: - on arm64,armhf,ppc64el,s390x: - lld-8 override-build: | + snapcraftctl set-version $(git describe --tags) export PATH=$PATH:$HOME/.cargo/bin rustup install stable - cargo +stable install cargo-web + cargo +stable install --force cargo-web # Only Tier 1 Rust platforms get rust-lld # On the others (arm64, armhf, powerpc64, s390x) fall back to using