| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# |
| 3 |
# Copyright (C) 2017-2018 Matthias Klumpp <[email protected]> |
| 4 |
# Copyright (c) 2012-2013 Paul Tagliamonte <[email protected]> |
| 5 |
# |
| 6 |
# Licensed under the GNU Lesser General Public License Version 3 |
| 7 |
# |
| 8 |
# This program is free software: you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU Lesser General Public License as published by |
| 10 |
# the Free Software Foundation, either version 3 of the license, or |
| 11 |
# (at your option) any later version. |
| 12 |
# |
| 13 |
# This software is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU Lesser General Public License for more details. |
| 17 |
# |
| 18 |
# You should have received a copy of the GNU Lesser General Public License |
| 19 |
# along with this software. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
|
| 21 |
import logging as log |
| 22 |
|
| 23 |
from firehose.model import Analysis, Metadata, Generator, DebianBinary, DebianSource |
| 24 |
|
| 25 |
|
| 26 |
def generate_sut_from_source(name, version, arch): |
| 27 |
local = None |
| 28 |
if "-" in version: |
| 29 |
version, local = version.rsplit("-", 1) |
| 30 |
return DebianSource(name, version, local) |
| 31 |
|
| 32 |
|
| 33 |
def generate_sut_from_binary(name, version, arch): |
| 34 |
local = None |
| 35 |
if "-" in version: |
| 36 |
version, local = version.rsplit("-", 1) |
| 37 |
return DebianBinary(name, version, local, arch) |
| 38 |
|
| 39 |
|
| 40 |
def create_firehose(ptype, package_name, package_version, arch, version_getter): |
| 41 |
log.debug("Initializing empty firehose report") |
| 42 |
sut = {"source": generate_sut_from_source, "binary": generate_sut_from_binary}[ptype]( |
| 43 |
package_name, package_version, arch |
| 44 |
) |
| 45 |
|
| 46 |
gname_, gversion = version_getter() |
| 47 |
gname = "laniakea-spark/%s" % gname_ |
| 48 |
|
| 49 |
return Analysis( |
| 50 |
metadata=Metadata( |
| 51 |
generator=Generator(name=gname, version=gversion), sut=sut, file_=None, stats=None |
| 52 |
), |
| 53 |
results=[], |
| 54 |
) |