Added command clean-data

This commit is contained in:
Dimitris Zlatanidis 2023-03-05 23:03:46 +02:00
parent db77a07391
commit 7d26326223
6 changed files with 32 additions and 4 deletions

View file

@ -3,7 +3,8 @@ Updated:
- Ponce repository - Ponce repository
- slpkg.toml file for ponce repository - slpkg.toml file for ponce repository
Added: Added:
- New option --generate-only for ponce repository - Option --generate-only for ponce repository
- Command clean-data for all the tables from the database
4.5.5 - 02/03/2023 4.5.5 - 02/03/2023
Fixed: Fixed:

View file

@ -7,7 +7,7 @@ slpkg \- Package manager utility for Slackware.
slpkg \c slpkg \c
[\fIOPTIONS\fR] [\fICOMMAND\fR] [\fIPACKAGES...\fR] [\fIOPTIONS\fR] [\fICOMMAND\fR] [\fIPACKAGES...\fR]
.P .P
slpkg [-h|-v] [-u, update] [-U, upgrade] [-c, check-updates] [-g, configs] [-L, clean-logs] [-D, clean-tmp] [-b, build] [-i, install] [-d, download] slpkg [-h|-v] [-u, update] [-U, upgrade] [-c, check-updates] [-g, configs] [-L, clean-logs] [-D, clean-tmp] [-T, clean-data] [-b, build] [-i, install] [-d, download]
[-R, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] [-t, tracking] -y, --yes, -j, --jobs, -o, --resolve-off, [-R, remove] [-f, find] [-w, view] [-s, search] [-e, dependees] [-t, tracking] -y, --yes, -j, --jobs, -o, --resolve-off,
-r, --reinstall, -k, --skip-installed, -E, --full-reverse, -S, --search, -n, --no-silent, -p, --pkg-version, -z, -G, --generate-only, --directory=[\fIPATH\fR], -F, --file-pattern=[\fIPATTERN\fR] -r, --reinstall, -k, --skip-installed, -E, --full-reverse, -S, --search, -n, --no-silent, -p, --pkg-version, -z, -G, --generate-only, --directory=[\fIPATH\fR], -F, --file-pattern=[\fIPATTERN\fR]
.SH DESCRIPTION .SH DESCRIPTION
@ -45,6 +45,12 @@ Cleans dependencies log tracking. After that procedure you should remove depende
Deletes all the downloaded SlackBuilds scripts and sources. Deletes all the downloaded SlackBuilds scripts and sources.
.RE .RE
.P .P
.B -T, clean-data
.RS
Sometimes is necessary to clean all the data from the database.
Run this command to drop all the tables from the database and run `\fIslpkg update\fR` to recreate.
.RE
.P
.B -g, configs .B -g, configs
.RS .RS
Edit the configuration /etc/slpkg/slpkg.toml file. Edit the configuration /etc/slpkg/slpkg.toml file.

View file

@ -131,6 +131,7 @@ class Argparse(Configs):
'configs': [], 'configs': [],
'clean-logs': [self.flag_yes], 'clean-logs': [self.flag_yes],
'clean-tmp': [], 'clean-tmp': [],
'clean-data': [],
'build': [ 'build': [
self.flag_yes, self.flag_yes,
self.flag_short_yes, self.flag_short_yes,
@ -221,6 +222,7 @@ class Argparse(Configs):
self.commands['-g'] = self.commands['configs'] self.commands['-g'] = self.commands['configs']
self.commands['-L'] = self.commands['clean-logs'] self.commands['-L'] = self.commands['clean-logs']
self.commands['-D'] = self.commands['clean-tmp'] self.commands['-D'] = self.commands['clean-tmp']
self.commands['-T'] = self.commands['clean-data']
self.commands['-b'] = self.commands['build'] self.commands['-b'] = self.commands['build']
self.commands['-i'] = self.commands['install'] self.commands['-i'] = self.commands['install']
self.commands['-d'] = self.commands['download'] self.commands['-d'] = self.commands['download']
@ -428,7 +430,13 @@ class Argparse(Configs):
self.utils.create_folder(path=self.tmp_slpkg, folder='build') self.utils.create_folder(path=self.tmp_slpkg, folder='build')
raise SystemExit() raise SystemExit()
self.usage.help(1)
def clean_data(self) -> None:
if len(self.args) == 1:
update = UpdateRepository(self.flags)
update.drop_the_tables()
raise SystemExit()
self.usage.help(1) self.usage.help(1)
def build(self) -> None: def build(self) -> None:
@ -616,6 +624,8 @@ def main():
'-L': argparse.clean_logs, '-L': argparse.clean_logs,
'clean-tmp': argparse.clean_tmp, 'clean-tmp': argparse.clean_tmp,
'-D': argparse.clean_tmp, '-D': argparse.clean_tmp,
'clean-database': argparse.clean_data,
'-T': argparse.clean_data,
'build': argparse.build, 'build': argparse.build,
'-b': argparse.build, '-b': argparse.build,
'install': argparse.install, 'install': argparse.install,

View file

@ -14,7 +14,7 @@ from slpkg.views.views import ViewMessage
from slpkg.progress_bar import ProgressBar from slpkg.progress_bar import ProgressBar
from slpkg.check_updates import CheckUpdates from slpkg.check_updates import CheckUpdates
from slpkg.models.models import session as Session from slpkg.models.models import session as Session
from slpkg.models.models import SBoTable, PonceTable from slpkg.models.models import Base, engine, SBoTable, PonceTable, LogsDependencies
class UpdateRepository(Configs, Utilities): class UpdateRepository(Configs, Utilities):
@ -118,3 +118,10 @@ class UpdateRepository(Configs, Utilities):
else: else:
self.session.query(SBoTable).delete() self.session.query(SBoTable).delete()
self.session.commit() self.session.commit()
@staticmethod
def drop_the_tables():
""" Drop all the tables from the database. """
Base.metadata.drop_all(bind=engine, tables=[PonceTable.__table__,
SBoTable.__table__,
LogsDependencies.__table__])

View file

@ -22,7 +22,7 @@ class Usage(Configs):
args = ( args = (
f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] [PACKAGES...]\n' f'Usage: {self.prog_name} [{self.yellow}OPTIONS{self.endc}] [{self.cyan}COMMAND{self.endc}] [PACKAGES...]\n'
f'\n slpkg [{self.cyan}COMMAND{self.endc}] [-u, update, -U, upgrade, -c, check-updates]\n' f'\n slpkg [{self.cyan}COMMAND{self.endc}] [-u, update, -U, upgrade, -c, check-updates]\n'
f' slpkg [{self.cyan}COMMAND{self.endc}] [-L, clean-logs, -D, clean-tmp, -g, configs]\n' f' slpkg [{self.cyan}COMMAND{self.endc}] [-L, clean-logs, -D, clean-tmp, -T, clean-data, -g, configs]\n'
f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -d, download] [packages...]\n' f' slpkg [{self.cyan}COMMAND{self.endc}] [-b, build, -i, install, -d, download] [packages...]\n'
f' slpkg [{self.cyan}COMMAND{self.endc}] [-R, remove, -f, find, -w, view, -s, search] [packages...]\n' f' slpkg [{self.cyan}COMMAND{self.endc}] [-R, remove, -f, find, -w, view, -s, search] [packages...]\n'
f' slpkg [{self.cyan}COMMAND{self.endc}] [-e, dependees, -t, tracking] [packages...]\n' f' slpkg [{self.cyan}COMMAND{self.endc}] [-e, dependees, -t, tracking] [packages...]\n'
@ -48,6 +48,7 @@ class Usage(Configs):
f' {self.cyan}-g, configs{self.endc} Edit the configuration file.\n' f' {self.cyan}-g, configs{self.endc} Edit the configuration file.\n'
f' {self.cyan}-L, clean-logs{self.endc} Clean dependencies log tracking.\n' f' {self.cyan}-L, clean-logs{self.endc} Clean dependencies log tracking.\n'
f' {self.cyan}-D, clean-tmp{self.endc} Delete all the downloaded sources.\n' f' {self.cyan}-D, clean-tmp{self.endc} Delete all the downloaded sources.\n'
f' {self.cyan}-T, clean-data{self.endc} Clean all the data from the database.\n'
f' {self.cyan}-b, build{self.endc} [packages...] Build only the packages.\n' f' {self.cyan}-b, build{self.endc} [packages...] Build only the packages.\n'
f' {self.cyan}-i, install{self.endc} [packages...] Build and install the packages.\n' f' {self.cyan}-i, install{self.endc} [packages...] Build and install the packages.\n'
f' {self.cyan}-d, download{self.endc} [packages...] Download only the scripts and sources.\n' f' {self.cyan}-d, download{self.endc} [packages...] Download only the scripts and sources.\n'

View file

@ -30,6 +30,8 @@ class Help(Configs):
'clean-logs': "Cleans dependencies log tracking. After that procedure you should remove dependencies " 'clean-logs': "Cleans dependencies log tracking. After that procedure you should remove dependencies "
"by hand.", "by hand.",
'clean-tmp': "Deletes all the downloaded SlackBuilds scripts and sources.", 'clean-tmp': "Deletes all the downloaded SlackBuilds scripts and sources.",
'clean-data': "Sometimes is necessary to clean all the data from the database. Run this command to drop "
"all the tables from the database and run 'slpkg update' to recreate.",
'build': "Builds the Slackbuilds scripts and adds them to the /tmp directory.", 'build': "Builds the Slackbuilds scripts and adds them to the /tmp directory.",
'install': "Builds and installs the packages in the correct order, and also logs the packages with the " 'install': "Builds and installs the packages in the correct order, and also logs the packages with the "
"dependencies for removal.", "dependencies for removal.",
@ -50,6 +52,7 @@ class Help(Configs):
help_commands['-g'] = help_commands['configs'] help_commands['-g'] = help_commands['configs']
help_commands['-L'] = help_commands['clean-logs'] help_commands['-L'] = help_commands['clean-logs']
help_commands['-D'] = help_commands['clean-tmp'] help_commands['-D'] = help_commands['clean-tmp']
help_commands['-T'] = help_commands['clean-data']
help_commands['-b'] = help_commands['build'] help_commands['-b'] = help_commands['build']
help_commands['-i'] = help_commands['install'] help_commands['-i'] = help_commands['install']
help_commands['-d'] = help_commands['download'] help_commands['-d'] = help_commands['download']