1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-23 08:18:51 -05:00

added support for alpm_pkg_checkmd5sum()

This commit is contained in:
Aurelien Foret 2006-02-05 09:58:16 +00:00
parent 298c1a8e97
commit b708e448ea

View File

@ -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;
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));
}
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) {
retval = 1;
ERR(NL, "archive %s is corrupted\n", pkgname);
}
FREE(md5sum2);
}
if(retval) {
goto cleanup;