/* Copyright (c) Oracle Corporation 1995. All Rights Reserved */ /******************************************************************************* NAME toolsdei.ois - External script for OIS Products' Deinstallation scripts DESCRIPTION This external script is a Library of Routines (like Functions/Procedures). Each Routine is a block of code that is being used by more than one Installer script. Each routine is uniquely identified by a global variable that needs to be set by the product script calling this script, and a roman numeral (for ease of locating the desired Routine). Following is a list of all the routines in this Library: I. CREATE_LABEL Create a label with the product name, version (used by all dei scripts) II. GET_DEINSTALLATION_PATH Set up deinstallation path (used by all dei scripts - unless path is preset) III. DEINSTALL_PARENT Deinstall parent if no other child product exists (used by all child scripts) IV. UNREFERENCE_DEINSTALL_CHILD_PRODUCTS Unreference and remove all child products if parent product was selected. V. DEINSTALL_COMPONENTS Same as "Unreference_Deinstall_Child_Products" but also removes all cross-referencing between components & parent. (used by parent scripts) VI. DEINSTALL_DEPENDENCIES Unreference product dependencies. (generally only used by parent scripts) VII. DEINSTALL_ENVIRONMENT_VARIABLES remove product variables VIII. REMOVE_DIRECTORIES Remove all the directories created by OIS while installing third party product OWNER Rajesh Bansal MODIFIED MM/DD/YY REASON arajagop 05/09/96 Made it OIS referencing file aharriso 08/29/95 Added Unreference_dependencies and deinstall_components. rbansal 08/07/95 Created (toolsdei.usr) ********************************************************************************/ { /******************************************************************** I. Create a label with the product name, version *********************************************************************/ if (OIS_EXECUTE_SCRIPT == "CREATE_LABEL") { installed_version = registry_version(current_registry); version_list = explode(installed_version,"."); { msb_version_list = list(first(version_list), first(rest(version_list))); } ['EMPTY_LIST: { msb_version_list = list(installed_version,".0"); continue(); } ] display_version = implode(msb_version_list,"."); display_registry_label = "%registry_label% %display_version%"; ui_product(instantiate(display_registry_label)); return(0); } /********************************************************************/ /******************************************************************** II. Set up deinstallation path *********************************************************************/ if (OIS_EXECUTE_SCRIPT == "GET_DEINSTALLATION_PATH") { home_variable = ""; /* bind product_home variable */ prompt_flag = FALSE; { home_variable = translate(deinstall_variable, ora_config, section_heading); /* Get path from variable in oracle.ini. */ full_path = "%home_variable%"; if(not(exists(full_path))) /* Make sure this is the product's location */ prompt_flag = TRUE; } [ 'FILE_NOT_FOUND, 'UNBOUND_ENVIRONMENT_VARIABLE,'INVALID_FILE_NAME: { prompt_flag = TRUE; } ] if(prompt_flag) { mark { home_variable = choose_directory_dialog(instantiate(deinstall_which),oracle_home); if(not(exists(instantiate("%home_variable%")))) /* Make sure this is the product's location */ { mark /* Allow user to backup to previous MARK level to select appropriate product location */ { deinstall_here = yesno_dialog(instantiate(deinstall_location), FALSE); if(not(deinstall_here)) signal('FAILURE, "Halted deinstallation process."); } } } } return(home_variable); } /********************************************************************/ /******************************************************************** III. Deinstall parent if no other child product exists *********************************************************************/ if (OIS_EXECUTE_SCRIPT == "DEINSTALL_PARENT") { if(member(registration("selected_registries"), current_registry)) { remove_parent = TRUE; child_products = all_child_registrations(PARENT_PRODUCT); extract(child_products, current_registry); while(not(empty(child_products))) { if(registered(registry_name(first(child_products)))) { remove_parent = FALSE; break(); } child_products = rest(child_products); } if(remove_parent) { dependent = registration(PARENT_REGISTRY_NAME); /*********************************************** if PARENT needs to be deinstalled, make sure all references to PARENT are unreferenced before attempting to deinstall the PARENT ************************************************/ reference_list = registry_references(dependent); while(not(empty(reference_list))) { if(registered(registry_name(first(reference_list)))) unreference(dependent, registration(registry_name(first(reference_list)))); reference_list = rest(reference_list); } /***********************************************/ unreference(dependent); deinstall(dependent); } } ['UNREGISTERED_PRODUCT: continue();] return(0); } /**********************************************************************************/ /********************************************************************************** IV. UNREFERENCE_DEINSTALL_CHILD_PRODUCTS Unreference and remove all child products if parent product was selected. **********************************************************************************/ if (OIS_EXECUTE_SCRIPT == "UNREFERENCE_DEINSTALL_CHILD_PRODUCTS") { if(member(registration("selected_registries"), current_registry)) { ui_product(instantiate(display_registry_label)); ui_action(instantiate(deinstall_components)); child_products = all_child_registrations(current_registry); /***************************** Deinstall the child product(s) ******************************/ while(not(empty(child_products))) { if(registered(registry_name(first(child_products)))) { dependent = registration(registry_name(first(child_products))); unreference(dependent); /* unset the child's self-reference */ deinstall(dependent); } child_products = rest(child_products); } } return(0); } /***********************************************************************************/ /************************************************************************************************************************* V . DEINSTALL_COMPONENTS Similar to "UNREFERENCE_DEINSTALL_CHILD_PRODUCTS" but eliminates cross-referencing between components & parent. ************************************************************************************************************************/ if (OIS_EXECUTE_SCRIPT == "DEINSTALL_COMPONENTS") { if(member(registration("selected_registries"), current_registry) || (child_child_product == "true")) /* remove all child products if parent product was selected */ { ui_product(instantiate(display_registry_label)); ui_action(instantiate(deinstall_components)); child_products = all_child_registrations(current_registry); /*************************************************** Make sure the cross-referencing between different component products/parent is eliminated, before continuing with the deinstallation of child products ****************************************************/ reference_products = child_products; while(not(empty(reference_products))) { if(registered(registry_name(first(reference_products)))) { dependent = registration(registry_name(first(reference_products))); reference_list = registry_references(dependent); while(not(empty(reference_list))) { if(registered(registry_name(first(reference_list)))) unreference(dependent, registration(registry_name(first(reference_list)))); reference_list = rest(reference_list); } } reference_products = rest(reference_products); } /***************************************************/ /******************************************* Deinstall the component (child) product(s) ********************************************/ while(not(empty(child_products))) { if(registered(registry_name(first(child_products)))) { dependent = registration(registry_name(first(child_products))); unreference(dependent); /* unset the child's self-reference */ deinstall(dependent); } child_products = rest(child_products); } /*******************************************/ } /**********************************************************/ return(0); } /***********************************************************************************/ /***************************************************************************** VI. DEINSTALL_DEPENDENCIES Unreference product dependencies. (generally only used by parent scripts) The variables dep_prd_list must be set before calling this script. *****************************************************************************/ if (OIS_EXECUTE_SCRIPT == "DEINSTALL_DEPENDENCIES") { ui_product(instantiate(display_registry_label)); ui_action(instantiate(unreference_dependencies)); dependency_list = dep_prod_list; while(not(empty(dependency_list))) { next_dependency = first(dependency_list); if(registered(next_dependency)) { dependent = registration(next_dependency); unreference(dependent, current_registry); unreference(dependent); deinstall(dependent); } dependency_list = rest(dependency_list); } return (1); } /*****************************************************************************/ /****************************** 10/10/95 *********************************************** VII. DEINSTALL_ENVIRONMENT_VARIABLES remove product variables Following variables need to be set by the product scripts: file (type STRING) Name of the file in which the modifiction is to be made varlist (type List) List of Path variables in File. For example, FORMS45_PATH for FORMS DEMOS. vallist (type LIST) List of all the paths required. For example, %FORMS45%\PLSQLLIB for FORMS DEMOS group (type STRING) Section Heading in File. For example, "CDE" implode_explode_delimiter (type STRING) Delimiter for implode/explode functions (set to ";" in USER.AVF). If any other value, needs to be set, for example, "," for REGISTERED_LIBRARIES variable in ORACLE.INI ****************************** 10/10/95 ***********************************************/ if (OIS_EXECUTE_SCRIPT == "REMOVE_ENVIRONMENT_VARIABLES") { temp_var_list = varlist; temp_val_list = vallist; while(not(empty(temp_var_list))) { variable = first(temp_var_list); temp_var_list = rest(temp_var_list); value = first(temp_val_list); temp_val_list = rest(temp_val_list); value_list = explode(value,";"); { path_variable_common = translate(variable, file, group); /* get variable from file */ path_variable = "%path_variable_common%"; paths_in_pathvar = explode(path_variable, ";"); while(not(empty(value_list))) { path_dir = first(value_list); value_list = rest(value_list); if(member(paths_in_pathvar,path_dir)) extract(paths_in_pathvar,path_dir); } if(empty(paths_in_pathvar)) { modify(variable, "", file,group); /* remove variable from file */ } else { path_variable = implode(paths_in_pathvar, ";"); modify(variable, path_variable,file,group); /* re-write the updated variable */ } } [ /* ORACLE.INI doesn't have FORMS45_PATH, continue */ 'OS_ERROR,'INVALID_FILE_NAME,'FILE_NOT_FOUND, 'PERMISSION_DENIED,'UNBOUND_ENVIRONMENT_VARIABLE: continue(); ] } return(1); } /******************************************************************** Viii. REMOVE_DIRECTORIES Remove all the directories created by OIS while installing third party product This script attempts to delete a directory recursively The name of the directory to be deleted should be passed in as deldir ********************************************************************/ if (OIS_EXECUTE_SCRIPT == "REMOVE_DIRECTORIES") { directorify(deldir); delfstack = list(deldir); deldstack = list(); /* In this loop, remove all the files in the directories */ while (not(empty(delfstack))) { deldir = first(delfstack); delfstack = rest(delfstack); /* Add this directory to the front of a list of directories that need to be deleted Reasoning : The root of the tree is at the very end of the list - All of the children of a directory will be deleted before we get to it */ deldstack = cons(deldir, deldstack); tdf = files("%deldir%\*"); tdd = directories("%deldir%\*"); /* Remove the files in the directory */ while(not(empty(tdf))) { { remove_file(first(tdf)); } ['default:continue();] tdf = rest(tdf); } while(not(empty(tdd))) { add(delfstack, first(tdd)); tdd = rest(tdd); } } /* In this loop, remove the directories starting at the deepest subdirs and moving up to the root */ while(not(empty(deldstack))) { deldir = first(deldstack); deldstack = rest(deldstack); { remove_directory(deldir); } ['default : continue(); ] } return(0); } /****************************** 10/10/95 ***********************************************/ }