Commit 0e3b7a8e authored by onny's avatar onny
Browse files

hardened systemd file

parent 5b3fb81d
{
"temp_directory": "/tmp/arch-upstream",
"database_sources": [
"database_sources": [
"http://mirror.23media.de/archlinux/community/os/x86_64/community.db",
"http://mirror.23media.de/archlinux/core/os/x86_64/core.db",
"http://mirror.23media.de/archlinux/extra/os/x86_64/extra.db"
],
"repositories": [ "community", "core", "extra", "aur" ],
"anitya_db_dump_link": "https://infrastructure.fedoraproject.org/infra/db-dumps/anitya.dump.xz"
"anitya_db_dump_link": "https://infrastructure.fedoraproject.org/infra/db-dumps/anitya.dump.xz",
"report_directory" : ""
}
......@@ -48,7 +48,7 @@ class AUR:
package['name'] = response_row.findAll("td")[0].text
package['version'] = response_row.findAll("td")[1].text
package['version'] = package['version'].split('-')[0]
if "flagged" in response_row.findAll("td")[1]:
if "flagged" in str(response_row.findAll("td")[1]):
package['status'] = "Flagged"
else:
package['status'] = "Unknown"
......
......@@ -10,9 +10,8 @@ import lzma
class Database:
def __init__(self, package_database, config):
def __init__(self, package_database):
self.package_database = package_database
self.temp_directory = config['temp_directory']
self.pkglist = []
self.packages = []
......
......@@ -7,9 +7,11 @@ from progressbar import AnimatedMarker, Bar, BouncingBar, Counter, ETA, \
widgets = ['', Percentage(), ' ', SimpleProgress(format='(%(value)d of %(max_value)d)'), ' ', Bar(), ' ', Timer(), ' ', AdaptiveETA()]
from time import sleep
from config import Config
class Download:
def __init__(self, config):
def __init__(self):
self.database_sources = config['database_sources']
self.temp_directory = config['temp_directory']
self.package_database = []
......
......@@ -37,9 +37,11 @@ class Versioncheck:
bar = ProgressBar(widgets=widgets, max_value=len(packages))
for idx, package in enumerate(packages):
bar.update(idx)
if "AUR" not in package['repository'] and package['state'] == "outdated":
if package['state'] == "outdated" and package['repository'] != 'AUR':
status = self.check_repository_status(package['name'])
packages[idx]['status'] = status
packages[idx]['status'] = status
else:
packages[idx]['status'] = "Unknown"
bar.update(idx+1)
print("")
return packages
......
#!/usr/bin/python
import os
import json
from lib.download import Download
from lib.database import Database
from lib.versioncheck import Versioncheck
from lib.template import Template
from lib.aur import AUR
PATH = os.path.dirname(os.path.abspath(__file__))
def load_config(config):
data = []
with open(config) as json_data:
data =json.load(json_data)
os.makedirs(data['temp_directory'], exist_ok=True)
return data
if __name__ == '__main__':
# Loading configuration file
config = load_config('config/config.json')
# Downloading package database
package_database = Download(config).sync_repos()
Download(config).sync_upstream_database()
packages = Database(package_database, config).load_database()
sqlite_conn = Database(package_database, config).convert_upstream_database()
# Returns array of file objects
package_database = Download().sync_repos()
# Download release_monitoring database
# Returns file descriptor of db dump
database_dump = Download().sync_upstream_database()
# Get packages array from package databases
packages = Database().load_database(package_database)
# Convert upstream database to sqlite
# Returns sqlite connection
sqlite_conn = Database().convert_upstream_database(database_dump)
# Scrape AUR packages
aur_packages = AUR().scrape_packages()
packages = packages + aur_packages
packages = sorted(packages, key=lambda k: k['name'])
packages = Versioncheck(packages, sqlite_conn).compare_upstream()
packages = Versioncheck(packages, sqlite_conn).get_repository_status(packages)
# Compare package versions
packages = Versioncheck().compare_versions(packages, sqlite_conn)
# Get repository state (flagged state)
packages = Versioncheck().get_repository_status(packages)
Template(PATH, packages).write()
# Write HTML pages
Template(packages).write()
......@@ -54,7 +54,15 @@
{% endif %}
<td>{{ package['version'] }}</td>
<td><a target=new href=https://release-monitoring.org/projects/search/?pattern={{ package['name'] }}>{{ package['upstreamversion'] }}</a></td>
<td>Unknown</td>
{% if package['status'] == "Unknown" %}
<td><span class="red">{{ package['status'] }}</span></td>
{% endif %}
{% if package['status'] == "Testing" %}
<td><span class="light_orange">{{ package['status'] }}</span></td>
{% endif %}
{% if package['status'] == "Flagged" %}
<td><span class="orange">{{ package['status'] }}</span></td>
{% endif %}
</tr>
{% endif %}
{% endfor %}
......
<html><head>
<title>Upstream releases - Arch Linux Upstream Tracker</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="icon" href="https://security.archlinux.org/static/favicon.ico">
<link href="upstream_files/css.css" rel="stylesheet">
<link rel="stylesheet" href="upstream_files/normalize.css" type="text/css" media="all">
<link rel="stylesheet" href="upstream_files/style.css" type="text/css" media="all">
<link href="https://security.archlinux.org/advisory/feed.atom" rel="alternate" title="Recent advisories" type="application/atom+xml">
<link rel="stylesheet" type="text/css" href="upstream_files/socialwidgets.css"></head>
<body>
<div id="archnavbar">
<div id="logo"><a href="https://archlinux.org/">overview</a></div>
<div id="archnavbarmenu">
<ul id="archnavbarlist">
<li id="anb-home"><a href="https://archlinux.org/" title="Arch news, packages, projects and more">Home</a></li>
<li id="anb-packages"><a href="https://archlinux.org/packages/" title="Arch Package Database">Packages</a></li>
<li id="anb-forums"><a href="https://bbs.archlinux.org/" title="Community forums">Forums</a></li>
<li id="anb-wiki"><a href="https://wiki.archlinux.org/" title="Community documentation">Wiki</a></li>
<li id="anb-bugs"><a href="https://bugs.archlinux.org/" title="Report and track bugs">Bugs</a></li>
<li id="anb-security"><a href="#" title="Arch Linux Security Tracker">Upstream</a></li>
<li id="anb-aur"><a href="https://aur.archlinux.org/" title="Arch Linux User Repository">AUR</a></li>
<li id="anb-download"><a href="https://archlinux.org/download/" title="Get Arch Linux">Download</a></li>
</ul>
</div>
</div>
<div class="content">
<h1>Packages</h1>
<div class="navbar">
<ul>
<li><a href="upstream.html">outdated</a></li>
<li><a href="notlisted_aur.html">notlisted</a></li>
<li><a href="upstream_aur.html">outdated (AUR)</a></li>
<li><b>notlisted (AUR)</b></li>
</ul>
</div>
<div class="scroll-x">
<table class="styled-table full size">
<thead>
<tr>
<th>Package</th>
<th>Version</th>
<th>Upstream Version</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for package in packages %}
{% if package['state'] == "notlisted" and package['repository'] == 'AUR' %}
<tr>
{% if package['repository'] == "AUR" %}
<td><a target=new href=https://aur.archlinux.org/packages/{{ package['name'] }}>{{ package['name'] }}</a></td>
{% else %}
<td><a target=new href=https://www.archlinux.org/packages/?name={{ package['name'] }}>{{ package['name'] }}</a></td>
{% endif %}
<td>{{ package['version'] }}</td>
<td><a target=new href=https://release-monitoring.org/projects/search/?pattern={{ package['name'] }}>{{ package['upstreamversion'] }}</a></td>
{% if package['status'] == "Unknown" %}
<td><span class="red">{{ package['status'] }}</span></td>
{% endif %}
{% if package['status'] == "Testing" %}
<td><span class="light_orange">{{ package['status'] }}</span></td>
{% endif %}
{% if package['status'] == "Flagged" %}
<td><span class="orange">{{ package['status'] }}</span></td>
{% endif %}
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
<i>{{ count_aur_notlisted }} packages not listed. Page last updated: {{ date }} UTC</i>
<br><br>
</div>
</body></html>
<html><head>
<title>Upstream releases - Arch Linux Upstream Tracker</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="icon" href="https://security.archlinux.org/static/favicon.ico">
<link href="upstream_files/css.css" rel="stylesheet">
<link rel="stylesheet" href="upstream_files/normalize.css" type="text/css" media="all">
<link rel="stylesheet" href="upstream_files/style.css" type="text/css" media="all">
<link href="https://security.archlinux.org/advisory/feed.atom" rel="alternate" title="Recent advisories" type="application/atom+xml">
<link rel="stylesheet" type="text/css" href="upstream_files/socialwidgets.css"></head>
<body>
<div id="archnavbar">
<div id="logo"><a href="https://archlinux.org/">overview</a></div>
<div id="archnavbarmenu">
<ul id="archnavbarlist">
<li id="anb-home"><a href="https://archlinux.org/" title="Arch news, packages, projects and more">Home</a></li>
<li id="anb-packages"><a href="https://archlinux.org/packages/" title="Arch Package Database">Packages</a></li>
<li id="anb-forums"><a href="https://bbs.archlinux.org/" title="Community forums">Forums</a></li>
<li id="anb-wiki"><a href="https://wiki.archlinux.org/" title="Community documentation">Wiki</a></li>
<li id="anb-bugs"><a href="https://bugs.archlinux.org/" title="Report and track bugs">Bugs</a></li>
<li id="anb-security"><a href="#" title="Arch Linux Security Tracker">Upstream</a></li>
<li id="anb-aur"><a href="https://aur.archlinux.org/" title="Arch Linux User Repository">AUR</a></li>
<li id="anb-download"><a href="https://archlinux.org/download/" title="Get Arch Linux">Download</a></li>
</ul>
</div>
</div>
<div class="content">
<h1>Packages</h1>
<div class="navbar">
<ul>
<li><a href="outdated.html">outdated</a></li>
<li><a href="notlisted.html">notlisted</a></li>
<li><b>outdated (AUR)</b></li>
<li><a href="notlisted_aur.html">notlisted (AUR)</a></li>
</ul>
</div>
<div class="scroll-x">
<table class="styled-table full size">
<thead>
<tr>
<th>Package</th>
<th>Version</th>
<th>Upstream Version</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for package in packages %}
{% if package['state'] == "outdated" and package['repository'] == 'AUR' %}
<tr>
{% if package['repository'] == "AUR" %}
<td><a target=new href=https://aur.archlinux.org/packages/{{ package['name'] }}>{{ package['name'] }}</a></td>
{% else %}
<td><a target=new href=https://www.archlinux.org/packages/?name={{ package['name'] }}>{{ package['name'] }}</a></td>
{% endif %}
<td>{{ package['version'] }}</td>
<td><a target=new href=https://release-monitoring.org/projects/search/?pattern={{ package['name'] }}>{{ package['upstreamversion'] }}</a></td>
{% if package['status'] == "Unknown" %}
<td><span class="red">{{ package['status'] }}</span></td>
{% endif %}
{% if package['status'] == "Testing" %}
<td><span class="light_orange">{{ package['status'] }}</span></td>
{% endif %}
{% if package['status'] == "Flagged" %}
<td><span class="orange">{{ package['status'] }}</span></td>
{% endif %}
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
<i>{{ count_aur_outdated }} packages outdated. Page last updated: {{ date }} UTC</i>
<br><br>
</div>
</body></html>
......@@ -3,7 +3,14 @@ Description=Arch-Upstream
[Service]
Type=simple
User=archupstream
Group=archupstream
WorkingDirectory=/home/onny/www/files/arch-upstream
ExecStart=/home/onny/www/files/arch-upstream/main.py
User=onny
Group=onny
PrivateDevices=yes
PrivateTmp=yes
ProtectSystem=full
CapabilityBoundingSet=
ReadWriteDirectories=/usr/share/webapps/arch-upstream
ProtectHome=yes
NoNewPrivileges=yes
WorkingDirectory=/usr/share/webapps/arch-upstream
ExecStart=/usr/share/webapps/arch-upstream/main.py
[Unit]
Description=Run arch-upstream every 3 hours
Description=Run arch-upstream every 12 hours
[Timer]
# Time to wait after booting before we run first time
OnBootSec=10min
# Time between running each consecutive time
OnUnitActiveSec=3h
OnUnitActiveSec=12h
Unit=arch-upstream.service
[Install]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment