diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100644 index 0000000..1aeb2f1 --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +#================================================= +# PACKAGE UPDATING HELPER +#================================================= + +# This script is meant to be run by GitHub Actions +# The YunoHost-Apps organisation offers a template Action to run this script periodically +# Since each app is different, maintainers can adapt its contents so as to perform +# automatic actions when a new upstream release is detected. + +#================================================= +# FETCHING LATEST RELEASE AND ITS ASSETS +#================================================= + +# Fetching information +current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') +repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') +# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) +version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) +version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .tag_name | contains("v") | not ) | .tag_name' | sort -V | tail -1) + +# Later down the script, we assume the version has only digits and dots +# Sometimes the release name starts with a "v", so let's filter it out. +# You may need more tweaks here if the upstream repository has different naming conventions. +if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then + version=${version:1} +fi + +# Setting up the environment variables +echo "Current version: $current_version" +echo "Latest release from upstream: $version" +echo "VERSION=$version" >> $GITHUB_ENV +echo "REPO=$repo" >> $GITHUB_ENV +# For the time being, let's assume the script will fail +echo "PROCEED=false" >> $GITHUB_ENV + +# Proceed only if the retrieved version is greater than the current one +if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then + echo "::warning ::No new version available" + exit 0 +# Proceed only if a PR for this new version does not already exist +elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then + echo "::warning ::A branch already exists for this update" + exit 0 +fi + +#================================================= +# SPECIFIC UPDATE STEPS +#================================================= + +# Any action on the app's source code can be done. +# The GitHub Action workflow takes care of committing all changes after this script ends. + +#================================================= +# GENERIC FINALIZATION +#================================================= + +# Replace new version in manifest +echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json + +# No need to update the README, yunohost-bot takes care of it + +# The Action will proceed only if the PROCEED environment variable is set to true +echo "PROCEED=true" >> $GITHUB_ENV +exit 0 diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000..fb72ba0 --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,49 @@ +# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected. +# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization. +# This file should be enough by itself, but feel free to tune it to your needs. +# It calls updater.sh, which is where you should put the app-specific update steps. +name: Check for new upstream releases +on: + # Allow to manually trigger the workflow + workflow_dispatch: + # Run it every day at 6:00 UTC + schedule: + - cron: '0 6 * * *' +jobs: + updater: + runs-on: ubuntu-latest + steps: + - name: Fetch the source code + uses: actions/checkout@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Run the updater script + id: run_updater + run: | + # Setting up Git user + git config --global user.name 'yunohost-bot' + git config --global user.email 'yunohost-bot@users.noreply.github.com' + # Run the updater script + /bin/bash .github/workflows/updater.sh + - name: Commit changes + id: commit + if: ${{ env.PROCEED == 'true' }} + run: | + git commit -am "Upgrade to v$VERSION" + - name: Create Pull Request + id: cpr + if: ${{ env.PROCEED == 'true' }} + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Update to version ${{ env.VERSION }} + committer: 'yunohost-bot ' + author: 'yunohost-bot ' + signoff: false + base: testing + branch: ci-auto-update-v${{ env.VERSION }} + delete-branch: true + title: 'Upgrade to version ${{ env.VERSION }}' + body: | + Upgrade to v${{ env.VERSION }} + draft: false diff --git a/check_process b/check_process index d17b06e..1a7dd50 100644 --- a/check_process +++ b/check_process @@ -12,8 +12,6 @@ setup_private=0 setup_public=1 upgrade=1 - # 0.11.3~ynh1 - upgrade=1 from_commit=1681bfab08bdc5e943d5fdaf5b5069066f84d35d backup_restore=1 multi_instance=0 port_already_use=0 @@ -21,6 +19,3 @@ ;;; Options Email= Notification=none -;;; Upgrade options - ; commit=CommitHash - name=0.11.3~ynh1 diff --git a/conf/lemmy.hjson b/conf/lemmy.hjson index c4a3df5..2ab0f22 100644 --- a/conf/lemmy.hjson +++ b/conf/lemmy.hjson @@ -103,7 +103,7 @@ # Whether the site is available over TLS. Needs to be true for federation to work. tls_enabled: true # Address where pictrs is available (for image hosting) - pictrs_url: "http://127.0.0.1:__PORT_PICTRS__" + ###pictrs_url: "http://127.0.0.1:__PORT_PICTRS__" slur_filter: "(\bThis\b)|(\bis\b)|(\bsample\b)" # Maximum length of local community and user names actor_name_max_length: 20 diff --git a/conf/pict-rs.service b/conf/pict-rs.service deleted file mode 100644 index 186ba5e..0000000 --- a/conf/pict-rs.service +++ /dev/null @@ -1,45 +0,0 @@ -[Unit] -Description=__APP__ pict-rs Daemon -After=network.target - -[Service] -Type=simple -User=__APP__ -Group=__APP__ -WorkingDirectory=__FINALPATH__/pict-rs/ -ExecStart=__FINALPATH__/pict-rs/pict-rs -a 127.0.0.1:__PORT_PICTRS__ -p __DATADIR__/pictrs-data -StandardOutput=append:/var/log/__APP__/__APP__-pict-rs.log -StandardError=inherit - -# Sandboxing options to harden security -# Depending on specificities of your service/app, you may need to tweak these -# .. but this should be a good baseline -# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html -NoNewPrivileges=yes -PrivateTmp=yes -PrivateDevices=yes -RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 -RestrictNamespaces=yes -RestrictRealtime=yes -DevicePolicy=closed -ProtectSystem=full -ProtectControlGroups=yes -ProtectKernelModules=yes -ProtectKernelTunables=yes -LockPersonality=yes -SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap - -# Denying access to capabilities that should not be relevant for webapps -# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html -CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD -CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE -CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT -CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK -CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM -CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG -CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE -CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW -CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG - -[Install] -WantedBy=multi-user.target diff --git a/conf/pict-rs.src b/conf/pict-rs.src deleted file mode 100644 index f927331..0000000 --- a/conf/pict-rs.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://git.asonix.dog/asonix/pict-rs/archive/v0.3.0-rc.2.tar.gz -SOURCE_SUM=b2dadfbb42c57d4abb6129aa07af8f208557cc948c0915aa8fcd3292cc8999b6 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 995fdf6..f216c43 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,2 +1,3 @@ * Lemmy require full domain path to be installed. Eg. lemmy.domain.tld -* The admin username and password will be sent to the admin of the YunoHost through mail. \ No newline at end of file +* The admin username and password will be sent to the admin of the YunoHost through mail. +* pict-rs image hosting service has been removed, it caused too much issue during compilation diff --git a/manifest.json b/manifest.json index b4402c7..6e732d0 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "A link aggregator / Reddit clone for the fediverse." }, - "version": "0.15.2~ynh2", + "version": "0.15.2~ynh3", "url": "https://join.lemmy.ml/", "upstream": { "license": "GPL-3.0", @@ -21,7 +21,7 @@ "url": "" }, "requirements": { - "yunohost": ">= 4.1.3" + "yunohost": ">= 4.3.0" }, "multi_instance": false, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 5f1b48e..1a51dbf 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,20 +9,12 @@ lemmy_dependencies="postgresql postgresql-contrib" lemmyui_dependencies="espeak" imagemagick_build_dependencies="libltdl-dev libjpeg-dev libpng-dev libwebp-dev liblzma-dev libxml2-dev" imagemagick_dependencies="" -pictrs_build_dependencies="pkg-config build-essential libgexiv2-dev libxml2 libltdl7 libavcodec-dev libavfilter-dev libavdevice-dev libavformat-dev libavresample-dev libavutil-dev libswscale-dev libswresample-dev llvm-dev libclang-dev clang" -pictrs_dependencies="libgexiv2-2 libpng16-16 libjpeg62-turbo libwebp6 libwebpdemux2 libwebpmux3 libltdl7 libgomp1 libxml2 libavcodec58 libavfilter7 libavdevice58 libavformat58 libavresample4 libavutil56 libswscale5 libswresample3 tini" -pkg_dependencies="$lemmy_dependencies $lemmyui_dependencies $imagemagick_dependencies $pictrs_dependencies" -pkg_build_dependencies="$imagemagick_build_dependencies $pictrs_build_dependencies" +pkg_dependencies="$lemmy_dependencies $lemmyui_dependencies $imagemagick_dependencies" +pkg_build_dependencies="$imagemagick_build_dependencies" NODEJS_VERSION=12 -LEMMY_VERSION=0.15.2 - -LEMMYUI_VERSION=0.15.2 - -PICTRS_VERSION=0.3.0-beta.12-r1 - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index e2dfb50..4ddf8d0 100755 --- a/scripts/backup +++ b/scripts/backup @@ -69,7 +69,6 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app-ui.service" -ynh_backup --src_path="/etc/systemd/system/$app-pict-rs.service" #================================================= # BACKUP THE POSTGRESQL DATABASE diff --git a/scripts/install b/scripts/install index 2ee880d..ee743b7 100755 --- a/scripts/install +++ b/scripts/install @@ -112,7 +112,6 @@ ynh_setup_source --dest_dir="$final_path/build-lemmy/" --source_id="docker-image ynh_setup_source --dest_dir="$final_path/build-lemmy-ui/" --source_id="docker-image-extract" ynh_setup_source --dest_dir="$final_path/lemmy-ui/lemmy-translations/" --source_id="lemmy-translations" ynh_setup_source --dest_dir="$final_path/build-imagemagick/" --source_id="imagemagick" -ynh_setup_source --dest_dir="$final_path/build-pict-rs/" --source_id="pict-rs" chmod 750 "$final_path" chmod -R o-rwx "$final_path" @@ -147,28 +146,9 @@ chown -R $app:$app "$datadir" #================================================= ynh_script_progression --message="Making install..." -# Install rustup with the toolchain needed by pict-rs -pushd "$final_path" - sudo -u "$app" RUSTUP_HOME="$final_path/.rustup" CARGO_HOME="$final_path/.cargo" bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain nightly' -popd - -export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" - -# Install pict-rs -pushd $final_path/build-pict-rs - ynh_exec_warn_less sudo -u "$app" env PATH="$PATH" cargo build --release -popd -mkdir -p "$final_path/pict-rs/" -mv -f "$final_path/build-pict-rs/target/release/pict-rs" "$final_path/pict-rs/pict-rs" -ynh_secure_remove --file="$final_path/build-pict-rs" - -# Remove rustup -ynh_secure_remove --file="$final_path/.cargo" -ynh_secure_remove --file="$final_path/.rustup" - # Install lemmy-ui pushd $final_path/build-lemmy-ui - ./docker-image-extract dessalines/lemmy-ui:$LEMMYUI_VERSION + ./docker-image-extract dessalines/lemmy-ui:$(ynh_app_upstream_version) popd mkdir -p "$final_path/lemmy-ui/" rsync -a "$final_path/build-lemmy-ui/output/app/" "$final_path/lemmy-ui/" @@ -176,7 +156,7 @@ ynh_secure_remove --file="$final_path/build-lemmy-ui" # Install lemmy pushd $final_path/build-lemmy - ./docker-image-extract dessalines/lemmy:$LEMMY_VERSION + ./docker-image-extract dessalines/lemmy:$(ynh_app_upstream_version) popd mkdir -p "$final_path/lemmy/" mv -f "$final_path/build-lemmy/output/app/lemmy" "$final_path/lemmy/lemmy" @@ -218,7 +198,6 @@ ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config --service="$app" --template="lemmy.service" ynh_add_systemd_config --service="$app-ui" --template="lemmy-ui.service" -ynh_add_systemd_config --service="$app-pict-rs" --template="pict-rs.service" #================================================= # GENERIC FINALIZATION @@ -240,9 +219,8 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" -yunohost service add $app-ui --description="A short description of the app" --log="/var/log/$app/$app-ui.log" -yunohost service add $app-pict-rs --description="A short description of the app" --log="/var/log/$app/$app-pict-rs.log" +yunohost service add $app --log="/var/log/$app/$app.log" +yunohost service add $app-ui --log="/var/log/$app/$app-ui.log" #================================================= # START SYSTEMD SERVICE @@ -252,7 +230,6 @@ ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --line_match="Started" --log_path=systemd ynh_systemd_action --service_name=$app-ui --action="start" --line_match="Started" --log_path=systemd -ynh_systemd_action --service_name=$app-pict-rs --action="start" --line_match="Started" --log_path=systemd #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index 366f7bc..b24a6d4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -38,11 +38,6 @@ then ynh_script_progression --message="Removing $app-ui service integration..." yunohost service remove $app-ui fi -if ynh_exec_warn_less yunohost service status $app-pict-rs >/dev/null -then - ynh_script_progression --message="Removing $app-pict-rs service integration..." - yunohost service remove $app-pict-rs -fi #================================================= # STOP AND REMOVE SERVICE @@ -52,7 +47,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config ynh_remove_systemd_config --service=$app-ui -ynh_remove_systemd_config --service=$app-pict-rs #================================================= # REMOVE LOGROTATE CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 9c9c432..6f1d813 100755 --- a/scripts/restore +++ b/scripts/restore @@ -137,8 +137,6 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet ynh_restore_file --origin_path="/etc/systemd/system/$app-ui.service" systemctl enable $app-ui.service --quiet -ynh_restore_file --origin_path="/etc/systemd/system/$app-pict-rs.service" -systemctl enable $app-pict-rs.service --quiet #================================================= # RESTORE THE LOGROTATE CONFIGURATION @@ -157,9 +155,8 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" -yunohost service add $app-ui --description="A short description of the app" --log="/var/log/$app/$app-ui.log" -yunohost service add $app-pict-rs --description="A short description of the app" --log="/var/log/$app/$app-pict-rs.log" +yunohost service add $app --log="/var/log/$app/$app.log" +yunohost service add $app-ui --log="/var/log/$app/$app-ui.log" #================================================= # START SYSTEMD SERVICE @@ -168,7 +165,6 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --line_match="Started" --log_path=systemd ynh_systemd_action --service_name=$app-ui --action="start" --line_match="Started" --log_path=systemd -ynh_systemd_action --service_name=$app-pict-rs --action="start" --line_match="Started" --log_path=systemd #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index ce9dbbd..015aec9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -62,7 +62,6 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped" --log_path=systemd ynh_systemd_action --service_name=$app-ui --action="stop" --line_match="Stopped" --log_path=systemd -ynh_systemd_action --service_name=$app-pict-rs --action="stop" --line_match="Stopped" --log_path=systemd #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -76,7 +75,6 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi - # Removing previously installed iframely if ynh_exec_warn_less yunohost service status $app-iframely >/dev/null then @@ -87,6 +85,15 @@ then ynh_remove_systemd_config --service=$app-iframely fi +# Removing previously installed pict-rs +if ynh_exec_warn_less yunohost service status $app-pict-rs >/dev/null +then + ynh_script_progression --message="Removing $app-pict-rs service integration..." + yunohost service remove $app-pict-rs +fi +ynh_remove_systemd_config --service=$app-pict-rs +ynh_secure_remove --file="$final_path/pict-rs" + #================================================= # CREATE DEDICATED USER #================================================= @@ -108,7 +115,6 @@ then ynh_setup_source --dest_dir="$final_path/build-lemmy-ui/" --source_id="docker-image-extract" ynh_setup_source --dest_dir="$final_path/lemmy-ui/lemmy-translations/" --source_id="lemmy-translations" ynh_setup_source --dest_dir="$final_path/build-imagemagick/" --source_id="imagemagick" - ynh_setup_source --dest_dir="$final_path/build-pict-rs/" --source_id="pict-rs" fi chmod 750 "$final_path" @@ -144,28 +150,9 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $pkg_build_dependencies - # Install rustup with the toolchain needed by pict-rs - pushd "$final_path" - sudo -u "$app" RUSTUP_HOME="$final_path/.rustup" CARGO_HOME="$final_path/.cargo" bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain nightly' - popd - - export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" - - # Install pict-rs - pushd $final_path/build-pict-rs - ynh_exec_warn_less sudo -u "$app" env PATH="$PATH" cargo build --release - popd - mkdir -p "$final_path/pict-rs/" - mv -f "$final_path/build-pict-rs/target/release/pict-rs" "$final_path/pict-rs/pict-rs" - ynh_secure_remove --file="$final_path/build-pict-rs" - - # Remove rustup - ynh_secure_remove --file="$final_path/.cargo" - ynh_secure_remove --file="$final_path/.rustup" - # Install lemmy-ui pushd $final_path/build-lemmy-ui - ./docker-image-extract dessalines/lemmy-ui:$LEMMYUI_VERSION + ./docker-image-extract dessalines/lemmy-ui:$(ynh_app_upstream_version) popd mkdir -p "$final_path/lemmy-ui/" rsync -a "$final_path/build-lemmy-ui/output/app/" "$final_path/lemmy-ui/" @@ -173,7 +160,7 @@ then # Install lemmy pushd $final_path/build-lemmy - ./docker-image-extract dessalines/lemmy:$LEMMY_VERSION + ./docker-image-extract dessalines/lemmy:$(ynh_app_upstream_version) popd mkdir -p "$final_path/lemmy/" mv -f "$final_path/build-lemmy/output/app/lemmy" "$final_path/lemmy/lemmy" @@ -223,7 +210,6 @@ ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config --service="$app" --template="lemmy.service" ynh_add_systemd_config --service="$app-ui" --template="lemmy-ui.service" -ynh_add_systemd_config --service="$app-pict-rs" --template="pict-rs.service" #================================================= # GENERIC FINALIZATION @@ -246,9 +232,8 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" -yunohost service add $app-ui --description="A short description of the app" --log="/var/log/$app/$app-ui.log" -yunohost service add $app-pict-rs --description="A short description of the app" --log="/var/log/$app/$app-pict-rs.log" +yunohost service add $app --log="/var/log/$app/$app.log" +yunohost service add $app-ui --log="/var/log/$app/$app-ui.log" #================================================= # START SYSTEMD SERVICE @@ -257,7 +242,6 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --line_match="Started" --log_path=systemd ynh_systemd_action --service_name=$app-ui --action="start" --line_match="Started" --log_path=systemd -ynh_systemd_action --service_name=$app-pict-rs --action="start" --line_match="Started" --log_path=systemd #================================================= # RELOAD NGINX