Skip to content
Snippets Groups Projects
Commit 4db7ebf8 authored by Lars Beckers's avatar Lars Beckers
Browse files

add painintheapt package with custom patches

parent 4ed24ebe
Branches
No related tags found
No related merge requests found
image: stretch_packages
stages:
- build
- test
before_script:
- export LANG=en_US.UTF-8
- export LANG="en_US.UTF-8"
- export DEBIAN_FRONTEND="noninteractive"
- export DEBIAN_PRIORITY="critical"
- export DEBFULLNAME="FSMPI Admin-Team"
- export DEBEMAIL="admin@fsmpi.rwth-aachen.de"
- export QUILT_PATCHES="debian/patches"
sssd:
stage: build
......@@ -13,6 +18,8 @@ sssd:
artifacts:
paths:
- packages/*
only:
- master
adcli:
stage: build
......@@ -20,6 +27,8 @@ adcli:
artifacts:
paths:
- packages/*
only:
- master
nginx:
stage: build
......@@ -27,6 +36,8 @@ nginx:
artifacts:
paths:
- packages/*
only:
- master
ganeti:
stage: build
......@@ -34,6 +45,8 @@ ganeti:
artifacts:
paths:
- packages/*
only:
- master
grml-zsh-config:
stage: build
......@@ -41,6 +54,22 @@ grml-zsh-config:
artifacts:
paths:
- packages/*
only:
- master
stages:
- build
painintheapt:
stage: build
script: scripts/painintheapt.sh
artifacts:
paths:
- packages/*
install-grml-zsh-config:
stage: test
script: dpkg -i packages/grml-zsh-config*.deb
only:
- master
install-painintheapt:
stage: test
script: dpkg -i packages/painintheapt*.deb
diff --git a/painintheapt b/painintheapt
index 9c2a27e..5fd816d 100755
--- a/painintheapt
+++ b/painintheapt
@@ -11,12 +11,14 @@ import email.mime.text
import email.utils
import hashlib
import html
+import json
import os
import smtplib
import socket
import subprocess
import sys
import textwrap
+import urllib.request
# additional modules
import apt
@@ -255,6 +257,29 @@ def sendmailx(config, config_dir, table, count, host, debug, changes):
mailx.wait()
+def sendhttpjson(config, config_dir, table, count, host, debug, changes):
+ """Send JSON encoded data via HTTP request."""
+ url = config.get("url", "http://localhost")
+ username = config.get("username", "")
+ password = read_password(config, config_dir)
+ data = json.dumps({'host': host,
+ 'packages': table,
+ 'changes': changes}).encode("utf-8")
+ headers = {"Content-Type": "application/json; charset=utf-8",
+ "Content-Length": len(data),
+ "User-Agent": longname}
+ request = urllib.request.Request(url, data, headers)
+ if username and password:
+ password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
+ password_mgr.add_password(None, url, username, password)
+ handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
+ opener = urllib.request.build_opener(handler)
+ urllib.request.install_opener(opener)
+ elif password:
+ headers["Authorization"] = "Device " + password
+ urllib.request.urlopen(request)
+
+
def has_changed(configfile, table, stampfile):
change = False
hashsum = hashlib.sha1()
@@ -302,10 +327,13 @@ if __name__ == '__main__':
ret = 0
for section, function in [("XMPP", sendxmpp),
+ ("HTTP", sendhttpjson),
("SMTP", sendsmtp),
("MAILX", sendmailx)]:
try:
if section in config.sections() and (change or args.force):
+ if section == "HTTP":
+ table = updates
send_changes = config[section].getboolean("send_changes", True)
function(config[section], config_dir, table, count, fqdn,
args.debug, get_changelogs(cache, send_changes))
diff --git a/painintheapt b/painintheapt
index 5fd816d..505b160 100755
--- a/painintheapt
+++ b/painintheapt
@@ -23,7 +23,6 @@ import urllib.request
# additional modules
import apt
import prettytable
-import sleekxmpp
longname = "Pain in the APT"
shortname = "painintheapt"
@@ -118,54 +117,6 @@ def maketable(lst):
return table.get_string()
-class JabberBot(sleekxmpp.ClientXMPP):
- def __init__(self, jid, password, to, room, pubsub_service, pubsub_node,
- nick, subject, message):
- sleekxmpp.ClientXMPP.__init__(self, jid, password)
- self.to = to
- self.room = room
- self.pubsub_service = pubsub_service
- self.pubsub_node = pubsub_node
- self.nick = nick
- self.add_event_handler("session_start", self.start)
- self.subject = subject
- self.message = message
-
- def start(self, event):
- self.getRoster()
- self.sendPresence()
- for to in self.to:
- self.send_message(
- mto=to,
- msubject=self.subject,
- # subject is not shown by all clients, better add it to body
- mbody="\n".join([self.subject, self.message]),
- mtype='chat')
- if self.room:
- self.plugin['xep_0045'].joinMUC(self.room, self.nick, wait=True)
- self.send_message(
- mto=self.room,
- # no per message subject in groupchats, add it to message body
- mbody="\n".join([self.subject, self.message]),
- mtype='groupchat')
- if self.pubsub_service and self.pubsub_node:
- payload = '<entry xmlns="http://www.w3.org/2005/Atom"><title>' \
- + html.escape(self.subject) \
- + '</title><content type="xhtml">' \
- + '<pre xmlns="http://www.w3.org/1999/xhtml">' \
- + html.escape(self.message) \
- + '</pre></content></entry>'
- self['xep_0060'].publish(
- self.pubsub_service, self.pubsub_node,
- payload=sleekxmpp.xmlstream.ET.fromstring(payload))
- try:
- self.disconnect(wait=True)
- except TypeError: # older SleekXMPP doesn't have "wait"
- import time
- time.sleep(10)
- self.disconnect()
-
-
def read_password(config, config_dir):
password_file = config.get("password_file", "").strip()
if len(password_file):
@@ -177,31 +128,6 @@ def read_password(config, config_dir):
return config.get("password", "")
-def sendxmpp(config, config_dir, table, count, host, debug, changes):
- """Send message to a jabber conference room."""
- jid = config.get("jid", "")
- password = read_password(config, config_dir)
- to = config.get("to", "").split(",")
- room = config.get("room")
- pubsub_service = config.get("pubsub_service", "").strip()
- pubsub_node = config.get("pubsub_node", "").strip()
- subject = '%d package update(s) for %s' % (count, host)
- xmpp = JabberBot(
- jid, password, to, room, pubsub_service, pubsub_node,
- longname, subject, "\n\n".join([table, changes]).strip())
- xmpp.register_plugin('xep_0030') # service discovery
- if room:
- xmpp.register_plugin('xep_0045') # multi-user chat
- if pubsub_service and pubsub_node:
- xmpp.register_plugin('xep_0060') # pubsub
- xmpp.register_plugin('xep_0199') # XMPP ping
-
- if xmpp.connect():
- xmpp.process(threaded=False)
- else:
- raise("XMPP connect() failed")
-
-
def sendsmtp(config, config_dir, table, count, host, debug, changes):
"""Send email by SMTP to whomsoever it may concern."""
server = config.get("server", "localhost")
@@ -326,8 +252,7 @@ if __name__ == '__main__':
change, newhash = has_changed(args.configfile, table, args.stampfile)
ret = 0
- for section, function in [("XMPP", sendxmpp),
- ("HTTP", sendhttpjson),
+ for section, function in [("HTTP", sendhttpjson),
("SMTP", sendsmtp),
("MAILX", sendmailx)]:
try:
#!/bin/bash
echo "deb-src http://ftp.halifax.rwth-aachen.de/debian/ buster main" > /etc/apt/sources.list.d/buster_src.list
apt-get update
apt-get source --only-source -t buster painintheapt
VERSION=$(rmadison painintheapt --architecture=all -s buster | cut -d\| -f2 | sed s"/ //g" | sed s"/\-.*$//g")
cd painintheapt-$VERSION
for patch in ../patches/painintheapt/*.patch ; do
quilt import $patch
quilt push
done
sed -i '/python3-sleekxmpp/d' debian/control
sed -i 's/Build-Depends: debhelper (>= 11),/Build-Depends: debhelper (>= 10),/g' debian/control
echo "10" > debian/compat
mk-build-deps --install --remove --tool "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes"
dch --local ~bpo9+ --distribution stretch-backports "Rebuild for stretch-backports."
dch --preserve --newversion ${VERSION}-fsmpi "Add HTTP-JSON support."
dch --preserve --newversion ${VERSION}-fsmpi "Remove XMPP support."
debuild -us -uc -nc
debi --with-depends
cd ..
mkdir packages
mv *.deb packages
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment