//* Dialog box for quit the installation *// void cancel_install(GtkWidget *w, gpointer user_data) { int result = fwife_question(_("Are you sure you want to exit from the installer?\n")); if(result == GTK_RESPONSE_YES) { fwife_exit(); } return; }
int install_pkgs_discs(GList *pkgs, char *srcdev) { int i, first = 1, ret; while(pkgs) { GList *list = NULL; struct stat buf; char *ptr; if(first) { // for the first time the volume is already loaded first = 0; } else { eject(srcdev, SOURCEDIR); ret = fwife_question(_("Please insert the next Frugalware install disc and press " "ENTER to continue installing packages. If you don't " "have more discs, choose NO, and then you can finish " "the installation. Have you inserted the next disc?")); if(ret == GTK_RESPONSE_NO) return 0; ptr = g_strdup_printf("mount -o ro -t iso9660 /dev/%s %s", srcdev, SOURCEDIR); fw_system(ptr); free(ptr); } // see what packages can be useful from this volume for(i = 0; i < g_list_length(pkgs); i++) { ptr = g_strdup_printf("%s/frugalware-%s/%s-%s.fpm", SOURCEDIR, ARCH, (char*)g_list_nth_data(pkgs, i), ARCH); if(!stat(ptr, &buf)) list = g_list_append(list, strdup((char*)g_list_nth_data(pkgs, i))); free(ptr); } // remove them from the full list for(i = 0; i < g_list_length(list); i++) pkgs = g_list_strremove(pkgs, (char*)g_list_nth_data(list, i)); // install them if(install_pkgs(list) == -1) return -1; } return 0; }
int run(GList **config) { int i, ret; fwnet_profile_t *newprofile=NULL; if((newprofile = (fwnet_profile_t*)malloc(sizeof(fwnet_profile_t))) == NULL) return(1); memset(newprofile, 0, sizeof(fwnet_profile_t)); sprintf(newprofile->name, "default"); for(i = 1; i<g_list_length(interfaceslist); i+=2) { newprofile->interfaces = g_list_append(newprofile->interfaces, (fwnet_interface_t *) g_list_nth_data(interfaceslist, i)); } switch(fwife_question(_("Do you want to configure a DSL connexion now?"))) { case GTK_RESPONSE_YES: dsl_config(newprofile); break; case GTK_RESPONSE_NO: break; } char *host = fwife_entry(_("Hostname"), _("We'll need the name you'd like to give your host.\nThe full hostname is needed, such as:\n\nfrugalware.example.net\n\nEnter full hostname:"), "frugalware.example.net"); pid_t pid = fork(); if(pid == -1) LOG("Error when forking process in grubconf plugin."); else if(pid == 0) { chroot(TARGETDIR); fwnet_writeconfig(newprofile, host); exit(0); } else { wait(&ret); } FREE(host); return 0; }
int run_discs_config(GList **config) { int ret = fwife_question(_("Do you want to search for a installation CD/DVD?\n\n" "If you want an installation from a CD/DVD, you should answer 'Yes'.\n" "Otherwise if you want a network installation, you should answer 'No'")); /* if the user whant a cd/dvd install */ if(ret == GTK_RESPONSE_YES) { if(run_discs_detection(config)) { char *pacbindir = g_strdup_printf("%s/frugalware-%s", SOURCEDIR, ARCH); disable_cache(pacbindir); FREE(pacbindir); skip_to_next_plugin(); return 1; } else { fwife_error("No package database found.\nPerforming a network installation."); } } return 0; }
int add_interface(GtkWidget *button, gpointer data) { fwnet_interface_t *newinterface = NULL; GtkWidget *cellview; GdkPixbuf *connectimg; char *ptr=NULL; char *nettype=NULL; char *iface=NULL; GtkTreeIter iter; GtkTreeModel *model; gtk_combo_box_get_active_iter(GTK_COMBO_BOX(intercombo), &iter); model = gtk_combo_box_get_model(GTK_COMBO_BOX(intercombo)); gtk_tree_model_get (model, &iter, 0, &iface, -1); int i; for(i=0;i<g_list_length(interfaceslist); i+=2) { if(!strcmp((char*)g_list_nth_data(interfaceslist, i), iface)) { fwife_error("This interface has been already configured!"); return -1; } } if((newinterface = (fwnet_interface_t*)malloc(sizeof(fwnet_interface_t))) == NULL) return(-1); memset(newinterface, 0, sizeof(fwnet_interface_t)); snprintf(newinterface->name, IF_NAMESIZE, iface); nettype = ask_nettype(); if(nettype == NULL) return -1; if(strcmp(nettype, "lo")) { interfaceslist = g_list_append(interfaceslist, strdup(iface)); interfaceslist = g_list_append(interfaceslist, newinterface); GtkTreeView *treeview = (GtkTreeView *)data; model = gtk_tree_view_get_model (treeview); cellview = gtk_cell_view_new (); connectimg = gtk_widget_render_icon (cellview, GTK_STOCK_NETWORK, GTK_ICON_SIZE_BUTTON, NULL); gtk_widget_destroy (cellview); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_NET_IMAGE, connectimg, COLUMN_NET_NAME, iface, -1); } if(strcmp(nettype, "lo") && fwnet_is_wireless_device(iface)) { switch(fwife_question(_("It seems that this network card has a wireless extension.\n\nConfigure your wireless now?"))) { case GTK_RESPONSE_YES: configure_wireless(newinterface); break; case GTK_RESPONSE_NO: break; } } if(!strcmp(nettype, "dhcp")) { ptr = fwife_entry(_("Set DHCP hostname"), _("Some network providers require that the DHCP hostname be\n" "set in order to connect.\n If so, they'll have assigned a hostname to your machine.\n If you were" "assigned a DHCP hostname, please enter it below.\n If you do not have a DHCP hostname, just" "hit enter."), NULL); if(strlen(ptr)) snprintf(newinterface->dhcp_opts, PATH_MAX, "-t 10 -h %s\n", ptr); else newinterface->dhcp_opts[0]='\0'; newinterface->options = g_list_append(newinterface->options, strdup("dhcp")); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_NET_IP, "dhcp", COLUMN_NET_NAMESERV, ptr, -1); FREE(ptr); } else if(!strcmp(nettype, "static")) { configure_static(newinterface, iter); } return 0; }
int install_pkgs(GList *pkgs) { int i = 0, questret; PM_LIST *pdata = NULL, *pkgsl; char *ptr, *file; /* nothing to install */ if(pkgs == NULL) return 0; if(pacman_initialize(TARGETDIR) == -1) { LOG("Failed to initialize pacman library (%s)\n", pacman_strerror(pm_errno)); return -1; } if (pacman_parse_config("/etc/pacman-g2.conf", NULL, "") == -1) { LOG("Failed to parse pacman-g2 configuration file (%s)", pacman_strerror(pm_errno)); pacman_release(); return(-1); } //* Set pacman options *// #ifndef NDEBUG pacman_set_option(PM_OPT_LOGMASK, -1); #else pacman_set_option(PM_OPT_LOGMASK, PM_LOG_ERROR | PM_LOG_WARNING); #endif pacman_set_option(PM_OPT_LOGCB, (long)cb_log); pacman_set_option (PM_OPT_DLCB, (long)progress_update); pacman_set_option (PM_OPT_DLOFFSET, (long)&offset); pacman_set_option (PM_OPT_DLRATE, (long)&rate); pacman_set_option (PM_OPT_DLFNM, (long)reponame); pacman_set_option (PM_OPT_DLHOWMANY, (long)&howmany); pacman_set_option (PM_OPT_DLREMAIN, (long)&remains); pacman_set_option (PM_OPT_DLT0, (long)&t0); pacman_set_option (PM_OPT_DLT0, (long)&t); pacman_set_option (PM_OPT_DLXFERED1, (long)&xferred1); PM_DB *db_local = pacman_db_register("local"); if(db_local == NULL) { LOG("Could not register 'local' database (%s)\n", pacman_strerror(pm_errno)); pacman_release(); return -1; } retry: if(pacman_trans_init(PM_TRANS_TYPE_SYNC, PM_TRANS_FLAG_FORCE|PM_TRANS_FLAG_NODEPS, progress_event, progress_conv, progress_install) == -1) { if (pm_errno == PM_ERR_HANDLE_LOCK) { file = g_strdup_printf("%s/tmp/pacman-g2.lck", TARGETDIR); g_remove (file); free(file); goto retry; } LOG("Failed to initialize transaction %s\n", pacman_strerror (pm_errno)); pacman_release(); return -1; } for (i = 0; i<g_list_length(pkgs); i++) { ptr = strdup((char*)g_list_nth_data(pkgs, i)); if(pacman_trans_addtarget(strdup(drop_version(ptr))) == -1) LOG("Error adding packet %s", pacman_strerror (pm_errno)); free(ptr); } //* prepare transaction *// if(pacman_trans_prepare(&pdata) == -1) { LOG("Failed to prepare transaction (%s)", pacman_strerror (pm_errno)); pacman_list_free(pdata); pacman_trans_release(); pacman_release(); return -1; } pkgsl = pacman_trans_getinfo (PM_TRANS_PACKAGES); if (pkgsl == NULL) { LOG("Error getting transaction info %s\n", pacman_strerror (pm_errno)); pacman_trans_release(); pacman_release(); return -1; } /* commit transaction */ if (pacman_trans_commit(&pdata) == -1) { switch(pm_errno) { case PM_ERR_DISK_FULL: fwife_error(_("Disk full, cannot install more packages")); break; case PM_ERR_PKG_CORRUPTED: questret = fwife_question(_("Some packages seems corrupted, do you want to download them again?")); if(questret == GTK_RESPONSE_YES) { pacman_list_free(pdata); pacman_trans_release(); goto retry; } break; case PM_ERR_RETRIEVE: fwife_error(_("Failed to retrieve packages")); break; default: break; } LOG("Failed to commit transaction (%s)\n", pacman_strerror (pm_errno)); pacman_list_free(pdata); pacman_trans_release(); pacman_release(); return -1; } /* release the transaction */ pacman_trans_release(); pacman_release(); return 0; }