pkg-version(8) usage shows [index] as its final and only non-option argument. It looks to me like pkg/version.c does not process this argument at all but makes the assumption that use of the -I option always means use an INDEX file in portsdir. I'm hoping this is an oversight which might be fixed soon, and that I'll be able to run reports like the following on systems that don't have a ports tree - just like I could with pkg_version(1). pkg version -IvL '=' /path/to/current/INDEX How-To-Repeat: rwpc13# cd /usr/ports rwpc13# make fetchindex /usr/ports/INDEX-9.bz2 100% of 1711 kB 11 MBps 00m00s rwpc13# pkg version -IvL '=' aalib-1.4.r5_6 < needs updating (index has 1.4.r5_8) chromium-32.0.1700.77 < needs updating (index has 32.0.1700.107) docbook-xsl-1.76.1_1 < needs updating (index has 1.76.1_2) fusefs-libs-2.9.3_1 < needs updating (index has 2.9.3_2) nspluginwrapper-1.4.4_2 < needs updating (index has 1.4.4_3) p5-IO-Socket-IP-0.27 < needs updating (index has 0.28) p5-Module-Build-0.4203 < needs updating (index has 0.4205) qt4-moc-4.8.5 < needs updating (index has 4.8.5_1) sqlite3-3.8.2_1 < needs updating (index has 3.8.3) vte-0.26.2_5 < needs updating (index has 0.28.2) rwpc13# mv INDEX-9 /var/tmp rwpc13# pkg version -IvL '=' /var/tmp/INDEX-9 pkg: Unable to open /usr/ports/INDEX-9!: No such file or directory rwpc13# cd .. rwpc13# mv ports ports.hiding rwpc13# pkg version -IvL '=' /var/tmp/INDEX-9 pkg: Unable to open ports directory /usr/ports: No such file or directory
Responsible Changed From-To: freebsd-ports-bugs->portmgr Over to maintainer (via the GNATS Auto Assign Tool)
Why would you need an INDEX at all if you have no ports tree. I guess if you have no ports tree it means you are running your own repo. which means you can direct run pkg version against the repository without the need for an index at all. Bapt
On Wed, 12 Feb 2014, 08:31 +0100, Baptiste Daroussin wrote: > I guess if you have no ports tree it means you are running your own > repo. which means you can direct run pkg version against the > repository without the need for an index at all. ...which is an obvious thing to do if the repository reflects the current ports tree. If the repository, as in this case, is only built as necessary for upgrades, it will usually lag the current ports tree. I am not a programmer so it has taken me a long time to produce this patch which "works for me". I am sorry if it doesn't do things in the right way but a programmer should be able to correct it easily. The patch: - removes the requirement for /usr/ports when using an index (-I) - reads and uses the optional index file argument which, if present, will supersede the default file in /usr/ports. --- pkg/version.c.orig 2014-02-02 05:33:30.000000000 +1100 +++ pkg/version.c 2014-02-13 15:34:07.000000000 +1100 @@ -318,7 +318,7 @@ opt |= VERSION_SOURCE_REMOTE; } - if (!have_ports && (opt & (VERSION_SOURCE_INDEX|VERSION_SOURCE_PORTS))) + if (!have_ports && (opt & VERSION_SOURCE_PORTS)) err(1, "Unable to open ports directory %s", portsdir); /* Only force remote mode if looking up remote, otherwise @@ -341,9 +341,13 @@ goto cleanup; if (opt & VERSION_SOURCE_INDEX) { - uname(&u); - rel_major_ver = (int) strtol(u.release, NULL, 10); - snprintf(indexpath, sizeof(indexpath), "%s/INDEX-%d", portsdir, rel_major_ver); + if (argc == 1) { + snprintf(indexpath, sizeof(indexpath), "%s", argv[0]); + } else { + uname(&u); + rel_major_ver = (int) strtol(u.release, NULL, 10); + snprintf(indexpath, sizeof(indexpath), "%s/INDEX-%d", portsdir, rel_major_ver); + } indexfile = fopen(indexpath, "r"); if (!indexfile) err(EX_SOFTWARE, "Unable to open %s!", indexpath); I have attached a patch to the ports tree which provides this fix by adding the above patch into the port's files directory. -- John Marshall
My previous patch worked fine with the '-I' option. I disovered, after the Friday night periodic weekly jobs had run, that the new weekly 400.status-pkg job didn't give me the expected result. It turns out that this job passes the index file argument without setting -I. The original pkg_install version of this job does the same thing. I checked the old pkg_version code and saw that it uses the index argument (with no -I option) as a fallback if it cannot find a ports tree. I have attached a new patch for pkg/version.c to restore this functionality. With the attached patch, the version source selection precedence, if not overridden by any of (-IPR), is as follows: - use ports tree if present - fall back to index if index argument is present and file readable - fall back to remote repository In the absence of an index file argument, the precedence is unaltered: - use ports tree if present - fall back to remote repository No doubt a programmer would find a more elegant way of doing this. I have tried my best. -- John Marshall
This has been addressed in the meantime.