mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-26 19:58:50 +01:00
Added checks file
This commit is contained in:
parent
1173107541
commit
085845b2ac
1 changed files with 51 additions and 0 deletions
51
slpkg/checks.py
Normal file
51
slpkg/checks.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
|
||||
from slpkg.metadata import Metadata
|
||||
from slpkg.queries import SBoQueries
|
||||
from slpkg.blacklist import Blacklist
|
||||
|
||||
|
||||
@dataclass
|
||||
class Check:
|
||||
log_packages: str = Metadata.log_packages
|
||||
repo_tag: str = Metadata.repo_tag
|
||||
|
||||
def exists(self, slackbuilds):
|
||||
''' Checking if the slackbuild exists in the repository. '''
|
||||
self.database()
|
||||
for sbo in slackbuilds:
|
||||
if not SBoQueries(sbo).slackbuild():
|
||||
raise SystemExit(f'\nPackage {sbo} does not exists.\n')
|
||||
|
||||
def unsupported(self, slackbuilds):
|
||||
''' Checking for unsupported slackbuilds. '''
|
||||
for sbo in slackbuilds:
|
||||
sources = SBoQueries(sbo).sources()
|
||||
if 'UNSUPPORTED' in sources:
|
||||
raise SystemExit(f'\nPackage {sbo} unsupported by arch.\n')
|
||||
|
||||
def installed(self, slackbuilds):
|
||||
''' Checking for installed packages. '''
|
||||
for package in os.listdir(self.log_packages):
|
||||
for sbo in slackbuilds:
|
||||
if sbo + '-' in package and self.repo_tag in package:
|
||||
return
|
||||
raise SystemExit('\nNot found packages for remove.\n')
|
||||
|
||||
def blacklist(self, slackbuilds):
|
||||
''' Checking for packages on the blacklist and removing them. '''
|
||||
black = Blacklist()
|
||||
for package in black.get():
|
||||
if package in slackbuilds:
|
||||
slackbuilds.remove(package)
|
||||
return slackbuilds
|
||||
|
||||
def database(self):
|
||||
''' Checking for empty table '''
|
||||
if not SBoQueries('').names():
|
||||
raise SystemExit('\nYou need to update the package lists first.\n'
|
||||
'Please run slpkg update.\n')
|
Loading…
Add table
Reference in a new issue