diff --git a/ChangeLog.txt b/ChangeLog.txt index 435d4110..df950983 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -3,6 +3,7 @@ Updated: - Cli menu view with colors Added: - Unittests +- Command clean-tmp to deletes all downloaded sources from /tmp/slpkg folder 4.1.0 - 20/06/2022 Updated: diff --git a/README.rst b/README.rst index 281bce06..d6e58cfb 100644 --- a/README.rst +++ b/README.rst @@ -52,7 +52,8 @@ Usage install Build and install the packages. remove Remove installed packages. search Search packages by name. - clean-logs Purge logs of dependencies. + clean-logs Clean dependencies log tracking. + clean-tmp Deletes all the downloaded sources. OPTIONS: --yes Answer Yes to all questions. diff --git a/man/slpkg.1 b/man/slpkg.1 index 3f26d72d..ffe5b8db 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -4,7 +4,7 @@ slpkg - [OPTIONS] .SH SYNAPSES .P -slpkg [-h|-v] [update] [build] [install] [remove] [search] [clean-logs] --yes --resolve-off --reinstall +slpkg [-h|-v] [update] [build] [install] [remove] [search] [clean-logs] [clean-tmp] --yes --resolve-off --reinstall .SH DESCRIPTION .P Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems. It automatically computes dependencies and figures out what things should occur to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update. @@ -39,7 +39,12 @@ Search packages by name and view everything in your terminal. .P clean-logs .RS -Purge logs of dependencies. +Cleans dependencies log tracking. +.RE +.P +clean-tmp +.RS +Deletes all the downloaded sources. .RE .SH OPTIONS .P diff --git a/slpkg/main.py b/slpkg/main.py index b926416b..caf5af78 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -8,6 +8,8 @@ from dataclasses import dataclass from slpkg.checks import Check from slpkg.search import Search from slpkg.version import Version +from slpkg.configs import Configs +from slpkg.utilities import Utilities from slpkg.views.cli_menu import usage from slpkg.slackbuild import Slackbuilds from slpkg.remove_packages import RemovePackages @@ -64,6 +66,15 @@ class Argparse: logs.clean() raise SystemExit() + if self.args[0] == 'clean-tmp': + path = Configs.tmp_path + tmp_slpkg = Configs.tmp_slpkg + folder = Configs.prog_name + utils = Utilities() + utils.remove_folder_if_exists(path, folder) + utils.create_folder(tmp_slpkg, 'build/') + raise SystemExit() + # Update repository if self.args[0] == 'update': update = UpdateRepository() diff --git a/slpkg/utilities.py b/slpkg/utilities.py index 43b8a8bb..af0e4ee0 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -53,3 +53,9 @@ class Utilities: directory = f'{path}/{folder}' if os.path.isdir(directory): shutil.rmtree(directory) + + def create_folder(self, path: str, folder: str): + ''' Creates folder. ''' + directory = f'{path}/{folder}' + if not os.path.isdir(directory): + os.makedirs(directory) diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 4456178f..50b59d4e 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -24,7 +24,8 @@ def usage(status: int): f' {CYAN}install{ENDC} Build and install the packages.', f' {CYAN}remove{ENDC} Remove installed packages.', f' {CYAN}search{ENDC} Search packages by name.', - f' {CYAN}clean-logs{ENDC} Purge logs of dependencies.\n', + f' {CYAN}clean-logs{ENDC} Clean dependencies log tracking.', + f' {CYAN}clean-tmp{ENDC} Delete all the downloaded sources.\n', f'{BOLD}OPTIONS:{ENDC}', f' {YELLOW}--yes{ENDC} Answer Yes to all questions.', f' {YELLOW}--jobs{ENDC} Set it for multicore systems.',