Initial commit
This commit is contained in:
0
packaging_scripts/__init__.py
Normal file
0
packaging_scripts/__init__.py
Normal file
BIN
packaging_scripts/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
packaging_scripts/__pycache__/__init__.cpython-37.pyc
Normal file
Binary file not shown.
BIN
packaging_scripts/__pycache__/pacmanconf.cpython-37.pyc
Normal file
BIN
packaging_scripts/__pycache__/pacmanconf.cpython-37.pyc
Normal file
Binary file not shown.
BIN
packaging_scripts/__pycache__/pkgfiles.cpython-37.pyc
Normal file
BIN
packaging_scripts/__pycache__/pkgfiles.cpython-37.pyc
Normal file
Binary file not shown.
47
packaging_scripts/pacmanconf.py
Normal file
47
packaging_scripts/pacmanconf.py
Normal file
@ -0,0 +1,47 @@
|
||||
"""Module for config file helper functions."""
|
||||
|
||||
import configparser
|
||||
import pathlib
|
||||
|
||||
PACMAN_CONF = pathlib.Path('/etc/pacman.conf')
|
||||
|
||||
|
||||
def parse_configfile(filepath):
|
||||
"""Parse a config file given its path and return
|
||||
a ConfigParser object.
|
||||
|
||||
:param path: path to config file to parse
|
||||
:type path: str, bytes, or path-like object
|
||||
:returns: object used to parse config file
|
||||
:rtype: ConfigParser object
|
||||
:raises: FileNotFoundError if path does not exist
|
||||
"""
|
||||
if not pathlib.Path(filepath).is_file():
|
||||
raise FileNotFoundError(f"{filepath} does not exist")
|
||||
|
||||
config_reader = configparser.ConfigParser(strict=False,
|
||||
allow_no_value=True)
|
||||
config_reader.read(filepath)
|
||||
|
||||
return config_reader
|
||||
|
||||
|
||||
def list_configured_repos():
|
||||
"""Read /etc/pacman.conf to list all configured repositories.
|
||||
|
||||
:raises FileNotFoundError: if config file does not exist
|
||||
:returns: all repos configured on the system
|
||||
:rtype: list
|
||||
"""
|
||||
if not PACMAN_CONF.is_file():
|
||||
raise FileNotFoundError(f"{PACMAN_CONF} was not found")
|
||||
|
||||
parsed_config = parse_configfile(PACMAN_CONF)
|
||||
|
||||
repos = parsed_config.sections()
|
||||
# remove the 'option' entry from the list
|
||||
del repos[0]
|
||||
|
||||
repos.sort()
|
||||
|
||||
return repos
|
24
packaging_scripts/pkgfiles.py
Normal file
24
packaging_scripts/pkgfiles.py
Normal file
@ -0,0 +1,24 @@
|
||||
"""Helper functions for dealing with package files."""
|
||||
|
||||
import pathlib
|
||||
|
||||
PKGEXT = 'pkg.tar.xz'
|
||||
SIGEXT = f"{PKGEXT}.sig"
|
||||
|
||||
def get_pkgfiles(directory=None, signatures=False):
|
||||
"""Return a list of package files in the current working directory.
|
||||
|
||||
:param directory: a directory to search in
|
||||
:type directory: str, bytes, or path-like object
|
||||
:returns: paths of package files
|
||||
:rtype: list
|
||||
"""
|
||||
if directory:
|
||||
path = pathlib.Path(directory)
|
||||
else:
|
||||
path = pathlib.Path.cwd()
|
||||
|
||||
if signatures:
|
||||
return list(path.glob(f"*.{SIGEXT}"))
|
||||
|
||||
return list(path.glob(f"*.{PKGEXT}"))
|
17
packaging_scripts/zsh-completions/_addpkg
Normal file
17
packaging_scripts/zsh-completions/_addpkg
Normal file
@ -0,0 +1,17 @@
|
||||
#compdef addpkg
|
||||
|
||||
# zsh completions for 'addpkg'
|
||||
# automatically generated with http://github.com/RobSis/zsh-completion-generator
|
||||
local arguments
|
||||
|
||||
arguments=(
|
||||
{-h,--help}'[show this help message and exit]'
|
||||
{-C,--compression-type}'[the compression algorithm the db is using]'
|
||||
{-c,--clean-cachedir}'[use paccache to clean the cache directory]'
|
||||
{-R,--remove}'[remove old package files]'
|
||||
{-s,--sign}'[sign repository file]'
|
||||
{-v,--verbose}'[increase script verbosity]'
|
||||
'*:filename:_files'
|
||||
)
|
||||
|
||||
_arguments -s $arguments
|
15
packaging_scripts/zsh-completions/_delpkg
Normal file
15
packaging_scripts/zsh-completions/_delpkg
Normal file
@ -0,0 +1,15 @@
|
||||
#compdef delpkg
|
||||
|
||||
# zsh completions for 'delpkg'
|
||||
# automatically generated with http://github.com/RobSis/zsh-completion-generator
|
||||
local arguments
|
||||
|
||||
arguments=(
|
||||
{-c,--clean-cachedir}'[run paccache to clean the cache directory]'
|
||||
{-h,--help}'[show this help message and exit]'
|
||||
{-s,--sign}'[sign repository file]'
|
||||
{-v, --verbose}'[increase script verbosity]'
|
||||
'*:filename:_files'
|
||||
)
|
||||
|
||||
_arguments -s $arguments
|
Reference in New Issue
Block a user