aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2005-01-06 21:34:01 +0000
committerJason Woodward2005-01-06 21:34:01 +0000
commit6e5b7ecc9ddba14181646b237b9c514f309d24d7 (patch)
tree1099fd5d3d67ccd80520db698efcbda47297276b /src
parent5b562bc1d3e751a1527923afdb4d3600443146c3 (diff)
downloadslapt-get-6e5b7ecc9ddba14181646b237b9c514f309d24d7.tar.gz
added --remove-obsolete option for dist-upgrade (see FAQ #9 and #28)
Diffstat (limited to 'src')
-rw-r--r--src/action.c29
-rw-r--r--src/configuration.c1
-rw-r--r--src/configuration.h1
-rw-r--r--src/main.c5
-rw-r--r--src/main.h1
5 files changed, 37 insertions, 0 deletions
diff --git a/src/action.c b/src/action.c
index 5414b90..fed191e 100644
--- a/src/action.c
+++ b/src/action.c
@@ -473,6 +473,35 @@ void pkg_action_upgrade_all(const rc_config *global_config){
/* free_pkg_list(matches); */
free(matches->pkgs);
free(matches);
+
+ /* remove obsolete packages if prompted to */
+ if( global_config->remove_obsolete == 1 ){
+ int r;
+
+ for(r = 0; r < installed_pkgs->pkg_count; r++){
+
+ /* if we can't find the installed package in our available pkg list, it must be obsolete */
+ if( get_newest_pkg(avail_pkgs,installed_pkgs->pkgs[r]->name) == NULL ){
+ struct pkg_list *deps;
+ int c;
+ /*
+ any packages that require this package we are about to remove should be
+ scheduled to remove as well
+ */
+ deps = is_required_by(global_config,avail_pkgs,installed_pkgs->pkgs[r]);
+ for(c = 0; c < deps->pkg_count; c++ ){
+ if( get_newest_pkg(installed_pkgs,deps->pkgs[c]->name) != NULL )
+ add_remove_to_transaction(&tran,deps->pkgs[c]);
+ }
+ free(deps->pkgs);
+ free(deps);
+ add_remove_to_transaction(&tran,installed_pkgs->pkgs[r]);
+ }
+
+ }
+
+ }/* end if remove_obsolete */
+
}
for(i = 0; i < installed_pkgs->pkg_count;i++){
diff --git a/src/configuration.c b/src/configuration.c
index 6e3f4cd..5f7e418 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -50,6 +50,7 @@ rc_config *read_rc_config(const char *file_name){
global_config->re_install = 0;
global_config->exclude_list = NULL;
global_config->working_dir[0] = '\0';
+ global_config->remove_obsolete = 0;
rc = open_file(file_name,"r");
if( rc == NULL ) exit(1);
diff --git a/src/configuration.h b/src/configuration.h
index fc28e65..f90063f 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -48,6 +48,7 @@ typedef struct {
int disable_dep_check;
int print_uris;
int dl_stats;
+ int remove_obsolete;
} rc_config;
rc_config *read_rc_config(const char *file_name);
diff --git a/src/main.c b/src/main.c
index 7532e14..78b9a8b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -58,6 +58,7 @@ int main( int argc, char *argv[] ){
{"S",0, 0, SHOW_STATS_OPT},
{"config",1, 0, CONFIG_OPT},
{"autoclean", 0, 0, AUTOCLEAN_OPT},
+ {"remove-obsolete", 0, 0, OBSOLETE_OPT},
{0, 0, 0, 0},
};
@@ -172,6 +173,9 @@ int main( int argc, char *argv[] ){
case AUTOCLEAN_OPT: /* clean old old package versions */
do_action = AUTOCLEAN;
break;
+ case OBSOLETE_OPT: /* remove obsolete packages */
+ global_config->remove_obsolete = 1;
+ break;
default:
usage();
exit(1);
@@ -305,6 +309,7 @@ void usage(void){
printf(" --print-uris - %s\n",_("print URIs only, do not download"));
printf(" --show-stats|-S - %s\n",_("show download statistics"));
printf(" --config [] - %s\n",_("specify alternate slapt-getrc location"));
+ printf(" --remove-obsolete - %s\n",_("remove obsolete packages (dist-upgrade only)"));
}
void version_info(void){
diff --git a/src/main.h b/src/main.h
index 8edd103..35008c4 100644
--- a/src/main.h
+++ b/src/main.h
@@ -71,6 +71,7 @@ enum action {
#define SHOW_STATS_OPT 'S'
#define CONFIG_OPT 'C'
#define AUTOCLEAN_OPT 'a'
+#define OBSOLETE_OPT 'O'
#define DEBUG 0
#define DO_NOT_UNLINK_BAD_FILES 1