PERFORCE change 176192 for review
Garrett Cooper
gcooper at FreeBSD.org
Sun Mar 28 09:53:39 UTC 2010
http://p4web.freebsd.org/chv.cgi?CH=176192
Change 176192 by gcooper at gcooper-bayonetta on 2010/03/28 09:52:51
Yank hardcoded INDEX filename detection scheme. Again, hardcoding is so 90's...
Affected files ...
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/lib/lib.h#3 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/version/perform.c#2 edit
Differences ...
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/lib/lib.h#3 (text+ko) ====
@@ -28,6 +28,7 @@
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/queue.h>
+#include <sys/utsname.h>
#include <ctype.h>
#include <dirent.h>
#include <err.h>
@@ -86,18 +87,6 @@
#define DISPLAY_FNAME "+DISPLAY"
#define MTREE_FNAME "+MTREE_DIRS"
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
-#define INDEX_FNAME "INDEX-9"
-#elif defined(__FreeBSD_version) && __FreeBSD_version >= 800000
-#define INDEX_FNAME "INDEX-8"
-#elif defined(__FreeBSD_version) && __FreeBSD_version >= 700000
-#define INDEX_FNAME "INDEX-7"
-#elif defined(__FreeBSD_version) && __FreeBSD_version >= 600000
-#define INDEX_FNAME "INDEX-6"
-#else
-#define INDEX_FNAME "INDEX"
-#endif
-
#define CMD_CHAR '@' /* prefix for extended PLIST cmd */
/* The name of the "prefix" environment variable given to scripts */
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/version/perform.c#2 (text+ko) ====
@@ -35,28 +35,42 @@
static void show_version(Package, const char *, const char *);
/*
- * This is the traditional pkg_perform, except that the argument is _not_
- * a list of packages. It is the index file from the command line.
+ * This is the traditional pkg_perform, except that the argument is _not_ a
+ * list of packages. It is the index file from the command line.
+ *
+ * We loop over the installed packages, matching them with the -s flag if
+ * needed and calling pkg_do(). Beforehand we set up a few things, and after
+ * we tear them down...
*
- * We loop over the installed packages, matching them with the -s flag
- * if needed and calling pkg_do(). Before hand we set up a few things,
- * and after we tear them down...
+ * Returns 0 on success, non-zero on failure, corresponding to the number of
+ * failed attempts to access the INDEX.
*/
int
pkg_perform(char **indexarg)
{
char **pkgs, *pat[2], **patterns;
struct index_entry *ie;
- int i, err_cnt = 0;
+ int i, err_cnt = 0, rel_major_ver;
int MatchType;
+ struct utsname u;
+
+ if (uname(&u) == -1) {
+ warn("%s.%s: failed to determine uname information", progname,
+ __func__);
+ return 1;
+ } else if ((rel_major_ver = (int) strtol(u.release, NULL, 10)) <= 0) {
+
+ }
+
/*
* Try to find and open the INDEX. We only check IndexFile != NULL
* later, if we actually need the INDEX.
*/
- if (*indexarg == NULL)
- snprintf(IndexPath, sizeof(IndexPath), "%s/%s", PORTS_DIR, INDEX_FNAME);
- else
+ if (*indexarg == NULL) {
+ snprintf(IndexPath, sizeof(IndexPath), "%s/INDEX-%d", PORTS_DIR,
+ rel_major_ver);
+ } else
strlcpy(IndexPath, *indexarg, sizeof(IndexPath));
if (isURL(IndexPath))
IndexFile = fetchGetURL(IndexPath, "");
More information about the p4-projects
mailing list