Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=afc015c733be6a62e20ba8212d253826bccd28b9

commit afc015c733be6a62e20ba8212d253826bccd28b9
Author: Michel Hermier <[email protected]>
Date:   Sat Nov 9 09:56:55 2013 +0100

libpacman: No need to duplicate _pacman_pkg_fileneedbackup return for md5 and 
sha1 case, it allways return the same hash.

diff --git a/lib/libpacman/add.c b/lib/libpacman/add.c
index 7ba73f2..2921b7c 100644
--- a/lib/libpacman/add.c
+++ b/lib/libpacman/add.c
@@ -379,8 +379,7 @@ int _pacman_add_commit(pmtrans_t *trans, pmlist_t **data)
for(i = 0; (archive_ret = archive_read_next_header (archive, &entry)) == 
ARCHIVE_OK; i++) {
int nb = 0;
int notouch = 0;
-                               char *md5_orig = NULL;
-                               char *sha1_orig = NULL;
+                               char *hash_orig = NULL;
char pathname[PATH_MAX];
struct stat buf;

@@ -440,9 +439,8 @@ int _pacman_add_commit(pmtrans_t *trans, pmlist_t **data)
nb = _pacman_list_is_strin(pathname, pkg_new->backup);
} else {
/* op == PM_TRANS_TYPE_UPGRADE */
-                                                               md5_orig = 
_pacman_pkg_fileneedbackup(oldpkg, pathname);
-                                                               sha1_orig = 
_pacman_pkg_fileneedbackup(oldpkg, pathname);
-                                                               if(md5_orig || 
sha1_orig) {
+                                                               hash_orig = 
_pacman_pkg_fileneedbackup(oldpkg, pathname);
+                                                               
if(!_pacman_strempty(hash_orig)) {
nb = 1;
}
}
@@ -467,8 +465,7 @@ int _pacman_add_commit(pmtrans_t *trans, pmlist_t **data)
errors++;
unlink(temp);
FREE(temp);
-                                               FREE(md5_orig);
-                                               FREE(sha1_orig);
+                                               FREE(hash_orig);
close(fd);
continue;
}
@@ -509,16 +506,13 @@ int _pacman_add_commit(pmtrans_t *trans, pmlist_t **data)
_pacman_log(PM_LOG_DEBUG, _("checking md5 hashes for %s"), pathname);
_pacman_log(PM_LOG_DEBUG, _("current:  %s"), md5_local);
_pacman_log(PM_LOG_DEBUG, _("new:      %s"), md5_pkg);
-                                               if(md5_orig) {
-                                                       
_pacman_log(PM_LOG_DEBUG, _("original: %s"), md5_orig);
-                                               }
} else {
_pacman_log(PM_LOG_DEBUG, _("checking sha1 hashes for %s"), pathname);
_pacman_log(PM_LOG_DEBUG, _("current:  %s"), sha1_local);
_pacman_log(PM_LOG_DEBUG, _("new:      %s"), sha1_pkg);
-                                               if(sha1_orig) {
-                                                       
_pacman_log(PM_LOG_DEBUG, _("original: %s"), sha1_orig);
-                                               }
+                                       }
+                                       if(!_pacman_strempty(hash_orig)) {
+                                               _pacman_log(PM_LOG_DEBUG, 
_("original: %s"), hash_orig);
}

if(!pmo_upgrade) {
@@ -542,12 +536,12 @@ int _pacman_add_commit(pmtrans_t *trans, pmlist_t **data)
_pacman_log(PM_LOG_WARNING, _("%s saved as %s.pacorig"), pathname, pathname);
}
}
-                                       } else if(md5_orig || sha1_orig) {
+                                       } else if(!_pacman_strempty(hash_orig)) 
{
/* PM_UPGRADE */
int installnew = 0;

/* the fun part */
-                                               if(!strcmp(md5_orig, 
md5_local)|| !strcmp(sha1_orig, sha1_local)) {
+                                               if(!strcmp(hash_orig, 
md5_local) || !strcmp(hash_orig, sha1_local)) {
if(!strcmp(md5_local, md5_pkg) || !strcmp(sha1_local, sha1_pkg)) {
_pacman_log(PM_LOG_DEBUG, _("action: installing new file"));
installnew = 1;
@@ -555,7 +549,7 @@ int _pacman_add_commit(pmtrans_t *trans, pmlist_t **data)
_pacman_log(PM_LOG_DEBUG, _("action: installing new file"));
installnew = 1;
}
-                                               } else if(!strcmp(md5_orig, 
md5_pkg) || !strcmp(sha1_orig, sha1_pkg)) {
+                                               } else if(!strcmp(hash_orig, 
md5_pkg) || !strcmp(hash_orig, sha1_pkg)) {
_pacman_log(PM_LOG_DEBUG, _("action: leaving existing file in place"));
} else if(!strcmp(md5_local, md5_pkg) || !strcmp(sha1_local, sha1_pkg)) {
_pacman_log(PM_LOG_DEBUG, _("action: installing new file"));
@@ -584,10 +578,9 @@ int _pacman_add_commit(pmtrans_t *trans, pmlist_t **data)

FREE(md5_local);
FREE(md5_pkg);
-                                       FREE(md5_orig);
FREE(sha1_local);
FREE(sha1_pkg);
-                                       FREE(sha1_orig);
+                                       FREE(hash_orig);
unlink(temp);
FREE(temp);
close(fd);
diff --git a/lib/libpacman/remove.c b/lib/libpacman/remove.c
index cafec54..4b46c4a 100644
--- a/lib/libpacman/remove.c
+++ b/lib/libpacman/remove.c
@@ -202,17 +202,15 @@ int _pacman_remove_commit(pmtrans_t *trans, pmlist_t 
**data)
int nb = 0;
double percent;
char *file = lp->data;
-                               char *md5 
=_pacman_pkg_fileneedbackup(pkg_local, file);
-                               char *sha1 
=_pacman_pkg_fileneedbackup(pkg_local, file);
+                               char *hash_orig = 
_pacman_pkg_fileneedbackup(pkg_local, file);

if (position != 0) {
percent = (double)position / filenum;
}
-                               if(md5 && sha1) {
+                               if(!_pacman_strempty(hash_orig)) {
nb = 1;
-                                       FREE(md5);
-                                       FREE(sha1);
}
+                               FREE(hash_orig);
if(!nb && trans->type == PM_TRANS_TYPE_UPGRADE) {
/* check noupgrade */
if(_pacman_list_is_strin(file, handle->noupgrade)) {
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to