forked from mirrors/pacman
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			morganamil
			...
			morganamil
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					6ce85053c5 | 
@@ -57,7 +57,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
 | 
			
		||||
	ASSERT(pkg->origin == ALPM_PKG_FROM_SYNCDB,
 | 
			
		||||
			RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
 | 
			
		||||
 | 
			
		||||
	fpath = _alpm_cache_find_pkg(pkg, 0);
 | 
			
		||||
	fpath = _alpm_filecache_find(pkg->handle, pkg->filename);
 | 
			
		||||
 | 
			
		||||
	retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_PKG_VALIDATION_MD5SUM);
 | 
			
		||||
 | 
			
		||||
@@ -283,7 +283,7 @@ int SYMEXPORT alpm_pkg_get_sig(alpm_pkg_t *pkg, unsigned char **sig, size_t *sig
 | 
			
		||||
		alpm_errno_t err;
 | 
			
		||||
		int ret = -1;
 | 
			
		||||
 | 
			
		||||
		pkgpath = _alpm_cache_find_pkg(pkg, 0);
 | 
			
		||||
		pkgpath = _alpm_filecache_find(pkg->handle, pkg->filename);
 | 
			
		||||
		if(!pkgpath) {
 | 
			
		||||
			GOTO_ERR(pkg->handle, ALPM_ERR_PKG_NOT_FOUND, cleanup);
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -323,7 +323,7 @@ static int compute_download_size(alpm_pkg_t *newpkg)
 | 
			
		||||
 | 
			
		||||
	ASSERT(newpkg->filename != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1));
 | 
			
		||||
	fname = newpkg->filename;
 | 
			
		||||
	fpath = _alpm_cache_find_pkg(newpkg, 0);
 | 
			
		||||
	fpath = _alpm_filecache_find(handle, fname);
 | 
			
		||||
 | 
			
		||||
	/* downloaded file exists, so there's nothing to grab */
 | 
			
		||||
	if(fpath) {
 | 
			
		||||
@@ -333,7 +333,7 @@ static int compute_download_size(alpm_pkg_t *newpkg)
 | 
			
		||||
 | 
			
		||||
	CALLOC(fnamepart, strlen(fname) + 6, sizeof(char), return -1);
 | 
			
		||||
	sprintf(fnamepart, "%s.part", fname);
 | 
			
		||||
	fpath = _alpm_cache_find_pkg(newpkg, 1);
 | 
			
		||||
	fpath = _alpm_filecache_find(handle, fnamepart);
 | 
			
		||||
	if(fpath) {
 | 
			
		||||
		struct stat st;
 | 
			
		||||
		if(stat(fpath, &st) == 0) {
 | 
			
		||||
@@ -737,13 +737,21 @@ static int find_dl_candidates(alpm_handle_t *handle, alpm_list_t **files)
 | 
			
		||||
 | 
			
		||||
			ASSERT(spkg->filename != NULL, RET_ERR(handle, ALPM_ERR_PKG_INVALID_NAME, -1));
 | 
			
		||||
 | 
			
		||||
			need_download = spkg->download_size != 0 || !_alpm_cache_pkg_exists(spkg, 0);
 | 
			
		||||
			need_download = spkg->download_size != 0 || !_alpm_filecache_exists(handle, spkg->filename);
 | 
			
		||||
			/* even if the package file in the cache we need to check for
 | 
			
		||||
			 * accompanion *.sig file as well.
 | 
			
		||||
			 * If *.sig is not cached then force download the package + its signature file.
 | 
			
		||||
			 */
 | 
			
		||||
			if(!need_download && (siglevel & ALPM_SIG_PACKAGE)) {
 | 
			
		||||
				need_download = !_alpm_cache_pkg_exists(spkg, 1);
 | 
			
		||||
				char *sig_filename = NULL;
 | 
			
		||||
				int len = strlen(spkg->filename) + 5;
 | 
			
		||||
 | 
			
		||||
				MALLOC(sig_filename, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
 | 
			
		||||
				snprintf(sig_filename, len, "%s.sig", spkg->filename);
 | 
			
		||||
 | 
			
		||||
				need_download = !_alpm_filecache_exists(handle, sig_filename);
 | 
			
		||||
 | 
			
		||||
				FREE(sig_filename);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if(need_download) {
 | 
			
		||||
@@ -982,7 +990,7 @@ static int check_validity(alpm_handle_t *handle,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		current_bytes += v.pkg->size;
 | 
			
		||||
		v.path = _alpm_cache_find_pkg(v.pkg, 0);
 | 
			
		||||
		v.path = _alpm_filecache_find(handle, v.pkg->filename);
 | 
			
		||||
		v.siglevel = alpm_db_get_siglevel(alpm_pkg_get_db(v.pkg));
 | 
			
		||||
 | 
			
		||||
		if(_alpm_pkg_validate_internal(handle, v.path, v.pkg,
 | 
			
		||||
@@ -1072,8 +1080,7 @@ static int load_packages(alpm_handle_t *handle, alpm_list_t **data,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		current_bytes += spkg->size;
 | 
			
		||||
 | 
			
		||||
		filepath = _alpm_cache_find_pkg(spkg, 0);
 | 
			
		||||
		filepath = _alpm_filecache_find(handle, spkg->filename);
 | 
			
		||||
 | 
			
		||||
		/* load the package file and replace pkgcache entry with it in the target list */
 | 
			
		||||
		/* TODO: alpm_pkg_get_db() will not work on this target anymore */
 | 
			
		||||
 
 | 
			
		||||
@@ -177,7 +177,8 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
 | 
			
		||||
	ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
 | 
			
		||||
	ASSERT(trans->state == STATE_PREPARED, RET_ERR(handle, ALPM_ERR_TRANS_NOT_PREPARED, -1));
 | 
			
		||||
 | 
			
		||||
	ASSERT(!(trans->flags & ALPM_TRANS_FLAG_NOLOCK), RET_ERR(handle, ALPM_ERR_TRANS_NOT_LOCKED, -1));
 | 
			
		||||
	ASSERT(!(trans->flags & ALPM_TRANS_FLAG_NOLOCK && !(trans->flags & ALPM_TRANS_FLAG_DOWNLOADONLY)),
 | 
			
		||||
			RET_ERR(handle, ALPM_ERR_TRANS_NOT_LOCKED, -1));
 | 
			
		||||
 | 
			
		||||
	/* If there's nothing to do, return without complaining */
 | 
			
		||||
	if(trans->add == NULL && trans->remove == NULL) {
 | 
			
		||||
 
 | 
			
		||||
@@ -815,37 +815,6 @@ int _alpm_str_cmp(const void *s1, const void *s2)
 | 
			
		||||
	return strcmp(s1, s2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *_alpm_cache_find_pkg(alpm_pkg_t *pkg, int sig) {
 | 
			
		||||
	alpm_handle_t *handle = pkg->handle;
 | 
			
		||||
	struct stat buf;
 | 
			
		||||
	alpm_list_t *servers = pkg->origin_data.db->servers;
 | 
			
		||||
	char *retpath;
 | 
			
		||||
	char filepath[PATH_MAX];
 | 
			
		||||
 | 
			
		||||
	for(alpm_list_t *j = servers; j; j = j->next) {
 | 
			
		||||
		char *server = j->data;
 | 
			
		||||
 | 
			
		||||
		if(strncmp("file://", server, strlen("file://")) == 0) {
 | 
			
		||||
			int len = strlen(server) - strlen("file://") + 1 + strlen(pkg->filename) + 1;
 | 
			
		||||
 | 
			
		||||
			if(sig) {
 | 
			
		||||
				len += strlen(".sig");
 | 
			
		||||
				snprintf(filepath, len, "%s/%s", server + strlen("file://"), pkg->filename);
 | 
			
		||||
			} else {
 | 
			
		||||
				snprintf(filepath, len, "%s/%s.sig", server + strlen("file://"), pkg->filename);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if(stat(filepath, &buf) == 0 && S_ISREG(buf.st_mode)) {
 | 
			
		||||
				STRDUP(retpath, filepath, RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
 | 
			
		||||
				_alpm_log(handle, ALPM_LOG_DEBUG, "found pkg in repo cache: %s\n", retpath);
 | 
			
		||||
				return retpath;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return _alpm_filecache_find(handle, pkg->filename);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Find a filename in a registered alpm cachedir.
 | 
			
		||||
 * @param handle the context handle
 | 
			
		||||
 * @param filename name of file to find
 | 
			
		||||
@@ -877,10 +846,10 @@ char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename)
 | 
			
		||||
 * @param filename name of file to find
 | 
			
		||||
 * @return 0 if the filename was not found, 1 otherwise
 | 
			
		||||
 */
 | 
			
		||||
int _alpm_cache_pkg_exists(alpm_pkg_t *pkg, int sig)
 | 
			
		||||
int _alpm_filecache_exists(alpm_handle_t *handle, const char *filename)
 | 
			
		||||
{
 | 
			
		||||
	int res;
 | 
			
		||||
	char *fpath = _alpm_cache_find_pkg(pkg, sig);
 | 
			
		||||
	char *fpath = _alpm_filecache_find(handle, filename);
 | 
			
		||||
	res = (fpath != NULL);
 | 
			
		||||
	FREE(fpath);
 | 
			
		||||
	return res;
 | 
			
		||||
 
 | 
			
		||||
@@ -133,10 +133,9 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[],
 | 
			
		||||
		_alpm_cb_io in_cb, void *in_ctx);
 | 
			
		||||
int _alpm_ldconfig(alpm_handle_t *handle);
 | 
			
		||||
int _alpm_str_cmp(const void *s1, const void *s2);
 | 
			
		||||
char *_alpm_cache_find_pkg(alpm_pkg_t *pkg, int sig);
 | 
			
		||||
char *_alpm_filecache_find(alpm_handle_t *handle, const char *filename);
 | 
			
		||||
/* Checks whether a file exists in cache */
 | 
			
		||||
int _alpm_cache_pkg_exists(alpm_pkg_t *pkg, int sig);
 | 
			
		||||
int _alpm_filecache_exists(alpm_handle_t *handle, const char *filename);
 | 
			
		||||
const char *_alpm_filecache_setup(alpm_handle_t *handle);
 | 
			
		||||
/* Unlike many uses of alpm_pkgvalidation_t, _alpm_test_checksum expects
 | 
			
		||||
 * an enum value rather than a bitfield. */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user