mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 00:04:15 +02:00
[gems.arch] enhancement: pacman.list_ignored_pkgs now use Python calls instead of system calls
This commit is contained in:
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
## [STAGING]
|
## [STAGING]
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
- Arch
|
||||||
|
- replaced some system calls by Python calls
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
- AppImage
|
- AppImage
|
||||||
- some desktop entries not being displayed on the desktop environment menu (requires the AppImage to be reinstalled) [#287](https://github.com/vinifmor/bauh/issues/287)
|
- some desktop entries not being displayed on the desktop environment menu (requires the AppImage to be reinstalled) [#287](https://github.com/vinifmor/bauh/issues/287)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import shutil
|
|||||||
import traceback
|
import traceback
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from typing import List, Set, Tuple, Dict, Iterable, Optional, Any
|
from typing import List, Set, Tuple, Dict, Iterable, Optional, Any, Pattern
|
||||||
|
|
||||||
from colorama import Fore
|
from colorama import Fore
|
||||||
|
|
||||||
@@ -26,6 +26,7 @@ RE_REMOVE_TRANSITIVE_DEPS = re.compile(r'removing\s([\w\-_]+)\s.+required\sby\s(
|
|||||||
RE_AVAILABLE_MIRRORS = re.compile(r'.+\s+OK\s+.+\s+(\d+:\d+)\s+.+(http.+)')
|
RE_AVAILABLE_MIRRORS = re.compile(r'.+\s+OK\s+.+\s+(\d+:\d+)\s+.+(http.+)')
|
||||||
RE_PACMAN_SYNC_FIRST = re.compile(r'SyncFirst\s*=\s*(.+)')
|
RE_PACMAN_SYNC_FIRST = re.compile(r'SyncFirst\s*=\s*(.+)')
|
||||||
RE_DESKTOP_FILES = re.compile(r'\n?([\w\-_]+)\s+(/usr/share/.+\.desktop)')
|
RE_DESKTOP_FILES = re.compile(r'\n?([\w\-_]+)\s+(/usr/share/.+\.desktop)')
|
||||||
|
RE_IGNORED_PACKAGES: Optional[Pattern] = None
|
||||||
|
|
||||||
|
|
||||||
def is_available() -> bool:
|
def is_available() -> bool:
|
||||||
@@ -234,22 +235,27 @@ def sign_key(key: str, root_password: Optional[str]) -> SystemProcess:
|
|||||||
|
|
||||||
def list_ignored_packages(config_path: str = '/etc/pacman.conf') -> Set[str]:
|
def list_ignored_packages(config_path: str = '/etc/pacman.conf') -> Set[str]:
|
||||||
ignored = set()
|
ignored = set()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pacman_conf = new_subprocess(['cat', config_path])
|
with open(config_path, 'r') as f:
|
||||||
grep = new_subprocess(['grep', '-Eo', r'\s*#*\s*ignorepkg\s*=\s*.+'], stdin=pacman_conf.stdout)
|
file_content = f.read()
|
||||||
for o in grep.stdout:
|
|
||||||
if o:
|
|
||||||
line = o.decode().strip()
|
|
||||||
|
|
||||||
if not line.startswith('#'):
|
global RE_IGNORED_PACKAGES
|
||||||
ignored.add(line.split('=')[1].strip())
|
|
||||||
|
|
||||||
pacman_conf.terminate()
|
if not RE_IGNORED_PACKAGES:
|
||||||
grep.terminate()
|
RE_IGNORED_PACKAGES = re.compile(r'[\s#]*ignorepkg\s*=\s*.+', re.IGNORECASE)
|
||||||
return ignored
|
|
||||||
except:
|
for raw_line in RE_IGNORED_PACKAGES.findall(file_content):
|
||||||
|
line = raw_line.strip()
|
||||||
|
|
||||||
|
if line and not line.startswith("#"):
|
||||||
|
ignored.add(line.split("=")[1].strip())
|
||||||
|
except (FileNotFoundError, OSError):
|
||||||
|
pass
|
||||||
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return ignored
|
|
||||||
|
return ignored
|
||||||
|
|
||||||
|
|
||||||
def check_missing(names: Set[str]) -> Set[str]:
|
def check_missing(names: Set[str]) -> Set[str]:
|
||||||
|
|||||||
@@ -98,4 +98,4 @@ Include = /etc/pacman.d/mirrorlist
|
|||||||
#Server = file:///home/custompkgs
|
#Server = file:///home/custompkgs
|
||||||
ignorepkg=google-chrome
|
ignorepkg=google-chrome
|
||||||
# ignorepkg=abc
|
# ignorepkg=abc
|
||||||
ignorepkg = firefox
|
IgnorePkg = firefox
|
||||||
Reference in New Issue
Block a user