From 9e9ae9bec0228c0a999d28fbdbb4531abc7f7f36 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 30 May 2018 16:44:22 +0300 Subject: [PATCH 1/5] Create gitattributes --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fcadb2c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text eol=lf From b4fa7ec808f4f08e91fec57f119f32652c505d04 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 30 May 2018 16:45:27 +0300 Subject: [PATCH 2/5] Modernize tests script --- tests.sh | 120 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/tests.sh b/tests.sh index ce5ab3f..394b174 100755 --- a/tests.sh +++ b/tests.sh @@ -1,21 +1,22 @@ #!/bin/bash # Extract version to build from the repo -DEBVERSION=`grep Version debian/control | awk -F': ' '{print $2}'` -DEBFILE="deb/thelounge_${DEBVERSION}_all.deb" -NPMVERSION=`echo "${DEBVERSION}" | sed -E 's/-[0-9]+$//'` +DEBVERSION=$(grep Version debian/control | awk -F': ' '{print $2}') +DEBARCH=$(grep Architecture debian/control | awk -F': ' '{print $2}') +DEBFILE="deb/thelounge_${DEBVERSION}_${DEBARCH}.deb" +NPMVERSION=$(echo "${DEBVERSION}" | sed -E 's/-[0-9]+$//') # Exit status code to update if there is a failure CODE=0 echo -echo $DEBFILE +echo "$DEBFILE" # The deb file should correctly exist if [ -e "$DEBFILE" ]; then - echo -e " \x1B[32m✓\x1B[0m \x1B[90mwas correctly built\x1B[0m" + echo -e " \\x1B[32m✓\\x1B[0m \\x1B[90mwas correctly built\\x1B[0m" else - echo -e " \x1B[31m✗ was not built\x1B[0m" + echo -e " \\x1B[31m✗ was not built\\x1B[0m" CODE=1 fi @@ -23,127 +24,128 @@ fi # empty file), and a maximum size (ensures we did not load way too much # third-party code. if [ -e "$DEBFILE" ]; then - FILESIZE=`ls -l $DEBFILE | awk '{print $5}'` - HUMANSIZE=`ls -lh $DEBFILE | awk '{print $5}'` + FILESIZE=$(ls -l "$DEBFILE" | awk '{print $5}') + HUMANSIZE=$(ls -lh "$DEBFILE" | awk '{print $5}') MINSIZE=3 MAXSIZE=10 - if [ "$FILESIZE" -gt "$(($MINSIZE * 1024 * 1024))" ] && - [ "$FILESIZE" -lt "$(($MAXSIZE * 1024 * 1024))" ]; then - echo -e " \x1B[32m✓\x1B[0m \x1B[90mhas a valid file size ($HUMANSIZE)\x1B[0m" + if [ "$FILESIZE" -gt "$((MINSIZE * 1024 * 1024))" ] && + [ "$FILESIZE" -lt "$((MAXSIZE * 1024 * 1024))" ]; then + echo -e " \\x1B[32m✓\\x1B[0m \\x1B[90mhas a valid file size ($HUMANSIZE)\\x1B[0m" else - echo -e " \x1B[31m✗ has an invalid file size\x1B[0m" - echo -e " \x1B[32mminimum: ${MINSIZE}M\x1B[0m" - echo -e " \x1B[32mmaximum: ${MAXSIZE}M\x1B[0m" - echo -e " \x1B[31mactual: ${HUMANSIZE}\x1B[0m" + echo -e " \\x1B[31m✗ has an invalid file size\\x1B[0m" + echo -e " \\x1B[32mminimum: ${MINSIZE}M\\x1B[0m" + echo -e " \\x1B[32mmaximum: ${MAXSIZE}M\\x1B[0m" + echo -e " \\x1B[31mactual: ${HUMANSIZE}\\x1B[0m" echo CODE=1 fi else - echo -e " \x1B[36m- file size could not be checked\x1B[0m" + echo -e " \\x1B[36m- file size could not be checked\\x1B[0m" fi # If the service was correctly set up with systemd, it should show in the big # `sudo systemctl` list. -SYSTEMCTL_LIST=`sudo systemctl | grep "thelounge.service"` +SYSTEMCTL_LIST=$(sudo systemctl | grep "thelounge.service") if [[ "$SYSTEMCTL_LIST" = *"The Lounge (IRC client)"* ]]; then - echo -e " \x1B[32m✓\x1B[0m \x1B[90mcorrectly shows up in systemctl list\x1B[0m" + echo -e " \\x1B[32m✓\\x1B[0m \\x1B[90mcorrectly shows up in systemctl list\\x1B[0m" else - echo -e " \x1B[31m✗ was not found or incorrectly listed\x1B[0m" - echo -e " \x1B[32mexpected: The Lounge (IRC client)\x1B[0m" - echo -e " \x1B[31mactual: ${SYSTEMCTL_LIST}\x1B[0m" + echo -e " \\x1B[31m✗ was not found or incorrectly listed\\x1B[0m" + echo -e " \\x1B[32mexpected: The Lounge (IRC client)\\x1B[0m" + echo -e " \\x1B[31mactual: ${SYSTEMCTL_LIST}\\x1B[0m" echo CODE=1 fi # Wait until The Lounge is actually fully started sleep 2 + # Entire entry for the service. We'll use this to see if everything is in order. -SYSTEMCTL_STATUS=`sudo systemctl status --full thelounge.service` +SYSTEMCTL_STATUS=$(sudo systemctl status --full thelounge.service) # `systemctl status` should report `Active: active (running) since ...` -SYSTEMCTL_ACTIVE=`echo "${SYSTEMCTL_STATUS}" | grep "Active:"` +SYSTEMCTL_ACTIVE=$(echo "${SYSTEMCTL_STATUS}" | grep "Active:") if [[ "$SYSTEMCTL_ACTIVE" = *"active (running)"* ]]; then - echo -e " \x1B[32m✓\x1B[0m \x1B[90mis reported as active and running by systemctl status\x1B[0m" + echo -e " \\x1B[32m✓\\x1B[0m \\x1B[90mis reported as active and running by systemctl status\\x1B[0m" else - echo -e " \x1B[31m✗ does not have a status of active and running\x1B[0m" - echo -e " \x1B[32mexpected: Active: active (running)\x1B[0m" - echo -e " \x1B[31mactual: ${SYSTEMCTL_ACTIVE}\x1B[0m" + echo -e " \\x1B[31m✗ does not have a status of active and running\\x1B[0m" + echo -e " \\x1B[32mexpected: Active: active (running)\\x1B[0m" + echo -e " \\x1B[31mactual: ${SYSTEMCTL_ACTIVE}\\x1B[0m" echo CODE=1 fi -SYSTEMCTL_STARTED=`echo "${SYSTEMCTL_STATUS}" | grep "systemd\["` +SYSTEMCTL_STARTED=$(echo "${SYSTEMCTL_STATUS}" | grep "systemd\\[") if [[ "$SYSTEMCTL_STARTED" = *"Started The Lounge (IRC client)"* ]]; then - echo -e " \x1B[32m✓\x1B[0m \x1B[90mshows up as started in systemctl logs\x1B[0m" + echo -e " \\x1B[32m✓\\x1B[0m \\x1B[90mshows up as started in systemctl logs\\x1B[0m" else - echo -e " \x1B[31m✗ does not show up as started in systemctl\x1B[0m" - echo -e " \x1B[32mexpected: Started The Lounge (IRC client)\x1B[0m" - echo -e " \x1B[31mactual: ${SYSTEMCTL_STARTED}\x1B[0m" + echo -e " \\x1B[31m✗ does not show up as started in systemctl\\x1B[0m" + echo -e " \\x1B[32mexpected: Started The Lounge (IRC client)\\x1B[0m" + echo -e " \\x1B[31mactual: ${SYSTEMCTL_STARTED}\\x1B[0m" echo CODE=1 fi -SYSTEMCTL_VERSION=`echo "${SYSTEMCTL_STATUS}" | grep "The Lounge v"` +SYSTEMCTL_VERSION=$(echo "${SYSTEMCTL_STATUS}" | grep "The Lounge v") if [[ "$SYSTEMCTL_VERSION" = *"$NPMVERSION"* ]]; then - echo -e " \x1B[32m✓\x1B[0m \x1B[90mshows correct version in systemctl logs\x1B[0m" + echo -e " \\x1B[32m✓\\x1B[0m \\x1B[90mshows correct version in systemctl logs\\x1B[0m" else - echo -e " \x1B[31m✗ does not show up correct version in systemctl\x1B[0m" - echo -e " \x1B[32mexpected: The Lounge v$NPMVERSION\x1B[0m" - echo -e " \x1B[31mactual: ${SYSTEMCTL_VERSION}\x1B[0m" + echo -e " \\x1B[31m✗ does not show up correct version in systemctl\\x1B[0m" + echo -e " \\x1B[32mexpected: The Lounge v$NPMVERSION\\x1B[0m" + echo -e " \\x1B[31mactual: ${SYSTEMCTL_VERSION}\\x1B[0m" echo CODE=1 fi -SYSTEMCTL_CONFIG=`echo "${SYSTEMCTL_STATUS}" | grep "Configuration file:"` +SYSTEMCTL_CONFIG=$(echo "${SYSTEMCTL_STATUS}" | grep "Configuration file:") if [[ "$SYSTEMCTL_CONFIG" = *"/etc/thelounge/config.js"* ]]; then - echo -e " \x1B[32m✓\x1B[0m \x1B[90mshows correct configuration path in systemctl logs\x1B[0m" + echo -e " \\x1B[32m✓\\x1B[0m \\x1B[90mshows correct configuration path in systemctl logs\\x1B[0m" else - echo -e " \x1B[31m✗ does not show up correct version in systemctl logs\x1B[0m" - echo -e " \x1B[32mexpected: Configuration file: /etc/thelounge/config.js\x1B[0m" - echo -e " \x1B[31mactual: ${SYSTEMCTL_CONFIG}\x1B[0m" + echo -e " \\x1B[31m✗ does not show up correct version in systemctl logs\\x1B[0m" + echo -e " \\x1B[32mexpected: Configuration file: /etc/thelounge/config.js\\x1B[0m" + echo -e " \\x1B[31mactual: ${SYSTEMCTL_CONFIG}\\x1B[0m" echo CODE=1 fi -SYSTEMCTL_URL=`echo "${SYSTEMCTL_STATUS}" | grep "Available at"` +SYSTEMCTL_URL=$(echo "${SYSTEMCTL_STATUS}" | grep "Available at") if [[ "$SYSTEMCTL_URL" = *"http://:::9000/"* ]]; then - echo -e " \x1B[32m✓\x1B[0m \x1B[90mshows correct URL in systemctl logs\x1B[0m" + echo -e " \\x1B[32m✓\\x1B[0m \\x1B[90mshows correct URL in systemctl logs\\x1B[0m" else - echo -e " \x1B[31m✗ does not show up correct URL in systemctl logs\x1B[0m" - echo -e " \x1B[32mexpected: Available at http://:::9000/\x1B[0m" - echo -e " \x1B[31mactual: ${SYSTEMCTL_URL}\x1B[0m" + echo -e " \\x1B[31m✗ does not show up correct URL in systemctl logs\\x1B[0m" + echo -e " \\x1B[32mexpected: Available at http://:::9000/\\x1B[0m" + echo -e " \\x1B[31mactual: ${SYSTEMCTL_URL}\\x1B[0m" echo CODE=1 fi -SYSTEMCTL_LOGS=`echo "${SYSTEMCTL_STATUS}" | grep "thelounge\["` +SYSTEMCTL_LOGS=$(echo "${SYSTEMCTL_STATUS}" | grep "thelounge\\[") if [[ "$SYSTEMCTL_LOGS" != *"[WARN]"* ]]; then - echo -e " \x1B[32m✓\x1B[0m \x1B[90mdoes not have any warnings in systemctl logs\x1B[0m" + echo -e " \\x1B[32m✓\\x1B[0m \\x1B[90mdoes not have any warnings in systemctl logs\\x1B[0m" else - echo -e " \x1B[31m✗ has warnings in systemctl in systemctl logs\x1B[0m" - echo -e " \x1B[31mactual: `echo "${SYSTEMCTL_LOGS}" | grep "\[WARN\]"`\x1B[0m" + echo -e " \\x1B[31m✗ has warnings in systemctl in systemctl logs\\x1B[0m" + echo -e " \\x1B[31mactual: $(echo "${SYSTEMCTL_LOGS}" | grep "\\[WARN\\]")\\x1B[0m" echo CODE=1 fi if [[ "$SYSTEMCTL_LOGS" != *"[ERROR]"* ]]; then - echo -e " \x1B[32m✓\x1B[0m \x1B[90mdoes not have any errors in systemctl logs\x1B[0m" + echo -e " \\x1B[32m✓\\x1B[0m \\x1B[90mdoes not have any errors in systemctl logs\\x1B[0m" else - echo -e " \x1B[31m✗ has errors in systemctl in systemctl logs\x1B[0m" - echo -e " \x1B[31mactual: `echo "${SYSTEMCTL_LOGS}" | grep "\[ERROR\]"`\x1B[0m" + echo -e " \\x1B[31m✗ has errors in systemctl in systemctl logs\\x1B[0m" + echo -e " \\x1B[31mactual: $(echo "${SYSTEMCTL_LOGS}" | grep "\\[ERROR\\]")\\x1B[0m" echo CODE=1 fi -THELOUNGE_HTML=`curl --silent http://localhost:9000` +THELOUNGE_HTML=$(curl --silent http://localhost:9000) if [[ "$THELOUNGE_HTML" = *"The Lounge"* ]]; then - echo -e " \x1B[32m✓\x1B[0m \x1B[90mreturns correct HTML markup when calling the webserver\x1B[0m" + echo -e " \\x1B[32m✓\\x1B[0m \\x1B[90mreturns correct HTML markup when calling the webserver\\x1B[0m" else - echo -e " \x1B[31m✗ does not return correct HTML markup when calling the webserver\x1B[0m" - echo -e " \x1B[32mexpected: The Lounge\x1B[0m" - echo -e " \x1B[31mactual:\x1B[0m" + echo -e " \\x1B[31m✗ does not return correct HTML markup when calling the webserver\\x1B[0m" + echo -e " \\x1B[32mexpected: The Lounge\\x1B[0m" + echo -e " \\x1B[31mactual:\\x1B[0m" echo "$THELOUNGE_HTML" CODE=1 fi From 4af1a83d4f49a586477dfa010be17ed97e01d5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 11 Jun 2018 00:12:47 -0400 Subject: [PATCH 3/5] Install sqlite3 from npm when installing the deb rather than when building it --- build-package | 2 +- debian/control | 2 +- debian/postinst | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build-package b/build-package index 38b5a08..88185bb 100755 --- a/build-package +++ b/build-package @@ -13,7 +13,7 @@ echo "Building $NPMVERSION..." rm -rf "$DESTDIR" "$OUTDIR" # Install the package itself -npm install -g --prefix "$DESTDIR/usr" thelounge@${NPMVERSION} +npm install -g --no-optional --prefix "$DESTDIR/usr" thelounge@${NPMVERSION} # Write .thelounge_home to set correct system config directory echo "/etc/thelounge" > "$DESTDIR/usr/lib/node_modules/thelounge/.thelounge_home" diff --git a/debian/control b/debian/control index 6eb4713..5236480 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Version: 3.0.0-pre.6-1 Section: net Priority: optional Architecture: all -Depends: nodejs (>= 6), bash, sqlite3 +Depends: nodejs (>= 6), npm, bash Maintainer: Maxime Poulin Description: A self-hosted, web-based IRC client Homepage: https://thelounge.chat diff --git a/debian/postinst b/debian/postinst index 3bae3cc..3b9fef6 100755 --- a/debian/postinst +++ b/debian/postinst @@ -3,6 +3,8 @@ set -e [[ "$1" == "configure" ]] || exit 0 +sudo npm install -g sqlite3 --unsafe-perm + if ! getent group thelounge >/dev/null; then addgroup --quiet --system thelounge fi From 5c016a9d6851cca6f535d25dbe71a882b8263678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 11 Jun 2018 23:21:21 -0400 Subject: [PATCH 4/5] Install sqlite3 locally in node_modules of thelounge instead of globally --- debian/postinst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/debian/postinst b/debian/postinst index 3b9fef6..6e208fd 100755 --- a/debian/postinst +++ b/debian/postinst @@ -3,7 +3,10 @@ set -e [[ "$1" == "configure" ]] || exit 0 -sudo npm install -g sqlite3 --unsafe-perm +sudo npm install sqlite3 \ + --no-package-lock \ + --prefix /usr/lib/node_modules/thelounge \ + --unsafe-perm if ! getent group thelounge >/dev/null; then addgroup --quiet --system thelounge From 053979e103ee9445b0289e7b6b8128c176f9e94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Tue, 19 Jun 2018 01:21:15 -0400 Subject: [PATCH 5/5] Bump version of The Lounge to v3.0.0-pre.7 --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 5236480..9f99046 100644 --- a/debian/control +++ b/debian/control @@ -1,5 +1,5 @@ Package: thelounge -Version: 3.0.0-pre.6-1 +Version: 3.0.0-pre.7-1 Section: net Priority: optional Architecture: all