[Midnightbsd-cvs] src [6618] trunk/libexec/mport.check-for-older/mport.check-for-older.c: change the behavior of check if older to allow for upgrades based on old os versions
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Mon Mar 17 23:06:29 EDT 2014
Revision: 6618
http://svnweb.midnightbsd.org/src/?rev=6618
Author: laffer1
Date: 2014-03-17 23:06:29 -0400 (Mon, 17 Mar 2014)
Log Message:
-----------
change the behavior of check if older to allow for upgrades based on old os versions
Modified Paths:
--------------
trunk/libexec/mport.check-for-older/mport.check-for-older.c
Modified: trunk/libexec/mport.check-for-older/mport.check-for-older.c
===================================================================
--- trunk/libexec/mport.check-for-older/mport.check-for-older.c 2014-03-18 03:05:55 UTC (rev 6617)
+++ trunk/libexec/mport.check-for-older/mport.check-for-older.c 2014-03-18 03:06:29 UTC (rev 6618)
@@ -33,6 +33,7 @@
#include <string.h>
#include <unistd.h>
#include <mport.h>
+#include <mport_private.h>
static void usage(void);
@@ -39,76 +40,78 @@
int
main(int argc, char *argv[])
{
- int ch;
- mportInstance *mport;
- mportPackageMeta **packs;
- const char *arg, *where, *version = NULL;
+ int ch;
+ mportInstance *mport;
+ mportPackageMeta **packs;
+ const char *arg, *where, *version = NULL;
- if (argc == 1)
- usage();
+ if (argc == 1)
+ usage();
- while ((ch = getopt(argc, argv, "v:o:n:")) != -1) {
- switch (ch) {
- case 'v':
- version = optarg;
- break;
- case 'o':
- where = "origin=%Q";
- arg = optarg;
- break;
- case 'n':
- where = "pkg=%Q";
- arg = optarg;
- break;
- case '?':
- default:
- usage();
- break;
- }
- }
+ while ((ch = getopt(argc, argv, "v:o:n:")) != -1) {
+ switch (ch) {
+ case 'v':
+ version = optarg;
+ break;
+ case 'o':
+ where = "origin=%Q";
+ arg = optarg;
+ break;
+ case 'n':
+ where = "pkg=%Q";
+ arg = optarg;
+ break;
+ case '?':
+ default:
+ usage();
+ break;
+ }
+ }
- argc -= optind;
- argv += optind;
+ argc -= optind;
+ argv += optind;
- if (arg == NULL || version == NULL)
- usage();
+ if (arg == NULL || version == NULL)
+ usage();
- mport = mport_instance_new();
+ mport = mport_instance_new();
- if (mport_instance_init(mport, NULL) != MPORT_OK) {
- warnx("%s", mport_err_string());
- mport_instance_free(mport);
- exit(1);
- }
+ if (mport_instance_init(mport, NULL) != MPORT_OK) {
+ warnx("%s", mport_err_string());
+ mport_instance_free(mport);
+ exit(1);
+ }
- if (mport_pkgmeta_search_master(mport, &packs, where, arg) != MPORT_OK) {
- warnx("%s", mport_err_string());
- mport_instance_free(mport);
- exit(1);
- }
+ if (mport_pkgmeta_search_master(mport, &packs, where, arg) != MPORT_OK) {
+ warnx("%s", mport_err_string());
+ mport_instance_free(mport);
+ exit(1);
+ }
- if (packs == NULL) {
- (void)printf("No packages installed matching '%s'\n", arg);
- mport_instance_free(mport);
- exit(1);
- }
-
+ if (packs == NULL) {
+ (void)printf("No packages installed matching '%s'\n", arg);
+ mport_instance_free(mport);
+ exit(1);
+ }
- if (packs[1] != NULL) {
- warnx("Ambiguous package identifier: %s", arg);
- mport_instance_free(mport);
- exit(3);
- }
+ if (packs[1] != NULL) {
+ warnx("Ambiguous package identifier: %s", arg);
+ mport_instance_free(mport);
+ exit(3);
+ }
- if (mport_version_cmp(packs[0]->version, version) >= 0) {
- (void)printf("%s is installed, but installed version (%s) is not older than port (%s).\n", packs[0]->name, packs[0]->version, version);
- mport_instance_free(mport);
- exit(1);
- }
+ if (mport_version_cmp(packs[0]->version, version) >= 0) {
+ /* a version from a previous OS release will show as not installed */
+ if (mport_check_preconditions(mport, packs[0], MPORT_PRECHECK_OS) != MPORT_OK) {
+ (void)printf("%s is installed, but installed version (%s) is not older than port (%s).\n", packs[0]->name, packs[0]->version, version);
+ mport_instance_free(mport);
+ exit(1);
+ }
+ }
- mport_instance_free(mport);
+ mport_instance_free(mport);
- return 0;
+ return(0);
}
More information about the Midnightbsd-cvs
mailing list