-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26f1680
commit e495571
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Basic tests, such as repos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python3 | ||
# label <[email protected]> | ||
import datetime | ||
import sys | ||
import dnf | ||
import dnf.exceptions | ||
|
||
# pylint: disable=unnecessary-lambda-assignment | ||
now = datetime.datetime.today().strftime("%m-%d-%Y %T") | ||
|
||
class DnfQuiet(dnf.Base): | ||
""" | ||
DNF object | ||
This is in the event we need special functions | ||
""" | ||
def __init__(self): | ||
dnf.Base.__init__(self) | ||
|
||
def main(): | ||
""" | ||
Main run | ||
""" | ||
dnfobj = DnfQuiet() | ||
releasever = dnfobj.conf.releasever | ||
try: | ||
dnfobj.read_all_repos() | ||
# pylint: disable=bare-except | ||
except: | ||
print(f'[-] {now} -> Could not read repos', file=sys.stderr) | ||
sys.exit(1) | ||
|
||
rocky_default_repos = { | ||
'8': ['baseos', 'appstream', 'extras'], | ||
'9': ['baseos', 'appstream', 'extras'] | ||
}.get(releasever, None) | ||
|
||
if not rocky_default_repos: | ||
print(f'[-] {now} -> Not a Rocky Linux system') | ||
sys.exit(1) | ||
|
||
print(f'[-] {now} -> Checking if non-default repo is enabled') | ||
_not_allowed=False | ||
for repo in list(dnfobj.repos.iter_enabled()): | ||
if not repo.id in rocky_default_repos: | ||
print(f'[-] {now} -> {repo.id} is enabled and should be disabled') | ||
_not_allowed=True | ||
if _not_allowed: | ||
print(f'[-] {now} -> FAIL - There are extra repos enabled') | ||
sys.exit(1) | ||
|
||
print(f'[-] {now} -> PASS') | ||
sys.exit(0) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters