Skip to content

Commit

Permalink
Add cpe_vendor, cpe_product package fields (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed May 5, 2020
1 parent c04131e commit c62bdca
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 0 deletions.
12 changes: 12 additions & 0 deletions repology/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ class Package:

'extrafields',

'cpe_vendor',
'cpe_product',

# calculated
'effname',

Expand Down Expand Up @@ -195,6 +198,9 @@ class Package:

extrafields: Dict[str, str]

cpe_vendor: Optional[str]
cpe_product: Optional[str]

effname: str

version: str
Expand Down Expand Up @@ -237,6 +243,9 @@ def __init__(self, *,

extrafields: Optional[Dict[str, str]] = None,

cpe_vendor: Optional[str] = None,
cpe_product: Optional[str] = None,

flags: int = 0,
shadow: bool = False,
flavors: Optional[List[str]] = None,
Expand Down Expand Up @@ -267,6 +276,9 @@ def __init__(self, *,

self.extrafields = extrafields if extrafields else {}

self.cpe_vendor = cpe_vendor
self.cpe_product = cpe_product

# calculated
self.effname = effname

Expand Down
16 changes: 16 additions & 0 deletions repology/packagemaker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class PackageTemplate:

'extrafields',

'cpe_vendor',
'cpe_product',

'flavors',
]

Expand All @@ -72,6 +75,9 @@ class PackageTemplate:

extrafields: Dict[str, str]

cpe_vendor: Optional[str]
cpe_product: Optional[str]

flavors: List[str]

def __init__(self) -> None:
Expand All @@ -93,6 +99,9 @@ def __init__(self) -> None:

self.extrafields = {}

self.cpe_vendor = None
self.cpe_product = None

self.flavors = []


Expand Down Expand Up @@ -262,6 +271,10 @@ def set_flags(self, mask: int, is_set: bool = True) -> None:
def set_extra_field(self, key: str, value: str) -> None:
self._package.extrafields[key] = value

def add_cpe(self, vendor: str, product: str) -> None:
self._package.cpe_vendor = vendor
self._package.cpe_product = product

def spawn(self, repo: str, family: str, subrepo: Optional[str] = None, shadow: bool = False, default_maintainer: Optional[str] = None) -> Package:
maintainers: List[str] = self._package.maintainers if self._package.maintainers else [default_maintainer] if default_maintainer else []

Expand Down Expand Up @@ -308,6 +321,9 @@ def spawn(self, repo: str, family: str, subrepo: Optional[str] = None, shadow: b

extrafields=self._package.extrafields,

cpe_vendor=self._package.cpe_vendor,
cpe_product=self._package.cpe_product,

flavors=self._package.flavors,

# XXX: see comment for PackageStatus.UNPROCESSED
Expand Down
3 changes: 3 additions & 0 deletions repology/test/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def check_package(self, reference: Dict[str, Any]) -> None:
'branch': None,

'extrafields': {},

'cpe_vendor': None,
'cpe_product': None,
}

# not relevant here
Expand Down
6 changes: 6 additions & 0 deletions sql.d/packages/add_packages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ INSERT INTO incoming_packages (

extrafields,

cpe_vendor,
cpe_product,

-- calculated
effname,

Expand Down Expand Up @@ -85,6 +88,9 @@ INSERT INTO incoming_packages (

%(extrafields)s,

%(cpe_vendor)s,
%(cpe_product)s,

-- calculated
%(effname)s,

Expand Down
3 changes: 3 additions & 0 deletions sql.d/update/create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ CREATE TABLE packages (

extrafields jsonb NOT NULL,

cpe_vendor text NULL,
cpe_product text NULL,

-- calculated
effname text NOT NULL,
version text NOT NULL,
Expand Down
6 changes: 6 additions & 0 deletions sql.d/update/update_apply_packages.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ INSERT INTO packages (

extrafields,

cpe_vendor,
cpe_product,

effname,

version,
Expand Down Expand Up @@ -93,6 +96,9 @@ INSERT INTO packages (

extrafields,

cpe_vendor,
cpe_product,

effname,

version,
Expand Down
3 changes: 3 additions & 0 deletions sql.d/update/update_start.sql
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ CREATE TEMPORARY TABLE incoming_packages (

extrafields jsonb NOT NULL,

cpe_vendor text NULL,
cpe_product text NULL,

-- calculated
effname text NOT NULL,
version text NOT NULL,
Expand Down

0 comments on commit c62bdca

Please sign in to comment.