summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>2000-09-20 08:53:55 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>2000-09-20 08:53:55 +0000
commit4152100663742c85bd133afba9fd5a4f387a479e (patch)
tree9329ff4957f7cf194b1e8b0527bc8d7ee1e2199e
parent012e830d4bea8fadd3cd949466dd2a17611a93e6 (diff)
Notes
-rw-r--r--usr.sbin/pkg_install/delete/main.c31
-rw-r--r--usr.sbin/pkg_install/info/main.c38
-rw-r--r--usr.sbin/pkg_install/lib/file.c25
-rw-r--r--usr.sbin/pkg_install/lib/lib.h1
-rw-r--r--usr.sbin/pkg_install/lib/plist.c4
-rw-r--r--usr.sbin/pkg_install/version/pkg_version.119
-rwxr-xr-xusr.sbin/pkg_install/version/pkg_version.pl4
7 files changed, 67 insertions, 55 deletions
diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c
index 4a75d118a8ef..3150118a660c 100644
--- a/usr.sbin/pkg_install/delete/main.c
+++ b/usr.sbin/pkg_install/delete/main.c
@@ -87,24 +87,19 @@ main(int argc, char **argv)
/* Get all the remaining package names, if any */
while (*argv) {
- if ((pkgs_split = rindex(*argv, (int)'/')) != NULL) {
- while (!isalpha(*(pkgs_split + 1))) {
- *pkgs_split = '\0';
- if ((pkgs_split = rindex(*argv, (int) '/')) == NULL)
- pkgs_split = *argv;
- }
- if (pkgs_split != NULL) {
- if (*pkgs_split == '/')
- pkgs_split++;
- *pkgs = pkgs_split;
- pkgs++;
- }
- }
- else {
- *pkgs = *argv;
- pkgs++;
- }
- argv++;
+ while ((pkgs_split = rindex(*argv, (int)'/')) != NULL) {
+ *pkgs_split++ = '\0';
+ /*
+ * If character after the '/' is alphanumeric, then we've found the
+ * package name. Otherwise we've come across a trailing '/' and
+ * need to continue our quest.
+ */
+ if (isalpha(*pkgs_split)) {
+ *argv = pkgs_split;
+ break;
+ }
+ }
+ *pkgs++ = *argv++;
}
/* If no packages, yelp */
diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c
index 01dccc75fb84..9329bbe8baec 100644
--- a/usr.sbin/pkg_install/info/main.c
+++ b/usr.sbin/pkg_install/info/main.c
@@ -148,30 +148,20 @@ main(int argc, char **argv)
Flags = SHOW_COMMENT | SHOW_DESC | SHOW_REQBY;
/* Get all the remaining package names, if any */
- while (*argv)
- {
- if( (pkgs_split = rindex(*argv, (int) '/')) != NULL )
- {
- while( !isalpha(*(pkgs_split+1)) )
- {
- *pkgs_split = '\0';
- if ( (pkgs_split = rindex(*argv, (int) '/')) == NULL)
- pkgs_split = *argv;
- }
- if(pkgs_split != NULL)
- {
- if (*pkgs_split == '/')
- pkgs_split++;
- *pkgs = pkgs_split;
- pkgs++;
- }
- }
- else
- {
- *pkgs = *argv;
- pkgs++;
- }
- argv++;
+ while (*argv) {
+ while ((pkgs_split = rindex(*argv, (int)'/')) != NULL) {
+ *pkgs_split++ = '\0';
+ /*
+ * If character after the '/' is alphanumeric, then we've found the
+ * package name. Otherwise we've come across a trailing '/' and
+ * need to continue our quest.
+ */
+ if (isalpha(*pkgs_split)) {
+ *argv = pkgs_split;
+ break;
+ }
+ }
+ *pkgs++ = *argv++;
}
/* If no packages, yelp */
diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c
index 49db19874c3a..a54df9e12359 100644
--- a/usr.sbin/pkg_install/lib/file.c
+++ b/usr.sbin/pkg_install/lib/file.c
@@ -40,7 +40,7 @@ fexists(char *fname)
return FALSE;
}
-/* Quick check to see if something is a directory */
+/* Quick check to see if something is a directory or symlink to a directory */
Boolean
isdir(char *fname)
{
@@ -54,7 +54,7 @@ isdir(char *fname)
return FALSE;
}
-/* Check to see if file is a dir, and is empty */
+/* Check to see if file is a dir or symlink to a dir, and is empty */
Boolean
isemptydir(char *fname)
{
@@ -77,6 +77,10 @@ isemptydir(char *fname)
return FALSE;
}
+/*
+ * Returns TRUE if file is a regular file or symlink pointing to a regular
+ * file
+ */
Boolean
isfile(char *fname)
{
@@ -86,8 +90,11 @@ isfile(char *fname)
return FALSE;
}
-/* Check to see if file is a file and is empty. If nonexistent or not
- a file, say "it's empty", otherwise return TRUE if zero sized. */
+/*
+ * Check to see if file is a file or symlink pointing to a file and is empty.
+ * If nonexistent or not a file, say "it's empty", otherwise return TRUE if
+ * zero sized.
+ */
Boolean
isemptyfile(char *fname)
{
@@ -99,6 +106,16 @@ isemptyfile(char *fname)
return TRUE;
}
+/* Returns TRUE if file is a symbolic link. */
+Boolean
+issymlink(char *fname)
+{
+ struct stat sb;
+ if (lstat(fname, &sb) != FAIL && S_ISLNK(sb.st_mode))
+ return TRUE;
+ return FALSE;
+}
+
/* Returns TRUE if file is a URL specification */
Boolean
isURL(char *fname)
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index 3d5f0ec58648..258465561b6e 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -129,6 +129,7 @@ Boolean isemptydir(char *fname);
Boolean isemptyfile(char *fname);
Boolean isfile(char *);
Boolean isempty(char *);
+Boolean issymlink(char *);
Boolean isURL(char *);
char *fileGetURL(char *, char *);
char *fileFindByPath(char *, char *);
diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c
index 6dfbabce09bd..88f68761b856 100644
--- a/usr.sbin/pkg_install/lib/plist.c
+++ b/usr.sbin/pkg_install/lib/plist.c
@@ -390,7 +390,7 @@ delete_package(Boolean ign_err, Boolean nukedirs, Package *pkg)
case PLIST_FILE:
last_file = p->name;
sprintf(tmp, "%s/%s", Where, p->name);
- if (isdir(tmp) && fexists(tmp)) {
+ if (isdir(tmp) && fexists(tmp) && !issymlink(tmp)) {
warnx("cannot delete specified file `%s' - it is a directory!\n"
"this packing list is incorrect - ignoring delete request", tmp);
}
@@ -477,7 +477,7 @@ delete_hierarchy(char *dir, Boolean ign_err, Boolean nukedirs)
if (vsystem("%s -r%s %s", REMOVE_CMD, (ign_err ? "f" : ""), dir))
return 1;
}
- else if (isdir(dir)) {
+ else if (isdir(dir) && !issymlink(dir)) {
if (RMDIR(dir) && !ign_err)
return 1;
}
diff --git a/usr.sbin/pkg_install/version/pkg_version.1 b/usr.sbin/pkg_install/version/pkg_version.1
index d104748be8de..741ef6264bcc 100644
--- a/usr.sbin/pkg_install/version/pkg_version.1
+++ b/usr.sbin/pkg_install/version/pkg_version.1
@@ -55,15 +55,23 @@ in the index.
The installed version of the package is newer than listed in the
index.
.It Li ?
-The relationship between the installed version of a package and the
-index file could not be determined. A common reason for this message
-is that there are multiple versions of a particular software package
-installed, or that multiple versions are listed in the index file.
+The installed package does not appear in the index.
+This could be due to an out of date index or a package taken from a PR
+that has not yet been committed.
+.It Li *
+There are multiple versions of a particular software package
+installed or there are multiple versions of a package listed in
+the index file.
Examples from the
.Fx
ports collection are the Tcl toolkit or the
.Tn EMACS
editor.
+.It Li !
+The installed package exists in the index but for some reason,
+.Nm
+was unable to compare the version number of the installed package
+with the corresponding entry in the index.
.Sh OPTIONS
.Nm
supports several command-line arguments:
@@ -140,7 +148,8 @@ suggestions, and then cut-and-paste (or retype) the commands you want to run.
.An Bruce A. Mah Aq bmah@FreeBSD.org
.Sh CONTRIBUTORS
.An Nik Clayton Aq nik@FreeBSD.org ,
-.An Dominic Mitchell Aq dom@palmerharvey.co.uk
+.An Dominic Mitchell Aq dom@palmerharvey.co.uk ,
+.An Mark Ovens Aq marko@FreeBSD.org
.Sh BUGS
There should be a better way of dealing with packages that
can have more than one installed version.
diff --git a/usr.sbin/pkg_install/version/pkg_version.pl b/usr.sbin/pkg_install/version/pkg_version.pl
index aed6bcc6074f..7b3a58b8af91 100755
--- a/usr.sbin/pkg_install/version/pkg_version.pl
+++ b/usr.sbin/pkg_install/version/pkg_version.pl
@@ -306,7 +306,7 @@ foreach $packageName (sort keys %currentPackages) {
$packagePath = $indexPackages{$packageName}{'path'};
if (($indexRefcount > 1) || ($currentRefcount > 1)) {
- $versionCode = "?";
+ $versionCode = "*";
$Comment = "multiple versions (index has $indexVersion)";
$Comment =~ s/\|/,/g;
}
@@ -332,7 +332,7 @@ foreach $packageName (sort keys %currentPackages) {
$Comment = "succeeds index (index has $indexVersion)";
}
else {
- $versionCode = "?";
+ $versionCode = "!";
$Comment = "Comparison failed";
}
}