aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--doc/libslapt.36
-rw-r--r--src/action.c19
-rw-r--r--src/package.h2
-rw-r--r--src/transaction.c90
-rw-r--r--src/transaction.h4
6 files changed, 106 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index be73d99..6618043 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
+0.10.2f June 07, 2010
+ * added reinstall notification
+
0.10.2e June 02, 2010
* updated essential packages for dist-upgrade
* always reinstall slapt-get on dist-upgrade
diff --git a/doc/libslapt.3 b/doc/libslapt.3
index 763f1df..2de73e4 100644
--- a/doc/libslapt.3
+++ b/doc/libslapt.3
@@ -452,11 +452,13 @@ Adding, removing, and upgrading packages can be wrapped in a \fIslapt_transactio
typedef struct {
slapt_pkg_info_t *installed;
slapt_pkg_info_t *upgrade;
+ SLAPT_BOOL_T reinstall;
} slapt_pkg_upgrade_t;
.sp
struct slapt_pkg_upgrade_list {
slapt_pkg_upgrade_t **pkgs;
unsigned int pkg_count;
+ unsigned int reinstall_count;
};
.sp
typedef struct {
@@ -484,6 +486,10 @@ Adding, removing, and upgrading packages can be wrapped in a \fIslapt_transactio
.B " slapt_pkg_info_t *installed_pkg,"
.B " slapt_pkg_info_t *upgrade_pkg);"
.sp
+.B "void slapt_add_reinstall_to_transaction(slapt_transaction_t *,"
+.B " slapt_pkg_info_t *installed_pkg,"
+.B " slapt_pkg_info_t *upgrade_pkg);"
+.sp
.B "void slapt_add_exclude_to_transaction(slapt_transaction_t *,"
.B " slapt_pkg_info_t *pkg);"
.sp
diff --git a/src/action.c b/src/action.c
index 9539129..c08e01d 100644
--- a/src/action.c
+++ b/src/action.c
@@ -123,7 +123,12 @@ void slapt_pkg_action_install(const slapt_rc_config *global_config,
slapt_add_remove_to_transaction(tran,conflicts->pkgs[cindex]);
}
}
- slapt_add_upgrade_to_transaction(tran,installed_pkg,pkg);
+
+ if (slapt_cmp_pkgs(installed_pkg,pkg) == 0)
+ slapt_add_reinstall_to_transaction(tran,installed_pkg,pkg);
+ else
+ slapt_add_upgrade_to_transaction(tran,installed_pkg,pkg);
+
slapt_free_pkg_list(conflicts);
} else {
@@ -627,8 +632,8 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
if (newest_slaptget != NULL) {
slapt_pkg_info_t *installed_slaptget = slapt_get_newest_pkg(installed_pkgs, "slapt-get");
slapt_add_deps_to_trans(global_config, tran, avail_pkgs, installed_pkgs, newest_slaptget);
- if (installed_slaptget != NULL)
- slapt_add_upgrade_to_transaction(tran,installed_slaptget, newest_slaptget);
+ if (installed_slaptget != NULL) /* should never be null */
+ slapt_add_reinstall_to_transaction(tran,installed_slaptget, newest_slaptget);
}
}
@@ -689,8 +694,12 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
&& ( global_config->ignore_dep == SLAPT_TRUE
|| ( conflicts->pkg_count == 0 ) )
) {
- slapt_add_upgrade_to_transaction(tran,installed_pkgs->pkgs[i],
- update_pkg);
+
+ if (cmp_r == 0)
+ slapt_add_reinstall_to_transaction(tran,installed_pkgs->pkgs[i], update_pkg);
+ else
+ slapt_add_upgrade_to_transaction(tran,installed_pkgs->pkgs[i], update_pkg);
+
} else {
/* otherwise exclude */
printf(gettext("Excluding %s, use --ignore-dep to override\n"),
diff --git a/src/package.h b/src/package.h
index 93108e7..a0fb2b0 100644
--- a/src/package.h
+++ b/src/package.h
@@ -61,11 +61,13 @@ struct slapt_pkg_list {
typedef struct {
slapt_pkg_info_t *installed;
slapt_pkg_info_t *upgrade;
+ SLAPT_BOOL_T reinstall;
} slapt_pkg_upgrade_t;
struct slapt_pkg_upgrade_list {
slapt_pkg_upgrade_t **pkgs;
unsigned int pkg_count;
+ unsigned int reinstall_count;
};
typedef struct {
diff --git a/src/transaction.c b/src/transaction.c
index 65ca3fd..130d07f 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -27,6 +27,12 @@ static void queue_free(slapt_queue_t *t);
static void add_suggestion(slapt_transaction_t *tran, slapt_pkg_info_t *pkg);
+static void _slapt_add_upgrade_to_transaction(slapt_transaction_t *tran,
+ slapt_pkg_info_t *installed_pkg,
+ slapt_pkg_info_t *slapt_upgrade_pkg,
+ SLAPT_BOOL_T reinstall
+);
+
slapt_transaction_t *slapt_init_transaction(void)
{
slapt_transaction_t *tran = slapt_malloc(sizeof *tran);
@@ -43,6 +49,7 @@ slapt_transaction_t *slapt_init_transaction(void)
tran->upgrade_pkgs = slapt_malloc(sizeof *tran->upgrade_pkgs);
tran->upgrade_pkgs->pkgs = slapt_malloc(sizeof *tran->upgrade_pkgs->pkgs);
tran->upgrade_pkgs->pkg_count = 0;
+ tran->upgrade_pkgs->reinstall_count = 0;
tran->suggests = slapt_malloc(sizeof *tran->suggests);
@@ -191,8 +198,11 @@ int slapt_handle_transaction (const slapt_rc_config *global_config,
/* show pkgs to upgrade */
if (tran->upgrade_pkgs->pkg_count > 0) {
unsigned int len = 0;
- printf(gettext("The following packages will be upgraded:\n"));
- printf(" ");
+
+ if ((tran->upgrade_pkgs->pkg_count - tran->upgrade_pkgs->reinstall_count) > 0) {
+ printf(gettext("The following packages will be upgraded:\n"));
+ printf(" ");
+ }
for (i = 0; i < tran->upgrade_pkgs->pkg_count; ++i) {
slapt_pkg_info_t *u = tran->upgrade_pkgs->pkgs[i]->upgrade;
@@ -201,6 +211,20 @@ int slapt_handle_transaction (const slapt_rc_config *global_config,
size_t existing_file_size = 0;
int line_len = len + strlen(u->name) + 1;
+ existing_file_size = slapt_get_pkg_file_size(
+ global_config,u) / 1024;
+
+ download_size += u->size_c;
+
+ if (existing_file_size <= u->size_c)
+ already_download_size += existing_file_size;
+
+ uncompressed_size += u->size_u;
+ uncompressed_size -= p->size_u;
+
+ if (tran->upgrade_pkgs->pkgs[i]->reinstall == SLAPT_TRUE)
+ continue;
+
if (line_len < MAX_LINE_LEN) {
printf("%s ",u->name);
len += strlen(u->name) + 1;
@@ -209,24 +233,40 @@ int slapt_handle_transaction (const slapt_rc_config *global_config,
len = strlen(u->name) + 3;
}
- existing_file_size = slapt_get_pkg_file_size(
- global_config,u) / 1024;
+ }
- download_size += u->size_c;
+ if ((tran->upgrade_pkgs->pkg_count - tran->upgrade_pkgs->reinstall_count) > 0)
+ printf("\n");
- if (existing_file_size <= u->size_c)
- already_download_size += existing_file_size;
+ if (tran->upgrade_pkgs->reinstall_count > 0) {
+ unsigned int len = 0;
+ printf(gettext("The following packages will be reinstalled:\n"));
+ printf(" ");
- uncompressed_size += u->size_u;
- uncompressed_size -= p->size_u;
+ for (i = 0; i < tran->upgrade_pkgs->pkg_count; ++i) {
+ slapt_pkg_info_t *u = tran->upgrade_pkgs->pkgs[i]->upgrade;
+ int line_len = len + strlen(u->name) + 1;
+
+ if (tran->upgrade_pkgs->pkgs[i]->reinstall == SLAPT_FALSE)
+ continue;
+
+ if (line_len < MAX_LINE_LEN) {
+ printf("%s ",u->name);
+ len += strlen(u->name) + 1;
+ } else {
+ printf("\n %s ",u->name);
+ len = strlen(u->name) + 3;
+ }
+ }
+ printf("\n");
}
- printf("\n");
}
/* print the summary */
printf(
- gettext("%d upgraded, %d newly installed, %d to remove and %d not upgraded.\n"),
- tran->upgrade_pkgs->pkg_count,
+ gettext("%d upgraded, %d reinstalled, %d newly installed, %d to remove and %d not upgraded.\n"),
+ tran->upgrade_pkgs->pkg_count - tran->upgrade_pkgs->reinstall_count,
+ tran->upgrade_pkgs->reinstall_count,
tran->install_pkgs->pkg_count,
tran->remove_pkgs->pkg_count,
tran->exclude_pkgs->pkg_count
@@ -536,11 +576,29 @@ void slapt_add_exclude_to_transaction(slapt_transaction_t *tran,
}
+void slapt_add_reinstall_to_transaction(slapt_transaction_t *tran,
+ slapt_pkg_info_t *installed_pkg,
+ slapt_pkg_info_t *slapt_upgrade_pkg
+)
+{
+ _slapt_add_upgrade_to_transaction(tran, installed_pkg, slapt_upgrade_pkg, SLAPT_TRUE);
+}
+
void slapt_add_upgrade_to_transaction(slapt_transaction_t *tran,
slapt_pkg_info_t *installed_pkg,
slapt_pkg_info_t *slapt_upgrade_pkg
)
{
+ _slapt_add_upgrade_to_transaction(tran, installed_pkg, slapt_upgrade_pkg, SLAPT_FALSE);
+}
+
+
+static void _slapt_add_upgrade_to_transaction(slapt_transaction_t *tran,
+ slapt_pkg_info_t *installed_pkg,
+ slapt_pkg_info_t *slapt_upgrade_pkg,
+ SLAPT_BOOL_T reinstall
+)
+{
slapt_pkg_upgrade_t **tmp_list;
/* don't add if already present in the transaction */
@@ -550,7 +608,8 @@ void slapt_add_upgrade_to_transaction(slapt_transaction_t *tran,
tmp_list = realloc(
tran->upgrade_pkgs->pkgs,
sizeof *tran->upgrade_pkgs->pkgs * (tran->upgrade_pkgs->pkg_count + 1)
- );
+ );
+
if (tmp_list != NULL) {
tran->upgrade_pkgs->pkgs = tmp_list;
@@ -575,11 +634,16 @@ void slapt_add_upgrade_to_transaction(slapt_transaction_t *tran,
tran->upgrade_pkgs->pkgs[tran->upgrade_pkgs->pkg_count]->upgrade,
slapt_upgrade_pkg);
+ tran->upgrade_pkgs->pkgs[tran->upgrade_pkgs->pkg_count]->reinstall = reinstall;
+
queue_add_upgrade(tran->queue,
tran->upgrade_pkgs->pkgs[tran->upgrade_pkgs->pkg_count]);
++tran->upgrade_pkgs->pkg_count;
+ if (reinstall == SLAPT_TRUE)
+ ++tran->upgrade_pkgs->reinstall_count;
+
}
}
diff --git a/src/transaction.h b/src/transaction.h
index 38f8e5c..11b37cd 100644
--- a/src/transaction.h
+++ b/src/transaction.h
@@ -49,6 +49,10 @@ void slapt_add_remove_to_transaction(slapt_transaction_t *,
void slapt_add_upgrade_to_transaction(slapt_transaction_t *,
slapt_pkg_info_t *installed_pkg,
slapt_pkg_info_t *upgrade_pkg);
+/* add package to reinstall to transaction */
+void slapt_add_reinstall_to_transaction(slapt_transaction_t *,
+ slapt_pkg_info_t *installed_pkg,
+ slapt_pkg_info_t *upgrade_pkg);
/* add package to exclude to transaction */
void slapt_add_exclude_to_transaction(slapt_transaction_t *,
slapt_pkg_info_t *pkg);