...
 
Commits (7)
#! /usr/bin/env python3
##
# A small utility to check for new project releases that need packaging
##
import re
import os
import pathlib
import logging
import smtplib
from email.message import EmailMessage
from github import Github
from github.GithubException import UnknownObjectException
def get_package_versions():
"""Read the spec files and extract the github repo names and versions"""
spec_versions = {}
spec_path = pathlib.Path("./")
for spec in spec_path.glob("*.spec"):
with open(spec) as f:
project = None
version = None
# this is fairly brittle, parsing the specfile would be much cleaner.
lines = f.readlines()
for line in lines:
if line.startswith("Version"):
version = line.split(":")[-1].strip()
if line.startswith("source0"):
url = line[line.find(":")+1:].strip()
match = re.match( r'https://github.com/([^/]+)/([^/]+)/archive/*', url )
if match:
project = "{}/{}".format(match.group(1), match.group(2))
if project and version:
spec_versions[project] = version
return spec_versions
# for all projects fetch the latest version and download urls
def get_releases(packages, api_key=None):
"""Use the github api to fetch releases for each one"""
if not api_key:
api_key = os.environ['GITHUB_API_KEY']
g = Github(api_key)
outdated = {}
for (project, packaged_version) in packages.items():
repo = g.get_repo(project)
try:
release = repo.get_latest_release()
release_version = release.tag_name
# clean up the tag name
if release_version[0] == "v" or release_version[0] == "V":
release_version = release_version[1:]
if release_version != packaged_version:
outdated[project] = (release_version, packaged_version, release.html_url)
logging.warning("project %s (release %s) doesn't match packaged version (%s)", project, release_version, packaged_version)
except UnknownObjectException as e:
logging.warning("project %s has no releases, cannot check version infomation", project)
return outdated
def send_email(user, outdated):
msg = EmailMessage()
mail_user = os.environ['EMAIL_NOTIFY_USER']
mail_pass = os.environ['EMAIL_NOTIFY_PASS']
text = "There were outdated packages in your set:\n"
for (project,data) in outdated.items():
text += "{}, last version: {}, package version: {}, details: {}".format(project, *data)
msg.set_content(text)
msg['Subject'] = "packages need update"
msg['From'] = mail_user+"@fossgalaxy.com"
msg['to'] = user
with smtplib.SMTP("mail.fossgalaxy.com", port=587) as s:
s.starttls()
s.login(mail_user, mail_pass)
s.send_message(msg)
s.quit()
if __name__ == '__main__':
packages = get_package_versions()
outdated = get_releases(packages)
if outdated:
send_email("webpigeon@fossgalaxy.com", outdated)
for (project, data) in outdated.items():
print(project, data)
Name: mako
Version: 1.2
Release: 4%{?dist}
Version: 1.4
Release: 1%{?dist}
Summary: A lightweight Wayland notification daemon
License: MIT
......@@ -45,6 +45,9 @@ A lightweight notification daemon for Wayland.
%license LICENSE
%changelog
* Tue Sep 24 2019 Joseph Walton-Rivers <webpigeon@fossgalaxy.com> - 1.4
- Bump version to 1.4
* Fri Aug 16 2019 Joseph Walton-Rivers <webpigeon@fossgalaxy.com> - 1.2-4
- use pkgconfig versions of dependencies
......
Name: sway
Version: 1.2.0
Release: 1%{?dist}
Summary: i3-compatible Wayland compositor
License: MIT
# The source was pulled from github
source0: https://github.com/swaywm/sway/archive/v%{version}.tar.gz
#Source0: v1.2.0.tar.gz
BuildRequires: gcc
BuildRequires: meson
BuildRequires: git
BuildRequires: pkgconfig(wlroots)
BuildRequires: pkgconfig(wayland)
BuildRequires: pkgconfig(wayland-protocols)
BuildRequires: pkgconfig(pcre)
BuildRequires: pkgconfig(json-c)
BuildRequires: pkgconfig(pango)
BuildRequires: pkgconfig(cairo)
BuildRequires: pkgconfig(gdk-pixbuf2)
BuildRequires: pkgconfig(scdoc)
%description
%{summary}.
%prep
%setup
%build
%meson
%meson_build
%install
%meson_install
%check
%meson_test
%files
%{_bindir}/sway
%{_mandir}/man1/sway.1*
Name: wlroots
Version: 1.2.0
Release: 1%{?dist}
Summary: A modular Wayland compositor library
License: MIT
# The source was pulled from github
source0: https://github.com/swaywm/wlroots/archive/v%{version}.tar.gz
#Source0: v1.2.0.tar.gz
BuildRequires: gcc
BuildRequires: meson
BuildRequires: git
BuildRequires: pkgconfig(wayland)
BuildRequires: pkgconfig(wayland-protocols)
BuildRequires: pkgconfig(EGL)
BuildRequires: pkgconfig(GLESv2)
BuildRequires: pkgconfig(libdrm)
BuildRequires: pkgconfig(GBM)
BuildRequires: pkgconfig(libinput)
BuildRequires: pkgconfig(xkbcommon)
BuildRequires: pkgconfig(udev)
BuildRequires: pkgconfig(pixman)
BuildRequires: pkgconfig(systemd)
BuildRequires: pkgconfig(libcap)
# x11 support - TODO
%description
%{summary}.
%prep
%setup
%build
%meson
%meson_build
%install
%meson_install
%check
%meson_test
%files
%{_bindir}/sway
%{_mandir}/man1/sway.1*