diff options
author | Simon J. Gerraty <sjg@FreeBSD.org> | 2015-05-27 01:19:58 +0000 |
---|---|---|
committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2015-05-27 01:19:58 +0000 |
commit | 98e0ffaefb0f241cda3a72395d3be04192ae0d47 (patch) | |
tree | 55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /usr.sbin/pkg | |
parent | b17ff922d4072ae132ece458f5b5d74a236880ac (diff) | |
parent | e81032ad243db32b8fd615b2d55ee94b9f6a5b6a (diff) | |
download | src-98e0ffaefb0f241cda3a72395d3be04192ae0d47.tar.gz src-98e0ffaefb0f241cda3a72395d3be04192ae0d47.zip |
Merge sync of head
Notes
Notes:
svn path=/projects/bmake/; revision=283595
Diffstat (limited to 'usr.sbin/pkg')
-rw-r--r-- | usr.sbin/pkg/Makefile | 5 | ||||
-rw-r--r-- | usr.sbin/pkg/Makefile.depend | 1 | ||||
-rw-r--r-- | usr.sbin/pkg/pkg.c | 39 |
3 files changed, 23 insertions, 22 deletions
diff --git a/usr.sbin/pkg/Makefile b/usr.sbin/pkg/Makefile index c372a3c492af..0884b6b528cd 100644 --- a/usr.sbin/pkg/Makefile +++ b/usr.sbin/pkg/Makefile @@ -6,9 +6,6 @@ MAN= pkg.7 CFLAGS+=-I${.CURDIR}/../../contrib/libucl/include .PATH: ${.CURDIR}/../../contrib/libucl/include -DPADD= ${LIBARCHIVE} ${LIBFETCH} ${LIBUCL} ${LIBSBUF} ${LIBSSL} \ - ${LIBCRYPTO} ${LIBM} -LDADD= -larchive -lfetch ${LDUCL} -lsbuf -lssl -lcrypto -lm -USEPRIVATELIB= ucl +LIBADD= archive fetch ucl sbuf crypto .include <bsd.prog.mk> diff --git a/usr.sbin/pkg/Makefile.depend b/usr.sbin/pkg/Makefile.depend index b61c29c20707..d8f6d6345f11 100644 --- a/usr.sbin/pkg/Makefile.depend +++ b/usr.sbin/pkg/Makefile.depend @@ -17,6 +17,7 @@ DIRDEPS = \ lib/libfetch \ lib/liblzma \ lib/libsbuf \ + lib/libthr \ lib/libucl \ lib/libz \ lib/msun \ diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 8f26c611e016..5ae6c19b96d9 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <stdio.h> #include <string.h> -#include <time.h> #include <unistd.h> #include <ucl.h> @@ -177,14 +176,11 @@ fetch_to_fd(const char *url, char *path) /* To store _https._tcp. + hostname + \0 */ int fd; int retry, max_retry; - off_t done, r; - time_t now, last; + ssize_t r; char buf[10240]; char zone[MAXHOSTNAMELEN + 13]; static const char *mirror_type = NULL; - done = 0; - last = 0; max_retry = 3; current = mirrors = NULL; remote = NULL; @@ -202,7 +198,11 @@ fetch_to_fd(const char *url, char *path) retry = max_retry; - u = fetchParseURL(url); + if ((u = fetchParseURL(url)) == NULL) { + warn("fetchParseURL('%s')", url); + return (-1); + } + while (remote == NULL) { if (retry == max_retry) { if (strcmp(u->scheme, "file") != 0 && @@ -234,19 +234,16 @@ fetch_to_fd(const char *url, char *path) } } - while (done < st.size) { - if ((r = fread(buf, 1, sizeof(buf), remote)) < 1) - break; - + while ((r = fread(buf, 1, sizeof(buf), remote)) > 0) { if (write(fd, buf, r) != r) { warn("write()"); goto fetchfail; } + } - done += r; - now = time(NULL); - if (now > last || done == st.size) - last = now; + if (r != 0) { + warn("An error occurred while fetching pkg(8)"); + goto fetchfail; } if (ferror(remote)) @@ -371,8 +368,11 @@ load_fingerprints(const char *path, int *count) return (NULL); STAILQ_INIT(fingerprints); - if ((d = opendir(path)) == NULL) + if ((d = opendir(path)) == NULL) { + free(fingerprints); + return (NULL); + } while ((ent = readdir(d))) { if (strcmp(ent->d_name, ".") == 0 || @@ -799,8 +799,11 @@ cleanup: close(fd_sig); unlink(tmpsig); } - close(fd_pkg); - unlink(tmppkg); + + if (fd_pkg != -1) { + close(fd_pkg); + unlink(tmppkg); + } return (ret); } @@ -849,7 +852,7 @@ bootstrap_pkg_local(const char *pkgpath, bool force) if (config_string(SIGNATURE_TYPE, &signature_type) != 0) { warnx("Error looking up SIGNATURE_TYPE"); - return (-1); + goto cleanup; } if (signature_type != NULL && strcasecmp(signature_type, "FINGERPRINTS") == 0) { |