diff --git a/ChangeLog.txt b/ChangeLog.txt index c3f9107c..e3f92fc0 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -5,6 +5,8 @@ Updated: - Merge sbo/remove.py in the slpkg/remove.py file Fixed: - Bugfix: update slpkg itself from gitlab repository +Added: +- Command clean to remove the packages and the sources from /tmp/slpkg/ directory 3.3.9 - 14/01/2019 Updated: diff --git a/man/slpkg.8 b/man/slpkg.8 index 179fd456..8e3f3870 100644 --- a/man/slpkg.8 +++ b/man/slpkg.8 @@ -29,6 +29,7 @@ Usage: slpkg [COMMANDS|OPTIONS] {repository|package...} [health, --silent] [deps-status, --tree, --graph=[type]] [new-config] + [clean] Optional arguments: [-h] [-v] @@ -152,6 +153,11 @@ Additional options: This command searches for .new configuration files in /etc/ path and ask the user what todo with those files. +.SS clean, the tmp/ directory +\fBslpkg\fP \fBclean\fP +.PP +Clean the /tmp/slpkg/ directory from downloaded packages and sources. + .SH OPTIONS .PP The following arguments are available. diff --git a/slpkg/arguments.py b/slpkg/arguments.py index 1f1d887a..eb260fab 100644 --- a/slpkg/arguments.py +++ b/slpkg/arguments.py @@ -78,6 +78,8 @@ Commands: new-config Manage .new configuration files. + clean Clean the tmp/ directory from + downloaded packages and sources. Optional arguments: -h | --help Print this help message and exit. @@ -184,6 +186,7 @@ def usage(repo): [health, --silent] [deps-status, --tree, --graph=[type]] [new-config] + [clean] Optional arguments: [-h] [-v] diff --git a/slpkg/clean.py b/slpkg/clean.py new file mode 100644 index 00000000..44e4f70f --- /dev/null +++ b/slpkg/clean.py @@ -0,0 +1,49 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# clean.py file is part of slpkg. + +# Copyright 2014-2019 Dimitris Zlatanidis +# All rights reserved. + +# Slpkg is a user-friendly package manager for Slackware installations + +# https://gitlab.com/dslackw/slpkg + +# Slpkg is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +import os +import shutil + +from slpkg.__metadata__ import MetaData as _meta_ + + +def clean_tmp(): + """Delete packages and sources from tmp/ directory + """ + tmps = [_meta_.tmp_path, # /tmp/slpkg/ + _meta_.build_path, # /tmp/slpkg/build/ + _meta_.slpkg_tmp_packages, # /tmp/slpkg/packages/ + _meta_.slpkg_tmp_patches # /tmp/slpkg/patches/ + ] + # Delete a whole slpkg folder from the tmp directory + if os.path.exists(tmps[0]): + shutil.rmtree(tmps[0]) + print("All packages and sources were deleted from: {0}".format( + tmps[0])) + # Recreate the paths again + if not os.path.exists(tmps[0]): + for tmp in tmps: + print("Create directory: {0}".format(tmp)) + os.mkdir(tmp) + print("Done!") diff --git a/slpkg/main.py b/slpkg/main.py index 1b761a7e..f5637cb6 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -25,6 +25,7 @@ import os import sys +from slpkg.clean import clean_tmp from slpkg.load import Regex from slpkg.desc import PkgDesc from slpkg.messages import Msg @@ -82,7 +83,8 @@ class ArgParse(object): "update-slpkg", "health", "deps-status", - "new-config" + "new-config", + "clean" ] # checking if repositories exists @@ -239,6 +241,13 @@ class ArgParse(object): else: usage("") + def command_clean(self): + """Clean all downloaded packages and sources""" + if len(self.args) == 1 and self.args[0] == "clean": + clean_tmp() + else: + usage("") + def auto_build(self): """Auto built tool """ @@ -806,6 +815,7 @@ def main(): "health": argparse.command_health, "deps-status": argparse.command_deps_status, "new-config": argparse.command_new_config, + "clean": argparse.command_clean, "-a": argparse.auto_build, "--autobuild": argparse.auto_build, "-l": argparse.pkg_list,