static struct pkg *load_from_file(int dirfd, const char *filename, const char *arch) { _cleanup_close_ int pkgfd = openat(dirfd, filename, O_RDONLY); if (pkgfd < 0) { err(EXIT_FAILURE, "failed to open %s", filename); } struct pkg *pkg = malloc(sizeof(pkg_t)); zero(pkg, sizeof(pkg_t)); if (load_package(pkg, pkgfd) < 0) goto error; if (arch && pkg->arch && !match_arch(pkg, arch)) goto error; pkg->filename = strdup(filename); return pkg; error: package_free(pkg); return NULL; }
static void parse_option(install_info *info, const char *component, xmlNodePtr node, OptionsBox *box, int level, OptionsButton *parent, int exclusive, RadioGroup **radio) { xmlNodePtr child; char text[1024] = ""; const char *help; const char *wanted; char *name; int i; OptionsButton *button = NULL; /* See if this node matches the current architecture */ wanted = xmlGetProp(node, "arch"); if ( ! match_arch(info, wanted) ) { return; } wanted = xmlGetProp(node, "libc"); if ( ! match_libc(info, wanted) ) { return; } wanted = xmlGetProp(node, "distro"); if ( ! match_distro(info, wanted) ) { return; } if ( ! get_option_displayed(info, node) ) { return; } /* See if the user wants this option */ if ( node->type == XML_TEXT_NODE ) { //name = g_strdup(node->content); name = strdup(node->content); //!!!TODO - Strip name //g_strstrip(name); if( *name ) { //button = gtk_label_new(name); //gtk_widget_show(button); //gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(button), FALSE, FALSE, 0); button = carbon_OptionsNewLabel(box, name); } //!!!TODO - Free name //g_free(name); return; } else { name = get_option_name(info, node, NULL, 0); for(i=0; i < (level*5); i++) text[i] = ' '; text[i] = '\0'; strncat(text, name, sizeof(text)-strlen(text)); } if ( GetProductIsMeta(info) ) { //button = gtk_radio_button_new_with_label(radio_list, text); //radio_list = gtk_radio_button_group(GTK_RADIO_BUTTON(button)); button = carbon_OptionsNewRadioButton(box, text, &radio_list); } else if ( exclusive ) { //button = gtk_radio_button_new_with_label(*radio, text); //*radio = gtk_radio_button_group(GTK_RADIO_BUTTON(button)); button = carbon_OptionsNewRadioButton(box, text, radio); } else { //button = gtk_check_button_new_with_label(text); button = carbon_OptionsNewCheckButton(box, text); } /* Add tooltip help, if available */ help = get_option_help(info, node); if ( help ) { //GtkTooltipsData* group; //group = gtk_tooltips_data_get(window); //if ( group ) { //gtk_tooltips_set_tip( group->tooltips, button, help, 0); //} else { //gtk_tooltips_set_tip( gtk_tooltips_new(), button, help, 0); //} carbon_OptionsSetTooltip(button, help); } /* Set the data associated with the button */ if ( button ) { //gtk_object_set_data(GTK_OBJECT(button), "data", (gpointer)node); button->Data = (void *)node; /* Register the button in the window's private data */ //window = glade_xml_get_widget(setup_glade, "setup_window"); //gtk_object_set_data(GTK_OBJECT(window), name, (gpointer)button); if(strlen(name) >= MAX_BUTTON_NAME) carbon_debug("parse_option() - Button name exceeeded length! This will cause problems with selecting options!\n"); else strcpy(button->Name, name); } /* Check for required option */ if ( xmlGetProp(node, "required") ) { xmlSetProp(node, "install", "true"); //gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); DisableControl(button->Control); } /* If this is a sub-option and parent is not active, then disable option */ wanted = xmlGetProp(node, "install"); //if( level>0 && GTK_IS_TOGGLE_BUTTON(parent) && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(parent)) ) { if( level>0 && parent->Type == ButtonType_Radio && !carbon_OptionsGetValue(parent)) { wanted = "false"; //gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE); DisableControl(button->Control); } //***This functionality is implemented automatically when creating no option*** // buttons and labels //if ( button ) { // gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(button), FALSE, FALSE, 0); // gtk_signal_connect(GTK_OBJECT(button), "toggled", // GTK_SIGNAL_FUNC(setup_checkbox_option_slot), (gpointer)node); // gtk_widget_show(button); //} if ( wanted && (strcmp(wanted, "true") == 0) ) { //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); carbon_OptionsSetValue(button, true); } else { /* Unmark this option for installation */ mark_option(info, node, "false", 1); } /* Recurse down any other options */ child = node->childs; while ( child ) { if ( !strcmp(child->name, "option") ) { //parse_option(info, component, child, window, box, level+1, button, 0, NULL); parse_option(info, component, child, box, level+1, button, 0, NULL); } else if ( !strcmp(child->name, "exclusive") ) { xmlNodePtr exchild; //GSList *list = NULL; RadioGroup *list = NULL; for ( exchild = child->childs; exchild; exchild = exchild->next) { //parse_option(info, component, exchild, window, box, level+1, button, 1, &list); parse_option(info, component, exchild, box, level+1, button, 1, &list); } } child = child->next; } /* Disable any options that are already installed */ if ( info->product && ! GetProductReinstall(info) ) { product_component_t *comp; if ( component ) { comp = loki_find_component(info->product, component); } else { comp = loki_getdefault_component(info->product); } if ( comp && loki_find_option(comp, name) ) { /* Unmark this option for installation */ //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); //gtk_widget_set_sensitive(button, FALSE); carbon_OptionsSetValue(button, FALSE); DisableControl(button->Control); mark_option(info, node, "false", 1); } } }
static int cfg_set (char *item, char *value) { CONFIG *walk; if (!strncasecmp (item, "image", 5)) { struct IMAGES **p = &images; int ignore = 0; if (item[5] == '[' && item[strlen(item) - 1] == ']') { char *s, *q = item; /* Get rid of braces */ item[strlen(item) - 1] = 0; item[5] = 0; for (s = item + 6; q; s = q) { q = strchr(s, '|'); if (q) *q++ = 0; if (match_arch(s)) goto cfg_set_cont; } /* This just creates an unused table. It will get ignored */ ignore = 1; } else if (item[5]) goto cfg_set_redo; cfg_set_cont: while (*p) p = &((*p)->next); *p = (struct IMAGES *)malloc (sizeof (struct IMAGES)); if (*p == NULL) { prom_printf("malloc error in cfg_set\n"); return -1; } (*p)->next = 0; (*p)->obsolete = ignore; curr_table = ((*p)->table); memcpy (curr_table, cf_image, sizeof (cf_image)); } cfg_set_redo: for (walk = curr_table; walk->type != cft_end; walk++) { if (walk->name && !strcasecmp (walk->name, item)) { if (value && walk->type != cft_strg) cfg_warn ("'%s' doesn't have a value", walk->name); else if (!value && walk->type == cft_strg) cfg_warn ("Value expected for '%s'", walk->name); else { if (!strcasecmp (item, "label")) check_for_obsolete(value); if (walk->data) cfg_warn ("Duplicate entry '%s'", walk->name); if (walk->type == cft_flag) walk->data = &flag_set; else if (walk->type == cft_strg) walk->data = value; } break; } } if (walk->type != cft_end) return 1; //cfg_return (item, value); return 0; }
static install_state carbonui_setup(install_info *info) { //GtkWidget *window; //GtkWidget *options; OptionsBox *options; xmlNodePtr node; carbon_debug("***carbonui_setup()\n"); // These are required before displaying the CDKey. I'm not sure why this // is true, but they show up blank later on...even when making a call to // these functions later in this function. init_install_path(); init_binary_path(); update_size(); update_space(); // If CDKEY attribute was specified, show the CDKEY screen if(GetProductCDKey(cur_info)) { // Show CDKey entry page and wait for user to hit cancel or continue carbon_SetProperWindowSize(MyRes, NULL); carbon_ShowInstallScreen(MyRes, CDKEY_PAGE); CDKeyOK = false; carbon_IterateForState(MyRes, &CDKeyOK); // Go back to the option page as normal for this function if(!express_setup) carbon_ShowInstallScreen(MyRes, OPTION_PAGE); } // If express setup, go right to copy page if(express_setup) { carbon_ShowInstallScreen(MyRes, COPY_PAGE); cur_state = SETUP_INSTALL; return cur_state; } // User could've canceled installation during the CDKey if(cur_state != SETUP_EXIT) { // Else, let the user select appropriate options //options = glade_xml_get_widget(setup_glade, "option_vbox"); //gtk_container_foreach(GTK_CONTAINER(options), empty_container, options); options = carbon_OptionsNewBox(MyRes, true, OnOptionClickEvent); info->install_size = 0; node = info->config->root->childs; radio_list = NULL; in_setup = TRUE; while ( node ) { if ( ! strcmp(node->name, "option") ) { parse_option(info, NULL, node, options, 0, NULL, 0, NULL); } else if ( ! strcmp(node->name, "exclusive") ) { xmlNodePtr child; RadioGroup *list = NULL; for ( child = node->childs; child; child = child->next) { parse_option(info, NULL, child, options, 0, NULL, 1, &list); } } else if ( ! strcmp(node->name, "component") ) { if ( match_arch(info, xmlGetProp(node, "arch")) && match_libc(info, xmlGetProp(node, "libc")) && match_distro(info, xmlGetProp(node, "distro")) ) { xmlNodePtr child; if ( xmlGetProp(node, "showname") ) { //GtkWidget *widget = gtk_hseparator_new(); //gtk_box_pack_start(GTK_BOX(options), GTK_WIDGET(widget), FALSE, FALSE, 0); //gtk_widget_show(widget); carbon_OptionsNewSeparator(options); //widget = gtk_label_new(xmlGetProp(node, "name")); //gtk_box_pack_start(GTK_BOX(options), GTK_WIDGET(widget), FALSE, FALSE, 10); //gtk_widget_show(widget); carbon_OptionsNewLabel(options, xmlGetProp(node, "name")); } for ( child = node->childs; child; child = child->next) { if ( ! strcmp(child->name, "option") ) { //parse_option(info, xmlGetProp(node, "name"), child, window, options, 0, NULL, 0, NULL); parse_option(info, xmlGetProp(node, "name"), child, options, 0, NULL, 0, NULL); } else if ( ! strcmp(child->name, "exclusive") ) { xmlNodePtr child2; RadioGroup *list = NULL; for ( child2 = child->childs; child2; child2 = child2->next) { //parse_option(info, xmlGetProp(node, "name"), child2, window, options, 0, NULL, 1, &list); parse_option(info, xmlGetProp(node, "name"), child2, options, 0, NULL, 1, &list); } } } } } node = node->next; } // Render and display options in window carbon_OptionsShowBox(options); // Refresh the enable/disable status of buttons carbon_RefreshOptions(options); // Resize the window if there are too many options to fit carbon_SetProperWindowSize(MyRes, options); init_install_path(); init_binary_path(); update_size(); update_space(); init_menuitems_option(info); in_setup = FALSE; int TempState = carbon_IterateForState(MyRes, &cur_state); // Return the window back to default size, if necessary except // if we're exiting (so we don't redisplay the window after it // has been hidden if(cur_state != SETUP_EXIT) carbon_SetProperWindowSize(MyRes, NULL); // Return the next state as appopriate return TempState; } // Return the current state if it's SETUP_EXIT return cur_state; }