diff options
-rw-r--r-- | PKGBUILD.proto | 1 | ||||
-rw-r--r-- | lib/libalpm/be_files.c | 11 | ||||
-rw-r--r-- | lib/libalpm/delta.c | 15 | ||||
-rw-r--r-- | lib/libalpm/dload.c | 10 | ||||
-rw-r--r-- | scripts/makepkg.sh.in | 2 | ||||
-rw-r--r-- | src/pacman/callback.c | 1 | ||||
-rw-r--r-- | src/pacman/pacman.c | 46 | ||||
-rw-r--r-- | src/pacman/sync.c | 3 |
8 files changed, 65 insertions, 24 deletions
diff --git a/PKGBUILD.proto b/PKGBUILD.proto index 32655306..eddcf759 100644 --- a/PKGBUILD.proto +++ b/PKGBUILD.proto @@ -14,6 +14,7 @@ license=('GPL') groups=() depends=() makedepends=() +optdepends=() provides=() conflicts=() replaces=() diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index f5d4e826..b9ff6464 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -51,7 +51,7 @@ * Return the last update time as number of seconds from the epoch. * Returns 0 if the value is unknown or can't be read. */ -time_t getlastupdate(const pmdb_t *db) +static time_t getlastupdate(const pmdb_t *db) { FILE *fp; char *file; @@ -85,7 +85,7 @@ time_t getlastupdate(const pmdb_t *db) /* * writes the dbpath/.lastupdate file with the value in time */ -int setlastupdate(const pmdb_t *db, time_t time) +static int setlastupdate(const pmdb_t *db, time_t time) { FILE *fp; char *file; @@ -500,7 +500,7 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) if(fgets(line, 512, fp) == NULL) { goto error; } - info->reason = atol(_alpm_strtrim(line)); + info->reason = (pmpkgreason_t)atol(_alpm_strtrim(line)); } else if(strcmp(line, "%SIZE%") == 0 || strcmp(line, "%CSIZE%") == 0) { /* NOTE: the CSIZE and SIZE fields both share the "size" field * in the pkginfo_t struct. This can be done b/c CSIZE @@ -618,7 +618,10 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq) _alpm_strtrim(line); if(strcmp(line, "%DELTAS%") == 0) { while(fgets(line, 512, fp) && strlen(_alpm_strtrim(line))) { - info->deltas = alpm_list_add(info->deltas, _alpm_delta_parse(line)); + pmdelta_t *delta = _alpm_delta_parse(line); + if(delta) { + info->deltas = alpm_list_add(info->deltas, delta); + } } } } diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c index 22d9beb4..8dce7e3b 100644 --- a/lib/libalpm/delta.c +++ b/lib/libalpm/delta.c @@ -22,6 +22,8 @@ #include <stdlib.h> #include <string.h> #include <limits.h> +#include <sys/types.h> +#include <regex.h> /* libalpm */ #include "delta.h" @@ -257,6 +259,19 @@ pmdelta_t *_alpm_delta_parse(char *line) { pmdelta_t *delta; char *tmp = line, *tmp2; + regex_t reg; + + regcomp(®, + "^[^[:space:]]* [[:xdigit:]]{32}" + " [^[:space:]]* [[:xdigit:]]{32}" + " [^[:space:]]* [[:xdigit:]]{32} [[:digit:]]*$", + REG_EXTENDED | REG_NOSUB | REG_NEWLINE); + if(regexec(®, line, 0, 0, 0) != 0) { + /* delta line is invalid, return NULL */ + regfree(®); + return(NULL); + } + regfree(®); CALLOC(delta, 1, sizeof(pmdelta_t), RET_ERR(PM_ERR_MEMORY, NULL)); diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index f197d060..9934f30a 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -112,12 +112,12 @@ static int download_internal(const char *url, const char *localpath, FILE *dlf, *localf = NULL; struct url_stat ust; struct stat st; - int chk_resume = 0; - size_t dl_thisfile = 0; + int chk_resume = 0, ret = 0; + size_t dl_thisfile = 0, nread = 0; char *tempfile, *destfile, *filename; - int ret = 0; struct sigaction new_action, old_action; struct url *fileurl = url_for_string(url); + char buffer[PM_DLBUF_LEN]; if(!fileurl) { return(-1); @@ -208,9 +208,8 @@ static int download_internal(const char *url, const char *localpath, handle->dlcb(filename, 0, ust.size); } - size_t nread = 0; - char buffer[PM_DLBUF_LEN]; while((nread = fread(buffer, 1, PM_DLBUF_LEN, dlf)) > 0) { + size_t nwritten = 0; if(ferror(dlf)) { pm_errno = PM_ERR_LIBFETCH; _alpm_log(PM_LOG_ERROR, _("error downloading '%s': %s\n"), @@ -219,7 +218,6 @@ static int download_internal(const char *url, const char *localpath, goto cleanup; } - size_t nwritten = 0; while(nwritten < nread) { nwritten += fwrite(buffer, 1, (nread - nwritten), localf); if(ferror(localf)) { diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 6dc7db41..0c74fcd4 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1080,7 +1080,7 @@ devel_check() { hg clone $_hgroot/$_hgrepo ./src/$_hgrepo cd ./src/$_hgrepo fi - newpkgver=$(hg tip | sed -n '1s/[^0-9]*\([^:]*\):.*$/\1/p') + newpkgver=$(hg tip --template "{rev}") cd ../../ fi diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 92a31f16..9f1cca89 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -443,6 +443,7 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) if(config->noprogressbar || file_total == -1) { if(file_xfered == 0) { printf(_("downloading %s...\n"), filename); + fflush(stdout); } return; } diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index a71381fa..3255cdf0 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -578,6 +578,7 @@ static int _parseconfig(const char *file, const char *givensection, int linenum = 0; char *ptr, *section = NULL; pmdb_t *db = NULL; + int ret = 0; pm_printf(PM_LOG_DEBUG, "config: attempting to read file %s\n", file); fp = fopen(file, "r"); @@ -620,7 +621,8 @@ static int _parseconfig(const char *file, const char *givensection, if(!strlen(section)) { pm_printf(PM_LOG_ERROR, _("config file %s, line %d: bad section name.\n"), file, linenum); - return(1); + ret = 1; + goto cleanup; } /* if we are not looking at the options section, register a db and also * ensure we have set all of our library paths as the library is too stupid @@ -628,6 +630,12 @@ static int _parseconfig(const char *file, const char *givensection, if(strcmp(section, "options") != 0) { setlibpaths(); db = alpm_db_register_sync(section); + if(db == NULL) { + pm_printf(PM_LOG_ERROR, _("could not register '%s' database (%s)\n"), + section, alpm_strerrorlast()); + ret = 1; + goto cleanup; + } } } else { /* directive */ @@ -642,13 +650,15 @@ static int _parseconfig(const char *file, const char *givensection, if(key == NULL) { pm_printf(PM_LOG_ERROR, _("config file %s, line %d: syntax error in config file- missing key.\n"), file, linenum); - return(1); + ret = 1; + goto cleanup; } /* For each directive, compare to the camelcase string. */ if(section == NULL) { pm_printf(PM_LOG_ERROR, _("config file %s, line %d: All directives must belong to a section.\n"), file, linenum); - return(1); + ret = 1; + goto cleanup; } if(ptr == NULL && strcmp(section, "options") == 0) { /* directives without settings, all in [options] */ @@ -673,7 +683,8 @@ static int _parseconfig(const char *file, const char *givensection, } else { pm_printf(PM_LOG_ERROR, _("config file %s, line %d: directive '%s' not recognized.\n"), file, linenum, key); - return(1); + ret = 1; + goto cleanup; } } else { /* directives with settings */ @@ -704,7 +715,8 @@ static int _parseconfig(const char *file, const char *givensection, if(alpm_option_add_cachedir(ptr) != 0) { pm_printf(PM_LOG_ERROR, _("problem adding cachedir '%s' (%s)\n"), ptr, alpm_strerrorlast()); - return(1); + ret = 1; + goto cleanup; } pm_printf(PM_LOG_DEBUG, "config: cachedir: %s\n", ptr); } else if(strcmp(key, "RootDir") == 0) { @@ -728,13 +740,15 @@ static int _parseconfig(const char *file, const char *givensection, config->cleanmethod = PM_CLEAN_KEEPCUR; } else { pm_printf(PM_LOG_ERROR, _("invalid value for 'CleanMethod' : '%s'\n"), ptr); - return(1); + ret = 1; + goto cleanup; } pm_printf(PM_LOG_DEBUG, "config: cleanmethod: %s\n", ptr); } else { pm_printf(PM_LOG_ERROR, _("config file %s, line %d: directive '%s' not recognized.\n"), file, linenum, key); - return(1); + ret = 1; + goto cleanup; } } else if(strcmp(key, "Server") == 0) { /* let's attempt a replacement for the current repo */ @@ -742,27 +756,35 @@ static int _parseconfig(const char *file, const char *givensection, if(alpm_db_setserver(db, server) != 0) { /* pm_errno is set by alpm_db_setserver */ - return(1); + pm_printf(PM_LOG_ERROR, _("could not add server URL to database '%s': %s (%s)\n"), + alpm_db_get_name(db), server, alpm_strerrorlast()); + free(server); + ret = 1; + goto cleanup; } free(server); } else { pm_printf(PM_LOG_ERROR, _("config file %s, line %d: directive '%s' not recognized.\n"), file, linenum, key); - return(1); + ret = 1; + goto cleanup; } } } } - fclose(fp); + +cleanup: + if(fp) { + fclose(fp); + } if(section){ free(section); } - /* call setlibpaths here to ensure we have called it at least once */ setlibpaths(); pm_printf(PM_LOG_DEBUG, "config: finished parsing %s\n", file); - return(0); + return(ret); } /** Parse a configuration file. diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 63397aa3..e3a772de 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -551,6 +551,7 @@ static int sync_trans(alpm_list_t *targets) int retval = 0; alpm_list_t *data = NULL; alpm_list_t *sync_dbs = alpm_option_get_syncdbs(); + alpm_list_t *packages = NULL; /* Step 1: create a new transaction... */ if(trans_init(PM_TRANS_TYPE_SYNC, config->flags) == -1) { @@ -659,7 +660,7 @@ static int sync_trans(alpm_list_t *targets) goto cleanup; } - alpm_list_t *packages = alpm_trans_get_pkgs(); + packages = alpm_trans_get_pkgs(); if(packages == NULL) { /* nothing to do: just exit without complaining */ printf(_(" local database is up to date\n")); |