While checking conf files and there were no changes, do not unpack file from binpkg.

This commit is contained in:
Juan RP 2012-10-26 10:23:12 +02:00
parent d99c505811
commit 89dadb0f20

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2009-2011 Juan Romero Pardines. * Copyright (c) 2009-2012 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -88,13 +88,13 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
* Get original hash for the file from current * Get original hash for the file from current
* installed package. * installed package.
*/ */
xbps_dbg_printf(xhp, "%s: processing conf_file %s\n", xbps_dbg_printf(xhp, "%s-%s: processing conf_file %s\n",
pkgname, entry_pname); pkgname, version, entry_pname);
forigd = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGFILES); forigd = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGFILES);
if (forigd == NULL) { if (forigd == NULL) {
xbps_dbg_printf(xhp, "%s: conf_file %s not currently installed\n", xbps_dbg_printf(xhp, "%s-%s: conf_file %s not currently "
pkgname, entry_pname); "installed\n", pkgname, version, entry_pname);
rv = 1; rv = 1;
goto out; goto out;
} }
@ -126,8 +126,8 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
* First case: original hash not found, install new file. * First case: original hash not found, install new file.
*/ */
if (sha256_orig == NULL) { if (sha256_orig == NULL) {
xbps_dbg_printf(xhp, "%s: conf_file %s unknown orig sha256\n", xbps_dbg_printf(xhp, "%s-%s: conf_file %s not installed\n",
pkgname, entry_pname); pkgname, version, entry_pname);
rv = 1; rv = 1;
goto out; goto out;
} }
@ -155,8 +155,9 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
/* /*
* File not installed, install new one. * File not installed, install new one.
*/ */
xbps_dbg_printf(xhp, "%s: conf_file %s not " xbps_dbg_printf(xhp, "%s-%s: conf_file %s not "
"installed\n", pkgname, entry_pname); "installed\n", pkgname, version,
entry_pname);
rv = 1; rv = 1;
break; break;
} else { } else {
@ -167,19 +168,20 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
/* /*
* Orig = X, Curr = X, New = X * Orig = X, Curr = X, New = X
* *
* Install new file. * Keep file as is (no changes).
*/ */
if ((strcmp(sha256_orig, sha256_cur) == 0) && if ((strcmp(sha256_orig, sha256_cur) == 0) &&
(strcmp(sha256_orig, sha256_new) == 0) && (strcmp(sha256_orig, sha256_new) == 0) &&
(strcmp(sha256_cur, sha256_new) == 0)) { (strcmp(sha256_cur, sha256_new) == 0)) {
xbps_dbg_printf(xhp, "%s: conf_file %s orig = X," xbps_dbg_printf(xhp, "%s-%s: conf_file %s orig = X, "
"cur = X, new = X\n", pkgname, entry_pname); "cur = X, new = X\n", pkgname, version,
rv = 1; entry_pname);
rv = 0;
break; break;
/* /*
* Orig = X, Curr = X, New = Y * Orig = X, Curr = X, New = Y
* *
* Install new file. * Install new file (installed file hasn't been modified).
*/ */
} else if ((strcmp(sha256_orig, sha256_cur) == 0) && } else if ((strcmp(sha256_orig, sha256_cur) == 0) &&
(strcmp(sha256_orig, sha256_new)) && (strcmp(sha256_orig, sha256_new)) &&
@ -192,7 +194,10 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
break; break;
/* /*
* Orig = X, Curr = Y, New = X * Orig = X, Curr = Y, New = X
* Keep current file as is. *
* Keep installed file as is because it has been modified,
* but new package doesn't contain new changes compared
* to the original version.
*/ */
} else if ((strcmp(sha256_orig, sha256_new) == 0) && } else if ((strcmp(sha256_orig, sha256_new) == 0) &&
(strcmp(sha256_cur, sha256_new)) && (strcmp(sha256_cur, sha256_new)) &&
@ -205,17 +210,21 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
break; break;
/* /*
* Orig = X, Curr = Y, New = Y * Orig = X, Curr = Y, New = Y
* Keep current file as is. *
* Keep file as is because changes made are compatible
* with new version.
*/ */
} else if ((strcmp(sha256_cur, sha256_new) == 0) && } else if ((strcmp(sha256_cur, sha256_new) == 0) &&
(strcmp(sha256_orig, sha256_new)) && (strcmp(sha256_orig, sha256_new)) &&
(strcmp(sha256_orig, sha256_cur))) { (strcmp(sha256_orig, sha256_cur))) {
xbps_dbg_printf(xhp, "%s: conf_file %s orig = X," xbps_dbg_printf(xhp, "%s-%s: conf_file %s orig = X, "
"cur = Y, new = Y\n", pkgname, entry_pname); "cur = Y, new = Y\n", pkgname, version,
entry_pname);
rv = 0; rv = 0;
break; break;
/* /*
* Orig = X, Curr = Y, New = Z * Orig = X, Curr = Y, New = Z
*
* Install new file as <file>.new-<version> * Install new file as <file>.new-<version>
*/ */
} else if ((strcmp(sha256_orig, sha256_cur)) && } else if ((strcmp(sha256_orig, sha256_cur)) &&
@ -246,8 +255,8 @@ out:
prop_object_iterator_release(iter); prop_object_iterator_release(iter);
xbps_dbg_printf(xhp, "%s: conf_file %s returned %d\n", xbps_dbg_printf(xhp, "%s-%s: conf_file %s returned %d\n",
pkgname, entry_pname, rv); pkgname, version, entry_pname, rv);
return rv; return rv;
} }