Merge branch 'maint'
Conflicts: lib/libalpm/dload.c
This commit is contained in:
commit
8e7652f1af
3 changed files with 36 additions and 15 deletions
|
@ -184,11 +184,11 @@ GCC_VISIBILITY_CC
|
||||||
GCC_GNU89_INLINE_CC
|
GCC_GNU89_INLINE_CC
|
||||||
|
|
||||||
# Host-dependant definitions
|
# Host-dependant definitions
|
||||||
SIZECMD="stat -c %s"
|
SIZECMD="stat -L -c %s"
|
||||||
SEDINPLACE="sed -i"
|
SEDINPLACE="sed -i"
|
||||||
case "${host_os}" in
|
case "${host_os}" in
|
||||||
*bsd*)
|
*bsd*)
|
||||||
SIZECMD="stat -f %z"
|
SIZECMD="stat -L -f %z"
|
||||||
SEDINPLACE="sed -i ''"
|
SEDINPLACE="sed -i ''"
|
||||||
;;
|
;;
|
||||||
cygwin*)
|
cygwin*)
|
||||||
|
@ -197,7 +197,7 @@ case "${host_os}" in
|
||||||
;;
|
;;
|
||||||
darwin*)
|
darwin*)
|
||||||
host_os_darwin=yes
|
host_os_darwin=yes
|
||||||
SIZECMD="/usr/bin/stat -f %z"
|
SIZECMD="/usr/bin/stat -L -f %z"
|
||||||
SEDINPLACE="/usr/bin/sed -i ''"
|
SEDINPLACE="/usr/bin/sed -i ''"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -76,6 +76,15 @@ static char *get_tempfile(const char *path, const char *filename) {
|
||||||
return(tempfile);
|
return(tempfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *gethost(struct url *fileurl)
|
||||||
|
{
|
||||||
|
const char *host = _("disk");
|
||||||
|
if(strcmp(SCHEME_FILE, fileurl->scheme) != 0) {
|
||||||
|
host = fileurl->host;
|
||||||
|
}
|
||||||
|
return(host);
|
||||||
|
}
|
||||||
|
|
||||||
static int download_internal(const char *url, const char *localpath,
|
static int download_internal(const char *url, const char *localpath,
|
||||||
time_t mtimeold, time_t *mtimenew) {
|
time_t mtimeold, time_t *mtimenew) {
|
||||||
fetchIO *dlf = NULL;
|
fetchIO *dlf = NULL;
|
||||||
|
@ -83,7 +92,8 @@ static int download_internal(const char *url, const char *localpath,
|
||||||
struct url_stat ust;
|
struct url_stat ust;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int chk_resume = 0, ret = 0;
|
int chk_resume = 0, ret = 0;
|
||||||
size_t dl_thisfile = 0, nread = 0;
|
size_t dl_thisfile = 0;
|
||||||
|
ssize_t nread = 0;
|
||||||
char *tempfile, *destfile, *filename;
|
char *tempfile, *destfile, *filename;
|
||||||
struct sigaction new_action, old_action;
|
struct sigaction new_action, old_action;
|
||||||
struct url *fileurl;
|
struct url *fileurl;
|
||||||
|
@ -149,13 +159,9 @@ static int download_internal(const char *url, const char *localpath,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fetchLastErrCode != 0 || dlf == NULL) {
|
if(fetchLastErrCode != 0 || dlf == NULL) {
|
||||||
const char *host = _("disk");
|
|
||||||
if(strcmp(SCHEME_FILE, fileurl->scheme) != 0) {
|
|
||||||
host = fileurl->host;
|
|
||||||
}
|
|
||||||
pm_errno = PM_ERR_LIBFETCH;
|
pm_errno = PM_ERR_LIBFETCH;
|
||||||
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
|
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s : %s\n"),
|
||||||
filename, host, fetchLastErrString);
|
filename, gethost(fileurl), fetchLastErrString);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
|
@ -208,8 +214,17 @@ static int download_internal(const char *url, const char *localpath,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* did the transfer complete normally? */
|
/* did the transfer complete normally? */
|
||||||
|
if (nread == -1) {
|
||||||
|
/* not PM_ERR_LIBFETCH here because libfetch error string might be empty */
|
||||||
|
pm_errno = PM_ERR_RETRIEVE;
|
||||||
|
_alpm_log(PM_LOG_ERROR, _("failed retrieving file '%s' from %s\n"),
|
||||||
|
filename, gethost(fileurl));
|
||||||
|
ret = -1;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (ust.size != -1 && dl_thisfile < ust.size) {
|
if (ust.size != -1 && dl_thisfile < ust.size) {
|
||||||
pm_errno = PM_ERR_LIBFETCH;
|
pm_errno = PM_ERR_RETRIEVE;
|
||||||
_alpm_log(PM_LOG_ERROR, _("%s appears to be truncated: %jd/%jd bytes\n"),
|
_alpm_log(PM_LOG_ERROR, _("%s appears to be truncated: %jd/%jd bytes\n"),
|
||||||
filename, (intmax_t)dl_thisfile, (intmax_t)ust.size);
|
filename, (intmax_t)dl_thisfile, (intmax_t)ust.size);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
|
@ -306,10 +306,15 @@ check_repo_db()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$REPO_DB_FILE" ]; then
|
if [ -f "$REPO_DB_FILE" ]; then
|
||||||
if ! bsdtar -tqf "$REPO_DB_FILE" '*/desc' 2>&1 >/dev/null; then
|
# there are two situations we can have here- a DB with some entries,
|
||||||
|
# or a DB with no contents at all.
|
||||||
|
if ! bsdtar -tqf "$REPO_DB_FILE" '*/desc' >/dev/null 2>&1; then
|
||||||
|
# check empty case
|
||||||
|
if [ -n "$(bsdtar -tqf "$REPO_DB_FILE" '*' 2>/dev/null)" ]; then
|
||||||
error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE"
|
error "$(gettext "Repository file '%s' is not a proper pacman database.")" "$REPO_DB_FILE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
msg "$(gettext "Extracting database to a temporary location...")"
|
msg "$(gettext "Extracting database to a temporary location...")"
|
||||||
bsdtar -xf "$REPO_DB_FILE" -C "$tmpdir"
|
bsdtar -xf "$REPO_DB_FILE" -C "$tmpdir"
|
||||||
else
|
else
|
||||||
|
@ -472,8 +477,9 @@ if [ $success -eq 1 ]; then
|
||||||
if [ -n "$(ls)" ]; then
|
if [ -n "$(ls)" ]; then
|
||||||
bsdtar -c${TAR_OPT}f "$filename" *
|
bsdtar -c${TAR_OPT}f "$filename" *
|
||||||
else
|
else
|
||||||
# the database will be moved to .old below, and there will be no new one to replace it
|
# we have no packages remaining? zip up some emptyness
|
||||||
error "$(gettext "All packages have been removed from the database. Deleting '%s'.")" "$REPO_DB_FILE"
|
warning "$(gettext "No packages remain, creating empty database.")"
|
||||||
|
bsdtar -c${TAR_OPT}f "$filename" -T /dev/null
|
||||||
fi
|
fi
|
||||||
cd "$startdir"
|
cd "$startdir"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue