Working on jinja build for releases.peachcloud.org
This commit is contained in:
parent
15402be01d
commit
9ccd148a8e
|
@ -0,0 +1,67 @@
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import jinja2
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
|
|
||||||
|
PROJECT_PATH = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
# load jinja templates
|
||||||
|
template_path = os.path.join(PROJECT_PATH, 'templates')
|
||||||
|
template_loader = jinja2.FileSystemLoader(searchpath=template_path)
|
||||||
|
template_env = jinja2.Environment(loader=template_loader, keep_trailing_newline=True)
|
||||||
|
|
||||||
|
|
||||||
|
def render_template(src, dest, template_vars=None):
|
||||||
|
"""
|
||||||
|
helper function fo rendering jinja template
|
||||||
|
:param src: relative string path to jinja template file
|
||||||
|
:param dest: absolute string path of output destination file
|
||||||
|
:param template_vars: variables to render template with
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
template = template_env.get_template(src)
|
||||||
|
if not template_vars:
|
||||||
|
template_vars= {}
|
||||||
|
output_text = template.render(**template_vars)
|
||||||
|
if os.path.exists(dest):
|
||||||
|
os.remove(dest)
|
||||||
|
with open(dest, 'w') as f:
|
||||||
|
f.write(output_text)
|
||||||
|
|
||||||
|
|
||||||
|
# remove old files
|
||||||
|
os.remove(os.path.join(PROJECT_PATH, 'raspi_3.img'))
|
||||||
|
os.remove(os.path.join(PROJECT_PATH, 'raspi_3.log'))
|
||||||
|
|
||||||
|
# build img
|
||||||
|
subprocess.check_call(['make', 'raspi_3.img'])
|
||||||
|
|
||||||
|
# copy image and log to releases dir
|
||||||
|
today = date.today()
|
||||||
|
today_str = "{}{}{}".format(today.year, today.month, today.day)
|
||||||
|
release_dir = "/var/www/releases.peachcloud.org/html/peach-imgs/{}".format(today_str)
|
||||||
|
print("++ successful image build, copying output to {}", release_dir)
|
||||||
|
|
||||||
|
os.makedirs(release_dir)
|
||||||
|
img_path = os.path.join(PROJECT_PATH, 'raspi_3.img')
|
||||||
|
log_path = os.path.join(PROJECT_PATH, 'raspi_3.log')
|
||||||
|
release_img_name = "{}_peach_raspi3.img".format(today_str)
|
||||||
|
release_log_name = "{}_peach_raspi3.log".format(today_str)
|
||||||
|
img_release_path = os.path.join(release_dir, release_img_name)
|
||||||
|
log_release_path = os.path.join(release_dir, release_log_name)
|
||||||
|
subprocess.check_call(['cp', img_path, img_release_path])
|
||||||
|
subprocess.check_call(['cp', log_path, log_release_path])
|
||||||
|
|
||||||
|
|
||||||
|
# rebuild release index.html
|
||||||
|
release_index_path = "/var/www/releases.peachcloud.org/html/index.html"
|
||||||
|
release_img_url = img_release_path.replace('/var/www/releases.peachcloud.org/html/', '/')
|
||||||
|
render_template(
|
||||||
|
src="release_index.html",
|
||||||
|
dest=release_index_path,
|
||||||
|
template_vars={
|
||||||
|
"release_img_url": release_img_url,
|
||||||
|
"release_img_name": release_img_name,
|
||||||
|
}
|
||||||
|
)
|
|
@ -0,0 +1,49 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>PeachCloud Release Builds</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
width: 35em;
|
||||||
|
margin: 0 auto;
|
||||||
|
font-family: Tahoma, Verdana, Arial, sans-serif;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>PeachCloud Image Builds</h1>
|
||||||
|
<p>The latest PeachCloud disc image for Raspberry Pi 3+ with all PeachCloud microservices pre-installed.</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a href="{{release_img_url}}">{{release_img_name}}</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<hr>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<h1>PeachCloud Release Builds</h1>
|
||||||
|
<p>The latest aarch64 release builds of PeachCloud microservices and other software components.</p>
|
||||||
|
<ul>
|
||||||
|
<li><a href="/peach-buttons">peach-buttons</a> - 0.1.0</li>
|
||||||
|
<li><a href="/peach-menu">peach-menu</a> - 0.2.0</li>
|
||||||
|
<li><a href="/peach-monitor">peach-monitor</a> - 0.1.0</li>
|
||||||
|
<li><a href="/peach-network">peach-network</a> - 0.2.0</li>
|
||||||
|
<li><a href="/peach-oled">peach-oled</a> - 0.1.0</li>
|
||||||
|
<li><a href="/peach-stats">peach-stats</a> - 0.1.0</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>For online documentation please refer to
|
||||||
|
<a href="http://docs.peachcloud.org/">docs.peachcloud.org</a>.<br/>
|
||||||
|
Code repositories can be found at
|
||||||
|
<a href="https://github.com/peachcloud">github.com/peachcloud</a>.<br/>
|
||||||
|
Support our efforts at
|
||||||
|
<a href="https://opencollective.com/peachcloud">opencollective.com/peachcloud</a>.</p>
|
||||||
|
|
||||||
|
<p><em>Thank you for your interest in PeachCloud.</em></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue