From 50944ae206f3a4a5f021648698f72159c0338cfc Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 18 Aug 2022 22:26:27 +0200 Subject: [PATCH 1/8] Fix shebang typo --- dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev.sh b/dev.sh index a83ab65..3d9219d 100755 --- a/dev.sh +++ b/dev.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash tmux has-session -t packagecontrol if [[ $? != 0 ]]; then From 4d65de6894921f6f7075a02806d3934be25263e7 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 19 Aug 2022 09:28:25 +0200 Subject: [PATCH 2/8] Fix failing postgresql dev-server start Creating /var/run/postgresql directory requires elevated privileges on debian. As postgresql runs without them the directory needs to be created beforehand. --- dev-servers.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dev-servers.sh b/dev-servers.sh index 5ef26ca..6d459af 100755 --- a/dev-servers.sh +++ b/dev-servers.sh @@ -17,6 +17,13 @@ mkdir -p "$PROJ_DIR/data/pgsql" mkdir -p "$PROJ_DIR/data/redis" mkdir -p "$PROJ_DIR/data/logs" +# Create run directory with elevated privileges +PGSQL_RUN_DIR=/var/run/postgresql +if [[ ! -d "$PGSQL_RUN_DIR" ]]; then + sudo mkdir -p "$PGSQL_RUN_DIR" + sudo chown -p $(whoami) "$PGSQL_RUN_DIR" +fi + if [[ ! -d "$PROJ_DIR/data/pgsql/base" ]]; then initdb "$PROJ_DIR/data/pgsql" createdb -U postgres -E 'UTF-8' package_control From 8b8011fb1fb70eb54bc35a3fc7ca3b840973db99 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 18 Aug 2022 22:48:03 +0200 Subject: [PATCH 3/8] Fix data base creation for development environment Reduce some initial hassle to get things running. --- dev-servers.sh | 22 ++++++++++++++++++---- dev.sh | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/dev-servers.sh b/dev-servers.sh index 6d459af..a868f08 100755 --- a/dev-servers.sh +++ b/dev-servers.sh @@ -24,11 +24,25 @@ if [[ ! -d "$PGSQL_RUN_DIR" ]]; then sudo chown -p $(whoami) "$PGSQL_RUN_DIR" fi -if [[ ! -d "$PROJ_DIR/data/pgsql/base" ]]; then - initdb "$PROJ_DIR/data/pgsql" - createdb -U postgres -E 'UTF-8' package_control +HAS_DB=1 +if [[ ! -e "$PROJ_DIR/data/pgsql/PG_VERSION" ]]; then + HAS_DB=0 + initdb -U postgres -E UTF-8 -D "$PROJ_DIR/data/pgsql" + sleep 1 fi pg_ctl -D "$PROJ_DIR/data/pgsql" -l "$PROJ_DIR/data/logs/pgsql.log" start -redis-server --port 6379 + +if ((!HAS_DB)); then + createdb -U postgres -E UTF-8 package_control + psql -U postgres -d package_control -f "$PROJ_DIR/setup/sql/up.sql" +fi + +redis-server --port 6379 --daemonize yes --loglevel warning --logfile $PROJ_DIR/data/logs/redis.log + +# enter sql shell +psql -U postgres package_control + +# shutdown servers +redis-cli -h 127.0.0.1 -p 6379 shutdown pg_ctl -D "$PROJ_DIR/data/pgsql" stop diff --git a/dev.sh b/dev.sh index 3d9219d..a0808b6 100755 --- a/dev.sh +++ b/dev.sh @@ -12,7 +12,7 @@ if [[ $? != 0 ]]; then tmux select-layout -t packagecontrol tiled sleep 0.6 - tmux send-keys -t packagecontrol:0.0 'psql -U postgres package_control' C-m + tmux send-keys -t packagecontrol:0.0 './dev-servers.sh' C-m tmux send-keys -t packagecontrol:0.1 '. venv/bin/activate' C-m tmux send-keys -t packagecontrol:0.2 '. venv/bin/activate' C-m tmux send-keys -t packagecontrol:0.3 '. venv/bin/activate' C-m From ba3c5d8f2f17a2ab3db97d3fc257dbc55643990d Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 19 Aug 2022 09:49:58 +0200 Subject: [PATCH 4/8] Add access tokens to secrets-example.yml --- secrets-example.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/secrets-example.yml b/secrets-example.yml index 4617da9..dcd908e 100644 --- a/secrets-example.yml +++ b/secrets-example.yml @@ -1,3 +1,6 @@ +bitbucket_access_token_wbond: "Enter your personal access token here" +github_access_token_packagecontrol-bot: "Enter your personal access token here" +gitlab_access_token_wbond: "Enter your personal access token here" github_client_id: "Visit https://github.com/settings/applications to register an application" github_client_secret: "Visit https://github.com/settings/applications to register an application" rollbar_key: "Visit https://rollbar.com/signup/ and sign up for a free tier account" From 8a28f2d87b560599e38c9582e8abbd706faa413c Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 19 Aug 2022 09:03:14 +0200 Subject: [PATCH 5/8] Use subprocess.check_output to call git Save some lines of code. --- app/tasks/crawl.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/tasks/crawl.py b/app/tasks/crawl.py index 0029668..e729785 100644 --- a/app/tasks/crawl.py +++ b/app/tasks/crawl.py @@ -24,11 +24,7 @@ break args = [git_binary, 'pull', 'origin', 'master'] -proc = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, cwd=dirname) -output, _ = proc.communicate() -print(output.decode(encoding='utf-8')) - +print(subprocess.check_output(args, cwd=dirname, encoding='utf-8')) if explicit_package: valid_sources = package.sources.sources_for(explicit_package) From fab0653ef1a73f2d66957b18af8f2c58ed09cef2 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 19 Aug 2022 09:54:57 +0200 Subject: [PATCH 6/8] Fix git warning when pulling package_control_channel Git prints a warning if no strategy for pulling (merge,rebase,ff-only) is configured. Hence explicitly request --ff-only to avoid it. --- app/tasks/crawl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/tasks/crawl.py b/app/tasks/crawl.py index e729785..a1dc10f 100644 --- a/app/tasks/crawl.py +++ b/app/tasks/crawl.py @@ -23,7 +23,7 @@ git_binary = path break -args = [git_binary, 'pull', 'origin', 'master'] +args = [git_binary, 'pull', '--ff-only', 'origin', 'master'] print(subprocess.check_output(args, cwd=dirname, encoding='utf-8')) if explicit_package: From f5a8ed227042cdb699b8f498db3379904967cd2d Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Fri, 19 Aug 2022 14:27:38 +0200 Subject: [PATCH 7/8] Fix indentation issues Convert some tabs into spaces. --- servers.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/servers.sh b/servers.sh index 573478b..0e2ea64 100755 --- a/servers.sh +++ b/servers.sh @@ -35,7 +35,7 @@ if [[ $TASK == "start" ]]; then if [[ ! -f "$PROJ_DIR/data/ssl/dhparam.pem" ]]; then echo -n "Generating dhparam for TLS ..." - openssl dhparam -out $PROJ_DIR/data/ssl/dhparam.pem 2048 + openssl dhparam -out $PROJ_DIR/data/ssl/dhparam.pem 2048 echo " done" fi @@ -97,17 +97,17 @@ if [[ $TASK == "start" ]]; then listen 443 ssl http2; server_name dev.packagecontrol.io; - ssl_certificate $PROJ_DIR/data/ssl/fullchain.pem; - ssl_certificate_key $PROJ_DIR/data/ssl/privkey.pem; - ssl_dhparam $PROJ_DIR/data/ssl/dhparam.pem; - ssl_protocols TLSv1.2 TLSv1.1 TLSv1; - ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'; - ssl_prefer_server_ciphers on; - ssl_session_timeout 5m; - - ssl_stapling on; - ssl_stapling_verify on; - ssl_trusted_certificate $PROJ_DIR/data/ssl/fullchain.pem; + ssl_certificate $PROJ_DIR/data/ssl/fullchain.pem; + ssl_certificate_key $PROJ_DIR/data/ssl/privkey.pem; + ssl_dhparam $PROJ_DIR/data/ssl/dhparam.pem; + ssl_protocols TLSv1.2 TLSv1.1 TLSv1; + ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'; + ssl_prefer_server_ciphers on; + ssl_session_timeout 5m; + + ssl_stapling on; + ssl_stapling_verify on; + ssl_trusted_certificate $PROJ_DIR/data/ssl/fullchain.pem; root $PROJ_DIR/public; From 0313b3683a758d65b271ad9d519a2914f12f1570 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 20 Aug 2022 17:55:55 +0200 Subject: [PATCH 8/8] Fix chown argument --- dev-servers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-servers.sh b/dev-servers.sh index a868f08..f7ee5bd 100755 --- a/dev-servers.sh +++ b/dev-servers.sh @@ -21,7 +21,7 @@ mkdir -p "$PROJ_DIR/data/logs" PGSQL_RUN_DIR=/var/run/postgresql if [[ ! -d "$PGSQL_RUN_DIR" ]]; then sudo mkdir -p "$PGSQL_RUN_DIR" - sudo chown -p $(whoami) "$PGSQL_RUN_DIR" + sudo chown $(whoami) "$PGSQL_RUN_DIR" fi HAS_DB=1