--- a/usr/src/cmd/auto-install/auto_ddu_lib.c Mon Aug 30 01:54:38 2010 -0600
+++ b/usr/src/cmd/auto-install/auto_ddu_lib.c Mon Aug 30 15:52:14 2010 -0700
@@ -39,39 +39,26 @@
#define DDU_PACKAGE_MODULE "DDU.ddu_package"
#define DDU_PACKAGE_OBJECT "ddu_package_object"
-/* Pkg commands. */
-#define PKG_PUBLISHER "/usr/bin/pkg publisher"
-
/* DDU error log */
#define DDU_ERRLOG "/tmp/ddu_err.log"
-/* DDU error module related. */
-#define DDU_ERROR_MODULE "DDU.ddu_errors"
-#define DDU_PACKAGE_NOT_FOUND_EXC "PackageNoFound"
-
/* ICT module related definitions. */
#define ICT_MODULE "osol_install.ict"
#define ICT_CLASS "ICT"
#define ICT_UPDATE_ARCHIVE "update_boot_archive"
/* AI Manifest (AIM) related path definitions. */
-#define AIM_PREFACE "auto_install/ai_instance/add_drivers/"
+#define AIM_PREFACE "auto_install/ai_instance/add_drivers/"
#define PKGSPEC_NODEPATH "software"
#define ORIGIN_NODEPATH "software/source/publisher/origin/name"
-#define TYPE_NODEPATH "software[source/publisher/origin/" \
- "name=\"%s\"]/software_data/type"
-#define NAME_NODEPATH "software[source/publisher/origin/" \
- "name=\"%s\":software_data/" \
- "type=\"%s\"]/software_data/name"
+#define TYPE_NODEPATH \
+ "software[source/publisher/origin/name=\"%s\"]/software_data/type"
+#define NAME_NODEPATH \
+ "software[source/publisher/origin/name=\"%s\":software_data/type=\"%s\"]/software_data/name"
#define ACTION_NONAME_NODEPATH \
- "software[source/publisher/origin/" \
- "name=\"%s\":software_data/" \
- "type=\"%s\"]/software_data/action"
+ "software[source/publisher/origin/name=\"%s\":software_data/type=\"%s\"]/software_data/action"
#define ACTION_YESNAME_NODEPATH \
- "software[source/publisher/origin/" \
- "name=\"%s\":software_data/type=\"%s\":" \
- "software_data/name=\"%s\"]/" \
- "software_data/action"
+ "software[source/publisher/origin/name=\"%s\":software_data/type=\"%s\":software_data/name=\"%s\"]/software_data/action"
#define SEARCH_NODEPATH "search_all"
#define SEARCH_ORIGIN_NODEPATH "search_all/source/publisher/origin/name"
@@ -85,7 +72,6 @@
PyThreadState *mainThreadState;
PyObject *pFunctionModule;
PyObject *pPackageModule;
- PyObject *pErrorModule;
PyObject *pICTModule;
} py_state_t;
@@ -97,33 +83,31 @@
static py_state_t *auto_ddu_lib_init();
static void auto_ddu_lib_fini(py_state_t *py_state_p);
-static void ai_dump_python_exception();
static PyObject *ai_call_ddu_devscan(py_state_t *py_state_p,
boolean_t get_only_missing_drivers, char *dev_type);
-static int ai_call_ddu_package_lookup(py_state_t *py_state_p,
- PyObject *pDevObj, PyObject *pRepoList, PyObject **pPackageObj_p);
+static PyObject *ai_call_ddu_package_lookup(py_state_t *py_state_p,
+ PyObject *pDevObj, PyObject *pRepoList);
static int ai_call_ddu_install_package(py_state_t *py_state_p,
PyObject *ddu_package_obj, char *install_root, boolean_t third_party_ok);
static PyObject *ai_new_ddu_package_object(py_state_t *py_state_p,
char *type, char *name, char *origin);
static int ai_get_ddu_package_object_values(PyObject *pDDUPackageObject,
- char **type, char **location, char **name, char **descr, char **inf_link,
+ char **type, char **origin, char **name, char **descr, char **inf_link,
boolean_t *third_party);
static int ai_get_ddu_dev_data_values(PyObject *pDDUDevData,
- char **dev_type_p, char **descr_p, char **vendor_ID_p, char **device_ID_p,
- char **class_p);
-static int ai_du_process_manual_pkg(py_state_t *py_state_p,
+ char **dev_type, char **descr);
+static void ai_du_process_manual_pkg(py_state_t *py_state_p,
PyObject *pPackageList, char *origin, char *type, char *name,
char *noinstall);
-static int ai_du_process_manual_pkg_names(py_state_t *py_state_p,
- path_t *path_p, PyObject *pPackageList, char *origin, char *type,
+static void ai_du_process_manual_pkg_names(py_state_t *py_state_p,
+ PyObject *pPackageList, path_t *path_p, char *origin, char *type,
char *name);
-static int ai_du_process_manual_pkg_types(py_state_t *py_state_p,
+static void ai_du_process_manual_pkg_types(py_state_t *py_state_p,
PyObject *pPackageList, path_t *path_p, char *origin, char *type);
-static int ai_du_get_manual_pkg_list(py_state_t *py_state_p, path_t *path_p,
- PyObject **pPackageList_p);
-static int ai_du_get_searched_pkg_list(py_state_t *py_state_p, path_t *path_p,
- char *install_root, PyObject **pPackageList_p);
+static PyObject *ai_du_get_manual_pkg_list(py_state_t *py_state_p,
+ path_t *path_p);
+static PyObject *ai_du_get_searched_pkg_list(py_state_t *py_state_p,
+ path_t *path_p);
static int ai_du_install_packages(py_state_t *py_state_p,
PyObject *pPkgTupleList, char *install_root, boolean_t honor_noinstall,
int *num_installed_pkgs_p);
@@ -158,70 +142,43 @@
static py_state_t *
auto_ddu_lib_init()
{
+ PyObject *pName;
py_state_t *py_state_p = malloc(sizeof (py_state_t));
- static PyObject *pFunctionModule = NULL;
- static PyObject *pPackageModule = NULL;
- static PyObject *pErrorModule = NULL;
- static PyObject *pICTModule = NULL;
-
- if (py_state_p == NULL) {
- auto_debug_print(AUTO_DBGLVL_ERR, "auto_ddu_lib_init: "
- "No memory.\n");
- return (NULL);
- }
-
- /* If one of the above is NULL, all will be NULL. */
- if (pFunctionModule == NULL) {
- PyObject *pName;
-
- /* Get names of modules for use by python/C interfaces. */
- if ((pName = PyString_FromString(DDU_FUNCTION_MODULE)) !=
- NULL) {
- pFunctionModule = PyImport_Import(pName);
- Py_DECREF(pName);
- }
- if ((pName = PyString_FromString(DDU_PACKAGE_MODULE)) != NULL) {
- pPackageModule = PyImport_Import(pName);
- Py_DECREF(pName);
- }
- if ((pName = PyString_FromString(DDU_ERROR_MODULE)) != NULL) {
- pErrorModule = PyImport_Import(pName);
- Py_DECREF(pName);
- }
- if ((pName = PyString_FromString(ICT_MODULE)) != NULL) {
- pICTModule = PyImport_Import(pName);
- Py_DECREF(pName);
- }
-
- /* Cleanup and return NULL on error. */
- if ((pFunctionModule == NULL) || (pPackageModule == NULL) ||
- (pErrorModule == NULL) || (pICTModule == NULL)) {
- auto_debug_print(AUTO_DBGLVL_ERR, "auto_ddu_lib_init: "
- "error accessing DDU library or ICT modules.\n");
- PyErr_Print();
- Py_XDECREF(pFunctionModule);
- Py_XDECREF(pPackageModule);
- Py_XDECREF(pErrorModule);
- Py_XDECREF(pICTModule);
- pFunctionModule = pPackageModule = NULL;
- pErrorModule = pICTModule = NULL;
- free(py_state_p);
- return (NULL);
- }
- }
+ py_state_p->pFunctionModule = NULL;
+ py_state_p->pPackageModule = NULL;
/* Set up python interpreter state. */
PyEval_InitThreads();
py_state_p->mainThreadState = PyThreadState_Get();
py_state_p->myThreadState =
PyThreadState_New(py_state_p->mainThreadState->interp);
- (void) PyThreadState_Swap(py_state_p->myThreadState);
+ PyThreadState_Swap(py_state_p->myThreadState);
- py_state_p->pFunctionModule = pFunctionModule;
- py_state_p->pPackageModule = pPackageModule;
- py_state_p->pErrorModule = pErrorModule;
- py_state_p->pICTModule = pICTModule;
+ /* Get names of modules for use by python/C interfaces. */
+ if ((pName = PyString_FromString(DDU_FUNCTION_MODULE)) != NULL) {
+ py_state_p->pFunctionModule = PyImport_Import(pName);
+ Py_DECREF(pName);
+ }
+ if ((pName = PyString_FromString(DDU_PACKAGE_MODULE)) != NULL) {
+ py_state_p->pPackageModule = PyImport_Import(pName);
+ Py_DECREF(pName);
+ }
+ if ((pName = PyString_FromString(ICT_MODULE)) != NULL) {
+ py_state_p->pICTModule = PyImport_Import(pName);
+ Py_DECREF(pName);
+ }
+
+ /* Cleanup and return NULL on error. */
+ if ((py_state_p->pFunctionModule == NULL) ||
+ (py_state_p->pPackageModule == NULL) ||
+ (py_state_p->pICTModule == NULL)) {
+ auto_debug_print(AUTO_DBGLVL_ERR, "auto_ddu_lib_init: "
+ "error accessing DDU library or ICT modules.\n");
+ PyErr_Print();
+ auto_ddu_lib_fini(py_state_p);
+ py_state_p = NULL;
+ }
return (py_state_p);
}
@@ -241,49 +198,16 @@
if (py_state_p == NULL) {
return;
}
- (void) PyThreadState_Swap(py_state_p->mainThreadState);
+ Py_XDECREF(py_state_p->pFunctionModule);
+ Py_XDECREF(py_state_p->pPackageModule);
+ Py_XDECREF(py_state_p->pICTModule);
+ PyThreadState_Swap(py_state_p->mainThreadState);
PyThreadState_Clear(py_state_p->myThreadState);
PyThreadState_Delete(py_state_p->myThreadState);
free(py_state_p);
}
/*
- * ai_dump_python_exception:
- * Dump the class and message of a python exception. Traceback not dumped.
- *
- * Caveat: An exception must be ready to be dumped, as indicated by
- * PyErr_Occurred() * returning Non-NULL.
- *
- * Arguments: None
- *
- * Returns: N/A
- */
-static void
-ai_dump_python_exception()
-{
- PyObject *pType, *pValue, *pTraceback;
- PyObject *pTypeString, *pValueString;
-
- if (PyErr_Occurred() == NULL) {
- return;
- }
-
- PyErr_Fetch(&pType, &pValue, &pTraceback);
- pTypeString = PyObject_Str(pType);
- pValueString = PyObject_Str(pValue);
- auto_debug_print(AUTO_DBGLVL_ERR,
- "%s\n", PyString_AsString(pTypeString));
- auto_debug_print(AUTO_DBGLVL_ERR,
- "%s\n", PyString_AsString(pValueString));
- Py_DECREF(pType);
- Py_DECREF(pValue);
- Py_DECREF(pTraceback);
- Py_DECREF(pTypeString);
- Py_DECREF(pValueString);
- PyErr_Clear();
-}
-
-/*
* ai_call_ddu_build_repo_list:
* Call the DDU library ddu_build_repo_list function. This sets up the
* list of repositories specified (as name/URL tuples) in the second argument,
@@ -320,16 +244,17 @@
Py_INCREF(pRepoTupleList);
/* Set up args to python function and call it. */
- (void) PyTuple_SetItem(pArgs, 0, pRepoTupleList);
+ PyTuple_SetItem(pArgs, 0, pRepoTupleList);
pRet = PyObject_CallObject(pFunc, pArgs);
Py_DECREF(pArgs);
- if ((PyErr_Occurred() != NULL) || (pRet == NULL) ||
- (pRet == Py_None)) {
+ if ((PyErr_Occurred()) || (pRet == NULL) || (pRet == Py_None)) {
auto_debug_dump_file(AUTO_DBGLVL_ERR, DDU_ERRLOG);
auto_debug_print(AUTO_DBGLVL_ERR,
"%s returned an error.\n", DDU_BUILD_REPO_LIST);
- ai_dump_python_exception();
+ if (PyErr_Occurred()) {
+ PyErr_Print();
+ }
Py_XDECREF(pRet);
pRet = NULL;
}
@@ -354,8 +279,7 @@
*
* Returns:
* Success:
- * A python object representing a list of unique ddu_dev_data objects is
- * returned.
+ * A python object representing a list of ddu_dev_data objects is returned.
* - NOTE: if no devices are missing drivers and get_only_missing_drivers
* is true, then an empty list is returned.
* - A ddu_dev_data object represents a found device.
@@ -367,11 +291,6 @@
boolean_t get_only_missing_drivers, char *dev_type)
{
PyObject *pRet = NULL;
- PyObject *pList = NULL;
- Py_ssize_t orig_listlen;
- char **vids, **dids, **classes;
- Py_ssize_t new_listused = 0;
- Py_ssize_t i, j;
/* Find the function */
PyObject *pFunc = PyObject_GetAttrString(py_state_p->pFunctionModule,
@@ -380,84 +299,28 @@
if ((pFunc == NULL) || (!PyCallable_Check(pFunc))) {
auto_debug_print(AUTO_DBGLVL_ERR,
"Function not callable: %s\n", DDU_DEVSCAN);
- Py_XDECREF(pFunc);
- return (NULL);
} else {
/* Set up args to python function and call it. */
PyObject *pArgs = PyTuple_New(2);
- (void) PyTuple_SetItem(pArgs, 0,
+ PyTuple_SetItem(pArgs, 0,
PyBool_FromLong((long)get_only_missing_drivers));
- (void) PyTuple_SetItem(pArgs, 1, PyString_FromString(dev_type));
- pList = PyObject_CallObject(pFunc, pArgs);
+ PyTuple_SetItem(pArgs, 1, PyString_FromString(dev_type));
+ pRet = PyObject_CallObject(pFunc, pArgs);
Py_DECREF(pArgs);
- if ((PyErr_Occurred() != NULL) || (pList == NULL) ||
- (pList == Py_None)) {
+ if ((PyErr_Occurred()) || (pRet == NULL) || (pRet == Py_None)) {
auto_debug_dump_file(AUTO_DBGLVL_ERR, DDU_ERRLOG);
auto_debug_print(AUTO_DBGLVL_ERR,
"%s returned an error.\n", DDU_DEVSCAN);
- ai_dump_python_exception();
- Py_XDECREF(pList);
- Py_XDECREF(pFunc);
- return (NULL);
+ if (PyErr_Occurred()) {
+ PyErr_Print();
+ }
+ Py_XDECREF(pRet);
+ pRet = NULL;
}
}
Py_XDECREF(pFunc);
-
- orig_listlen = PyList_Size(pList);
- if (orig_listlen < 2) {
- return (pList);
- }
-
- /* Check for duplicates. */
- vids = (char **)malloc(sizeof (char *) * orig_listlen);
- dids = (char **)malloc(sizeof (char *) * orig_listlen);
- classes = (char **)malloc(sizeof (char *) * orig_listlen);
- if ((vids == NULL) || (dids == NULL) || (classes == NULL)) {
- auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_call_ddu_devscan: No memory.\n");
- return (NULL);
- }
-
- /* Build a list of unique values to be returned. */
- pRet = PyList_New(0);
-
- /* Loop through the list. */
- for (i = 0; i < orig_listlen; i++) {
- PyObject *pDDUDevData = PyList_GetItem(pList, i);
- char *vendor_ID, *device_ID, *class;
- boolean_t dup;
-
- if (ai_get_ddu_dev_data_values(pDDUDevData, NULL, NULL,
- &vendor_ID, &device_ID, &class) != AUTO_INSTALL_SUCCESS) {
- /* If can't compare, just allow it. */
- continue;
- }
-
- /* Check for matching vendor, device, class. */
- for (j = 0, dup = B_FALSE; j < new_listused; j++) {
- if ((strcmp(class, classes[j]) == 0) &&
- (strcmp(device_ID, dids[j]) == 0) &&
- (strcmp(vendor_ID, vids[j]) == 0)) {
- dup = B_TRUE;
- break;
- }
- }
-
- if (!dup) {
- (void) PyList_Append(pRet, pDDUDevData);
- vids[new_listused] = vendor_ID;
- dids[new_listused] = device_ID;
- classes[new_listused++] = class;
- }
- }
-
- free(vids);
- free(dids);
- free(classes);
-
- Py_XDECREF(pList);
return (pRet);
}
@@ -472,28 +335,22 @@
* pDevObj: A python ddu_dev_data object representing a device.
* pRepoList: A python list of ddu_repo_object objects. This represents the
* list of repositories to search through for a driver package.
- * pPackageObj_p: Pointer to the returned ddu_package_object.
*
* Returns:
- * AUTO_INSTALL_SUCCESS: pPackageObj_p points to an object representing a
- * package to install for the given device.
- * AUTO_INSTALL_PKG_NOT_FOUND: No package was found to install for the given
- * device. pPackageObj_p set to NULL.
- * AUTO_INSTALL_FAILURE: Corresponds to an error other than not finding the
- * package to install for the given device. pPackageObj_p set to NULL.
+ * Success: A python ddu_package_object representing a package to install for
+ * the given device.
+ * Failure: NULL
*/
-static int
+static PyObject *
ai_call_ddu_package_lookup(py_state_t *py_state_p,
- PyObject *pDevObj, PyObject *pRepoList, PyObject **pPackageObj_p)
+ PyObject *pDevObj, PyObject *pRepoList)
{
- int err = AUTO_INSTALL_SUCCESS;
+ PyObject *pRet = NULL;
/* Find the function */
PyObject *pFunc = PyObject_GetAttrString(py_state_p->pFunctionModule,
DDU_PACKAGE_LOOKUP);
- *pPackageObj_p = NULL;
-
if ((pFunc == NULL) || (!PyCallable_Check(pFunc))) {
auto_debug_print(AUTO_DBGLVL_ERR,
"Function not callable: %s\n", DDU_PACKAGE_LOOKUP);
@@ -502,61 +359,26 @@
PyObject *pArgs = PyTuple_New(2);
Py_INCREF(pDevObj); /* PyTuple_SetItem steals reference. */
Py_INCREF(pRepoList); /* PyTuple_SetItem steals reference. */
- (void) PyTuple_SetItem(pArgs, 0, pDevObj);
- (void) PyTuple_SetItem(pArgs, 1, pRepoList);
+ PyTuple_SetItem(pArgs, 0, pDevObj);
+ PyTuple_SetItem(pArgs, 1, pRepoList);
/* Call ddu_package_lookup() */
- *pPackageObj_p = PyObject_CallObject(pFunc, pArgs);
+ pRet = PyObject_CallObject(pFunc, pArgs);
Py_DECREF(pArgs);
- if ((PyErr_Occurred() != NULL) || (*pPackageObj_p == NULL) ||
- (*pPackageObj_p == Py_None)) {
- err = AUTO_INSTALL_FAILURE;
+ if ((PyErr_Occurred()) || (pRet == NULL) || (pRet == Py_None)) {
auto_debug_dump_file(AUTO_DBGLVL_ERR, DDU_ERRLOG);
auto_debug_print(AUTO_DBGLVL_ERR,
"%s returned an error.\n", DDU_PACKAGE_LOOKUP);
- if (PyErr_Occurred() != NULL) {
- PyObject *pType, *pValue, *pTraceback;
- PyObject *pPkgNotFndExcObj =
- PyObject_GetAttrString(
- py_state_p->pErrorModule,
- DDU_PACKAGE_NOT_FOUND_EXC);
- PyErr_Fetch(&pType, &pValue, &pTraceback);
-
- if (PyObject_IsSubclass(pType,
- pPkgNotFndExcObj) == 1) { /* 1 = match */
- err = AUTO_INSTALL_PKG_NOT_FND;
- }
- Py_DECREF(pType);
- Py_DECREF(pValue);
- Py_DECREF(pTraceback);
- Py_DECREF(pPkgNotFndExcObj);
- PyErr_Clear();
+ if (PyErr_Occurred()) {
+ PyErr_Print();
}
- Py_XDECREF(*pPackageObj_p);
- *pPackageObj_p = NULL;
-
- } else {
- /*
- * DDU can return a pPackageObj_p that has type unknown,
- * no location and no inf_link. Treat these as
- * "package not found" as well.
- */
- char *ttype = empty_string;
- char *tlocn = empty_string;
- char *tinf_link = empty_string;
- (void) ai_get_ddu_package_object_values(*pPackageObj_p,
- &ttype, &tlocn, NULL, NULL, &tinf_link, NULL);
- if ((tlocn[0] == '\0') && (tinf_link[0] == '\0') &&
- (strcmp(ttype, "UNK") == 0)) {
- err = AUTO_INSTALL_PKG_NOT_FND;
- Py_XDECREF(*pPackageObj_p);
- *pPackageObj_p = NULL;
- }
+ Py_XDECREF(pRet);
+ pRet = NULL;
}
}
Py_XDECREF(pFunc);
- return (err);
+ return (pRet);
}
/*
@@ -601,21 +423,20 @@
/* Set up args to python function. */
PyObject *pArgs = PyTuple_New(3);
Py_INCREF(pDDUPackageObj); /* PyTuple_SetItem steals ref */
- (void) PyTuple_SetItem(pArgs, 0, pDDUPackageObj);
- (void) PyTuple_SetItem(pArgs, 1,
- PyString_FromString(install_root));
- (void) PyTuple_SetItem(pArgs, 2,
+ PyTuple_SetItem(pArgs, 0, pDDUPackageObj);
+ PyTuple_SetItem(pArgs, 1, PyString_FromString(install_root));
+ PyTuple_SetItem(pArgs, 2,
PyBool_FromLong((long)third_party_ok));
/* Call ddu_install_packages() */
- (void) PyObject_CallObject(pFunc, pArgs);
+ PyObject_CallObject(pFunc, pArgs);
Py_DECREF(pArgs);
- if (PyErr_Occurred() != NULL) {
+ if (PyErr_Occurred()) {
auto_debug_dump_file(AUTO_DBGLVL_ERR, DDU_ERRLOG);
auto_debug_print(AUTO_DBGLVL_ERR,
"%s returned an error\n", DDU_INSTALL_PACKAGE);
- ai_dump_python_exception();
+ PyErr_Print();
rval = AUTO_INSTALL_FAILURE;
}
}
@@ -626,7 +447,7 @@
/*
* ai_new_ddu_package_object:
- * Create a new ddu_package_object of given type, name and location.
+ * Create a new ddu_package_object of given type, name and origin.
*
* Arguments:
* py_state_p: Initialized py_state_t object.
@@ -636,7 +457,7 @@
*
* Returns:
* Success: A new python ddu_package_object object of the given
- * type/name/location.
+ * type/name/origin.
* Failure: NULL
*/
static PyObject *
@@ -662,19 +483,20 @@
} else {
/* Set up args to python function. */
PyObject *pArgs = PyTuple_New(3);
- (void) PyTuple_SetItem(pArgs, 0, PyString_FromString(type));
- (void) PyTuple_SetItem(pArgs, 1, PyString_FromString(name));
- (void) PyTuple_SetItem(pArgs, 2, PyString_FromString(origin));
+ PyTuple_SetItem(pArgs, 0, PyString_FromString(type));
+ PyTuple_SetItem(pArgs, 1, PyString_FromString(name));
+ PyTuple_SetItem(pArgs, 2, PyString_FromString(origin));
/* Call ddu_package_object constructor. */
pRet = PyObject_CallObject(pFunc, pArgs);
Py_DECREF(pArgs);
- if ((PyErr_Occurred() != NULL) || (pRet == NULL) ||
- (pRet == Py_None)) {
+ if ((PyErr_Occurred()) || (pRet == NULL) || (pRet == Py_None)) {
auto_debug_dump_file(AUTO_DBGLVL_ERR, DDU_ERRLOG);
auto_debug_print(AUTO_DBGLVL_ERR,
"ddu_package_object constructor failed\n");
- ai_dump_python_exception();
+ if (PyErr_Occurred()) {
+ PyErr_Print();
+ }
Py_XDECREF(pRet);
pRet = NULL;
}
@@ -698,7 +520,7 @@
* ddu_package_object; not verified.
* type: char string pointer returned filled in with "pkg_type" field.
* Not processed if NULL.
- * location: char string pointer returned filled in with "pkg_location" field.
+ * origin: char string pointer returned filled in with "pkg_location" field.
* Not processed if NULL.
* name: char string pointer returned filled in with "pkg_name" field.
* Not processed if NULL.
@@ -716,7 +538,7 @@
*/
static int
ai_get_ddu_package_object_values(PyObject *pDDUPackageObject,
- char **type, char **location, char **name, char **descr, char **inf_link,
+ char **type, char **origin, char **name, char **descr, char **inf_link,
boolean_t *third_party)
{
PyObject *pValue;
@@ -732,7 +554,7 @@
*type = PyString_AsString(pValue);
}
- if (location != NULL) {
+ if (origin != NULL) {
pValue = PyObject_GetAttrString(pDDUPackageObject,
"pkg_location");
if (pValue == NULL) {
@@ -741,7 +563,7 @@
"no ddu_package_object pkg_location field.\n");
return (AUTO_INSTALL_FAILURE);
}
- *location = PyString_AsString(pValue);
+ *origin = PyString_AsString(pValue);
}
if (name != NULL) {
@@ -806,15 +628,9 @@
* Arguments:
* pDDUDevData: Object to extract values from. Assumed to be a
* ddu_dev_data object; not verified.
- * dev_type_p: char string pointer returned filled in with "device_type"
- * field. Not processed if NULL.
- * descr_p: char string pointer returned filled in with "description" field.
+ * dev_type: char string pointer returned filled in with "device_type" field.
* Not processed if NULL.
- * vendor_ID_p: char string pointer returned filled in with "vendor ID" field.
- * Not processed if NULL.
- * device_ID_p: char string pointer returned filled in with "device ID" field.
- * Not processed if NULL.
- * class_p: char string pointer returned filled in with PCI "class" field.
+ * descr: char string pointer returned filled in with "description" field.
* Not processed if NULL.
*
* Returns:
@@ -823,12 +639,11 @@
* extracted.
*/
static int
-ai_get_ddu_dev_data_values(PyObject *pDDUDevData, char **dev_type_p,
- char **descr_p, char **vendor_ID_p, char **device_ID_p, char **class_p)
+ai_get_ddu_dev_data_values(PyObject *pDDUDevData, char **dev_type, char **descr)
{
PyObject *pValue;
- if (dev_type_p != NULL) {
+ if (dev_type != NULL) {
pValue = PyObject_GetAttrString(pDDUDevData, "device_type");
if (pValue == NULL) {
auto_debug_print(AUTO_DBGLVL_ERR,
@@ -836,10 +651,10 @@
"no ddu_dev_data device_type field.\n");
return (AUTO_INSTALL_FAILURE);
}
- *dev_type_p = PyString_AsString(pValue);
+ *dev_type = PyString_AsString(pValue);
}
- if (descr_p != NULL) {
+ if (descr != NULL) {
pValue = PyObject_GetAttrString(pDDUDevData, "description");
if (pValue == NULL) {
auto_debug_print(AUTO_DBGLVL_ERR,
@@ -847,40 +662,7 @@
"no ddu_dev_data description field.\n");
return (AUTO_INSTALL_FAILURE);
}
- *descr_p = PyString_AsString(pValue);
- }
-
- if (vendor_ID_p != NULL) {
- pValue = PyObject_GetAttrString(pDDUDevData, "vendor_id");
- if (pValue == NULL) {
- auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_get_ddu_dev_data_values: "
- "no ddu_dev_data vendor_id field.\n");
- return (AUTO_INSTALL_FAILURE);
- }
- *vendor_ID_p = PyString_AsString(pValue);
- }
-
- if (device_ID_p != NULL) {
- pValue = PyObject_GetAttrString(pDDUDevData, "device_id");
- if (pValue == NULL) {
- auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_get_ddu_dev_data_values: "
- "no ddu_dev_data device_id field.\n");
- return (AUTO_INSTALL_FAILURE);
- }
- *device_ID_p = PyString_AsString(pValue);
- }
-
- if (class_p != NULL) {
- pValue = PyObject_GetAttrString(pDDUDevData, "class_code");
- if (pValue == NULL) {
- auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_get_ddu_dev_data_values: "
- "no ddu_dev_data class_code field.\n");
- return (AUTO_INSTALL_FAILURE);
- }
- *class_p = PyString_AsString(pValue);
+ *descr = PyString_AsString(pValue);
}
return (AUTO_INSTALL_SUCCESS);
@@ -893,29 +675,24 @@
* Arguments:
* py_state_p: Initialized py_state_t object.
* pPackageList: List of packages to append the new ddu_package_object to.
- * origin: directory of where package or package directive is located.
+ * origin: directory of where package is located.
* type: type of package.
* name: name of package.
* noinstall: boolean whether package is to be installed only to booted
* environment, not to target.
*
- * Returns:
- * AUTO_INSTALL_SUCCESS: A new package object was successfully appended to
- * pPackageList.
- * AUTO_INSTALL_FAILURE: An error occurred when trying to create a new
- * package object or append it to the pPackageList.
- *
- * Note: The list object referenced by pPackageList will be modified.
+ * Returns: None
+ * Note 1: the pPackageList will be modified.
+ * Note 2: Appropriate error messages are logged/displayed.
*/
-static int
+static void
ai_du_process_manual_pkg(py_state_t *py_state_p, PyObject *pPackageList,
char *origin, char *type, char *name, char *noinstall)
{
PyObject *pDDUPackageObject;
PyObject *pTuple;
- auto_log_print(gettext(
- "Add Drivers: Found manifest entry for package:\n"));
+ auto_log_print(gettext("Found manifest entry for package:\n"));
if (name != empty_string) {
auto_log_print(gettext(" type:%s, origin:%s, name:%s\n"),
type, origin, name);
@@ -937,55 +714,48 @@
if (pDDUPackageObject == NULL) {
auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_du_process_manual_pkg: <add_drivers> error:\n"
+ "ai_du_get_pkg_list: <add_drivers> error:\n"
"Error creating new package object for "
"origin %s %s\n", origin, name);
- return (AUTO_INSTALL_FAILURE);
+ return;
}
pTuple = PyTuple_New(3);
- (void) PyTuple_SetItem(pTuple, 0, pDDUPackageObject);
- (void) PyTuple_SetItem(pTuple, 1, Py_True); /* third party OK */
- (void) PyTuple_SetItem(pTuple, 2,
+ PyTuple_SetItem(pTuple, 0, pDDUPackageObject);
+ PyTuple_SetItem(pTuple, 1, Py_True); /* third party OK */
+ PyTuple_SetItem(pTuple, 2,
(strcmp(noinstall, "true") == 0) ? Py_True : Py_False);
/*
* NOTE: Don't decref pTuple here as PyList_Append doesn't
* steal a reference to it.
*/
- (void) PyList_Append(pPackageList, pTuple);
- return (AUTO_INSTALL_SUCCESS);
+ PyList_Append(pPackageList, pTuple);
}
/*
* ai_du_process_manual_pkg_names:
- * Do any processing of packages for which unique origin (location), type and
- * name are known.
+ * Do any processing of packages for which unique origin, type and name are
+ * known.
*
* Arguments:
* py_state_p: Initialized py_state_t object.
- * path_p: Used to build nodepath strings for manifest checking.
* pPackageList: List of packages to append the new ddu_package_object to.
* origin: directory of where package is located.
* type: type of package.
* name: name of package.
*
- * Returns:
- * AUTO_INSTALL_SUCCESS: Package processed successfully and appended to
- * pPackageList.
- * AUTO_INSTALL_FAILURE: An error occurred. No package appended to
- * pPackageList.
- *
- * Note 1: the object pointed to by pPackageList will be modified.
+ * Returns: None
+ * Note 1: the pPackageList will be modified.
+ * Note 2: Appropriate error messages are logged/displayed.
*/
-static int
-ai_du_process_manual_pkg_names(py_state_t *py_state_p, path_t *path_p,
- PyObject *pPackageList, char *origin, char *type, char *name)
+static void
+ai_du_process_manual_pkg_names(py_state_t *py_state_p, PyObject *pPackageList,
+ path_t *path_p, char *origin, char *type, char *name)
{
char **actions;
int actions_len;
char *nodespec;
- int rval;
/* Get the action attribute. */
@@ -998,33 +768,32 @@
if (snprintf(path_p->post_prefix_start, path_p->post_prefix_len,
nodespec, origin, type, name) >= path_p->post_prefix_len) {
- auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_du_process_manual_pkg_names: "
+ auto_debug_print(AUTO_DBGLVL_ERR, "ai_du_get_pkg_list: "
"<add_drivers> manifest error:\n"
"action path buffer overflow for origin \"%s\", "
"type \"%s\", name \"%s\"\n", origin, type, name);
- return (AUTO_INSTALL_FAILURE);
+ return;
}
actions = ai_get_manifest_values(path_p->path_str, &actions_len);
/*
- * Note: action must be present and must be
- * either "install" or "noinstall".
+ * Note: action must be present and must be either "install"
+ * or "noinstall".
*/
if (actions_len <= 0) {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_pkg_list: "
"<add_drivers> manifest error:\n"
"no action value for origin \"%s\", "
"type \"%s\", name \"%s\"\n"), origin, type, name);
- rval = AUTO_INSTALL_FAILURE;
+ return;
} else if (actions_len > 1) {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_pkg_list: "
"<add_drivers> manifest error:\n"
"multiple action values for origin \"%s\", "
"type \"%s\", name \"%s\"\n"), origin, type, name);
- rval = AUTO_INSTALL_FAILURE;
+ return;
} else if (strcmp(actions[0], "install") == 0) {
/*
@@ -1034,8 +803,8 @@
*/
/* Obj pointed to by pPackageList will be modified. */
- rval = ai_du_process_manual_pkg(py_state_p, pPackageList,
- origin, type, name, empty_string);
+ ai_du_process_manual_pkg(py_state_p, pPackageList, origin,
+ type, name, empty_string);
} else if (strcmp(actions[0], "noinstall") == 0) {
/*
* If action="noinstall" then call ai_du_process_manual_pkg with
@@ -1043,22 +812,22 @@
* installed in both boot env and not in target.
*/
/* Obj pointed to by pPackageList will be modified. */
- rval = ai_du_process_manual_pkg(py_state_p, pPackageList,
- origin, type, name, "true");
+ ai_du_process_manual_pkg(py_state_p, pPackageList, origin,
+ type, name, "true");
} else {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_pkg_list: "
"<add_drivers> manifest error:\n"
"action must be install or noinstall for origin \"%s\", "
"type \"%s\", name \"%s\"\n"), origin, type, name);
- rval = AUTO_INSTALL_FAILURE;
+ return;
+
}
ai_free_manifest_values(actions);
- return (rval);
}
/*
* ai_du_process_manual_pkg_types:
- * Do any processing of packages for which unique location and type are known.
+ * Do any processing of packages for which unique origin and type are known.
*
* Arguments:
* py_state_p: Initialized py_state_t object.
@@ -1066,16 +835,11 @@
* origin: directory of where package is located.
* type: type of package.
*
- * Returns:
- * AUTO_INSTALL_SUCCESS: Package processed successfully and appended to
- * pPackageList.
- * AUTO_INSTALL_FAILURE: An error occurred. No package appended to
- * pPackageList.
- *
+ * Returns: None
* Note 1: the pPackageList will be modified.
* Note 2: Appropriate error messages are logged/displayed.
*/
-static int
+static void
ai_du_process_manual_pkg_types(py_state_t *py_state_p, PyObject *pPackageList,
path_t *path_p, char *origin, char *type)
{
@@ -1083,27 +847,26 @@
char **uniq_names;
int namelen;
int k;
- int rval = AUTO_INSTALL_SUCCESS;
if ((strcmp(type, "P5I") != 0) &&
(strcmp(type, "SVR4") != 0) &&
(strcmp(type, "DU") != 0)) {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_pkg_list: "
"<add_drivers> manifest error:\n"
- "invalid type %s given for origin %s\n"), type, origin);
- return (AUTO_INSTALL_FAILURE);
+ "invalid type %s given for origin %s\n"),
+ type, origin);
+ return;
}
/* Get all names assocated with type and origin. */
if (snprintf(path_p->post_prefix_start, path_p->post_prefix_len,
NAME_NODEPATH, origin, type) >= path_p->post_prefix_len) {
- auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_du_process_manual_pkg_types: "
+ auto_debug_print(AUTO_DBGLVL_ERR, "ai_du_get_pkg_list: "
"<add_drivers> manifest error:\n"
"name path buffer overflow for origin "
"%s, type %s\n", origin, type);
- return (AUTO_INSTALL_FAILURE);
+ return;
}
names = ai_get_manifest_values(path_p->path_str, &namelen);
@@ -1115,54 +878,54 @@
if (strcmp(type, "SVR4") != 0) {
if (namelen > 0) {
auto_log_print(gettext(
- "Add Drivers: <add_drivers> "
+ "ai_du_get_pkg_list: <add_drivers> "
"manifest error:\n"
- "name given to P5I or DU package specification at "
+ "name given to P5I or DU pkg spec at "
"origin %s\n"), origin);
- rval = AUTO_INSTALL_FAILURE;
+ return;
} else {
/* Obj pointed to by pPackageList will be modified. */
- rval = ai_du_process_manual_pkg_names(py_state_p,
- path_p, pPackageList, origin, type, empty_string);
+ ai_du_process_manual_pkg_names(py_state_p, pPackageList,
+ path_p, origin, type, empty_string);
}
- /* There must be at least one "name" entry per pkgspec for SVR4 type. */
+ /*
+ * There must be at least one "name" entry per pkg spec
+ * for SVR4 type.
+ */
} else if (namelen <= 0) {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_pkg_list: "
"<add_drivers> manifest error:\n"
- " no name given for SVR4 package specification\n"
- " at origin %s, type %s\n"), origin, type);
- rval = AUTO_INSTALL_FAILURE;
+ "no name given for SVR4 pkg spec at origin %s, type %s\n"),
+ origin, type);
+ return;
} else {
/* Process each origin/type/name entry. */
for (k = 0; k < namelen; k++) {
/* Obj pointed to by pPackageList will be modified. */
- int status = ai_du_process_manual_pkg_names(py_state_p,
- path_p, pPackageList, origin, type, names[k]);
- if (status == AUTO_INSTALL_FAILURE) {
- rval = AUTO_INSTALL_FAILURE;
- }
+ ai_du_process_manual_pkg_names(py_state_p, pPackageList,
+ path_p, origin, type, names[k]);
}
+
}
ai_free_manifest_values(names);
- return (rval);
}
/*
* ai_du_get_manual_pkg_list:
- * Read the AI ai.xml Manifest file and process the <software> tags under the
- * <add_drivers> section. <software> represents a manual specification of a
- * package to install. Do error checking of the manifest as necessary, as this
- * function reads the manifest before it is validated against a schema.
+ * Read the AI ai.xml Manifest file and process the <software> under the
+ * <add_drivers> section. A <software> is a manual specification of a package
+ * to install. Do error checking of the manifest as necessary, as this function
+ * reads the manifest before it is validated against a schema.
*
* Validates syntax and processes the following from the manifest:
* <add_drivers>
* <software>
* <source>
* <publisher>
- * <origin name="location"/>
+ * <origin name="origin"/>
* </publisher>
* </source>
* <software_data type="type" action="noinstall">
@@ -1174,84 +937,70 @@
* type can be "SVR4", "P5I" or "DU".
* name not allowed if type is "P5I" or "DU"
*
- * Always return a list. An empty list can be returned if the manifest shows
- * there are no packages to install for Driver Update, or on some errors.
- *
* Arguments:
* py_state_p: Initialized py_state_t object.
* path_p: Used to build nodepath strings for manifest checking.
*
* Returns:
- * AUTO_INSTALL_SUCCESS: A complete python list of (ddu_package_object,
- * third_party_ok, noinstall) tuples suitable for input to
- * ai_du_install_packages() has been created.
- * AUTO_INSTALL_FAILURE: A python list of tuples suitable for input to
- * ai_du_install_packages() has been created, but is missing one or more
- * requested packages due to errors. These errors could be manifest
- * parsing errors or errors in setting up the packages.
+ * Success: A python list of (ddu_package_object, third_party_ok, noinstall)
+ * tuples suitable for input to ai_du_install_packages().
+ * NOTE: if the manifest shows no packages to install for Driver Update,
+ * this function will return an empty list.
+ * Failure: NULL
*
* NOTE: check installer logfile for details of the failure.
*/
-static int
-ai_du_get_manual_pkg_list(py_state_t *py_state_p, path_t *path_p,
- PyObject **pPackageList_p)
+static PyObject *
+ai_du_get_manual_pkg_list(py_state_t *py_state_p, path_t *path_p)
{
+ PyObject *pPackageList = NULL;
char **uniq_origins = NULL;
char **types = NULL;
int origin_len, typelen;
char **origins;
char **uniq_types;
- int num_pkgspecs;
+ int num_pkg_specs;
int i, j;
- int rval = AUTO_INSTALL_SUCCESS;
-
- /*
- * Initialize a zero-length list.
- * This will be returned empty if nothing to install has been found
- * or if an error is found early on.
- */
- *pPackageList_p = PyList_New(0);
/* Read manifest for specific package requests. */
- /* Get the number of <software> package spec entries. */
+ /* Get the number of pkg spec entries. */
if (strlcpy(path_p->post_prefix_start, PKGSPEC_NODEPATH,
path_p->post_prefix_len) > path_p->post_prefix_len) {
- auto_debug_print(AUTO_DBGLVL_ERR, "ai_du_get_manual_pkg_list: "
- "<software> path buffer overflow\n");
- return (AUTO_INSTALL_FAILURE);
+ auto_debug_print(AUTO_DBGLVL_ERR,
+ "ai_du_get_pkg_list: pkg spec path buffer overflow\n");
+ return (NULL);
}
- /* Use "origins" like a dummy here. Interest only in num_pkgspecs. */
- origins = ai_get_manifest_values(path_p->path_str, &num_pkgspecs);
+ /* Use "origins" like a dummy here. Interest only in num_pkg_specs. */
+ origins = ai_get_manifest_values(path_p->path_str, &num_pkg_specs);
ai_free_manifest_values(origins);
- /* No package specs. Return an empty list. */
- if (num_pkgspecs <= 0) {
- return (AUTO_INSTALL_SUCCESS);
+ /* No pkg specs. Return an empty list. */
+ if (num_pkg_specs <= 0) {
+ return (PyList_New(0));
}
/* Retrieve a list of all specific package request origins. */
if (strlcpy(path_p->post_prefix_start, ORIGIN_NODEPATH,
path_p->post_prefix_len) > path_p->post_prefix_len) {
auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_du_get_manual_pkg_list: origin path buffer overflow\n");
- return (AUTO_INSTALL_FAILURE);
+ "ai_du_get_pkg_list: origin path buffer overflow\n");
+ return (NULL);
}
/* Get real origins list here for use below. */
origins = ai_get_manifest_values(path_p->path_str, &origin_len);
/*
- * Not a perfect test to validate package specs vs origins in
- * manifest, but it will do...
+ * Not a perfect test to validate pkg specs and origins in manifest,
+ * but it will do...
*/
- if (origin_len != num_pkgspecs) {
+ if (origin_len != num_pkg_specs) {
auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_du_get_manual_pkg_list: <add_drivers> manifest error:\n"
- "There is not a 1-1 <origin> - <software> mapping.\n");
- ai_free_manifest_values(origins);
- return (AUTO_INSTALL_FAILURE);
+ "ai_du_get_pkg_list: <add_drivers> manifest error:\n"
+ "There is not a 1-1 origin to pkg spec mapping.\n");
+ return (NULL);
}
uniq_origins = ai_uniq_manifest_values(origins, &origin_len);
@@ -1259,9 +1008,15 @@
origins = uniq_origins;
/*
- * For each origin (location), get types. Note it is possible for
- * there to be more than one type at an origin. There can also be more
- * than one item of a given type at an origin.
+ * Initialize a zero-length list.
+ * This will be returned empty if nothing to install has been found.
+ */
+ pPackageList = PyList_New(0);
+
+ /*
+ * For each origin, get types. Note it is possible for there to be
+ * more than one type at a origin. There can also be more than one
+ * item of a given type at a origin.
*/
for (i = 0; i < origin_len; i++) {
@@ -1270,20 +1025,18 @@
if (snprintf(path_p->post_prefix_start, path_p->post_prefix_len,
TYPE_NODEPATH, origins[i]) >= path_p->post_prefix_len) {
auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_du_get_manual_pkg_list: "
+ "ai_du_get_pkg_list: "
"<add_drivers> manifest error:\n"
"type path buffer overflow for origin %s\n",
origins[i]);
- rval = AUTO_INSTALL_FAILURE;
continue;
}
types = ai_get_manifest_values(path_p->path_str, &typelen);
if (typelen <= 0) {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_pkg_list: "
"<add_drivers> manifest error:\n"
"no type given for origin %s\n"), origins[i]);
- rval = AUTO_INSTALL_FAILURE;
continue;
}
@@ -1294,18 +1047,14 @@
/* Loop for all types found at this origin... */
for (j = 0; j < typelen; j++) {
- /* Obj *pPackageList_p points to will be modified. */
- int status = ai_du_process_manual_pkg_types(py_state_p,
- *pPackageList_p, path_p, origins[i], types[j]);
- if (status == AUTO_INSTALL_FAILURE) {
- rval = AUTO_INSTALL_FAILURE;
- }
+ /* Obj pointed to by pPackageList will be modified. */
+ ai_du_process_manual_pkg_types(py_state_p, pPackageList,
+ path_p, origins[i], types[j]);
}
}
-
ai_free_manifest_values(origins);
ai_free_manifest_values(types);
- return (rval);
+ return (pPackageList);
}
/*
@@ -1316,51 +1065,38 @@
* checking of the manifest as necessary, as this function reads the manifest
* before it is validated against a schema.
*
- * Always return a list. An empty list can be returned if a search determines
- * there are no packages to install for Driver Update (i.e. the system is
- * missing no drivers), or on some errors.
- *
* Validates syntax and processes the following from the manifest:
* <add_drivers>
* <search_all addall="false">
* <source>
* <publisher name="publisher">
- * <origin name="location"/>
+ * <origin name="origin"/>
* </publisher>
* </source>
* </search_all>
* </add_drivers>
*
- * publisher and origin are both optional, but if one is specified then
- * the other must also be specified.
- *
- * addall is optional. When true, it allows search_all to install third
- * party drivers (found via the database in the given pkg(5) repository,
- * but installed from somewhere else). Defaults to "false" if not
- * specified.
+ * publisher and origin are both optional, but if one is specified then the
+ * other must also be specified.
+ * addall is optional. Defaults to "false" if not specified.
*
* Arguments:
* py_state_p: Initialized py_state_t object.
* path_p: Used to build nodepath strings for manifest checking.
- * install_root: Root used for determining pkg publisher.
- * pPackageList_p: A python list of (ddu_package_object, third_party_ok,
- * noinstall) tuples suitable for input to ai_du_install_packages().
*
* Returns:
- * AUTO_INSTALL_SUCCESS: No errors were encountered in retrieving package
- * information. It is also possible that the system is missing no drivers,
- * and an empty list is returned.
- * AUTO_INSTALL_PKG_NOT_FND: Packages for one or more missing drivers are not
- * available.
- * AUTO_INSTALL_FAILURE: One or more errors (other than packages which were
- * not available) were encountered in retrieving package information.
+ * Success: A python list of (ddu_package_object, third_party_ok, noinstall)
+ * tuples suitable for input to ai_du_install_packages().
+ * NOTE: if the system is missing no drivers, this function will return
+ * an empty list.
+ * Failure: NULL
*
* NOTE: check installer logfile for details of the failure.
*/
-static int
-ai_du_get_searched_pkg_list(py_state_t *py_state_p, path_t *path_p,
- char *install_root, PyObject **pPackageList_p)
+static PyObject *
+ai_du_get_searched_pkg_list(py_state_t *py_state_p, path_t *path_p)
{
+ PyObject *pPackageList = NULL;
PyObject *pDeviceList = NULL;
PyObject *pTuple;
PyObject *pRepoTupleList;
@@ -1373,9 +1109,9 @@
char **search_pubs = NULL;
char **search_addalls = NULL;
Py_ssize_t i, listlen;
- int rval = AUTO_INSTALL_FAILURE;
+ PyObject *pRval = NULL;
- *pPackageList_p = PyList_New(0); /* Initialize a zero-length list. */
+ pPackageList = PyList_New(0); /* Initialize a zero-length list. */
/* Read manifest for search requests. */
@@ -1384,22 +1120,21 @@
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_get_searched_pkg_list: "
"search pathname buffer overflow.\n");
- return (AUTO_INSTALL_FAILURE);
+ return (NULL);
}
searches = ai_get_manifest_values(path_p->path_str, &len);
ai_free_manifest_values(searches);
if (len > 1) {
- auto_log_print(gettext("Add Drivers: "
- "Only one <search_all> entry allowed in manifest\n"));
- return (AUTO_INSTALL_FAILURE);
+ auto_log_print(gettext("ai_du_get_searched_pkg_list: "
+ "too many <search_all> entries in manifest\n"));
+ return (NULL);
+
+ } else if (len <= 0) {
+ return (pPackageList);
}
- if (len <= 0) {
- return (AUTO_INSTALL_SUCCESS);
- }
-
- auto_log_print(gettext("Add Drivers: Doing a device "
+ auto_log_print(gettext("ai_du_get_searched_pkg_list: Doing a device "
"scan for devices which are missing drivers...\n"));
/*
@@ -1410,27 +1145,25 @@
if (pDeviceList == NULL) {
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_get_searched_pkg_list: "
- "Error scanning for missing drivers.\n");
- return (AUTO_INSTALL_FAILURE);
+ "Error scanning for missing devices.\n");
+ return (NULL);
/* An empty list is perfectly acceptable here. No missing drivers. */
} else if (PyList_Size(pDeviceList) == 0) {
- auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_du_get_searched_pkg_list: No missing drivers found.\n");
- return (AUTO_INSTALL_SUCCESS);
+ return (pPackageList);
}
- /* Get repo location, if specified. */
+ /* Get repo origin, if specified. */
if (strlcpy(path_p->post_prefix_start, SEARCH_ORIGIN_NODEPATH,
path_p->post_prefix_len) > path_p->post_prefix_len) {
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_get_searched_pkg_list: search repo origin path "
"buffer overflow.\n");
- return (AUTO_INSTALL_FAILURE);
+ return (NULL);
}
- auto_log_print(gettext("Add Drivers: Querying manifest "
+ auto_log_print(gettext("ai_du_get_searched_pkg_list: Querying manifest "
"for explicit repo for getting missing driver packages...\n"));
search_origins = ai_get_manifest_values(path_p->path_str, &sublen);
@@ -1439,7 +1172,7 @@
} else if (sublen <= 0) {
search_origin = empty_string;
} else {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_searched_pkg_list: "
"<add_drivers> manifest error:\n"
"Only one origin allowed per <search_all> entry.\n"));
goto done;
@@ -1461,7 +1194,7 @@
} else if (sublen <= 0) {
search_pub = empty_string;
} else {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_searched_pkg_list: "
"<add_drivers> manifest error:\n"
"Only one publisher allowed for a <search_all> entry\n"));
goto done;
@@ -1470,7 +1203,7 @@
/* Can't have one without the other. */
if ((search_pub == empty_string) ^
(search_origin == empty_string)) {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_searched_pkg_list: "
"<add_drivers> manifest error:\n"
"search repo origin and "
"publisher must be specified together.\n"));
@@ -1483,17 +1216,15 @@
*/
if (search_pub != empty_string) {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_searched_pkg_list: "
"Found repo in manifest: publisher:%s, origin:%s\n"),
search_pub, search_origin);
pTuple = PyTuple_New(2);
- (void) PyTuple_SetItem(pTuple, 0,
- PyString_FromString(search_pub));
- (void) PyTuple_SetItem(pTuple, 1,
- PyString_FromString(search_origin));
+ PyTuple_SetItem(pTuple, 0, PyString_FromString(search_pub));
+ PyTuple_SetItem(pTuple, 1, PyString_FromString(search_origin));
pRepoTupleList = PyList_New(0);
- (void) PyList_Append(pRepoTupleList, pTuple);
+ PyList_Append(pRepoTupleList, pTuple);
pSearchRepoList = ai_call_ddu_build_repo_list(py_state_p,
pRepoTupleList);
Py_DECREF(pTuple);
@@ -1505,31 +1236,12 @@
"Error building search repo list.\n");
goto done;
}
-
- auto_log_print(gettext("Add Drivers: "
- "Searching for packages in %s repository at %s\n"),
- search_pub, search_origin);
-
} else {
- FILE *pub_info;
- char pub_buf[MAXPATHLEN];
- char cmd_buf[MAXPATHLEN];
-
/* No publisher/URL provided. Return an empty repo list. */
- auto_log_print(gettext("Add Drivers: "
- "No explicit <search_all> repo specified in manifest\n"));
- auto_log_print(gettext("... Searching for packages in "
- "repositories already configured on the system\n"));
-
- (void) snprintf(cmd_buf, MAXPATHLEN,
- "/usr/bin/pkg -R %s publisher", install_root);
- if ((pub_info = popen(cmd_buf, "r")) != NULL) {
- while (fgets(pub_buf, MAXPATHLEN, pub_info) != NULL) {
- auto_log_print("%s\n", pub_buf);
- }
- (void) pclose(pub_info);
- }
+ auto_debug_print(AUTO_DBGLVL_INFO,
+ "ai_du_get_searched_pkg_list: "
+ "No <search_all> repo found in manifest\n");
pSearchRepoList = PyList_New(0);
}
@@ -1550,7 +1262,7 @@
((sublen == 1) &&
((strcmp(search_addalls[0], "true") != 0) &&
(strcmp(search_addalls[0], "false") != 0)))) {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_searched_pkg_list: "
"<add_drivers> manifest error:\n"
"invalid addall value for <search_all> entry\n"));
goto done;
@@ -1561,7 +1273,7 @@
py_search_addall = Py_False;
} else {
- auto_log_print(gettext("Add Drivers: Manifest "
+ auto_log_print(gettext("ai_du_get_searched_pkg_list: Manifest "
"allows adding of third-party drivers\n"));
Py_INCREF(Py_True);
py_search_addall = Py_True;
@@ -1571,7 +1283,6 @@
* Append packages found for missing devices, to the list of packages
* to install.
*/
- rval = AUTO_INSTALL_SUCCESS;
listlen = PyList_Size(pDeviceList);
for (i = 0; i < listlen; i++) {
@@ -1579,45 +1290,30 @@
PyObject *pDDUDevData;
char *dev_type;
char *descr;
- int lookup_err;
boolean_t third_party = B_FALSE;
pDDUDevData = PyList_GetItem(pDeviceList, i);
/* Find the package containing the driver for this device. */
- lookup_err = ai_call_ddu_package_lookup(py_state_p,
- pDDUDevData, pSearchRepoList, &pDDUPackageObject);
+ pDDUPackageObject = ai_call_ddu_package_lookup(py_state_p,
+ pDDUDevData, pSearchRepoList);
/* Get info for display / logging purposes, and log it. */
- if (ai_get_ddu_dev_data_values(pDDUDevData, &dev_type, &descr,
- NULL, NULL, NULL) != AUTO_INSTALL_SUCCESS) {
+ if (ai_get_ddu_dev_data_values(pDDUDevData,
+ &dev_type, &descr) != AUTO_INSTALL_SUCCESS) {
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_get_searched_pkg_list: Error retrieving "
"device information for display\n");
dev_type = descr = empty_string;
}
- /* Package not found is not considered an error. */
- if (lookup_err == AUTO_INSTALL_PKG_NOT_FND) {
- auto_log_print(gettext("Add Drivers: "
- "Warning: Search found no package for "
- "\"%s\" type device \"%s\".\n"), dev_type, descr);
- /*
- * Set marginal success status.
- * Don't override failure status.
- */
- if (rval == AUTO_INSTALL_SUCCESS) {
- rval = AUTO_INSTALL_PKG_NOT_FND;
- }
- continue;
- } else if (lookup_err != AUTO_INSTALL_SUCCESS) {
- auto_log_print(gettext("Add Drivers: "
+ if (pDDUPackageObject == NULL) {
+ auto_log_print(gettext("ai_du_get_searched_pkg_list: "
"Error retrieving package for "
"\"%s\" type device \"%s\".\n"), dev_type, descr);
- rval = AUTO_INSTALL_FAILURE;
continue;
} else {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_get_searched_pkg_list: "
"DDU returned package info for "
"\"%s\" type device \"%s\".\n"), dev_type, descr);
}
@@ -1636,13 +1332,18 @@
* steal a reference to it.
*/
pTuple = PyTuple_New(3);
- (void) PyTuple_SetItem(pTuple, 0, pDDUPackageObject);
- Py_INCREF(py_search_addall); /* 3rd party OK */
- (void) PyTuple_SetItem(pTuple, 1, py_search_addall);
- Py_INCREF(Py_False); /* always install */
- (void) PyTuple_SetItem(pTuple, 2, Py_False);
- (void) PyList_Append(*pPackageList_p, pTuple);
+ PyTuple_SetItem(pTuple, 0, pDDUPackageObject);
+ Py_INCREF(py_search_addall);
+ PyTuple_SetItem(pTuple, 1, py_search_addall); /* 3rd party OK */
+ Py_INCREF(Py_False);
+ PyTuple_SetItem(pTuple, 2, Py_False); /* always install */
+
+ PyList_Append(pPackageList, pTuple);
}
+
+ /* Success. Prepare to return the package list just prepared. */
+ pRval = pPackageList;
+
done:
/* Cleanup time, whether an error occured or not. */
ai_free_manifest_values(search_origins);
@@ -1650,7 +1351,7 @@
Py_XDECREF(py_search_addall);
Py_XDECREF(pSearchRepoList);
Py_XDECREF(pDeviceList);
- return (rval);
+ return (pRval);
}
/*
@@ -1659,9 +1360,6 @@
* tree under install_root, skipping packages with noinstall flag set if
* honor_noinstall is set.
*
- * NOTE: it is assumed that the DDU library returns successful status when
- * attempting to install a package which is already installed.
- *
* Arguments:
* py_state_p: Initialized py_state_t object.
* pPkgTupleList: Python list of (ddu_package_object, third_party_ok,
@@ -1693,7 +1391,7 @@
Py_ssize_t i;
int rval = AUTO_INSTALL_SUCCESS;
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_install_packages: "
"Installing packages to %s\n"), install_root);
len = PyList_Size(pPkgTupleList);
@@ -1705,32 +1403,36 @@
PyObject *pDDUPackageObject = PyTuple_GetItem(pTuple, 0);
PyObject *pThirdPartyOK = PyTuple_GetItem(pTuple, 1);
PyObject *pNoInstall = PyTuple_GetItem(pTuple, 2);
- char *type, *location, *name, *descr, *inf_link;
+ char *type = empty_string;
+ char *origin = empty_string;
+ char *name = empty_string;
+ char *descr = empty_string;
+ char *inf_link = empty_string;
boolean_t third_party;
if (ai_get_ddu_package_object_values(pDDUPackageObject,
- &type, &location, &name, &descr, &inf_link, &third_party) !=
+ &type, &origin, &name, &descr, &inf_link, &third_party) !=
AUTO_INSTALL_SUCCESS) {
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_install_packages: Error extracting package "
"information for ddu_package_object.\n");
- type = location = name = descr = inf_link =
+ type = origin = name = descr = inf_link =
empty_string;
third_party = B_FALSE;
} else {
if (strcmp(name, empty_string) == 0) {
auto_log_print(gettext(
" %s package at origin:%s\n"),
- type, location);
+ type, origin);
} else {
auto_log_print(gettext(
" %s package at origin:%s, name:%s\n"),
- type, location, name);
+ type, origin, name);
}
}
if (PyObject_IsTrue(pNoInstall) && honor_noinstall) {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_install_packages: "
" honoring noinstall: skipping package.\n"));
continue;
}
@@ -1753,15 +1455,16 @@
}
/* Handle uninstallable package objects. */
- if (strcmp(location, empty_string) == 0) {
+ if (strcmp(origin, empty_string) == 0) {
if (strcmp(inf_link, empty_string) == 0) {
auto_log_print(gettext(
- "Add Drivers: Package not "
+ "ai_du_install_packages: Package not "
"found for device: \"%s\"\n"), descr);
} else {
auto_log_print(gettext(
- "Add Drivers: Package for device: \"%s\" "
- "must be installed manually.\n"
+ "ai_du_install_packages: Package for "
+ "device: \"%s\" must be installed "
+ "manually.\n"
"For more information go to:\n %s\n"),
descr, inf_link);
}
@@ -1773,7 +1476,7 @@
if (ai_call_ddu_install_package(py_state_p, pDDUPackageObject,
install_root, PyObject_IsTrue(pThirdPartyOK)) ==
AUTO_INSTALL_FAILURE) {
- auto_log_print(gettext("Add Drivers: "
+ auto_log_print(gettext("ai_du_install_packages: "
"Error installing package to %s\n"), install_root);
rval = AUTO_INSTALL_FAILURE;
} else {
@@ -1823,9 +1526,6 @@
}
out = (char **)malloc((in_len - dup_count + 1) * sizeof (char *));
- if (out == NULL) {
- return (NULL);
- }
for (i = 0, j = 0; i < in_len; i++) {
if (!is_dup[i]) {
out[j++] = strdup(in[i]);
@@ -1866,19 +1566,20 @@
} else {
/* Set up args to python function. */
PyObject *pArgs = PyTuple_New(1);
- (void) PyTuple_SetItem(pArgs, 0,
- PyString_FromString(install_root));
+ PyTuple_SetItem(pArgs, 0, PyString_FromString(install_root));
/* Call constructor. */
pICT_instance = PyObject_CallObject(pFunc, pArgs);
Py_XDECREF(pFunc);
Py_DECREF(pArgs);
- if ((PyErr_Occurred() != NULL) || (pICT_instance == NULL) ||
+ if ((PyErr_Occurred()) || (pICT_instance == NULL) ||
(pICT_instance == Py_None)) {
auto_debug_dump_file(AUTO_DBGLVL_ERR, DDU_ERRLOG);
auto_debug_print(AUTO_DBGLVL_ERR,
"ICT constructor failed\n");
- ai_dump_python_exception();
+ if (PyErr_Occurred()) {
+ PyErr_Print();
+ }
Py_CLEAR(pICT_instance);
}
}
@@ -1917,18 +1618,6 @@
* This is to handle any explicit requests for matching a special driver to a
* device, before <search_all> finds the first available one.
*
- * If search determines that a driver is missing and cannot find a package for
- * it, this is not reported as an error. A ddu_package_object is not created in
- * this case, so no installation or package fetch is done for this driver. Any
- * other kind of problem which occurs around searched packages, during the
- * search itself or during an installation of a package found during search, is
- * reported as an error.
- *
- * Any issue found around explicitly specified packages (<software>s), whether
- * it be that the package is not found or there was an issue during
- * installation, is reported as an error. ddu_package_objects are always
- * created for these packages.
- *
* Assumes ai_create_manifest_image() has set up the manifest data.
* Does not assume any data has been verified though.
*
@@ -1938,23 +1627,15 @@
* honor_noinstall: When true and the noinstall flag is set in a package
* tuple, skip installing that package.
* update_boot_archive: When true, run the ICT to update the boot archive.
- * num_pkgs_installed_p: Returns the number of packages installed.
*
* Returns:
- * AUTO_INSTALL_SUCCESS: No errors found.
- * AUTO_INSTALL_PKG_NOT_FND: At least one needed package found during search
- * could not be found. No other errors encountered.
- * AUTO_INSTALL_FAILURE: An error was encountered and was different than
- * not being able to find a package for a missing driver.
- *
+ * The number of packages successfully processed if all are successfully
+ * processed. NOTE: this can be zero if there are none to process.
+ * -1: One or more packages could not be successfully processed.
* Boot archive update status is not reflected in this return status.
* NOTE: this routine will continue on most errors, in order to install as
* many packages as possible.
*
- * NOTE: return status and num_pkgs_installed together tell the caller the full
- * story. It is possible, for example, that no packages were installed because
- * one package flagged during search could not be found.
- *
* NOTE: check installer logfile for details of the failure.
*
* Side effects:
@@ -1962,7 +1643,7 @@
*/
int
ai_du_get_and_install(char *install_root, boolean_t honor_noinstall,
- boolean_t update_boot_archive, int *num_installed_pkgs_p)
+ boolean_t update_boot_archive)
{
PyObject *manual_pkg_list;
PyObject *searched_pkg_list;
@@ -1973,9 +1654,8 @@
int len;
Py_ssize_t manual_size = 0;
Py_ssize_t searched_size = 0;
- int rval = AUTO_INSTALL_SUCCESS;
-
- *num_installed_pkgs_p = 0;
+ int rval = 0;
+ int num_pkgs_installed = 0;
/* Initialize path, post_prefix_start and post_prefix_len for later. */
(void) strncpy(path.path_str, AIM_PREFACE, MAX_NODEPATH_SIZE);
@@ -1994,37 +1674,37 @@
py_pkg_list = PyList_New(0);
/*
- * See if the manifest has at least one <software> or search_all entry.
+ * See if the manifest has at least one pkg spec or searchall entry.
* If not, just return success (e.g. no-op).
*/
- /* Get the number of <software> entries. */
+ /* Get the number of pkg spec entries. */
if (strlcpy(path.post_prefix_start, PKGSPEC_NODEPATH,
path.post_prefix_len) > path.post_prefix_len) {
auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_du_get_and_install: <software> path buffer overflow\n");
- return (AUTO_INSTALL_FAILURE);
+ "ai_du_get_and_install: pkg spec path buffer overflow\n");
+ return (-1);
}
- /* Get number of <software> entries in the manifest. */
+ /* Get number of pkg spec entries in the manifest. */
dummy_list = ai_get_manifest_values(path.path_str, &num_entries);
ai_free_manifest_values(dummy_list);
if (num_entries <= 0) {
- /* See if there is a search_all entry in the manifest. */
+ /* See if there is a searchall entry in the manifest. */
if (strlcpy(path.post_prefix_start, SEARCH_NODEPATH,
path.post_prefix_len) > path.post_prefix_len) {
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_get_and_install: "
"search path buffer overflow\n");
- return (AUTO_INSTALL_FAILURE);
+ return (-1);
}
dummy_list = ai_get_manifest_values(path.path_str,
&num_entries);
ai_free_manifest_values(dummy_list);
if (num_entries <= 0) {
- return (AUTO_INSTALL_SUCCESS);
+ return (0);
}
}
@@ -2040,65 +1720,57 @@
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_get_and_install: "
"Error initializing auto_ddu_lib.\n");
- rval = AUTO_INSTALL_FAILURE;
+ rval = -1;
goto done;
}
- if (ai_du_get_manual_pkg_list(py_state_p, &path,
- &manual_pkg_list) != AUTO_INSTALL_SUCCESS) {
+ manual_pkg_list = ai_du_get_manual_pkg_list(py_state_p, &path);
+ if (manual_pkg_list == NULL) {
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_get_and_install: "
- "Error getting <software> package specification.\n");
- rval = AUTO_INSTALL_FAILURE;
+ "Error getting package specification.\n");
+ rval = -1;
/* Keep going. Don't abort. */
- }
-
- manual_size = PyList_Size(manual_pkg_list);
- if (manual_size > 0) {
- if (ai_du_install_packages(py_state_p, manual_pkg_list,
- install_root, honor_noinstall, num_installed_pkgs_p) !=
- AUTO_INSTALL_SUCCESS) {
- auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_du_get_and_install: Error installing at least "
- "one <software> package specification.\n");
- rval = AUTO_INSTALL_FAILURE;
- /* Keep going. Don't abort. */
+ } else {
+ manual_size = PyList_Size(manual_pkg_list);
+ if (manual_size > 0) {
+ if (ai_du_install_packages(py_state_p, manual_pkg_list,
+ install_root, honor_noinstall,
+ &num_pkgs_installed) != AUTO_INSTALL_SUCCESS) {
+ auto_debug_print(AUTO_DBGLVL_ERR,
+ "ai_du_get_and_install: Error installing "
+ "at least one package.\n");
+ rval = -1;
+ /* Keep going. Don't abort. */
+ }
}
}
- switch (ai_du_get_searched_pkg_list(py_state_p, &path, install_root,
- &searched_pkg_list)) {
- case AUTO_INSTALL_FAILURE:
- rval = AUTO_INSTALL_FAILURE;
+ searched_pkg_list = ai_du_get_searched_pkg_list(py_state_p, &path);
+ if (searched_pkg_list == NULL) {
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_get_and_install: "
"Error searching for inoperable devices and "
"missing driver packages.\n");
+ rval = -1;
/* Keep going. Don't abort. */
- break;
- case AUTO_INSTALL_PKG_NOT_FND:
- if (rval != AUTO_INSTALL_FAILURE) {
- rval = AUTO_INSTALL_PKG_NOT_FND;
- }
- break;
- default:
- break;
- }
-
- searched_size = PyList_Size(searched_pkg_list);
- if (searched_size > 0) {
- if (ai_du_install_packages(py_state_p, searched_pkg_list,
- install_root, honor_noinstall, num_installed_pkgs_p) !=
- AUTO_INSTALL_SUCCESS) {
- auto_debug_print(AUTO_DBGLVL_ERR,
- "ai_du_get_and_install: Error installing at least "
- "one searched package for <search_all>.\n");
- rval = AUTO_INSTALL_FAILURE;
- /* Keep going. Don't abort. */
+ } else {
+ searched_size = PyList_Size(searched_pkg_list);
+ if (searched_size > 0) {
+ if (ai_du_install_packages(py_state_p,
+ searched_pkg_list, install_root, honor_noinstall,
+ &num_pkgs_installed) != AUTO_INSTALL_SUCCESS) {
+ auto_debug_print(AUTO_DBGLVL_ERR,
+ "ai_du_get_and_install: Error installing "
+ "at least one searched package "
+ "for <search_all>.\n");
+ rval = -1;
+ /* Keep going. Don't abort. */
+ }
}
}
- if (update_boot_archive && (*num_installed_pkgs_p > 0)) {
+ if ((update_boot_archive) && (num_pkgs_installed > 0)) {
if (ai_du_call_update_archive_ict(py_state_p, install_root) !=
AUTO_INSTALL_SUCCESS) {
auto_debug_print(AUTO_DBGLVL_ERR,
@@ -2113,20 +1785,20 @@
*/
if (manual_size > 0) {
- (void) PyList_SetSlice(py_pkg_list, 0, manual_size - 1,
+ PyList_SetSlice(py_pkg_list, 0, manual_size - 1,
manual_pkg_list);
}
- Py_DECREF(manual_pkg_list);
if (searched_size > 0) {
- (void) PyList_SetSlice(py_pkg_list, manual_size,
+ PyList_SetSlice(py_pkg_list, manual_size,
manual_size + searched_size - 1, searched_pkg_list);
}
- Py_DECREF(searched_pkg_list);
-
done:
auto_ddu_lib_fini(py_state_p);
+ if (rval != -1) {
+ rval = num_pkgs_installed;
+ }
return (rval);
}
@@ -2141,9 +1813,9 @@
* This routine assumes the py_pkg_list was set up via a prior call to
* ai_du_get_and_install_packages().
*
- * The availability and origin (location) of all packages to be installed is
- * assumed the same as when the py_pkg_list was built (i.e. the most recent
- * call to ai_du_get_and_install()).
+ * The availability and origin of all packages to be installed is assumed the
+ * same as when the py_pkg_list was built (i.e. the most recent call to
+ * ai_du_get_and_install()).
*
* Arguments:
* install_root: Top of the filesystem or tree where the packages are to be
@@ -2151,62 +1823,51 @@
* honor_noinstall: When true and the noinstall flag is set in a package
* tuple, skip installing that package.
* update_boot_archive: When true, run the ICT to update the boot archive.
- * num_installed_pkgs_p: Returns the number of packages successfully
- * installed.
* NOTE: the modular global py_pkg_list specifies the packages to install.
*
* Returns:
- * AUTO_INSTALL_SUCCESS: No errors found and at least one package was
- * installed.
- * AUTO_INSTALL_FAILURE: An error was encountered. Some packages may have
- * been installed.
- *
+ * The number of packages successfully processed if all are successfully
+ * processed. NOTE: this can be zero if there are none to process.
+ * -1: At least one package was not able to be installed.
* Boot archive update status is not reflected in this return status.
- * NOTE: this routine will continue on most errors, in order to install as
- * many packages as possible.
- *
- * NOTE: return status and num_pkgs_installed together tell the caller the full
- * story. It is possible, for example, that no packages were installed because
- * one package flagged during search could not be found.
*
* NOTE: check installer logfile for details of the failure.
*/
int
ai_du_install(char *install_root, boolean_t honor_noinstall,
- boolean_t update_boot_archive, int *num_installed_pkgs_p)
+ boolean_t update_boot_archive)
{
- int rval = AUTO_INSTALL_SUCCESS;
+ int rval = 0;
+ int num_pkgs_installed = 0;
py_state_t *py_state_p;
- *num_installed_pkgs_p = 0;
-
if (py_pkg_list == NULL) {
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_install: ai_du_get_and_install needs to be "
"called first.\n");
- return (AUTO_INSTALL_FAILURE);
+ return (-1);
} else if (PyList_Size(py_pkg_list) == 0) {
- return (AUTO_INSTALL_SUCCESS);
+ return (num_pkgs_installed);
}
if ((py_state_p = auto_ddu_lib_init()) == NULL) {
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_install: "
"Error initializing auto_ddu_lib.\n");
- return (AUTO_INSTALL_FAILURE);
+ return (-1);
}
if ((rval = ai_du_install_packages(py_state_p, py_pkg_list,
- install_root, honor_noinstall, num_installed_pkgs_p)) !=
+ install_root, honor_noinstall, &num_pkgs_installed)) !=
AUTO_INSTALL_SUCCESS) {
auto_debug_print(AUTO_DBGLVL_ERR,
"ai_du_install: Error installing packages.\n");
- rval = AUTO_INSTALL_FAILURE;
+ rval = -1;
}
- if (update_boot_archive && (*num_installed_pkgs_p > 0)) {
+ if (update_boot_archive && (num_pkgs_installed > 0)) {
if (ai_du_call_update_archive_ict(py_state_p,
install_root) != AUTO_INSTALL_SUCCESS) {
auto_debug_print(AUTO_DBGLVL_ERR,
@@ -2215,6 +1876,10 @@
}
}
+ if (rval != -1) {
+ rval = num_pkgs_installed;
+ }
+
auto_ddu_lib_fini(py_state_p);
return (rval);