aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--README2
-rw-r--r--doc/slapt-get.89
-rw-r--r--src/action.c88
-rw-r--r--src/action.h2
-rw-r--r--src/configuration.c1
-rw-r--r--src/main.c6
7 files changed, 55 insertions, 58 deletions
diff --git a/ChangeLog b/ChangeLog
index 6998146..53df85c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,10 @@
-0.9.3 Sep 23, 2003
+0.9.3 Sep 24, 2003
* default make target doesn't build slack pkg
* --dist-upgrade becomes target instead of option
+ * merged dist-upgrade into --upgrade, --install also
+ checks if available pkg is newer than installed
+ dist-upgrade removed.
0.9.2 Sep 22, 2003
* renamed to slapt-get
diff --git a/README b/README
index eeeab52..5f38440 100644
--- a/README
+++ b/README
@@ -37,7 +37,7 @@ Table of Contents:
* show description of packages
* list installed packages
* remove packages (frontent to removepkg)
- * --dist-upgrade from one slackware release to another
+ * dist-upgrade from one slackware release to another
* exclude (hold) packages from upgrades
diff --git a/doc/slapt-get.8 b/doc/slapt-get.8
index f487baf..e8baf12 100644
--- a/doc/slapt-get.8
+++ b/doc/slapt-get.8
@@ -24,9 +24,6 @@ slapt-get \- frontend to pkgtools
.B --download-only
]
[
-.B --dist-upgrade
-]
-[
.B --simulate
]
[
@@ -84,12 +81,6 @@ tries to emulate Debian's apt-get as closely as possible.
.B --download-only
Download the package only. Do not install/upgrade.
.TP
-.B --dist-upgrade
-assumes MIRROR is set to newer release
-Assume the MIRROR location is set to a newer release, and
-check the package listing for newer version, instead of
-only checking the update list for updates.
-.TP
.B --simulate
Will not install or download packages.
.TP
diff --git a/src/action.c b/src/action.c
index 67a0351..055f131 100644
--- a/src/action.c
+++ b/src/action.c
@@ -30,14 +30,14 @@ void pkg_action_install(const rc_config *global_config,const char *pkg_name){
pkg_info_t *pkg;
struct pkg_list *installed;
- struct pkg_list *upgrades;
- struct pkg_list *current;
+ struct pkg_list *updates;
+ struct pkg_list *available;
- upgrades = get_update_pkgs();
+ updates = get_update_pkgs();
installed = get_installed_pkgs();
- current = get_available_pkgs();
+ available = get_available_pkgs();
- if( (pkg = get_newest_pkg(current->pkgs,pkg_name,current->pkg_count)) == NULL ){
+ if( (pkg = get_newest_pkg(available->pkgs,pkg_name,available->pkg_count)) == NULL ){
fprintf(stderr,"No Such package: %s\n",pkg_name);
return;
}
@@ -46,13 +46,13 @@ void pkg_action_install(const rc_config *global_config,const char *pkg_name){
&& (global_config->re_install != 1 ) ){
/* it's already installed, attempt an upgrade */
- pkg_action_upgrade(global_config,installed_pkg);
+ pkg_action_upgrade(global_config,installed_pkg,updates,pkg);
}else{
/* check to see if the package exists in the update list */
/* this way we install the most up to date pkg */
- if( (update_pkg = get_newest_pkg(upgrades->pkgs,pkg_name,upgrades->pkg_count)) != NULL ){
+ if( (update_pkg = get_newest_pkg(updates->pkgs,pkg_name,updates->pkg_count)) != NULL ){
if( (install_pkg(global_config,update_pkg)) == -1 ){
fprintf(stderr,"Installation of %s failed.\n",update_pkg->name);
}
@@ -66,8 +66,8 @@ void pkg_action_install(const rc_config *global_config,const char *pkg_name){
}
free_pkg_list(installed);
- free_pkg_list(upgrades);
- free_pkg_list(current);
+ free_pkg_list(updates);
+ free_pkg_list(available);
return;
}
@@ -202,15 +202,15 @@ void pkg_action_update(const rc_config *global_config){
/* upgrade pkg */
/* flesh me out so that pkg_action_upgrade_all() calls me */
-void pkg_action_upgrade(const rc_config *global_config,pkg_info_t *installed_pkg){
+void pkg_action_upgrade(const rc_config *global_config,pkg_info_t *installed_pkg,struct pkg_list *update_pkgs,pkg_info_t *available_pkg){
pkg_info_t *update_pkg;
- struct pkg_list *update_pkgs;
int cmp_result;
- update_pkgs = get_update_pkgs();
-
/* if we found an update, make sure it's version is greater */
- if( (update_pkg = get_newest_pkg(update_pkgs->pkgs,installed_pkg->name,update_pkgs->pkg_count)) != NULL ){
+ if(
+ (update_pkg = get_newest_pkg(update_pkgs->pkgs,installed_pkg->name,update_pkgs->pkg_count)) != NULL
+ && strcmp(available_pkg->version,update_pkg->version) < 0
+ ){
cmp_result = strcmp(installed_pkg->version,update_pkg->version);
@@ -227,16 +227,23 @@ void pkg_action_upgrade(const rc_config *global_config,pkg_info_t *installed_pkg
}
}
}else{
- printf("%s is already the newest version.\n",installed_pkg->name);
+ if( strcmp(installed_pkg->version,available_pkg->version) < 0 ){
+ if( (upgrade_pkg(global_config,available_pkg)) == -1 ){
+ fprintf(stderr,"Failed to update %s.\n",installed_pkg->name);
+ exit(1);
+ }
+ }else{
+ printf("%s is already the newest version.\n",installed_pkg->name);
+ }
}
- free_pkg_list(update_pkgs);
}
/* upgrade all installed pkgs with available updates */
/* use pkg_action_upgrade() soon, pass in pkg_list(s) */
void pkg_action_upgrade_all(const rc_config *global_config){
int iterator;
+ int try_dist_upgrade = 0;
struct pkg_list *installed_pkgs;
struct pkg_list *update_pkgs;
struct pkg_list *current_pkgs;
@@ -271,35 +278,38 @@ void pkg_action_upgrade_all(const rc_config *global_config){
}/* end upgrade attempt */
}else{
- /* if --dist-upgrade is set */
- if( global_config->dist_upgrade == 1 ){
- current_pkg = get_newest_pkg(
- current_pkgs->pkgs,
- installed_pkgs->pkgs[iterator]->name,
- current_pkgs->pkg_count
- );
- if( current_pkg != NULL ){
- /* the current version of the pkg is greater than the installed version */
- if( (strcmp(installed_pkgs->pkgs[iterator]->version,current_pkg->version)) < 0 ){
- /* attempt to upgrade */
- if( (upgrade_pkg(global_config,current_pkg)) == -1 ){
- fprintf(
- stderr,
- "Failed to update %s.\n",
- installed_pkgs->pkgs[iterator]->name
- );
- exit(1);
- }/* end upgrade attempt */
- }/* end if strcmp */
- free(current_pkg);
- }/* end if current_pkg */
- }
+ try_dist_upgrade = 1;
} /* end version check */
+ } else {
+ try_dist_upgrade = 1;
}/* end upgrade pkg found */
+ if( try_dist_upgrade == 1 ){
+ current_pkg = get_newest_pkg(
+ current_pkgs->pkgs,
+ installed_pkgs->pkgs[iterator]->name,
+ current_pkgs->pkg_count
+ );
+ if( current_pkg != NULL ){
+ /* the current version of the pkg is greater than the installed version */
+ if( (strcmp(installed_pkgs->pkgs[iterator]->version,current_pkg->version)) < 0 ){
+ /* attempt to upgrade */
+ if( (upgrade_pkg(global_config,current_pkg)) == -1 ){
+ fprintf(
+ stderr,
+ "Failed to update %s.\n",
+ installed_pkgs->pkgs[iterator]->name
+ );
+ exit(1);
+ }/* end upgrade attempt */
+ }/* end if strcmp */
+ }/* end if current_pkg */
+ }
+
}/* end for */
+
printf("Done.\n");
free_pkg_list(current_pkgs);
diff --git a/src/action.h b/src/action.h
index 3ce5ba6..7ff84ca 100644
--- a/src/action.h
+++ b/src/action.h
@@ -23,7 +23,7 @@ void pkg_action_list_installed(void);
void pkg_action_remove(const char *);
void pkg_action_search(const char *);
void pkg_action_show(const char *);
-void pkg_action_upgrade(const rc_config *,pkg_info_t *);
+void pkg_action_upgrade(const rc_config *,pkg_info_t *,struct pkg_list *,pkg_info_t *);
void pkg_action_upgrade_all(const rc_config *);
void pkg_action_update(const rc_config *);
diff --git a/src/configuration.c b/src/configuration.c
index aa9e606..6d8007d 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -90,7 +90,6 @@ rc_config *read_rc_config(const char *file_name){
/* initialize */
global_config->download_only = 0;
- global_config->dist_upgrade = 0;
global_config->simulate = 0;
global_config->ignore_excludes = 0;
diff --git a/src/main.c b/src/main.c
index 52df21c..54fd462 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,7 +35,6 @@ int main( int argc, char *argv[] ){
{"installed", 0, 0, 'd'},
{"clean", 0, 0, 'c'},
{"download-only", 0, 0, 'o'},
- {"dist-upgrade", 0, 0, 'a'},
{"simulate", 0, 0, 'm'},
{"version", 0, 0, 'v'},
{"no-prompt", 0, 0, 'b'},
@@ -110,10 +109,6 @@ int main( int argc, char *argv[] ){
case 'o': /* download only flag */
global_config->download_only = 1;
break;
- case 'a': /* dist-upgrade */
- global_config->dist_upgrade = 1;
- pkg_action_upgrade_all(global_config);
- break;
case 'm': /* simulate */
global_config->simulate = 1;
break;
@@ -149,7 +144,6 @@ void usage(){
printf("Targets:\n");
printf(" --update - retrieves pkg data from MIRROR\n");
printf(" --upgrade - upgrade installed pkgs\n");
- printf(" --dist-upgrade - assumes MIRROR is set to newer release\n");
printf(" --install [pkg name(s)] - install specified pkg(s)\n");
printf(" --remove [pkg name(s)] - remove specified pkg(s)\n");
printf(" --show [pkg name] - show pkg description\n");