diff --git a/README.md b/README.md index 50a5b30..38cfc1c 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ It shall NOT be edited by hand. To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Shipped version:** 2.8.14~ynh5 +**Shipped version:** 3.3.1~ynh1 **Demo:** diff --git a/README_es.md b/README_es.md index bd7dd51..736451c 100644 --- a/README_es.md +++ b/README_es.md @@ -25,7 +25,7 @@ No se debe editar a mano. To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Versión actual:** 2.8.14~ynh5 +**Versión actual:** 3.3.1~ynh1 **Demo:** diff --git a/README_eu.md b/README_eu.md index e7a2ba5..dbcad00 100644 --- a/README_eu.md +++ b/README_eu.md @@ -25,7 +25,7 @@ EZ editatu eskuz. To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Paketatutako bertsioa:** 2.8.14~ynh5 +**Paketatutako bertsioa:** 3.3.1~ynh1 **Demoa:** diff --git a/README_fr.md b/README_fr.md index 2bfcf6f..97ca4bd 100644 --- a/README_fr.md +++ b/README_fr.md @@ -25,7 +25,7 @@ Il NE doit PAS être modifié à la main. Pour en savoir plus sur la philosophie et les objectifs du projet, [visitez **discourse.org**](http://www.discourse.org). -**Version incluse :** 2.8.14~ynh5 +**Version incluse :** 3.3.1~ynh1 **Démo :** diff --git a/README_gl.md b/README_gl.md index 4d07579..cd96e1b 100644 --- a/README_gl.md +++ b/README_gl.md @@ -25,7 +25,7 @@ NON debe editarse manualmente. To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Versión proporcionada:** 2.8.14~ynh5 +**Versión proporcionada:** 3.3.1~ynh1 **Demo:** diff --git a/README_id.md b/README_id.md index d843ac3..edd787f 100644 --- a/README_id.md +++ b/README_id.md @@ -25,7 +25,7 @@ Ini TIDAK boleh diedit dengan tangan. To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Versi terkirim:** 2.8.14~ynh5 +**Versi terkirim:** 3.3.1~ynh1 **Demo:** diff --git a/README_ru.md b/README_ru.md index 75081ea..d01326c 100644 --- a/README_ru.md +++ b/README_ru.md @@ -25,7 +25,7 @@ To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**Поставляемая версия:** 2.8.14~ynh5 +**Поставляемая версия:** 3.3.1~ynh1 **Демо-версия:** diff --git a/README_zh_Hans.md b/README_zh_Hans.md index 60c0ea9..753f59a 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -25,7 +25,7 @@ To learn more about the philosophy and goals of the project, [visit **discourse.org**](http://www.discourse.org). -**分发版本:** 2.8.14~ynh5 +**分发版本:** 3.3.1~ynh1 **演示:** diff --git a/conf/nginx.conf b/conf/nginx.conf index 13682be..20ccd61 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,7 +8,7 @@ send_timeout 600; # path to discourse's public directory - set $public __INSTALL_DIR__/public/; + set $public __INSTALL_DIR__/discourse/public/; # without weak etags we get zero benefit from etags on dynamically compressed content # further more etags are based on the file in nginx not sha of data @@ -29,7 +29,7 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { - alias __INSTALL_DIR__/public/ ; + alias __INSTALL_DIR__/discourse/public/ ; proxy_hide_header ETag; # auth_basic on; @@ -53,7 +53,7 @@ proxy_set_header X-Request-Start "t=${msec}"; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; break; } @@ -99,7 +99,7 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Sendfile-Type X-Accel-Redirect; - proxy_set_header X-Accel-Mapping __INSTALL_DIR__/public/=/downloads/; + proxy_set_header X-Accel-Mapping __INSTALL_DIR__/discourse/public/=/downloads/; expires 1y; more_set_headers "Cache-Control : public,immutable"; @@ -120,7 +120,7 @@ try_files $uri =404; } - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; break; } @@ -131,8 +131,8 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Sendfile-Type X-Accel-Redirect; - proxy_set_header X-Accel-Mapping __INSTALL_DIR__/public/=/downloads/; - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_set_header X-Accel-Mapping __INSTALL_DIR__/discourse/public/=/downloads/; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; break; } @@ -155,7 +155,7 @@ # proxy_cache one; proxy_cache_valid 200 301 302 7d; proxy_cache_valid any 1m; - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; break; } @@ -189,7 +189,7 @@ proxy_set_header X-Forwarded-Proto https; proxy_http_version 1.1; proxy_buffering off; - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; break; } @@ -199,7 +199,7 @@ location __PATH__/downloads/ { internal; - alias __INSTALL_DIR__/public/ ; + alias __INSTALL_DIR__/discourse/public/ ; } location @__NAME__ { @@ -209,5 +209,5 @@ proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; - proxy_pass http://unix:__INSTALL_DIR__/tmp/sockets/unicorn.sock; + proxy_pass http://unix:__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock; } diff --git a/conf/systemd.service b/conf/systemd.service index d233091..6f17727 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,19 +8,19 @@ After=postgresql.service [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__ +WorkingDirectory=__INSTALL_DIR__/discourse Environment=__ADDITIONAL_ENV__ Environment=RAILS_ENV=production Environment=UNICORN_SIDEKIQS=1 Environment=LD_PRELOAD=__LIBJEMALLOC__ -Environment=UNICORN_LISTENER=__INSTALL_DIR__/tmp/sockets/unicorn.sock -Environment="__YNH_RUBY_LOAD_PATH__" -ExecStart=__INSTALL_DIR__/bin/bundle exec unicorn --config config/unicorn.conf.rb -E production +Environment=UNICORN_LISTENER=__INSTALL_DIR__/discourse/tmp/sockets/unicorn.sock +Environment="__YNH_RUBY_LOAD_PATH__:__TOOLS_PREFIX__/bin" +ExecStart=__INSTALL_DIR__/discourse/bin/bundle exec unicorn --config config/unicorn.conf.rb -E production Restart=always RestartSec=10 # Sandboxing options to harden security -# Depending on specificities of your service/app, you may need to tweak these +# 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 @@ -47,7 +47,7 @@ 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 +CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG [Install] WantedBy=multi-user.target diff --git a/doc/ADMIN.md b/doc/ADMIN.md index f4e0cea..abe9312 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -66,7 +66,7 @@ When disabling Local Login and other authentication services, clicking the `Logi ### Installing plugins ```bash -cd /var/www/discourse +cd /var/www/discourse/discourse sudo -i -u discourse RAILS_ENV=production bin/rake --trace plugin:install repo=https://github.com/discourse/discourse-solved (for example) sudo -i -u discourse RAILS_ENV=production bin/rake --trace assets:precompile systemctl restart discourse diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index fdd59af..b4d88d4 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -65,7 +65,7 @@ Lors de la désactivation de la connexion locale et d'autres services d'authenti ### Installer des plugins ```bash -cd /var/www/discourse +cd /var/www/discourse/discourse sudo -i -u discourse RAILS_ENV=production bin/rake --trace plugin:install repo=https://github.com/discourse/discourse-solved (for example) sudo -i -u discourse RAILS_ENV=production bin/rake --trace assets:precompile systemctl restart discourse diff --git a/manifest.toml b/manifest.toml index d65d87c..4e99e5d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -7,7 +7,7 @@ name = "Discourse" description.en = "Discussion platform" description.fr = "Plateforme de discussion" -version = "2.8.14~ynh5" +version = "3.3.1~ynh1" maintainers = ["JimboJoe"] @@ -19,7 +19,7 @@ code = "https://github.com/discourse/discourse" cpe = "cpe:2.3:a:discourse:discourse" [integration] -yunohost = ">=11.2.20" +yunohost = ">=12.0.1" architectures = "all" multi_instance = true ldap = true @@ -47,8 +47,8 @@ ram.runtime = "1G" [resources] [resources.sources] [resources.sources.main] - url = "https://github.com/discourse/discourse/archive/v2.8.14.tar.gz" - sha256 = "b4b9a2857515ab79b2bc71cc0bdd09f9bf749d506c095b76d86846c9adf62623" + url = "https://github.com/discourse/discourse/archive/refs/tags/v3.3.1.tar.gz" + sha256 = "910efab3a8e0508507f1cd32e512390272e029f9a8c689a23d52444fc6f1f666" autoupdate.strategy = "latest_github_tag" @@ -59,6 +59,25 @@ ram.runtime = "1G" autoupdate.strategy = "latest_github_tag" autoupdate.upstream = "https://github.com/jonmbake/discourse-ldap-auth" + [resources.sources.imagemagickv7] + url = "https://github.com/ImageMagick/ImageMagick/archive/7.1.0-62.tar.gz" + sha256 = "d282117bc6d0e91ad1ad685d096623b96ed8e229f911c891d83277b350ef884a" + + autoupdate.strategy = "latest_github_tag" + autoupdate.upstream = "https://github.com/ImageMagick/ImageMagick" + + [resources.sources.oxipng] + amd64.url = "https://github.com/shssoichiro/oxipng/releases/download/v9.1.2/oxipng-9.1.2-x86_64-unknown-linux-gnu.tar.gz" + amd64.sha256 = "6d47453f623d7d12499e206fe089fe96d76bc6f01a00962b91e4ee3e6845e1a6" + + arm64.url = "https://github.com/shssoichiro/oxipng/releases/download/v9.1.2/oxipng-9.1.2-aarch64-unknown-linux-gnu.tar.gz" + arm64.sha256 = "9716b3aba89e7ed9fa9fa07aef4867a7b65a9dd26516e6b16f8ae5a56006cafa" + + autoupdate.strategy = "latest_github_release" + autoupdate.upstream = "https://github.com/shssoichiro/oxipng" + autoupdate.asset.amd64 = "^oxipng-.*-x86_64-unknown-linux-gnu\\.tar\\.gz$" + autoupdate.asset.arm64 = "^oxipng-.*-aarch64-unknown-linux-gnu\\.tar\\.gz$" + [resources.system_user] [resources.install_dir] @@ -73,7 +92,7 @@ ram.runtime = "1G" "cmake", "g++", "gifsicle", - "imagemagick", + # "imagemagick", "jhead", "jpegoptim", "libapr1-dev", @@ -96,6 +115,17 @@ ram.runtime = "1G" "redis-server", "zlib1g-dev", + # Dependencies of imagemagick + "make", + "libltdl-dev", + "libbz2-dev", "zlib1g-dev", "libfreetype6-dev", "libjpeg-dev", "liblzma-dev", + "libwebp-dev", "libtiff-dev", "librsvg2-dev", + "libpng16-16", "libpng-dev", + "libjpeg62-turbo", "libjpeg62-turbo-dev", + "libheif1", "libheif-dev", + "libde265-0", "libde265-dev", + # ${LIBWEBP} + "postgresql", "postgresql-client", "postgresql-contrib", diff --git a/scripts/_common.sh b/scripts/_common.sh index 06ebbfb..0ccc74f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,9 @@ # COMMON VARIABLES #================================================= -ruby_version="3.0.0" +ruby_version="3.2" -nodejs_version="18" +nodejs_version="20" libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')" @@ -14,59 +14,108 @@ libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')" # PERSONAL HELPERS #================================================= +_exec_as_app_with_ruby_node() { + ynh_exec_as "$app" -E env PATH="$nodejs_path:$ruby_path:$PATH" "$@" +} + # Returns true if a swap partition is enabled, false otherwise # usage: is_swap_present is_swap_present() { - [ $(awk '/^SwapTotal:/{print $2}' /proc/meminfo) -gt 0 ] + [ $(awk '/^SwapTotal:/{print $2}' /proc/meminfo) -gt 0 ] } # Returns true if swappiness higher than 10 # usage: is_swappiness_sufficient is_swappiness_sufficient() { - [ $(cat /proc/sys/vm/swappiness) -gt 10 ] + [ $(cat /proc/sys/vm/swappiness) -gt 10 ] } # Returns true if specified free memory is available (RAM + swap) # usage: is_memory_available MEMORY (in bytes) is_memory_available() { - local needed_memory=$1 - local freemem="$(awk '/^MemAvailable:/{print $2}' /proc/meminfo)" - local freeswap="$(awk '/^SwapFree:/{print $2}' /proc/meminfo)" - [ $(($freemem+$freeswap)) -gt $needed_memory ] + local needed_memory=$1 + local freemem="$(awk '/^MemAvailable:/{print $2}' /proc/meminfo)" + local freeswap="$(awk '/^SwapFree:/{print $2}' /proc/meminfo)" + [ $(($freemem+$freeswap)) -gt $needed_memory ] } # Checks discourse install memory requirements # terminates installation if requirements not met check_memory_requirements() { - if ! is_swap_present ; then - ynh_print_warn --message="You must have a swap partition in order to install and use this application" - elif ! is_swappiness_sufficient ; then - ynh_print_warn --message="Your swappiness must be higher than 10; please see https://en.wikipedia.org/wiki/Swappiness" - elif ! is_memory_available 1000000 ; then - ynh_print_warn --message="You must have a minimum of 1Gb available memory (RAM+swap) for the installation" - fi + if ! is_swap_present ; then + ynh_print_warn --message="You must have a swap partition in order to install and use this application" + elif ! is_swappiness_sufficient ; then + ynh_print_warn --message="Your swappiness must be higher than 10; please see https://en.wikipedia.org/wiki/Swappiness" + elif ! is_memory_available 1000000 ; then + ynh_print_warn --message="You must have a minimum of 1Gb available memory (RAM+swap) for the installation" + fi } # Checks discourse upgrade memory requirements # Less requirements as the software is already installed and running # terminates upgrade if requirements not met check_memory_requirements_upgrade() { - if ! is_memory_available 400000 ; then - ynh_die --message="You must have a minimum of 400Mb available memory (RAM+swap) for the upgrade" - fi + if ! is_memory_available 400000 ; then + ynh_die --message="You must have a minimum of 400Mb available memory (RAM+swap) for the upgrade" + fi +} + +tools_prefix="$install_dir/dependencies" + +install_imagemagick() { + # See https://github.com/discourse/discourse_docker/blob/main/image/base/install-imagemagick + ynh_setup_source --source_id="imagemagickv7" --dest_dir="$install_dir/imagemagick_source" + mkdir -p "$tools_prefix" + chown -R "$app:$app" "$install_dir/imagemagick_source" "$tools_prefix" + + pushd "$install_dir/imagemagick_source" + ynh_exec_as "$app" CFLAGS="-O2 -I$tools_prefix/include -Wno-deprecated-declarations" \ + ./configure \ + --prefix="$tools_prefix" \ + --enable-static \ + --enable-bounds-checking \ + --enable-hdri \ + --enable-hugepages \ + --with-threads \ + --with-modules \ + --with-quantum-depth=16 \ + --without-magick-plus-plus \ + --with-bzlib \ + --with-zlib \ + --without-autotrace \ + --with-freetype \ + --with-jpeg \ + --without-lcms \ + --with-lzma \ + --with-png \ + --with-tiff \ + --with-heic \ + --with-rsvg \ + --with-webp + ynh_exec_as "$app" make all -j"$(nproc)" + ynh_exec_as "$app" LIBTOOLFLAGS=-Wnone make install + popd + ynh_secure_remove --file="$install_dir/imagemagick_source" +} + +install_oxipng() { + ynh_setup_source --source_id="oxipng" --dest_dir="$install_dir/oxipng_source" + mkdir -p "$tools_prefix/bin" + mv "$install_dir/oxipng_source/oxipng" "$tools_prefix/bin/oxipng" + ynh_secure_remove --file="$install_dir/oxipng_source" } ynh_maintenance_mode_ON () { - # Create an html to serve as maintenance notice - echo " + # Create an html to serve as maintenance notice + echo " Your app $app is currently under maintenance! @@ -77,8 +126,8 @@ ynh_maintenance_mode_ON () { " > "/var/www/html/maintenance.$app.html" - # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. - echo "# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice + # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. + echo "# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice rewrite ^${path}/(.*)$ ${path}_maintenance/? redirect; # Use another location, to not be in conflict with the original config file location ${path}_maintenance/ { @@ -90,30 +139,30 @@ try_files maintenance.$app.html =503; include conf.d/yunohost_panel.conf.inc; }" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - # The current config file will redirect all requests to the root of the app. - # To keep the full path, we can use the following rewrite rule: - # rewrite ^${path}/(.*)$ ${path}_maintenance/\$1? redirect; - # The difference will be in the $1 at the end, which keep the following queries. - # But, if it works perfectly for a html request, there's an issue with any php files. - # This files are treated as simple files, and will be downloaded by the browser. - # Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was. + # The current config file will redirect all requests to the root of the app. + # To keep the full path, we can use the following rewrite rule: + # rewrite ^${path}/(.*)$ ${path}_maintenance/\$1? redirect; + # The difference will be in the $1 at the end, which keep the following queries. + # But, if it works perfectly for a html request, there's an issue with any php files. + # This files are treated as simple files, and will be downloaded by the browser. + # Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was. - systemctl reload nginx + systemctl reload nginx } ynh_maintenance_mode_OFF () { - # Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app. - echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - systemctl reload nginx + # Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app. + echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" + systemctl reload nginx - # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. - sleep 4 + # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. + sleep 4 - # Then remove the temporary files used for the maintenance. - rm "/var/www/html/maintenance.$app.html" - rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" + # Then remove the temporary files used for the maintenance. + rm "/var/www/html/maintenance.$app.html" + rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - systemctl reload nginx + systemctl reload nginx } #================================================= diff --git a/scripts/change_url b/scripts/change_url index f693d23..6ec3fdd 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -26,7 +26,7 @@ ynh_change_url_nginx_config #================================================= ynh_script_progression --message="Updating a config file..." -discourse_config_file="$install_dir/config/discourse.conf" +discourse_config_file="$install_dir/discourse/config/discourse.conf" old_relative_url_root="${old_path%/}" new_relative_url_root="${new_path%/}" @@ -46,14 +46,16 @@ UPDATE site_settings SET value = '${new_path}' WHERE name='long_polling_base_url ynh_use_ruby # Remap URLs in forum posts -ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec script/discourse remap "$old_relative_url_root/uploads" "$new_relative_url_root/uploads" <<< "YES +_exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec script/discourse remap "$old_relative_url_root/uploads" "$new_relative_url_root/uploads" <<< "YES # " -# Regenerate assets -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake assets:precompile +pushd "$install_dir/discourse" + # Regenerate assets + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production bin/rake assets:precompile -# Regenerate all forum posts -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake posts:rebake + # Regenerate all forum posts + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production bin/rake posts:rebake +popd #================================================= # START SYSTEMD SERVICE @@ -61,7 +63,7 @@ ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake post ynh_script_progression --message="Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stdout.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 941613f..5e9d206 100644 --- a/scripts/install +++ b/scripts/install @@ -41,14 +41,18 @@ ynh_app_setting_set --app="$app" --key=unicorn_workers --value=$unicorn_workers # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing Ruby..." - ynh_exec_warn_less ynh_install_ruby --ruby_version="$ruby_version" ynh_use_ruby ynh_script_progression --message="Installing NodeJS..." - ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_script_progression --message="Building and installing ImageMagick v7..." +install_imagemagick + +ynh_script_progression --message="Installing Oxipng..." +install_oxipng + #================================================= # CONFIGURE A POSTGRESQL DATABASE #================================================= @@ -73,20 +77,21 @@ if dpkg --print-architecture | grep -q "arm"; then fi # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir/discourse" # Install LDAP plugin -ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/plugins/discourse-ldap-auth" +# See https://github.com/jonmbake/discourse-ldap-auth/issues/77 +ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/discourse/plugins/ldap" # Add a pids and socket directory for the systemd script. -mkdir -p "$install_dir/tmp/pids" -mkdir -p "$install_dir/tmp/sockets" -mkdir -p "$install_dir/public/forum" +mkdir -p "$install_dir/discourse/tmp/pids" +mkdir -p "$install_dir/discourse/tmp/sockets" +mkdir -p "$install_dir/discourse/public/forum" # Create specific folders and links for subfolder compatibility # (see: https://meta.discourse.org/t/subfolder-support-with-docker/30507) -ln -s "$install_dir/public/uploads" "$install_dir/public/forum/uploads" -ln -s "$install_dir/public/backups" "$install_dir/public/forum/backups" +ln -s "$install_dir/discourse/public/uploads" "$install_dir/discourse/public/forum/uploads" +ln -s "$install_dir/discourse/public/backups" "$install_dir/discourse/public/forum/backups" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" @@ -96,53 +101,53 @@ chown -R "$app:www-data" "$install_dir" #================================================= ynh_script_progression --message="Adding $app's configuration file..." -ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/config/discourse.conf" -ynh_add_config --template="secrets.yml" --destination="$install_dir/config/secrets.yml" -ynh_add_config --template="settings.yml" --destination="$install_dir/plugins/discourse-ldap-auth/config/settings.yml" +ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/discourse/config/discourse.conf" +ynh_add_config --template="secrets.yml" --destination="$install_dir/discourse/config/secrets.yml" +ynh_add_config --template="settings.yml" --destination="$install_dir/discourse/plugins/ldap/config/settings.yml" # Disable svgo worker -echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/.image_optim.yml" >/dev/null +echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/discourse/.image_optim.yml" >/dev/null #================================================= # SETUP UNICORN, A RUBY SERVER #================================================= ynh_script_progression --message="Setting up Unicorn..." -pushd "$install_dir" - # Install bundler, a gems installer - ynh_gem install bundler - # Install without documentation - echo "gem: --no-ri --no-rdoc" | ynh_exec_as "$app" tee "$install_dir/.gemrc" >/dev/null -popd - -# Specific actions on ARM architecture -if dpkg --print-architecture | grep -q "arm"; then - # Define the platform specifically to retrieve binaries - # for libv8 because it currently doesn't compile on ARM devices - ynh_exec_as "$app" --login bin/bundle config specific_platform arm-linux -fi - -# Install dependencies -ynh_exec_as "$app" --login bin/bundle config set path 'vendor/bundle' -ynh_exec_as "$app" --login bin/bundle config set with 'development' -ynh_exec_as "$app" --login MAKEFLAGS=-j2 bin/bundle install --jobs 2 - # On ARM architecture, replace bundled libpsl by system native libpsl # because the provided binary isn't compatible if dpkg --print-architecture | grep -q "arm"; then ( - cd "$install_dir/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor" + cd "$install_dir/discourse/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor" rm libpsl.so ln -s "$(ldconfig -p | grep libpsl | awk 'END {print $NF}')" libpsl.so ) fi -pushd "$install_dir" +pushd "$install_dir/discourse" + # Install bundler, a gems installer + ynh_gem install bundler + # Install without documentation + echo "gem: --no-ri --no-rdoc" | ynh_exec_as "$app" tee "$install_dir/.gemrc" >/dev/null + + # Specific actions on ARM architecture + if dpkg --print-architecture | grep -q "arm"; then + # Define the platform specifically to retrieve binaries + # for libv8 because it currently doesn't compile on ARM devices + _exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config specific_platform arm-linux + fi + + # Install dependencies + _exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle' + _exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set without test development + _exec_as_app_with_ruby_node MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2 +popd + +pushd "$install_dir/discourse" ynh_use_nodejs ynh_npm install --location=global terser ynh_npm install --location=global uglify-js - ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn install --production --frozen-lockfile - ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn cache clean + ynh_exec_warn_less _exec_as_app_with_ruby_node yarn install --frozen-lockfile + ynh_exec_warn_less _exec_as_app_with_ruby_node yarn cache clean popd #================================================= @@ -150,8 +155,10 @@ popd #================================================= ynh_script_progression --message="Preparing the database..." -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake db:migrate -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile +pushd "$install_dir/discourse" + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile +popd # Set default data (especially to have correct image URLs for subfolder install) ynh_add_config --template="provisioning.sql" --destination="$install_dir/provisioning.sql" @@ -163,11 +170,13 @@ ynh_secure_remove --file="$install_dir/provisioning.sql" #================================================= ynh_script_progression --message="Creating Discourse admin user..." -ynh_exec_as "$app" --login RAILS_ENV=production bin/rake admin:create <<< "$admin_mail +pushd "$install_dir/discourse" + _exec_as_app_with_ruby_node RAILS_ENV=production bin/rake admin:create <<< "$admin_mail $admin_pwd $admin_pwd y " +popd #================================================= # CONFIGURE PLUGINS @@ -177,7 +186,7 @@ ynh_script_progression --message="Configuring plugins..." # Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder # (Can only do that now because we are patching dependencies which have just been downloaded) # Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16 -patch -p1 -d "$install_dir/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \ +patch -p1 -d "$install_dir/discourse/plugins/ldap/gems/$ruby_version/gems/omniauth-ldap"*/ \ < "../conf/ldap-auth-fix-subfolder.patch" #================================================= @@ -197,13 +206,13 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" additional_env="UNICORN_WORKERS=$unicorn_workers" ynh_add_systemd_config -yunohost service add "$app" --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log" +yunohost service add "$app" --log "$install_dir/discourse/log/unicorn.stderr.log" "$install_dir/discourse/log/unicorn.stdout.log" "$install_dir/discourse/log/production.log" # Use logrotate to manage application logfile(s) -ynh_use_logrotate --logfile="$install_dir/log/unicorn.stderr.log" -ynh_use_logrotate --logfile="$install_dir/log/unicorn.stdout.log" -ynh_use_logrotate --logfile="$install_dir/log/production.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stderr.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stdout.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/production.log" #================================================= # START SYSTEMD SERVICE @@ -211,7 +220,7 @@ ynh_use_logrotate --logfile="$install_dir/log/production.log" ynh_script_progression --message="Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stdout.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index aa3ffee..4119d81 100644 --- a/scripts/restore +++ b/scripts/restore @@ -48,7 +48,7 @@ ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" #================================================= ynh_script_progression --message="Reinstall Bundle Gem..." -pushd "$install_dir" +pushd "$install_dir/discourse" ynh_gem install bundler popd @@ -61,7 +61,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet -yunohost service add "$app" --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log" +yunohost service add "$app" --log "$install_dir/discourse/log/unicorn.stderr.log" "$install_dir/discourse/log/unicorn.stdout.log" "$install_dir/discourse/log/production.log" ynh_restore_file --origin_path="/etc/logrotate.d/$app" @@ -70,7 +70,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stdout.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 0cb4d02..55d5c33 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,7 +32,7 @@ ynh_maintenance_mode_ON #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name="$app" --action="stop" --log_path="$install_dir/log/unicorn.stderr.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="$install_dir/discourse/log/unicorn.stdout.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -51,6 +51,18 @@ if [ -z "$unicorn_workers" ]; then ynh_app_setting_set --app="$app" --key="unicorn_workers" --value="$unicorn_workers" fi +if [ -f "$install_dir/tmp/sockets/unicorn.sock" ]; then + # Move sources into the discourse subdir. + mkdir -p "$install_dir/__new__" + find "$install_dir" -mindepth 1 -maxdepth 1 -not -name "__new__" -print0 | xargs -0 mv -t "$install_dir/__new__" + mv "$install_dir/__new__" "$install_dir/discourse" +fi + +# See https://github.com/jonmbake/discourse-ldap-auth/issues/77 +if [ -d "$install_dir/discourse/plugins/discourse-ldap-auth" ]; then + mv "$install_dir/discourse/plugins/discourse-ldap-auth" "$install_dir/discourse/plugins/ldap" +fi + #================================================= # UPGRADING DEPENDENCIES #================================================= @@ -60,6 +72,11 @@ ynh_exec_warn_less ynh_install_ruby --ruby_version="$ruby_version" ynh_script_progression --message="Upgrading NodeJS..." ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_script_progression --message="Building and upgrading ImageMagick v7..." +install_imagemagick + +ynh_script_progression --message="Upgrading Oxipng..." +install_oxipng #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -75,35 +92,35 @@ if dpkg --print-architecture | grep -q "arm"; then fi # Small trick to backup non-core plugins -mv "$install_dir/plugins" "$install_dir/plugins_old" +mv "$install_dir/discourse/plugins" "$install_dir/discourse/plugins_old" # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" --full_replace=1 \ +ynh_setup_source --dest_dir="$install_dir/discourse" --full_replace=1 \ --keep="config/discourse.conf plugins_old public/uploads public/backups log" # Restore all non-core plugins -for plugin_dir in "$install_dir/plugins_old"/*; do +for plugin_dir in "$install_dir/discourse/plugins_old"/*; do plugin_name=$(basename "$plugin_dir") - if [ ! -d "$install_dir/plugins/$plugin_name" ]; then - mv "$plugin_dir" "$install_dir/plugins/$plugin_name" + if [ ! -d "$install_dir/discourse/plugins/$plugin_name" ]; then + mv "$plugin_dir" "$install_dir/discourse/plugins/$plugin_name" fi done -ynh_secure_remove --file="$install_dir/plugins_old" +ynh_secure_remove --file="$install_dir/discourse/plugins_old" # Install LDAP plugin -ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/plugins/discourse-ldap-auth" --full_replace=1 \ +ynh_setup_source --source_id=ldap-auth --dest_dir="$install_dir/discourse/plugins/ldap" --full_replace=1 \ --keep="config/settings.yml" # Add a pids and socket directory for the systemd script. -mkdir -p "$install_dir/tmp/pids" -mkdir -p "$install_dir/tmp/sockets" -mkdir -p "$install_dir/public/forum" +mkdir -p "$install_dir/discourse/tmp/pids" +mkdir -p "$install_dir/discourse/tmp/sockets" +mkdir -p "$install_dir/discourse/public/forum" # Create specific folders and links for subfolder compatibility # (see: https://meta.discourse.org/t/subfolder-support-with-docker/30507) -ln -s "$install_dir/public/uploads" "$install_dir/public/forum/uploads" -ln -s "$install_dir/public/backups" "$install_dir/public/forum/backups" +ln -s "$install_dir/discourse/public/uploads" "$install_dir/discourse/public/forum/uploads" +ln -s "$install_dir/discourse/public/backups" "$install_dir/discourse/public/forum/backups" # Set permissions to app files chmod -R o-rwx "$install_dir" @@ -114,12 +131,12 @@ chown -R "$app:www-data" "$install_dir" #================================================= ynh_script_progression --message="Updating $app's config file..." -ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/config/discourse.conf" -ynh_add_config --template="secrets.yml" --destination="$install_dir/config/secrets.yml" -ynh_add_config --template="settings.yml" --destination="$install_dir/plugins/discourse-ldap-auth/config/settings.yml" +ynh_add_config --template="discourse_defaults.conf" --destination="$install_dir/discourse/config/discourse.conf" +ynh_add_config --template="secrets.yml" --destination="$install_dir/discourse/config/secrets.yml" +ynh_add_config --template="settings.yml" --destination="$install_dir/discourse/plugins/ldap/config/settings.yml" # Disable svgo worker -echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/.image_optim.yml" >/dev/null +echo "svgo: false" | ynh_exec_as "$app" tee "$install_dir/discourse/.image_optim.yml" >/dev/null #================================================= # SETUP UNICORN, A RUBY SERVER @@ -130,11 +147,11 @@ ynh_script_progression --message="Setting up Unicorn..." ynh_use_ruby # Make a backup of the original config file if modified -unicorn_config_file="$install_dir/config/unicorn.conf.rb" +unicorn_config_file="$install_dir/discourse/config/unicorn.conf.rb" ynh_backup_if_checksum_is_different "$unicorn_config_file" ynh_store_file_checksum --file="$unicorn_config_file" -pushd "$install_dir" +pushd "$install_dir/discourse" # Install bundler, a gems installer ynh_gem install bundler # Install without documentation @@ -145,30 +162,30 @@ popd if dpkg --print-architecture | grep -q "arm"; then # Define the platform specifically to retrieve binaries # for libv8 because it currently doesn't compile on ARM devices - ynh_exec_as "$app" --login bin/bundle config specific_platform arm-linux + _exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config specific_platform arm-linux fi # Install dependencies -ynh_exec_as "$app" --login bin/bundle config set path 'vendor/bundle' -ynh_exec_as "$app" --login bin/bundle config set with 'development' -ynh_exec_as "$app" --login MAKEFLAGS=-j2 bin/bundle install --jobs 2 +_exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle' +_exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set with 'development' +_exec_as_app_with_ruby_node MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2 # On ARM architecture, replace bundled libpsl by system native libpsl # because the provided binary isn't compatible if dpkg --print-architecture | grep -q "arm"; then ( - cd "$install_dir/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor" + cd "$install_dir/discourse/vendor/bundle/ruby"/*/"gems/mini_suffix-*/vendor" rm libpsl.so ln -s "$(ldconfig -p | grep libpsl | awk 'END {print $NF}')" libpsl.so ) fi -pushd "$install_dir" +pushd "$install_dir/discourse" ynh_use_nodejs ynh_npm install --location=global terser ynh_npm install --location=global uglify-js - ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn install --production --frozen-lockfile - ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn cache clean + ynh_exec_warn_less _exec_as_app_with_ruby_node yarn install --production --frozen-lockfile + ynh_exec_warn_less _exec_as_app_with_ruby_node yarn cache clean popd #================================================= @@ -177,8 +194,10 @@ popd ynh_script_progression --message="Preparing the database..." -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake db:migrate -ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile +pushd "$install_dir/discourse" + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate + ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile +popd #================================================= # CONFIGURE PLUGINS @@ -188,7 +207,7 @@ ynh_script_progression --message="Configuring plugins..." # Patch ldap-auth plugin dependency (omniauth-ldap) to fix it when using domain subfolder # (Can only do that now because we are patching dependencies which have just been downloaded) # Patch applied: https://github.com/omniauth/omniauth-ldap/pull/16 -patch -p1 -d "$install_dir/plugins/discourse-ldap-auth/gems/$ruby_version/gems/omniauth-ldap"*/ \ +patch -p1 -d "$install_dir/discourse/plugins/ldap/gems/$ruby_version/gems/omniauth-ldap"*/ \ < "../conf/ldap-auth-fix-subfolder.patch" #================================================= @@ -208,19 +227,19 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" additional_env="UNICORN_WORKERS=$unicorn_workers" ynh_add_systemd_config -yunohost service add "$app" --log "$install_dir/log/unicorn.stderr.log" "$install_dir/log/unicorn.stdout.log" "$install_dir/log/production.log" +yunohost service add "$app" --log "$install_dir/discourse/log/unicorn.stderr.log" "$install_dir/discourse/log/unicorn.stdout.log" "$install_dir/discourse/log/production.log" # Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --logfile="$install_dir/log/unicorn.stderr.log" -ynh_use_logrotate --logfile="$install_dir/log/unicorn.stdout.log" -ynh_use_logrotate --logfile="$install_dir/log/production.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stderr.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/unicorn.stdout.log" +ynh_use_logrotate --logfile="$install_dir/discourse/log/production.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/log/unicorn.stderr.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" +ynh_systemd_action --service_name="$app" --action="start" --log_path="$install_dir/discourse/log/unicorn.stdout.log" --line_match="INFO -- : worker=$((unicorn_workers-1)) ready" #================================================= # DISABLE MAINTENANCE MODE diff --git a/sources/patches/main-1-use-latest_uglify-js.patch b/sources/patches/main-1-use-latest_uglify-js.patch index 415ec9e..ad1af53 100644 --- a/sources/patches/main-1-use-latest_uglify-js.patch +++ b/sources/patches/main-1-use-latest_uglify-js.patch @@ -1,14 +1,26 @@ +From 0d5cfdaf5d1b65cff5b2c1bde026dbb9b3351d4f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= +Date: Fri, 26 Jul 2024 14:15:56 +0200 +Subject: [PATCH 1/3] Use latest uglify-js + +--- + lib/tasks/assets.rake | 3 +++ + 1 file changed, 3 insertions(+) + diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake -index 4a02d5f1b1..7b47f21658 100644 +index 96082977..ce59ce85 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake -@@ -126,6 +126,9 @@ - data = File.read("#{assets_path}/#{from}") - - uglified, map = Uglifier.new(comments: :none, -+ harmony: true, -+ mangle: false, -+ compress: false, - source_map: { - filename: File.basename(from), - output_filename: File.basename(to) +@@ -181,6 +181,9 @@ def compress_ruby(from, to) + uglified, map = + Uglifier.new( + comments: :none, ++ harmony: true, ++ mangle: false, ++ compress: false, + source_map: { + filename: File.basename(from), + output_filename: File.basename(to), +-- +2.45.2 + diff --git a/sources/patches/main-3-Re-add-support-for-older-versions-of-brotli.patch b/sources/patches/main-3-Re-add-support-for-older-versions-of-brotli.patch deleted file mode 100644 index 728758a..0000000 --- a/sources/patches/main-3-Re-add-support-for-older-versions-of-brotli.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake -index 7b47f21658..ea6d0da2c4 100644 ---- a/lib/tasks/assets.rake -+++ b/lib/tasks/assets.rake -@@ -116,9 +116,21 @@ def gzip(path) - end - - # different brotli versions use different parameters --def brotli_command(path, max_compress) -- compression_quality = max_compress ? "11" : "6" -- "brotli -f --quality=#{compression_quality} #{path} --output=#{path}.br" -+ver_out, _ver_err, ver_status = Open3.capture3('brotli --version') -+if !ver_status.success? -+ # old versions of brotli don't respond to --version -+ def brotli_command(path, max_compress) -+ compression_quality = max_compress ? "11" : "6" -+ "brotli --quality 11 --input #{path} --output #{path}.br" -+ end -+elsif ver_out >= "brotli 1.0.0" -+ def brotli_command(path, max_compress) -+ compression_quality = max_compress ? "11" : "6" -+ "brotli -f --quality=11 #{path} --output=#{path}.br" -+ end -+else -+ # not sure what to do here, not expecting this -+ raise "cannot determine brotli version" - end - - def brotli(path, max_compress) diff --git a/sources/patches/main-4-fix-missing-git-repository.patch b/sources/patches/main-4-fix-missing-git-repository.patch index a98afb6..3cab00a 100644 --- a/sources/patches/main-4-fix-missing-git-repository.patch +++ b/sources/patches/main-4-fix-missing-git-repository.patch @@ -1,22 +1,31 @@ -diff --git a/lib/discourse.rb b/lib/discourse.rb -index 2b53a91eb3..eec55647d5 100644 ---- a/lib/discourse.rb -+++ b/lib/discourse.rb -@@ -439,7 +439,7 @@ module Discourse - def self.full_version - @full_version ||= begin - git_cmd = 'git describe --dirty --match "v[0-9]*" 2> /dev/null' -- self.try_git(git_cmd, 'unknown') -+ self.try_git(git_cmd, Discourse::VERSION::STRING) - end - end +From 17a2d3241889c117ac5bb15d0609837592b16cb3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= +Date: Fri, 30 Aug 2024 11:50:04 +0200 +Subject: [PATCH] Fix missing git commands in repository -@@ -448,7 +448,7 @@ module Discourse - def self.last_commit_date - @last_commit_date ||= begin - git_cmd = 'git log -1 --format="%ct"' -- seconds = self.try_git(git_cmd, nil) -+ seconds = '1563199245' # Note(decentral1se): Output from actual command in the v2.3.2 branch - seconds.nil? ? nil : DateTime.strptime(seconds, '%s') - end +--- + lib/git_utils.rb | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/lib/git_utils.rb b/lib/git_utils.rb +index fb664fe2..aa81fd2d 100644 +--- a/lib/git_utils.rb ++++ b/lib/git_utils.rb +@@ -11,12 +11,13 @@ class GitUtils end + + def self.full_version +- self.try_git('git describe --dirty --match "v[0-9]*" 2> /dev/null', "unknown") ++ self.try_git('git describe --dirty --match "v[0-9]*" 2> /dev/null', Discourse::VERSION::STRING) + end + + def self.last_commit_date + git_cmd = 'git log -1 --format="%ct"' +- seconds = self.try_git(git_cmd, nil) ++ # Note(decentral1se): Output from actual command in the v3.2.4 branch ++ seconds = self.try_git(git_cmd, '1721046633') + seconds.nil? ? nil : DateTime.strptime(seconds, "%s") + end + +-- +2.43.0 diff --git a/sources/patches/main-5-fix-admin-watched-words-action.patch b/sources/patches/main-5-fix-admin-watched-words-action.patch index a431d71..36125b3 100644 --- a/sources/patches/main-5-fix-admin-watched-words-action.patch +++ b/sources/patches/main-5-fix-admin-watched-words-action.patch @@ -1,8 +1,17 @@ +From 714ba4449257b3770dfe991b1a19bda0b147d56e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= +Date: Fri, 30 Aug 2024 11:52:09 +0200 +Subject: [PATCH] Fix admin-watched-words-action.js + +--- + .../admin/addon/controllers/admin-watched-words-action.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + diff --git a/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js b/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js -index 2b53a91eb3..eec55647d5 100644 +index d5ad0c49..faeb04ab 100644 --- a/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js +++ b/app/assets/javascripts/admin/addon/controllers/admin-watched-words-action.js -@@ -32,9 +32,9 @@ +@@ -37,7 +37,7 @@ export default class AdminWatchedWordsActionController extends Controller { for (const { regexp, word } of words) { try { RegExp(regexp); @@ -11,5 +20,6 @@ index 2b53a91eb3..eec55647d5 100644 return I18n.t("admin.watched_words.invalid_regex", { word }); } } - }, - +-- +2.43.0 + diff --git a/sources/patches/main-6-fix-download-calendar.patch b/sources/patches/main-6-fix-download-calendar.patch index 580e10d..0f34f43 100644 --- a/sources/patches/main-6-fix-download-calendar.patch +++ b/sources/patches/main-6-fix-download-calendar.patch @@ -1,13 +1,25 @@ +From c4f4fb51b0b12c520bf78870842c4c0034296323 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= +Date: Fri, 30 Aug 2024 11:53:46 +0200 +Subject: [PATCH] Fix download-calendar.js + +--- + app/assets/javascripts/discourse/app/lib/download-calendar.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + diff --git a/app/assets/javascripts/discourse/app/lib/download-calendar.js b/app/assets/javascripts/discourse/app/lib/download-calendar.js -index 2b53a91eb3..eec55647d5 100644 +index 3fd2951a..b71e4e09 100644 --- a/app/assets/javascripts/discourse/app/lib/download-calendar.js +++ b/app/assets/javascripts/discourse/app/lib/download-calendar.js -@@ -22,7 +22,7 @@ +@@ -23,7 +23,7 @@ export function downloadCalendar(title, dates, options = {}) { } - export function downloadIcs(title, dates) { + export function downloadIcs(title, dates, options = {}) { - const REMOVE_FILE_AFTER = 20_000; + const REMOVE_FILE_AFTER = 20000; - const file = new File([generateIcsData(title, dates)], { + const file = new File([generateIcsData(title, dates, options)], { type: "text/plain", }); +-- +2.43.0 + diff --git a/sources/patches/main-7-fix-uppy-upload.patch b/sources/patches/main-7-fix-uppy-upload.patch index 6af3580..9b19083 100644 --- a/sources/patches/main-7-fix-uppy-upload.patch +++ b/sources/patches/main-7-fix-uppy-upload.patch @@ -1,13 +1,25 @@ +From c1dc85c042033cd689346d0bf6e747a97f4c4e7e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= +Date: Fri, 30 Aug 2024 11:55:03 +0200 +Subject: [PATCH] Fix uppy-upload.js + +--- + app/assets/javascripts/discourse/app/mixins/uppy-upload.js | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + diff --git a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js -index 2b53a91eb3..eec55647d5 100644 +index ff2a0e95..50be945e 100644 --- a/app/assets/javascripts/discourse/app/mixins/uppy-upload.js +++ b/app/assets/javascripts/discourse/app/mixins/uppy-upload.js -@@ -21,7 +21,7 @@ - import { warn } from "@ember/debug"; - import bootbox from "bootbox"; +@@ -23,7 +23,7 @@ import { deepMerge } from "discourse-common/lib/object"; + import { bind, on } from "discourse-common/utils/decorators"; + import I18n from "discourse-i18n"; -export const HUGE_FILE_THRESHOLD_BYTES = 104_857_600; // 100MB +export const HUGE_FILE_THRESHOLD_BYTES = "104_857_600"; // 100MB - export default Mixin.create(UppyS3Multipart, { - uploading: false, + export default Mixin.create(UppyS3Multipart, ExtendableUploader, { + dialog: service(), +-- +2.43.0 +