mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-23 23:07:17 +00:00
add clean subcommand
This commit is contained in:
parent
db0a6bf34e
commit
4c20d0241a
@ -49,6 +49,16 @@ def add(args: argparse.Namespace, architecture: str, config: Configuration) -> N
|
||||
Application(architecture, config).add(args.package, args.without_dependencies)
|
||||
|
||||
|
||||
def clean(args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
'''
|
||||
clean caches callback
|
||||
:param args: command line args
|
||||
:param architecture: repository architecture
|
||||
:param config: configuration instance
|
||||
'''
|
||||
Application(architecture, config).clean()
|
||||
|
||||
|
||||
def rebuild(args: argparse.Namespace, architecture: str, config: Configuration) -> None:
|
||||
'''
|
||||
world rebuild callback
|
||||
@ -141,6 +151,9 @@ if __name__ == '__main__':
|
||||
check_parser.add_argument('--no-vcs', help='do not check VCS packages', action='store_true')
|
||||
check_parser.set_defaults(fn=update, no_aur=False, no_manual=True, dry_run=True)
|
||||
|
||||
clean_parser = subparsers.add_parser('clean', description='clear all local caches')
|
||||
clean_parser.set_defaults(fn=clean)
|
||||
|
||||
rebuild_parser = subparsers.add_parser('rebuild', description='rebuild whole repository')
|
||||
rebuild_parser.set_defaults(fn=rebuild)
|
||||
|
||||
|
@ -128,6 +128,16 @@ class Application:
|
||||
for name in names:
|
||||
process_single(name)
|
||||
|
||||
def clean(self) -> None:
|
||||
'''
|
||||
run all clean methods
|
||||
'''
|
||||
self.repository._clear_build()
|
||||
self.repository._clear_cache()
|
||||
self.repository._clear_chroot()
|
||||
self.repository._clear_manual()
|
||||
self.repository._clear_packages()
|
||||
|
||||
def remove(self, names: Iterable[str]) -> None:
|
||||
'''
|
||||
remove packages from repository
|
||||
|
@ -79,6 +79,20 @@ class Repository:
|
||||
for package in os.listdir(self.paths.sources):
|
||||
shutil.rmtree(os.path.join(self.paths.sources, package))
|
||||
|
||||
def _clear_cache(self) -> None:
|
||||
'''
|
||||
clear cache directory
|
||||
'''
|
||||
for package in os.listdir(self.paths.cache):
|
||||
shutil.rmtree(os.path.join(self.paths.cache, package))
|
||||
|
||||
def _clear_chroot(self) -> None:
|
||||
'''
|
||||
clear cache directory. Warning: this method is architecture independent and will clear every chroot
|
||||
'''
|
||||
for chroot in os.listdir(self.paths.chroot):
|
||||
shutil.rmtree(os.path.join(self.paths.chroot, chroot))
|
||||
|
||||
def _clear_manual(self) -> None:
|
||||
'''
|
||||
clear directory with manual package updates
|
||||
|
Loading…
Reference in New Issue
Block a user