From fed137f82d7635f995c208864dd3e3f265c91061 Mon Sep 17 00:00:00 2001 From: Max Fowler Date: Thu, 12 Nov 2020 17:21:48 +0100 Subject: [PATCH] Reprepro working --- conf/templates/debian/distributions | 8 ----- conf/templates/debian/options | 3 -- conf/templates/debian/override.buster | 4 --- conf/templates/debian_repo/distributions | 2 +- conf/templates/debian_repo/nginx_debian.conf | 2 +- conf/templates/devdocs/git-post-receive | 13 -------- conf/templates/nginx/nginx.conf | 31 -------------------- conf/templates/nginx/nginx_devdocs.conf | 10 ------- scripts/setup_debian_repo.py | 7 ++--- scripts/utils.py | 4 +-- 10 files changed, 6 insertions(+), 78 deletions(-) delete mode 100644 conf/templates/debian/distributions delete mode 100644 conf/templates/debian/options delete mode 100644 conf/templates/debian/override.buster delete mode 100644 conf/templates/devdocs/git-post-receive delete mode 100644 conf/templates/nginx/nginx.conf delete mode 100644 conf/templates/nginx/nginx_devdocs.conf diff --git a/conf/templates/debian/distributions b/conf/templates/debian/distributions deleted file mode 100644 index f6fed0f..0000000 --- a/conf/templates/debian/distributions +++ /dev/null @@ -1,8 +0,0 @@ -Origin: PeachCloud -Label: PeachCloud -Codename: buster -Architectures: amd64 -Components: main -Description: Apt repository for PeachCloud debian packages -SignWith: {{gpg_key_id}} -DebOverride: override.buster diff --git a/conf/templates/debian/options b/conf/templates/debian/options deleted file mode 100644 index 5dd7345..0000000 --- a/conf/templates/debian/options +++ /dev/null @@ -1,3 +0,0 @@ -verbose -basedir {{debian_rep_dir}} -ask-passphrase diff --git a/conf/templates/debian/override.buster b/conf/templates/debian/override.buster deleted file mode 100644 index ec9fb2d..0000000 --- a/conf/templates/debian/override.buster +++ /dev/null @@ -1,4 +0,0 @@ -{% for service in services %} -{{service}} Priority optional -{{service}} Section net -{% endfor %} \ No newline at end of file diff --git a/conf/templates/debian_repo/distributions b/conf/templates/debian_repo/distributions index f6fed0f..45d7c64 100644 --- a/conf/templates/debian_repo/distributions +++ b/conf/templates/debian_repo/distributions @@ -1,7 +1,7 @@ Origin: PeachCloud Label: PeachCloud Codename: buster -Architectures: amd64 +Architectures: amd64 arm64 Components: main Description: Apt repository for PeachCloud debian packages SignWith: {{gpg_key_id}} diff --git a/conf/templates/debian_repo/nginx_debian.conf b/conf/templates/debian_repo/nginx_debian.conf index 73b671e..53ea5bc 100644 --- a/conf/templates/debian_repo/nginx_debian.conf +++ b/conf/templates/debian_repo/nginx_debian.conf @@ -1,6 +1,6 @@ server { listen 80; - server_name 167.99.136.83; + server_name deb.peachcloud.org; access_log /var/log/nginx-debian.log; error_log /var/log/nginx-debian.error; diff --git a/conf/templates/devdocs/git-post-receive b/conf/templates/devdocs/git-post-receive deleted file mode 100644 index 36b37bd..0000000 --- a/conf/templates/devdocs/git-post-receive +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -while read oldrev newrev ref -do - if [[ $ref =~ .*/master$ ]]; - then - echo "Master ref received. Deploying master branch to build directory..." - git --work-tree={{src_dir}}/devdocs_build --git-dir={{src_dir}}/devdocs_bare checkout -f - echo "Building docs and deploying to production..." - /root/.cargo/bin/mdbook build {{src_dir}}/devdocs_build --dest-dir {{web_dir}}/docs:peachcloud:org/html - else - echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server." - fi -done \ No newline at end of file diff --git a/conf/templates/nginx/nginx.conf b/conf/templates/nginx/nginx.conf deleted file mode 100644 index 668b54c..0000000 --- a/conf/templates/nginx/nginx.conf +++ /dev/null @@ -1,31 +0,0 @@ -user www-data; -worker_processes 1; -worker_rlimit_nofile 8192; - -events { - worker_connections 3000; -} - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - #gzip on; - - include /etc/nginx/conf.d/*.conf; - include /etc/nginx/sites-enabled/*; -} \ No newline at end of file diff --git a/conf/templates/nginx/nginx_devdocs.conf b/conf/templates/nginx/nginx_devdocs.conf deleted file mode 100644 index c97291c..0000000 --- a/conf/templates/nginx/nginx_devdocs.conf +++ /dev/null @@ -1,10 +0,0 @@ -server { - listen 80; - server_name 159.89.5.141; - - location / { - root {{web_dir}}/docs:peachcloud:org/html; - index index.html; - try_files $uri $uri/ /index.html; - } -} \ No newline at end of file diff --git a/scripts/setup_debian_repo.py b/scripts/setup_debian_repo.py index a29b341..fb8fa9c 100644 --- a/scripts/setup_debian_repo.py +++ b/scripts/setup_debian_repo.py @@ -98,11 +98,8 @@ for service in SERVICES: service_path = os.path.join(MICROSERVICES_SRC_DIR, service_name) print("[ BUILIDING SERVICE {} ]".format(service_name)) subprocess.call(["git", "pull"], cwd=service_path) - debian_package_path = str(subprocess.check_output(["/root/.cargo/bin/cargo", "deb", "--target", "aarch64-unknown-linux-gnu"], cwd=service_path)) + debian_package_path = subprocess.check_output(["/root/.cargo/bin/cargo", "deb", "--target", "aarch64-unknown-linux-gnu"], cwd=service_path).decode("utf-8").strip() print('OUTPUT: {}'.format(debian_package_path)) - subprocess.call("reprepro includedeb buster {deb_path}".format( - debian_dir=DEBIAN_REPO_DIR, - deb_path=debian_package_path - ), cwd=DEBIAN_REPO_DIR) + subprocess.call(["reprepro", "includedeb", "buster", debian_package_path], cwd=DEBIAN_REPO_DIR) diff --git a/scripts/utils.py b/scripts/utils.py index c6362ab..6d208a1 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -7,7 +7,7 @@ print('PROJECT_PATH: {}'.format(PROJECT_PATH)) template_path = os.path.join(PROJECT_PATH, 'conf/templates') template_loader = jinja2.FileSystemLoader(searchpath=template_path) -template_env = jinja2.Environment(loader=template_loader) +template_env = jinja2.Environment(loader=template_loader, keep_trailing_newline=True) def render_template(src, dest, template_vars=None): @@ -20,7 +20,7 @@ def render_template(src, dest, template_vars=None): template = template_env.get_template(src) if not template_vars: template_vars= {} - output_text = template.render(template_vars=template_vars) + output_text = template.render(**template_vars) if os.path.exists(dest): os.remove(dest) with open(dest, 'w') as f: