Merge pull request #230 from lnussel/master

some preparation to run as package
This commit is contained in:
Alberto Planas 2014-09-03 17:26:44 +02:00
commit 7f2f65b064
17 changed files with 117 additions and 14 deletions

26
Makefile Normal file
View File

@ -0,0 +1,26 @@
SUBDIRS = factory-package-news
prefix=/usr
datadir=$(prefix)/share
sysconfdir=/etc
unitdir=$(prefix)/lib/systemd/system
pkgdatadir=$(datadir)/osc-plugin-factory
oscplugindir=$(prefix)/lib/osc-plugins
pkgdata_SCRIPTS=$(wildcard *.py *.pl *.sh)
pkgdata_SCRIPTS+=bs_mirrorfull findfileconflicts
pkgdata_DATA+=bs_copy osclib $(wildcard *.pm *.testcase)
repocheckerhome = /var/lib/opensuse-repo-checker
all:
install:
install -d -m 755 $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(unitdir) $(DESTDIR)$(oscplugindir)
install -d -m 755 $(DESTDIR)$(repocheckerhome)
for i in $(pkgdata_SCRIPTS); do install -m 755 $$i $(DESTDIR)$(pkgdatadir); done
chmod 644 $(DESTDIR)$(pkgdatadir)/osc-*.py
for i in $(pkgdata_DATA); do cp -a $$i $(DESTDIR)$(pkgdatadir); done
for i in osc-*.py osclib; do ln -s $(pkgdatadir)/$$i $(DESTDIR)$(oscplugindir)/$$i; done
for i in $(SUBDIRS); do $(MAKE) -C $$i install; done
install -m 644 systemd/* $(DESTDIR)$(unitdir)
.PHONY: all install

View File

@ -0,0 +1,13 @@
prefix=/usr
sysconfdir=/etc
apachedir=$(sysconfdir)/apache2/conf.d
unitdir=$(prefix)/lib/systemd/system
install:
install -d -m 755 $(DESTDIR)$(apachedir) $(DESTDIR)$(unitdir) $(DESTDIR)$(sysconfdir)/rsyslog.d
install -m 644 systemd/* $(DESTDIR)$(unitdir)
install -m 644 rsyslog/* $(DESTDIR)$(sysconfdir)/rsyslog.d
install -m 644 apache/factory-package-news.conf $(DESTDIR)$(apachedir)/factory-package-news.conf.in
install -d -m 755 $(DESTDIR)/var/lib/factory-package-news
.PHONY: install

View File

@ -0,0 +1,11 @@
WSGIDaemonProcess factory-package-news user=_factory-news group=nogroup display-name=%{GROUP}
WSGIProcessGroup factory-package-news
WSGIScriptAlias /factory-package-news /usr/share/osc-plugin-factory/factory-package-news/factory-package-news-web.py
<Directory /usr/share/osc-plugin-factory/factory-package-news>
<Files factory-package-news-web.py>
Order allow,deny
Allow from all
</Files>
</Directory>

View File

@ -1,4 +0,0 @@
WSGIDaemonProcess factory-package-news user=FIXME group=FIXME display-name=%{GROUP}
WSGIProcessGroup factory-package-news
WSGIScriptAlias /factory-package-news FIXME/osc-plugin-factory/factory-package-news/factory-package-news-web.py

View File

@ -0,0 +1,5 @@
if ($programname == 'factory-package-news') then {
$template factorypackagenewsfile,"/var/log/factory-package-news/%$NOW%"
-?factorypackagenewsfile;RSYSLOG_TraditionalFileFormat
stop
}

View File

@ -0,0 +1,8 @@
[Unit]
Description=Announce new Factory snapshots
[Service]
ExecStart=/usr/share/osc-plugin-factory/factory-package-news/announcer.py --from "Ludwig Nussel <ludwig.nussel@suse.de>" --to lnussel@suse.de --relay relay.suse.de
WorkingDirectory=/var/lib/factory-package-news
User=factoryauto
SyslogIdentifier=factory-package-news

View File

@ -0,0 +1,9 @@
[Unit]
Description=Regular Factory snapshot announcer
[Timer]
OnCalendar=hourly
AccuracySec=30m
[Install]
WantedBy=timers.target

View File

@ -31,8 +31,8 @@ from osc import cmdln
# Expand sys.path to search modules inside the pluging directory
_plugin_dir = os.path.expanduser('~/.osc-plugins')
sys.path.append(_plugin_dir)
PLUGINDIR = os.path.expanduser(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(PLUGINDIR)
from osclib.checkrepo import CheckRepo
from osclib.cycle import CycleDetector
from osclib.memoize import CACHEDIR
@ -341,7 +341,7 @@ def _check_repo_group(self, id_, requests, debug=False):
os.unlink(target)
os.symlink(d, target)
repochecker = os.path.join(self.plugin_dir, 'repo-checker.pl')
repochecker = os.path.join(PLUGINDIR, 'repo-checker.pl')
civs = "LC_ALL=C perl %s '%s' -r %s -f %s" % (repochecker, destdir, self.repo_dir, params_file.name)
p = subprocess.Popen(civs, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
stdoutdata, stderrdata = p.communicate()
@ -512,10 +512,8 @@ def do_check_repo(self, subcmd, opts, *args):
groups[request.group] = rqs
# Mirror the packages locally in the CACHEDIR
plugin = '~/.osc-plugins/osc-check_repo.py'
self.plugin_dir = os.path.dirname(os.path.realpath(os.path.expanduser(plugin)))
self.repo_dir = '%s/repo-%s-%s-x86_64' % (CACHEDIR, 'openSUSE:{}'.format(opts.project), 'standard')
self._mirror_full(self.plugin_dir, self.repo_dir)
self._mirror_full(PLUGINDIR, self.repo_dir)
print
print 'Analysis results'

View File

@ -17,8 +17,8 @@ from datetime import date
from osc import cmdln, oscerr
# Expand sys.path to search modules inside the pluging directory
_plugin_dir = os.path.expanduser('~/.osc-plugins')
sys.path.append(_plugin_dir)
PLUGINDIR = os.path.expanduser(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(PLUGINDIR)
from osclib.stagingapi import StagingAPI
from osclib.comments import CommentAPI

View File

@ -25,8 +25,9 @@ except:
import pickle
from xdg.BaseDirectory import save_cache_path
# Where the cache files are stored
CACHEDIR = '/var/cache/repo-checker'
CACHEDIR = save_cache_path('opensuse-repo-checker')
def memoize(ttl=None):

View File

@ -171,7 +171,7 @@ sub mirror_repo($$$) {
my $repo = shift;
my $arch = shift;
my $repodir = "/var/cache/repo-checker/repo-$project-$repo-$arch";
my $repodir = ($ENV{XDG_CACHE_HOME}||<~>."/.cache")."/opensuse-repo-checker/repo-$project-$repo-$arch";
mkdir($repodir);
system(

View File

@ -1,6 +1,7 @@
PyYAML
pycurl
urlgrabber
pyxdg
git+https://github.com/openSUSE/osc
# Dependencies for testing

View File

@ -0,0 +1,2 @@
[Unit]
Description=openSUSE repo checker

View File

@ -0,0 +1,8 @@
[Unit]
Description=openSUSE repo checker for %i
PartOf=opensuse-repo-checker.target
[Service]
ExecStart=/usr/bin/osc check_repo -p %i --dry
User=_opensuse-repo-checker
SyslogIdentifier=opensuse-repo-checker

View File

@ -0,0 +1,9 @@
[Unit]
Description=openSUSE repochecker for %i
[Timer]
OnUnitInactiveSec=15m
AccuracySec=5m
[Install]
WantedBy=timers.target

View File

@ -0,0 +1,7 @@
[Unit]
Description=openSUSE Factory ToTest Manager
[Service]
ExecStart=/usr/bin/osc totest
User=_opensuse-totest-manager
SyslogIdentifier=opensuse-totest-manager

View File

@ -0,0 +1,9 @@
[Unit]
Description=openSUSE Factory ToTest Manager Timer
[Timer]
OnUnitInactiveSec=15m
AccuracySec=5m
[Install]
WantedBy=timers.target