From bc54dd803a6793d0935300d49ee3c2a63dad9d32 Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Sun, 10 Mar 2019 21:04:31 -0700 Subject: [PATCH] Add new flags -c and -d for overriding cachedir and database filenames --- PKGBUILD | 2 +- bin/addpkg | 23 +++++++++++++++++++---- bin/delpkg | 23 +++++++++++++++++++---- packaging_scripts/zsh-completions/_addpkg | 2 ++ packaging_scripts/zsh-completions/_delpkg | 2 ++ setup.py | 2 +- 6 files changed, 44 insertions(+), 10 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index b911c20..322a47a 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: Eric Torres pkgname=packaging-scripts -pkgver=1.0.3 +pkgver=1.1 pkgrel=1 pkgdesc="A set of helper scripts for handling Arch Linux packages" arch=('any') diff --git a/bin/addpkg b/bin/addpkg index 843765b..35f8958 100644 --- a/bin/addpkg +++ b/bin/addpkg @@ -58,6 +58,16 @@ def add_pkgfile(pkgfile, cachedir): if __name__ == "__main__": parser = argparse.ArgumentParser() + parser.add_argument( + "-c", + "--cachedir", + help="alternative directory to use for moving package" + ) + parser.add_argument( + "-d", + "--db-filename", + help="alternative filename for database without extension" + ) parser.add_argument( "-s", "--sign", @@ -86,10 +96,15 @@ if __name__ == "__main__": else: opts = args.opts - cachedir = os.path.join("/var", "cache", "pacman", repo) - # this assumes that the db file for the repo - # has the same name as that repo - db = os.path.join(cachedir, f"{repo}.{DB_EXT}") + if args.cachedir is not None: + cachedir = args.cachedir + else: + cachedir = os.path.join("/var", "cache", "pacman", repo) + + if args.db-filename is not None: + db = os.path.join(cachedir, f"{args.db-filename}.{DB_EXT}") + else: + db = os.path.join(cachedir, f"{repo}.{DB_EXT}") if args.verbose: stdout_handler.setLevel(logging.DEBUG) diff --git a/bin/delpkg b/bin/delpkg index 5c97afb..d900d9d 100644 --- a/bin/delpkg +++ b/bin/delpkg @@ -53,6 +53,16 @@ def del_pkgfile(pkg): if __name__ == "__main__": parser = argparse.ArgumentParser() + parser.add_argument( + "-c", + "--cachedir", + help="alternative directory to use for moving package" + ) + parser.add_argument( + "-d", + "--db-filename", + help="alternative filename for database without extension" + ) parser.add_argument( "-s", "--sign", @@ -81,10 +91,15 @@ if __name__ == "__main__": else: opts = args.opts - cachedir = os.path.join("/var", "cache", "pacman", repo) - # this assumes that the db file for the repo - # has the same name as that repo - db = os.path.join(cachedir, f"{repo}.{DB_EXT}") + if args.cachedir is not None: + cachedir = args.cachedir + else: + cachedir = os.path.join("/var", "cache", "pacman", repo) + + if args.db-filename is not None: + db = os.path.join(cachedir, f"{args.db-filename}.{DB_EXT}") + else: + db = os.path.join(cachedir, f"{repo}.{DB_EXT}") if args.verbose: stdout_handler.setLevel(logging.DEBUG) diff --git a/packaging_scripts/zsh-completions/_addpkg b/packaging_scripts/zsh-completions/_addpkg index e9c0cb4..acd4f56 100644 --- a/packaging_scripts/zsh-completions/_addpkg +++ b/packaging_scripts/zsh-completions/_addpkg @@ -5,6 +5,8 @@ local arguments arguments=( {-h,--help}'[show this help message and exit]' + {-c,--cachedir}'[alternative directory to use for moving package]' + {-d,--db-filename}'[alternative filename for database without extension]' {-s,--sign}'[sign repository file]' {-v,--verbose}'[increase script verbosity]' '*:filename:_files' diff --git a/packaging_scripts/zsh-completions/_delpkg b/packaging_scripts/zsh-completions/_delpkg index 22a9688..a860654 100644 --- a/packaging_scripts/zsh-completions/_delpkg +++ b/packaging_scripts/zsh-completions/_delpkg @@ -6,6 +6,8 @@ local arguments arguments=( {-h,--help}'[show this help message and exit]' + {-c,--cachedir}'[alternative directory to use for deleting package]' + {-d,--db-filename}'[alternative filename for database without extension]' {-s,--sign}'[sign repository file]' {-v,--verbose}'[increase script verbosity]' '*:filename:_files' diff --git a/setup.py b/setup.py index d462a43..e592370 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.rst", "r") as fh: setuptools.setup( name="packaging_scripts", - version="1.0.3", + version="1.1", author="Eric Russel Torres", author_email="erictorres4@protonmail.com", description="A set of helpers for automating borg interaction",