Code cleanup for add_pkgfiles in addpkg
This commit is contained in:
parent
31d17b910c
commit
89e9673132
26
bin/addpkg
26
bin/addpkg
@ -9,6 +9,7 @@ Functions:
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -37,27 +38,28 @@ syslog.addHandler(stderr_handler)
|
|||||||
|
|
||||||
|
|
||||||
# ========== Functions ==========
|
# ========== Functions ==========
|
||||||
def add_pkgfiles(cachedir, pkgs):
|
def add_pkgfiles(cachedir, pkgs=None):
|
||||||
""" Remove package files from the repository directory.
|
"""Add package files to the repository directory.
|
||||||
|
|
||||||
:param cachedir: directory to operate on
|
:param pkgs: names of packages to add
|
||||||
:type cachedir: str, bytes, or path-like object
|
|
||||||
:param pkgs: names of packages to remove
|
|
||||||
:type pkgs: any container object
|
:type pkgs: any container object
|
||||||
"""
|
"""
|
||||||
syslog.info(f"Adding package files to {cachedir}")
|
syslog.info(f"Adding package files to {cachedir}")
|
||||||
syslog.debug(f"Packages: {pkgs}")
|
syslog.debug(f"Packages: {pkgs}")
|
||||||
|
|
||||||
for pkg in pkgs:
|
if pkgs is not None:
|
||||||
for pkgfile in pkgfiles.get_pkgfiles(pkg, directory=cachedir) +\
|
pkglist = pkgs
|
||||||
pkgfiles.get_pkgfiles(pkg, directory=cachedir,
|
else:
|
||||||
signatures_only=True):
|
pkglist = pkgfiles.get_pkgfiles() +\
|
||||||
pkgfile.unlink()
|
pkgfiles.get_pkgfiles(signatures_only=True)
|
||||||
syslog.info(f"Added {pkgfile}")
|
|
||||||
|
for pkg in pkglist:
|
||||||
|
shutil.move(pkg, cachedir)
|
||||||
|
syslog.info(f"Added {pkg}")
|
||||||
|
|
||||||
|
|
||||||
def repo_add(db, pkgs, opts=None):
|
def repo_add(db, pkgs, opts=None):
|
||||||
""" Run repo-add.
|
"""Run repo-add.
|
||||||
|
|
||||||
:param repo: the repository to remove from
|
:param repo: the repository to remove from
|
||||||
:type repo: str
|
:type repo: str
|
||||||
|
Loading…
x
Reference in New Issue
Block a user