index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | lib/libalpm/add.c | 14 | ||||
-rw-r--r-- | lib/libalpm/alpm.h | 14 | ||||
-rw-r--r-- | lib/libalpm/be_files.c | 10 | ||||
-rw-r--r-- | lib/libalpm/db.c | 1 | ||||
-rw-r--r-- | lib/libalpm/delta.c | 16 | ||||
-rw-r--r-- | lib/libalpm/delta.h | 8 | ||||
-rw-r--r-- | lib/libalpm/dload.c | 6 | ||||
-rw-r--r-- | lib/libalpm/graph.h | 4 | ||||
-rw-r--r-- | lib/libalpm/package.c | 4 | ||||
-rw-r--r-- | lib/libalpm/package.h | 11 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 13 |
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index c5454bab..03698622 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -27,6 +27,8 @@ #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> +#include <inttypes.h> /* int64_t */ +#include <stdint.h> /* intmax_t */ /* libarchive */ #include <archive.h> @@ -635,7 +637,6 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count, int i, ret = 0, errors = 0; char scriptlet[PATH_MAX+1]; int is_upgrade = 0; - double percent = 0.0; pmpkg_t *oldpkg = NULL; ALPM_LOG_FUNC; @@ -730,17 +731,22 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count, } for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) { + double percent; + if(newpkg->size != 0) { /* Using compressed size for calculations here, as newpkg->isize is not * exact when it comes to comparing to the ACTUAL uncompressed size * (missing metadata sizes) */ - unsigned long pos = archive_position_compressed(archive); + int64_t pos = archive_position_compressed(archive); percent = (double)pos / (double)newpkg->size; - _alpm_log(PM_LOG_DEBUG, "decompression progress: %f%% (%ld / %ld)\n", - percent*100.0, pos, newpkg->size); + _alpm_log(PM_LOG_DEBUG, "decompression progress: " + "%f%% (%"PRId64" / %jd)\n", + percent*100.0, pos, (intmax_t)newpkg->size); if(percent >= 1.0) { percent = 1.0; } + } else { + percent = 0.0; } if(is_upgrade) { diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 62a517b4..fd3be0d3 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -1,7 +1,7 @@ /* * alpm.h * - * Copyright (c) 2002-2007 by Judd Vinet <jvinet@zeroflux.org> + * Copyright (c) 2002-2008 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu> * Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org> @@ -26,6 +26,7 @@ extern "C" { #endif +#include <sys/types.h> /* for off_t */ #include <time.h> /* for time_t */ #include <stdarg.h> /* for va_list */ @@ -79,7 +80,8 @@ int alpm_logaction(char *fmt, ...); * Downloading */ -typedef void (*alpm_cb_download)(const char *filename, int xfered, int total); +typedef void (*alpm_cb_download)(const char *filename, + off_t xfered, off_t total); /* * Options @@ -201,8 +203,8 @@ time_t alpm_pkg_get_installdate(pmpkg_t *pkg); const char *alpm_pkg_get_packager(pmpkg_t *pkg); const char *alpm_pkg_get_md5sum(pmpkg_t *pkg); const char *alpm_pkg_get_arch(pmpkg_t *pkg); -unsigned long alpm_pkg_get_size(pmpkg_t *pkg); -unsigned long alpm_pkg_get_isize(pmpkg_t *pkg); +off_t alpm_pkg_get_size(pmpkg_t *pkg); +off_t alpm_pkg_get_isize(pmpkg_t *pkg); pmpkgreason_t alpm_pkg_get_reason(pmpkg_t *pkg); alpm_list_t *alpm_pkg_get_licenses(pmpkg_t *pkg); alpm_list_t *alpm_pkg_get_groups(pmpkg_t *pkg); @@ -221,7 +223,7 @@ size_t alpm_pkg_changelog_read(void *ptr, size_t size, int alpm_pkg_changelog_close(const pmpkg_t *pkg, void *fp); unsigned short alpm_pkg_has_scriptlet(pmpkg_t *pkg); -unsigned long alpm_pkg_download_size(pmpkg_t *newpkg); +off_t alpm_pkg_download_size(pmpkg_t *newpkg); /* * Deltas @@ -233,7 +235,7 @@ const char *alpm_delta_get_to(pmdelta_t *delta); const char *alpm_delta_get_to_md5sum(pmdelta_t *delta); const char *alpm_delta_get_filename(pmdelta_t *delta); const char *alpm_delta_get_md5sum(pmdelta_t *delta); -unsigned long alpm_delta_get_size(pmdelta_t *delta); +off_t alpm_delta_get_size(pmdelta_t *delta); /* * Groups diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index 2302374d..dc644cea 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -25,7 +25,7 @@ #include <stdlib.h> #include <errno.h> #include <string.h> -#include <stdint.h> /* uintmax_t */ +#include <stdint.h> /* uintmax_t, intmax_t */ #include <sys/stat.h> #include <dirent.h> #include <ctype.h> @@ -710,10 +710,10 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) fprintf(fp, "%%PACKAGER%%\n" "%s\n\n", info->packager); } - if(info->size) { + if(info->isize) { /* only write installed size, csize is irrelevant once installed */ fprintf(fp, "%%SIZE%%\n" - "%lu\n\n", info->isize); + "%ju\n\n", (intmax_t)info->isize); } if(info->reason) { fprintf(fp, "%%REASON%%\n" @@ -722,11 +722,11 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) } else { if(info->size) { fprintf(fp, "%%CSIZE%%\n" - "%lu\n\n", info->size); + "%ju\n\n", (intmax_t)info->size); } if(info->isize) { fprintf(fp, "%%ISIZE%%\n" - "%lu\n\n", info->isize); + "%ju\n\n", (intmax_t)info->isize); } if(info->md5sum) { fprintf(fp, "%%MD5SUM%%\n" diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index df16c3c9..0be81cb1 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -28,7 +28,6 @@ #include <stdlib.h> #include <errno.h> #include <string.h> -#include <stdint.h> /* uintmax_t */ #include <sys/stat.h> #include <dirent.h> #include <regex.h> diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c index fdb4d99b..22d9beb4 100644 --- a/lib/libalpm/delta.c +++ b/lib/libalpm/delta.c @@ -71,7 +71,7 @@ const char SYMEXPORT *alpm_delta_get_md5sum(pmdelta_t *delta) return(delta->delta_md5); } -unsigned long SYMEXPORT alpm_delta_get_size(pmdelta_t *delta) +off_t SYMEXPORT alpm_delta_get_size(pmdelta_t *delta) { ASSERT(delta != NULL, return(-1)); return(delta->delta_size); @@ -89,7 +89,7 @@ static alpm_list_t *delta_graph_init(alpm_list_t *deltas) pmgraph_t *v = _alpm_graph_new(); pmdelta_t *vdelta = i->data; vdelta->download_size = vdelta->delta_size; - v->weight = ULONG_MAX; + v->weight = LONG_MAX; /* determine whether the delta file already exists */ fpath = _alpm_filecache_find(vdelta->delta); @@ -139,7 +139,7 @@ static alpm_list_t *delta_graph_init(alpm_list_t *deltas) return(vertices); } -static unsigned long delta_vert(alpm_list_t *vertices, +static off_t delta_vert(alpm_list_t *vertices, const char *to, const char *to_md5, alpm_list_t **path) { alpm_list_t *i; pmgraph_t *v; @@ -157,7 +157,7 @@ static unsigned long delta_vert(alpm_list_t *vertices, v = v_i; } } - if(v == NULL || v->weight == ULONG_MAX) { + if(v == NULL || v->weight == LONG_MAX) { break; } @@ -178,7 +178,7 @@ static unsigned long delta_vert(alpm_list_t *vertices, } v = NULL; - unsigned long bestsize = 0; + off_t bestsize = 0; for(i = vertices; i; i = i->next) { pmgraph_t *v_i = i->data; @@ -214,14 +214,14 @@ static unsigned long delta_vert(alpm_list_t *vertices, * @param path the pointer to a list location where pmdelta_t * objects that * have the smallest size are placed. NULL is set if there is no path * possible with the files available. - * @return the size of the path stored, or ULONG_MAX if path is unfindable + * @return the size of the path stored, or LONG_MAX if path is unfindable */ -unsigned long _alpm_shortest_delta_path(alpm_list_t *deltas, +off_t _alpm_shortest_delta_path(alpm_list_t *deltas, const char *to, const char *to_md5, alpm_list_t **path) { alpm_list_t *bestpath = NULL; alpm_list_t *vertices; - unsigned long bestsize = ULONG_MAX; + off_t bestsize = LONG_MAX; ALPM_LOG_FUNC; diff --git a/lib/libalpm/delta.h b/lib/libalpm/delta.h index 33d47e1e..5bb86b94 100644 --- a/lib/libalpm/delta.h +++ b/lib/libalpm/delta.h @@ -19,6 +19,8 @@ #ifndef _ALPM_DELTA_H #define _ALPM_DELTA_H +#include <sys/types.h> /* off_t */ + #include "alpm.h" struct __pmdelta_t { @@ -35,14 +37,14 @@ struct __pmdelta_t { /** md5sum of the delta file */ char *delta_md5; /** filesize of the delta file */ - unsigned long delta_size; + off_t delta_size; /** download filesize of the delta file */ - unsigned long download_size; + off_t download_size; }; pmdelta_t *_alpm_delta_parse(char *line); void _alpm_delta_free(pmdelta_t *delta); -unsigned long _alpm_shortest_delta_path(alpm_list_t *deltas, +off_t _alpm_shortest_delta_path(alpm_list_t *deltas, const char *to, const char *to_md5, alpm_list_t **path); #endif /* _ALPM_DELTA_H */ diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 44acec70..b5f0b876 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -112,7 +112,7 @@ static int download_internal(const char *url, const char *localpath, struct url_stat ust; struct stat st; int chk_resume = 0; - int dl_thisfile = 0; + size_t dl_thisfile = 0; char *tempfile, *destfile, *filename; int ret = 0; struct url *fileurl = url_for_string(url); @@ -200,7 +200,7 @@ static int download_internal(const char *url, const char *localpath, handle->dlcb(filename, 0, ust.size); } - int nread = 0; + size_t nread = 0; char buffer[PM_DLBUF_LEN]; while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) { if(ferror(dlf)) { @@ -211,7 +211,7 @@ static int download_internal(const char *url, const char *localpath, goto cleanup; } - int nwritten = 0; + size_t nwritten = 0; while(nwritten < nread) { nwritten += fwrite(buffer, 1, (nread - nwritten), localf); if(ferror(localf)) { diff --git a/lib/libalpm/graph.h b/lib/libalpm/graph.h index 3078e25f..72a7136f 100644 --- a/lib/libalpm/graph.h +++ b/lib/libalpm/graph.h @@ -17,6 +17,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <sys/types.h> /* off_t */ + #include "alpm_list.h" #include "util.h" /* MALLOC() */ #include "alpm.h" @@ -24,7 +26,7 @@ struct __pmgraph_t { char state; /* 0: untouched, -1: entered, other: leaving time */ void *data; - unsigned long int weight; /* weight of the node */ + off_t weight; /* weight of the node */ struct __pmgraph_t *parent; /* where did we come from? */ alpm_list_t *children; alpm_list_t *childptr; /* points to a child in children list */ diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 685a411f..3708a58a 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -225,7 +225,7 @@ const char SYMEXPORT *alpm_pkg_get_arch(pmpkg_t *pkg) return pkg->arch; } -unsigned long SYMEXPORT alpm_pkg_get_size(pmpkg_t *pkg) +off_t SYMEXPORT alpm_pkg_get_size(pmpkg_t *pkg) { ALPM_LOG_FUNC; @@ -239,7 +239,7 @@ unsigned long SYMEXPORT alpm_pkg_get_size(pmpkg_t *pkg) return pkg->size; } -unsigned long SYMEXPORT alpm_pkg_get_isize(pmpkg_t *pkg) +off_t SYMEXPORT alpm_pkg_get_isize(pmpkg_t *pkg) { ALPM_LOG_FUNC; diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index ddf1d073..d06cf150 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -23,7 +23,8 @@ #ifndef _ALPM_PACKAGE_H #define _ALPM_PACKAGE_H -#include <time.h> +#include <sys/types.h> /* off_t */ +#include <time.h> /* time_t */ #include "alpm.h" #include "db.h" @@ -44,8 +45,9 @@ struct __pmpkg_t { char *packager; char *md5sum; char *arch; - unsigned long size; - unsigned long isize; + off_t size; + off_t isize; + off_t download_size; unsigned short scriptlet; unsigned short force; pmpkgreason_t reason; @@ -59,6 +61,7 @@ struct __pmpkg_t { alpm_list_t *conflicts; alpm_list_t *provides; alpm_list_t *deltas; + alpm_list_t *delta_path; /* internal */ pmpkgfrom_t origin; /* Replaced 'void *data' with this union as follows: @@ -70,8 +73,6 @@ struct __pmpkg_t { char *file; } origin_data; pmdbinfrq_t infolevel; - unsigned long download_size; - alpm_list_t *delta_path; }; pmpkg_t* _alpm_pkg_new(void); diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 0d6a6ee3..2dad8bf7 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -22,6 +22,7 @@ #include "config.h" +#include <sys/types.h> /* off_t */ #include <stdlib.h> #include <stdio.h> #include <fcntl.h> @@ -385,7 +386,7 @@ static int compute_download_size(pmpkg_t *newpkg) { const char *fname; char *fpath; - unsigned long size = 0; + off_t size = 0; fname = alpm_pkg_get_filename(newpkg); ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1)); @@ -395,8 +396,8 @@ static int compute_download_size(pmpkg_t *newpkg) FREE(fpath); size = 0; } else if(handle->usedelta) { - unsigned long dltsize; - unsigned long pkgsize = alpm_pkg_get_size(newpkg); + off_t dltsize; + off_t pkgsize = alpm_pkg_get_size(newpkg); dltsize = _alpm_shortest_delta_path( alpm_pkg_get_deltas(newpkg), @@ -417,8 +418,8 @@ static int compute_download_size(pmpkg_t *newpkg) size = alpm_pkg_get_size(newpkg); } - _alpm_log(PM_LOG_DEBUG, "setting download size %ld for pkg %s\n", size, - alpm_pkg_get_name(newpkg)); + _alpm_log(PM_LOG_DEBUG, "setting download size %lld for pkg %s\n", + (long long)size, alpm_pkg_get_name(newpkg)); newpkg->download_size = size; return(0); @@ -670,7 +671,7 @@ cleanup: * @param newpkg the new package to upgrade to * @return the size of the download */ -unsigned long SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg) +off_t SYMEXPORT alpm_pkg_download_size(pmpkg_t *newpkg) { return(newpkg->download_size); } |