summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorsimon <simon@FreeBSD.org>2007-10-26 10:12:26 +0000
committersimon <simon@FreeBSD.org>2007-10-26 10:12:26 +0000
commit4a2eb6368a35b58e924f0164751381e9a2420944 (patch)
tree215a6823c6b2c965dfd0d68cbdaefad548f329c4 /usr.sbin/pkg_install
parentab55394041e2f726054c2ff02c011293f9c52129 (diff)
downloadFreeBSD-src-4a2eb6368a35b58e924f0164751381e9a2420944.zip
FreeBSD-src-4a2eb6368a35b58e924f0164751381e9a2420944.tar.gz
If the INDEX file cannot be opened, print the actual filename / path
pkg_version tried to open instead of just "INDEX" to make the actual problem more clear (e.g. missing INDEX-8). MFC after: 3 days Reviewed by: portmgr (pav)
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r--usr.sbin/pkg_install/version/perform.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.sbin/pkg_install/version/perform.c b/usr.sbin/pkg_install/version/perform.c
index f1ed5fc..e39adaf 100644
--- a/usr.sbin/pkg_install/version/perform.c
+++ b/usr.sbin/pkg_install/version/perform.c
@@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$");
#include <signal.h>
FILE *IndexFile;
+char IndexPath[PATH_MAX] = "";
struct index_head Index = SLIST_HEAD_INITIALIZER(Index);
static int pkg_do(char *);
@@ -44,7 +45,7 @@ static void show_version(Package, const char *, const char *);
int
pkg_perform(char **indexarg)
{
- char tmp[PATH_MAX], **pkgs, *pat[2], **patterns;
+ char **pkgs, *pat[2], **patterns;
struct index_entry *ie;
int i, err_cnt = 0;
int MatchType;
@@ -54,13 +55,13 @@ pkg_perform(char **indexarg)
* later, if we actually need the INDEX.
*/
if (*indexarg == NULL)
- snprintf(tmp, PATH_MAX, "%s/%s", PORTS_DIR, INDEX_FNAME);
+ snprintf(IndexPath, sizeof(IndexPath), "%s/%s", PORTS_DIR, INDEX_FNAME);
else
- strlcpy(tmp, *indexarg, PATH_MAX);
- if (isURL(tmp))
- IndexFile = fetchGetURL(tmp, "");
+ strlcpy(IndexPath, *indexarg, sizeof(IndexPath));
+ if (isURL(IndexPath))
+ IndexFile = fetchGetURL(IndexPath, "");
else
- IndexFile = fopen(tmp, "r");
+ IndexFile = fopen(IndexPath, "r");
/* Get either a list of matching or all packages */
if (MatchName != NULL) {
@@ -172,7 +173,7 @@ pkg_do(char *pkg)
/* We only pull in the INDEX once, if needed. */
if (SLIST_EMPTY(&Index)) {
if (!IndexFile)
- errx(2, "Unable to open INDEX in %s.", __func__);
+ errx(2, "Unable to open %s in %s.", IndexPath, __func__);
while ((ch = fgetln(IndexFile, &len)) != NULL) {
/*
* Don't use strlcpy() because fgetln() doesn't
OpenPOWER on IntegriCloud