perform.c (173014) | perform.c (206043) |
---|---|
1/* 2 * FreeBSD install - a package for the installation and maintainance 3 * of non-core utilities. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 5 unchanged lines hidden (view full) --- 14 * Jeremy D. Lea. 15 * 11 May 2002 16 * 17 * This is the version module. Based on pkg_version.pl by Bruce A. Mah. 18 * 19 */ 20 21#include <sys/cdefs.h> | 1/* 2 * FreeBSD install - a package for the installation and maintainance 3 * of non-core utilities. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 5 unchanged lines hidden (view full) --- 14 * Jeremy D. Lea. 15 * 11 May 2002 16 * 17 * This is the version module. Based on pkg_version.pl by Bruce A. Mah. 18 * 19 */ 20 21#include <sys/cdefs.h> |
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/version/perform.c 173014 2007-10-26 10:12:26Z simon $"); | 22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/version/perform.c 206043 2010-04-01 14:27:29Z flz $"); |
23 24#include "lib.h" 25#include "version.h" 26#include <err.h> 27#include <fetch.h> 28#include <signal.h> 29 30FILE *IndexFile; 31char IndexPath[PATH_MAX] = ""; 32struct index_head Index = SLIST_HEAD_INITIALIZER(Index); 33 34static int pkg_do(char *); 35static void show_version(Package, const char *, const char *); 36 37/* | 23 24#include "lib.h" 25#include "version.h" 26#include <err.h> 27#include <fetch.h> 28#include <signal.h> 29 30FILE *IndexFile; 31char IndexPath[PATH_MAX] = ""; 32struct index_head Index = SLIST_HEAD_INITIALIZER(Index); 33 34static int pkg_do(char *); 35static void show_version(Package, const char *, const char *); 36 37/* |
38 * This is the traditional pkg_perform, except that the argument is _not_ 39 * a list of packages. It is the index file from the command line. | 38 * This is the traditional pkg_perform, except that the argument is _not_ a 39 * list of packages. It is the index file from the command line. |
40 * | 40 * |
41 * We loop over the installed packages, matching them with the -s flag 42 * if needed and calling pkg_do(). Before hand we set up a few things, 43 * and after we tear them down... | 41 * We loop over the installed packages, matching them with the -s flag if 42 * needed and calling pkg_do(). Beforehand we set up a few things, and after 43 * we tear them down... 44 * 45 * Returns 0 on success, non-zero on failure, corresponding to the number of 46 * failed attempts to access the INDEX. |
44 */ 45int 46pkg_perform(char **indexarg) 47{ 48 char **pkgs, *pat[2], **patterns; 49 struct index_entry *ie; | 47 */ 48int 49pkg_perform(char **indexarg) 50{ 51 char **pkgs, *pat[2], **patterns; 52 struct index_entry *ie; |
50 int i, err_cnt = 0; | 53 int i, err_cnt = 0, rel_major_ver; |
51 int MatchType; 52 | 54 int MatchType; 55 |
56 struct utsname u; 57 58 if (uname(&u) == -1) { 59 warn("%s(): failed to determine uname information", __func__); 60 return 1; 61 } else if ((rel_major_ver = (int) strtol(u.release, NULL, 10)) <= 0) { 62 63 } 64 |
|
53 /* 54 * Try to find and open the INDEX. We only check IndexFile != NULL 55 * later, if we actually need the INDEX. 56 */ | 65 /* 66 * Try to find and open the INDEX. We only check IndexFile != NULL 67 * later, if we actually need the INDEX. 68 */ |
57 if (*indexarg == NULL) 58 snprintf(IndexPath, sizeof(IndexPath), "%s/%s", PORTS_DIR, INDEX_FNAME); 59 else | 69 if (*indexarg == NULL) { 70 snprintf(IndexPath, sizeof(IndexPath), "%s/INDEX-%d", PORTS_DIR, 71 rel_major_ver); 72 } else |
60 strlcpy(IndexPath, *indexarg, sizeof(IndexPath)); 61 if (isURL(IndexPath)) 62 IndexFile = fetchGetURL(IndexPath, ""); 63 else 64 IndexFile = fopen(IndexPath, "r"); 65 66 /* Get either a list of matching or all packages */ 67 if (MatchName != NULL) { --- 341 unchanged lines hidden --- | 73 strlcpy(IndexPath, *indexarg, sizeof(IndexPath)); 74 if (isURL(IndexPath)) 75 IndexFile = fetchGetURL(IndexPath, ""); 76 else 77 IndexFile = fopen(IndexPath, "r"); 78 79 /* Get either a list of matching or all packages */ 80 if (MatchName != NULL) { --- 341 unchanged lines hidden --- |