From b708e448ea3ab31cbdc67afbb086b1900452d66a Mon Sep 17 00:00:00 2001 From: Aurelien Foret Date: Sun, 5 Feb 2006 09:58:16 +0000 Subject: added support for alpm_pkg_checkmd5sum() --- src/pacman/sync.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/pacman/sync.c b/src/pacman/sync.c index c46cf7b3..3eb85d8b 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -725,30 +725,15 @@ int pacman_sync(list_t *targets) for(lp = alpm_list_first(packages); lp; lp = alpm_list_next(lp)) { PM_SYNCPKG *sync = alpm_list_getdata(lp); PM_PKG *spkg = alpm_sync_getinfo(sync, PM_SYNC_PKG); - char str[PATH_MAX], pkgname[PATH_MAX]; - char *md5sum1, *md5sum2; - - snprintf(pkgname, PATH_MAX, "%s-%s" PM_EXT_PKG, - (char *)alpm_pkg_getinfo(spkg, PM_PKG_NAME), - (char *)alpm_pkg_getinfo(spkg, PM_PKG_VERSION)); - md5sum1 = alpm_pkg_getinfo(spkg, PM_PKG_MD5SUM); - if(md5sum1 == NULL) { - ERR(NL, "can't get md5 checksum for package %s\n", pkgname); - retval = 1; - continue; - } - snprintf(str, PATH_MAX, "%s/%s", ldir, pkgname); - md5sum2 = alpm_get_md5sum(str); - if(md5sum2 == NULL) { - ERR(NL, "can't get md5 checksum for package %s\n", pkgname); - retval = 1; - continue; - } - if(strcmp(md5sum1, md5sum2) != 0) { + if(alpm_pkg_checkmd5sum(spkg) == -1) { + if(pm_errno == PM_ERR_PKG_INVALID) { + ERR(NL, "archive %s is corrupted\n", alpm_pkg_getinfo(spkg, PM_PKG_NAME)); + } else { + ERR(NL, "could not get checksum for package %s (%s)\n", + alpm_pkg_getinfo(spkg, PM_PKG_NAME), alpm_strerror(pm_errno)); + } retval = 1; - ERR(NL, "archive %s is corrupted\n", pkgname); } - FREE(md5sum2); } if(retval) { goto cleanup; -- cgit v1.2.3-24-g4f1b