1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

Merge branch 'maint'

Conflicts:
	lib/libalpm/dload.c
This commit is contained in:
Dan McGee 2008-12-02 22:15:02 -06:00
commit 61c6552862
8 changed files with 65 additions and 24 deletions

View File

@ -14,6 +14,7 @@ license=('GPL')
groups=()
depends=()
makedepends=()
optdepends=()
provides=()
conflicts=()
replaces=()

View File

@ -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);
}
}
}
}

View File

@ -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(&reg,
"^[^[:space:]]* [[:xdigit:]]{32}"
" [^[:space:]]* [[:xdigit:]]{32}"
" [^[:space:]]* [[:xdigit:]]{32} [[:digit:]]*$",
REG_EXTENDED | REG_NOSUB | REG_NEWLINE);
if(regexec(&reg, line, 0, 0, 0) != 0) {
/* delta line is invalid, return NULL */
regfree(&reg);
return(NULL);
}
regfree(&reg);
CALLOC(delta, 1, sizeof(pmdelta_t), RET_ERR(PM_ERR_MEMORY, NULL));

View File

@ -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)) {

View File

@ -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

View File

@ -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;
}

View File

@ -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.

View File

@ -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"));