added packages integrity checking

This commit is contained in:
Aurelien Foret 2005-04-13 21:05:08 +00:00
parent c78bcae401
commit 35762528df

View file

@ -364,9 +364,8 @@ int pacman_sync(list_t *targets)
{ {
int confirm = 0; int confirm = 0;
int retval = 0; int retval = 0;
list_t *final = NULL;
list_t *i; list_t *i;
PM_LIST *packages, *data; PM_LIST *packages, *data, *lp;
char *root; char *root;
char ldir[PATH_MAX]; char ldir[PATH_MAX];
int varcache = 1; int varcache = 1;
@ -428,8 +427,6 @@ int pacman_sync(list_t *targets)
} }
if(pmo_s_upgrade) { if(pmo_s_upgrade) {
PM_LIST *lp;
alpm_logaction("starting full system upgrade"); alpm_logaction("starting full system upgrade");
if(alpm_sync_sysupgrade(&data) == -1) { if(alpm_sync_sysupgrade(&data) == -1) {
@ -543,13 +540,13 @@ int pacman_sync(list_t *targets)
goto cleanup; goto cleanup;
} }
/* list targets */ /* list targets and get confirmation */
if(!pmo_s_printuris) { if(!pmo_s_printuris) {
list_t *list = NULL; list_t *list = NULL;
char *str; char *str;
unsigned long totalsize = 0; unsigned long totalsize = 0;
double mb; double mb;
PM_LIST *lp;
/* ORE /* ORE
for(i = rmtargs; i; i = i->next) { for(i = rmtargs; i; i = i->next) {
list = list_add(list, strdup(i->data)); list = list_add(list, strdup(i->data));
@ -600,7 +597,6 @@ int pacman_sync(list_t *targets)
FREELIST(list); FREELIST(list);
FREE(str); FREE(str);
/* get confirmation */
if(pmo_s_downloadonly) { if(pmo_s_downloadonly) {
if(pmo_noconfirm) { if(pmo_noconfirm) {
MSG(NL, "\nBeginning download...\n"); MSG(NL, "\nBeginning download...\n");
@ -632,8 +628,8 @@ int pacman_sync(list_t *targets)
/* group sync records by repository and download */ /* group sync records by repository and download */
alpm_get_option(PM_OPT_ROOT, (long *)&root); alpm_get_option(PM_OPT_ROOT, (long *)&root);
snprintf(ldir, PATH_MAX, "%s" CACHEDIR, root); snprintf(ldir, PATH_MAX, "%s" CACHEDIR, root);
for(i = pmc_syncs; i; i = i->next) { for(i = pmc_syncs; i; i = i->next) {
PM_LIST *lp;
sync_t *current = i->data; sync_t *current = i->data;
for(lp = alpm_list_first(packages); lp; lp = alpm_list_next(lp)) { for(lp = alpm_list_first(packages); lp; lp = alpm_list_next(lp)) {
@ -703,37 +699,34 @@ int pacman_sync(list_t *targets)
MSG(NL, "\n"); MSG(NL, "\n");
/* Check integrity of files */ /* Check integrity of files */
MSG(NL, "checking package integrity... "); MSG(NL, "checking packages integrity... ");
for(i = final; i; i = i->next) { for(lp = alpm_list_first(packages); lp; lp = alpm_list_next(lp)) {
char /*str[PATH_MAX],*/ pkgname[PATH_MAX] = "dummy"; PM_SYNCPKG *sync = alpm_list_getdata(lp);
PM_PKG *spkg = alpm_sync_getinfo(sync, PM_SYNC_SYNCPKG);
char str[PATH_MAX], pkgname[PATH_MAX];
char *md5sum1, *md5sum2; char *md5sum1, *md5sum2;
snprintf(pkgname, PATH_MAX, "%s-%s" PM_EXT_PKG, "", ""); snprintf(pkgname, PATH_MAX, "%s-%s" PM_EXT_PKG,
(char *)alpm_pkg_getinfo(spkg, PM_PKG_NAME),
md5sum1 = NULL; (char *)alpm_pkg_getinfo(spkg, PM_PKG_VERSION));
/* ORE md5sum1 = alpm_pkg_getinfo(spkg, PM_PKG_MD5SUM);
md5sum1 = sync->pkg->md5sum;
if(md5sum1 == NULL) { if(md5sum1 == NULL) {
ERR(NL, "can't get md5 checksum for package %s\n", pkgname); ERR(NL, "can't get md5 checksum for package %s\n", pkgname);
retval = 1; retval = 1;
continue; continue;
} */ }
snprintf(str, PATH_MAX, "%s/%s", ldir, pkgname);
md5sum2 = NULL; md5sum2 = alpm_get_md5sum(str);
/* ORE
md5sum2 = alpm_get_md5sum();
if(md5sum2 == NULL) { if(md5sum2 == NULL) {
ERR(NL, "can't get md5 checksum for package %s\n", pkgname); ERR(NL, "can't get md5 checksum for package %s\n", pkgname);
retval = 1; retval = 1;
continue; continue;
} */ }
if(strcmp(md5sum1, md5sum2) != 0) { if(strcmp(md5sum1, md5sum2) != 0) {
retval = 1; retval = 1;
ERR(NL, "archive %s is corrupted\n", pkgname); ERR(NL, "archive %s is corrupted\n", pkgname);
} }
FREE(md5sum2); FREE(md5sum2);
} }
if(retval) { if(retval) {
@ -741,14 +734,16 @@ int pacman_sync(list_t *targets)
} }
MSG(CL, "done.\n"); MSG(CL, "done.\n");
if(pmo_s_downloadonly) {
goto cleanup;
}
/* Step 3: actually perform the installation */ /* Step 3: actually perform the installation */
if(!pmo_s_downloadonly) {
if(alpm_trans_commit(&data) == -1) { if(alpm_trans_commit(&data) == -1) {
ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno)); ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno));
retval = 1; retval = 1;
goto cleanup; goto cleanup;
} }
}
if(!varcache && !pmo_s_downloadonly) { if(!varcache && !pmo_s_downloadonly) {
/* delete packages */ /* delete packages */