Пример #1
0
int run(GList **config)
{
	char *ptr;
	//mount system point to targetdir
	ptr = g_strdup_printf("mount /proc -o bind %s/proc", TARGETDIR);
	fw_system(ptr);
	free(ptr);
	ptr = g_strdup_printf("mount /sys -o bind %s/sys", TARGETDIR);
	fw_system(ptr);
	free(ptr);

	return 0;
}
Пример #2
0
int run(GList **config)
{
    	char *ptr;
	// unmout system directories
	ptr = g_strdup_printf("umount %s/sys", TARGETDIR);
	fw_system(ptr);
	FREE(ptr);
	ptr = g_strdup_printf("umount %s/proc", TARGETDIR);
	fw_system(ptr);
	FREE(ptr);
	ptr = g_strdup_printf("umount %s/dev", TARGETDIR);
	fw_system(ptr);
	FREE(ptr);
		
	return 0;
}
Пример #3
0
int run_discs_detection(GList **config)
{
	GList *drives=NULL;
	int i;
	int found = 0;
	char *ptr;

	umount_if_needed(SOURCEDIR);
    makepath(SOURCEDIR);

	drives = grep_drives("/proc/sys/dev/cdrom/info");
	for (i = 0; i < g_list_length(drives); i++) {
		ptr = get_blkid((char*)g_list_nth_data(drives, i));
		if(ptr && !strcmp(ptr, "Frugalware Install")) {
			LOG("install medium found in %s", (char*)g_list_nth_data(drives, i));
			free(ptr);
			ptr = g_strdup_printf("mount -o ro -t iso9660 /dev/%s %s",
				(char*)g_list_nth_data(drives, i),
				SOURCEDIR);
			fw_system(ptr);
			free(ptr);

			if(!is_netinstall(SOURCEDIR)) {
				data_put(config, "srcdev", (char*)g_list_nth_data(drives, i));
				found = 1;
				break;
			}
		} else {
			LOG("skipping non-install medium in %s", (char*)g_list_nth_data(drives, i));
        }
	}

	return found;
}
Пример #4
0
int prerun(GList **config)
{
	// fix gtk graphical bug : forward button is clicked in
	set_page_completed();
	set_page_incompleted();
	long long *compsize = (long long*)data_get(*config,"compsizepkg");
	if(compsize != NULL)
		compressedsize = *compsize;

	makepath(TARGETDIR "/dev");
	fw_system("mount /dev -o bind " TARGETDIR "/dev");

	if(data_get(*config, "srcdev") != NULL) {
		if(install_pkgs_discs((GList*)data_get(*config, "packages"), (char*)data_get(*config, "srcdev")) == -1) {
			fwife_error(_("An error occurs during packages installation (see /var/log/fwife.log for more details)"));
			return -1;
		}
	} else {
		if(install_pkgs((GList*)data_get(*config, "packages")) == -1) {
			fwife_error(_("An error occurs during packages installation (see /var/log/fwife.log for more details)"));
			return -1;
		}
	}

	gtk_label_set_label(GTK_LABEL(labelpkg), _("Packages installation completed"));
	set_page_completed();
	return 0;
}
Пример #5
0
int setcharset(char *name, GList **config)
{
	char *ptr;

	//TODO: maybe there is a proper system call for this?
	ptr = g_strdup_printf("setfont %s", name);
	fw_system(ptr);
	FREE(ptr);
	// save the font for later usage
	data_put(config, "font", strdup(name));
	return(0);
}
Пример #6
0
void selection_changed(GtkTreeSelection *selection, gpointer data)
{
	GtkTreeIter iter;
	GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(viewlayout));
	char *ptr, *layout, *variante;

	if (gtk_tree_selection_get_selected(selection, NULL, &iter)) {
		gtk_tree_model_get (model, &iter, 1, &layout, -1);
		gtk_tree_model_get (model, &iter, 2, &variante, -1);

		if(!strcmp(variante, "default")) {
			ptr = g_strdup_printf("setxkbmap -layout %s", layout);
			fw_system(ptr);
			free(ptr);
		} else {
			ptr = g_strdup_printf("setxkbmap -layout %s -variant %s", layout, variante);
			fw_system(ptr);
			free(ptr);
		}
	}
}
Пример #7
0
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;
}
Пример #8
0
int prerun(GList **config)
{
	struct stat buf;
	char *ptr;

	//* disable x configuration if no x server detected *//
	ptr = g_strdup_printf("%s/usr/bin/X", TARGETDIR);
	if(!stat(ptr, &buf))
	{
		gtk_widget_set_sensitive(pHBoxFrameX, TRUE);
		xlayout = (char*)data_get(*config, "xlayout");
		xvariant = (char*)data_get(*config, "xvariant");
	}

	// configure kernel modules	
	ptr = g_strdup_printf("chroot %s /sbin/depmod -a", TARGETDIR);
	fw_system(ptr);
	FREE(ptr);	

	return 0;
}
Пример #9
0
int mountdev(char *dev, char *mountpoint, GList **config)
{
	char *type=NULL;
	char *tmp=NULL;
	FILE* fp;

	// open fstab
	if ((fp = fopen((char*)data_get(*config, "fstab"), "a")) == NULL)
	{
		perror(_("Could not open output file for writing"));
		return(-1);
	}

	// mount
	tmp = g_strdup_printf("%s/%s", TARGETDIR, mountpoint);
	makepath(tmp);
	FREE(tmp);

	umount_if_needed(mountpoint);
	tmp = g_strdup_printf("mount %s %s/%s",
			dev, TARGETDIR, mountpoint);
	fw_system(tmp);
	FREE(tmp);
	// unlink a possible stale lockfile
	tmp = g_strdup_printf("%s/%s/tmp/pacman-g2.lck", TARGETDIR, mountpoint);
	unlink(tmp);
	FREE(tmp);

	// make fstab entry
	type = findmount(dev, 0);
	char *uuid = get_uuid(dev);
	fprintf(fp, "%-16s %-16s %-11s %-16s %-3s %s\n", uuid, mountpoint,
		type, "defaults", "1", "1");
	free(uuid);
	free(type);
	fclose(fp);
	return(0);
}
Пример #10
0
int run(GList **config)
{
	GList *partlist;
	char **nrdevs, *ptr, *op, *np, *dest;
	int ret;
	char my_buffer[MAX_LEN + 1] = "";

	detect_parts(0);

	// select swap partitions to use
	partlist = selswap();

	// format swap partitions
	if(doswap(partlist, config) == -1)
		return(-1);

	// root partition
	ptr = selrootdev();
	if(ptr == NULL)
		return(-1);
	if(formatdev(ptr) == -1)
		return(-1);
	mountdev(ptr, "/", config);

	// move temporarily stuff to the final location
	chdir(TARGETDIR);
	np = g_strdup_printf("%s/%s", TARGETDIR, "/etc/profile.d");
	makepath(np);
	FREE(np);
	op = (char*)data_get(*config, "fstab");
	np = g_strdup_printf("%s/%s", TARGETDIR, "/etc/fstab");
	copyfile(op, np);
	unlink(op);
	chmod (np, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
	data_put(config, "fstab", strdup(np));
	FREE(np);

	np = g_strdup_printf("%s/%s", TARGETDIR, "/etc/sysconfig");
	makepath(np);
	FREE(np);

	// so that 1) the user can't mount a partition as /dev because
	// it'll be used 2) install scriptlets will be able to do
	// >/dev/null
	makepath(TARGETDIR "/dev");
	makepath(TARGETDIR "/proc");
	makepath(TARGETDIR "/sys");
	fw_system("mount none -t devtmpfs " TARGETDIR "/dev");
	fw_system("mount none -t proc " TARGETDIR "/proc");
	fw_system("mount none -t sysfs " TARGETDIR "/sys");

	// non-root partitions
	dialog_vars.backtitle=gen_backtitle(_("Selecting other partitions"));
	while(1)
	{
		dialog_vars.input_result = my_buffer;
		nrdevs = parts2dialog(parts);
		dlg_put_backtitle();
		dlg_clear();
		dialog_vars.cancel_label = _("Continue");
		dialog_vars.input_result = my_buffer;
		dialog_vars.input_result[0]='\0';
		ret = dialog_menu(
		_("Select other Linux partitions for /etc/fstab"),
		_("You may use your other partitions to distribute your Linux "
		"system across more than one partition. Currently, you have "
		"only mounted your / partition. You might want to mount "
		"directories such as /boot, /home or /usr/local on separate "
		"partitions. You should not try to mount /usr, /etc, /sbin or "
		"/bin on their own partitions since they contain utilities "
		"needed to bring the system up and mount partitions. Also, "
		"do not reuse a partition that you've already entered before. "
		"Please select one of the partitions listed below, or if "
		"you're done, hit Continue."),
		0, 0, 0, g_list_length(parts)/2, nrdevs);
		dialog_vars.cancel_label = '\0';
		FREE(nrdevs);
		if (ret != DLG_EXIT_CANCEL)
		{
			if(!strcmp(_("(in use)"), dialog_vars.input_result))
				continue;
			ptr = strdup(dialog_vars.input_result);
			if(formatdev(ptr) == -1)
				return(-1);
			dest = asktowhere(ptr);
			if(dest == NULL)
				return(-1);
			mountdev(ptr, dest, config);
			FREE(dest);
			FREE(ptr);
		}
		else
			break;
	}

	makepath(g_strdup_printf("%s/%s", TARGETDIR, "/var/log"));
	np = g_strdup_printf("%s/%s", TARGETDIR, LOGFILE);
	copyfile(LOGFILE, np);
	unlink(LOGFILE);
	chmod (np, S_IRUSR|S_IWUSR);
	FREE(np);

	// disable caching for cds
	// this is needed here since when the cds is loaded we had no
	// formatted root partition
	if((char*)data_get(*config, "netinstall")==NULL)
	{
		char *pacbindir = g_strdup_printf("%s/frugalware-%s", SOURCEDIR, ARCH);
		char *ptr;

		ptr = g_strdup_printf("%s/var/cache/pacman-g2/pkg", TARGETDIR);
		makepath(ptr);
		FREE(ptr);
		disable_cache(pacbindir);
		FREE(pacbindir);
	}
	return(0);
}
Пример #11
0
int mkfss(char *dev, char *fs, int check)
{
	char *opts=NULL;
	char *cmd=NULL;
	int ret=1;

	opts = strdup(check ? "-c" : "");

	fw_info(_("Formatting"), g_strdup_printf(check ?
		_("Creating %s filesystem on %s and checking for bad blocks") :
		_("Creating %s filesystem on %s"),
		fs, dev));
	umount(findmount(dev, 1));
	if(!strcmp(fs, "ext2"))
	{
		cmd = g_strdup_printf("mke2fs %s %s", opts, dev);
		ret = fw_system(cmd);
		goto cleanup;
	}
	else if(!strcmp(fs, "ext3"))
	{
		cmd = g_strdup_printf("mke2fs -j %s %s", opts, dev);
		ret = fw_system(cmd);
		goto cleanup;
	}
	else if(!strcmp(fs, "ext4"))
	{
		cmd = g_strdup_printf("mkfs.ext4 %s %s", opts, dev);
		ret = fw_system(cmd);
		goto cleanup;
	}
	else if(!strcmp(fs, "reiserfs"))
	{
		cmd = g_strdup_printf("echo y |mkreiserfs %s", dev);
		ret = fw_system(cmd);
		goto cleanup;
	}
	else if(!strcmp(fs, "jfs"))
	{
		cmd = g_strdup_printf("mkfs.jfs -q %s %s", opts, dev);
		ret = fw_system(cmd);
		goto cleanup;
	}
	else if(!strcmp(fs, "xfs"))
	{
		cmd = g_strdup_printf("mkfs.xfs -f %s", dev);
		ret = fw_system(cmd);
		goto cleanup;
	}
	else if(!strcmp(fs, "btrfs"))
	{
		cmd = g_strdup_printf("mkfs.btrfs %s", dev);
		ret = fw_system(cmd);
		goto cleanup;
	}
	// never reached
	cleanup:
	FREE(opts);
	if (cmd)
		FREE(cmd);
	return(ret);
}
Пример #12
0
int doswap(GList *partlist, GList **config)
{
	char *fn, *item, *ptr;
	FILE* fp;
	int i;

	// create an initial fstab
	fn = strdup("/tmp/setup_XXXXXX");
	mkstemp(fn);
	if ((fp = fopen(fn, "wb")) == NULL)
	{
		perror(_("Could not open output file for writing"));
		FREE(fn);
		return(-1);
	}
	fprintf(fp, "%-16s %-16s %-11s %-16s %-3s %s\n",
		"none", "/proc", "proc", "defaults", "0", "0");
	fprintf(fp, "%-16s %-16s %-11s %-16s %-3s %s\n",
		"none", "/sys", "sysfs", "defaults", "0", "0");
	fprintf(fp, "%-16s %-16s %-11s %-16s %-3s %s\n",
		"devpts", "/dev/pts", "devpts", "gid=5,mode=620", "0", "0");
	fprintf(fp, "%-16s %-16s %-11s %-16s %-3s %s\n",
		"usbfs", "/proc/bus/usb", "usbfs", "devgid=23,devmode=664", "0", "0");
	fprintf(fp, "%-16s %-16s %-11s %-16s %-3s %s\n",
		"tmpfs", "/dev/shm", "tmpfs", "defaults", "0", "0");

	// format the partitions
	for (i=0; i<g_list_length(partlist); i++)
	{
		char *tmp;
		dialog_vars.input_result[0]='\0';
		item = strdup((char*)g_list_nth_data(partlist, i));
		ptr = selmkswapmode(item);
		if(ptr == NULL)
			return(-1);
		if(!strcmp("format", ptr))
		{
			tmp = g_strdup_printf(_("Formatting %s as a swap "
						"partition"), item);
			fw_info(_("Formatting swap partition"), tmp);
			FREE(tmp);
			tmp = g_strdup_printf("%s %s", MKSWAP, item);
			fw_system(tmp);
			FREE(tmp);
		}
		else if (!strcmp("check", ptr))
		{
			tmp = g_strdup_printf(_("Formatting %s as a swap "
						"partition and checking for bad blocks"), item);
			fw_info(_("Formatting swap partition"), tmp);
			FREE(tmp);
			tmp = g_strdup_printf("%s -c %s", MKSWAP, item);
			fw_system(tmp);
			FREE(tmp);
		}
		ptr = g_strdup_printf("%s %s", SWAPON, item);
		fw_system(ptr);
		FREE(ptr);
		char *uuid = get_uuid(item);
		fprintf(fp, "%-16s %-16s %-11s %-16s %-3s %s\n",
			uuid, "swap", "swap", "defaults", "0", "0");
		free(uuid);
	}

	fclose(fp);

	// save fstab location for later
	data_put(config, "fstab", fn);
	// re-detect parts so that new swap partitions will recognized as swap
	// partitions
	detect_parts(0);
	return(0);
}
Пример #13
0
int run(GList **config)
{
	GList *drives=NULL;
	int i;
	int found = 0;
	char *ptr;

	umount_if_needed(SOURCEDIR);

	dialog_vars.backtitle=gen_backtitle(_("Selecting source media"));
	dlg_put_backtitle();
	dlg_clear();
	dialog_msgbox(_("Scanning"), _("Scanning for a CD/DVD drive containing "
		"a Frugalware install disc..."), 0, 0, 0);
	
	drives = grep_drives("/proc/sys/dev/cdrom/info");
	for (i=0; i<g_list_length(drives); i++)
	{
		ptr = get_blkid((char*)g_list_nth_data(drives, i));
		if(ptr && !strcmp(ptr, "Frugalware Install"))
		{
			LOG("install medium found in %s", (char*)g_list_nth_data(drives, i));
			FREE(ptr);
			ptr = g_strdup_printf("mount -o ro -t iso9660 /dev/%s %s", (char*)g_list_nth_data(drives, i),
					SOURCEDIR);
			fw_system(ptr);
			data_put(config, "srcdev", (char*)g_list_nth_data(drives, i));
			dlg_put_backtitle();
			dialog_msgbox(_("CD/DVD drive found"), g_strdup_printf(_("A Frugalware install disc was found in device /dev/%s."), (char*)g_list_nth_data(drives, i)), 0, 0, 0);
			if(is_netinstall(SOURCEDIR))
			{
				data_put(config, "netinstall", "");
				LOG("install medium contains no packages, performing a network installation");
			}
			else
				LOG("install medium contains packages, performing an offline installation");
			found = 1;
			break;
		}
		else
			LOG("skipping non-install medium in %s", (char*)g_list_nth_data(drives, i));
		FREE(ptr);
	}
	if(!found)
	{
		LOG("no package database found, performing a network installation");
		data_put(config, "netinstall", "");
	}
	// disable caching for cds
	if((char*)data_get(*config, "netinstall")==NULL)
	{
		char *pacbindir = g_strdup_printf("%s/frugalware-%s", SOURCEDIR, ARCH);
		disable_cache(pacbindir);
		FREE(pacbindir);
	}
	if(data_get(*config, "srcdev")==NULL)
	{
		LOG("no cd/dvd drive found, this is normal if you are running setup from a pendrive or in an emulator");
	}
	return(0);
}
Пример #14
0
void x_config(GtkWidget *button, gpointer data)
{
	GtkWidget* pBoite;
  	GtkWidget *pEntryRes, *pEntryDepth;
  	char* sRes, *sDepth, *mdev, *sDms, *ptr;
	int ret;
	
	GtkWidget *pVBox;
    	GtkWidget *pFrame;
    	GtkWidget *pVBoxFrame;
    	GtkWidget *pLabel;

	GtkWidget *combo;
	GtkTreeIter iter;
	GtkListStore *store;
	GtkTreeModel *model;	
	
	extern GtkWidget *assistant;

	//* Check if all necessary x files are present *//
	if(checkx() == -1)
	{
		fwife_error(_("Corrupted X installation. Missing file, see log for more details"));
		return;
	}

	pBoite = gtk_dialog_new_with_buttons(_("Configuring X11"),
      		  NULL,
      		  GTK_DIALOG_MODAL,
      		  GTK_STOCK_OK,GTK_RESPONSE_OK,
		  GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,
      		  NULL);
	gtk_window_set_transient_for(GTK_WINDOW(pBoite), GTK_WINDOW(assistant));
	gtk_window_set_position(GTK_WINDOW(pBoite), GTK_WIN_POS_CENTER_ON_PARENT);
   	
	pVBox = gtk_vbox_new(TRUE, 0);
   	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(pBoite)->vbox), pVBox, TRUE, FALSE, 5);	

    	/* Creation du premier GtkFrame */
    	pFrame = gtk_frame_new(_("X11 Configuration"));
    	gtk_box_pack_start(GTK_BOX(pVBox), pFrame, TRUE, FALSE, 0);

    	/* Creation et insertion d une boite pour le premier GtkFrame */
    	pVBoxFrame = gtk_vbox_new(TRUE, 0);
    	gtk_container_add(GTK_CONTAINER(pFrame), pVBoxFrame);   

    	/* Creation et insertion des elements contenus dans le premier GtkFrame */
    	pLabel = gtk_label_new(_("Resolution :"));
    	gtk_box_pack_start(GTK_BOX(pVBoxFrame), pLabel, TRUE, FALSE, 0);
	pEntryRes = gtk_entry_new();
	gtk_entry_set_text(GTK_ENTRY(pEntryRes), "1024x768");
    	gtk_box_pack_start(GTK_BOX(pVBoxFrame), pEntryRes, TRUE, FALSE, 0);
    
    	pLabel = gtk_label_new(_("Color depth :"));
    	gtk_box_pack_start(GTK_BOX(pVBoxFrame), pLabel, TRUE, FALSE, 0);
    	pEntryDepth = gtk_entry_new();
	gtk_entry_set_text(GTK_ENTRY(pEntryDepth), "24");
	gtk_box_pack_start(GTK_BOX(pVBoxFrame), pEntryDepth, TRUE, FALSE, 0);

    	/* Creation du deuxieme GtkFrame */
    	pFrame = gtk_frame_new(_("Select your default display manager : "));
    	gtk_box_pack_start(GTK_BOX(pVBox), pFrame, TRUE, FALSE, 0);

    	/* Creation et insertion d une boite pour le deuxieme GtkFrame */
    	pVBoxFrame = gtk_vbox_new(TRUE, 0);
    	gtk_container_add(GTK_CONTAINER(pFrame), pVBoxFrame);

	store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
	combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
	g_object_unref (GTK_TREE_MODEL (store));	
	
	GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,"text", 0, NULL);

	renderer = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,"text", 1, NULL);

	//* Find Desktop managers installed *//
	checkdms(store);
	gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);

    	gtk_box_pack_start(GTK_BOX(pVBoxFrame), combo, TRUE, FALSE, 0);

    	gtk_widget_show_all(pBoite);

	//* Run dialog box *//
    	switch (gtk_dialog_run(GTK_DIALOG(pBoite)))
    	{
        	case GTK_RESPONSE_OK:
            		sRes = strdup((char*)gtk_entry_get_text(GTK_ENTRY(pEntryRes)));
	    		sDepth = strdup((char*)gtk_entry_get_text(GTK_ENTRY(pEntryDepth)));
			
			gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter);
			model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
			gtk_tree_model_get (model, &iter, 0, &sDms, -1);

			if((sRes == NULL) || !strcmp(sRes, "") || (sDepth == NULL) || !strcmp(sDepth, ""))
				return;

			pid_t pid = fork();

			if(pid == -1)
			{
				LOG("Error when forking process (X11 config)");
			}
			else if (pid == 0)
			{
				chroot(TARGETDIR);
				mdev = fwx_get_mousedev();

				if(fwx_doprobe())
				{
					exit(-1);
				}	
	
				fwx_doconfig(mdev, sRes, sDepth);	
				unlink("/root/xorg.conf.new");
				ret = fwx_dotest();
				//* create /sysconfig/desktop file *//
				write_dms(sDms);
				
				exit(ret);
			}
			else
			{
				wait(&ret);

				//* change keyboard localisation *//
				ptr = g_strdup_printf("%s/xkeybchange %s %s %s", SCRIPTDIR, xlayout, xvariant, TARGETDIR);
				fw_system(ptr);
				FREE(ptr);

				gtk_widget_destroy(pBoite);
				if(ret)
					x_config(button, data);
				else
					gtk_label_set_text(GTK_LABEL(data), g_strdup_printf("%s %s bpp", sRes, sDepth));
			}
           		break;
        	case GTK_RESPONSE_CANCEL:
        	case GTK_RESPONSE_NONE:
        	default:
			gtk_widget_destroy(pBoite);
        		break;
    	}
	FREE(sRes);
	FREE(sDepth);
	return;
}
Пример #15
0
int run(GList **config)
{
	char **array;
	char *fn, *ptr, *layout;
	FILE* fp;
	int ret = 0;
	
	if (layoutl)
	{
		g_list_free(layoutl);
		layoutl = NULL;
	}
	find("/usr/share/keymaps/i386");
	layoutl = g_list_sort(layoutl, sort_layouts);
	array = glist4dialog(layoutl, "");
	
	dialog_vars.backtitle=gen_backtitle(_("Configuring the keyboard"));
	dlg_put_backtitle();
	dlg_clear();
	/* this string should be the best keyboard layout for the given
	 * language from /usr/share/keymaps/i386 */
	dialog_vars.default_item=strdup(_("qwerty/us.map.gz"));
	if(fw_menu(_("Keyboard map selection"),
		_("You may select one of the following keyboard maps. If you "
		"do not select a keyboard map, 'qwerty/us.map.gz' (the US "
		"keyboard map) is the default. Use the UP/DOWN arrow keys and "
		"PageUp/PageDown to scroll through the whole list of choices."),
		0, 0, 0, g_list_length(layoutl), array) == -1)
		ret = -1;
	FREE(dialog_vars.default_item);
	if(ret == -1)
		return(ret);
	layout=strdup(dialog_vars.input_result);

	FREE(array);
	// drop .map.gz
	if(strlen(layout) >= 7)
		layout[strlen(layout)-7]='\0';
	
	//TODO: maybe there is a proper system call for this?
	LOG("selected layout '%s'", layout);
	ptr = g_strdup_printf("loadkeys /usr/share/keymaps/i386/%s.map.gz", layout);
	fw_system(ptr);
	FREE(ptr);
	
	fn = strdup("/tmp/setup_XXXXXX");
	mkstemp(fn);
	if ((fp = fopen(fn, "w")) == NULL)
	{
		perror(_("Could not open output file for writing"));
		return(1);
	}
	fprintf(fp, "# /etc/vconsole.conf\n\n"
		"# specify the keyboard map, maps are in "
		"/usr/share/keymaps\n\n");
	if(strstr(layout, "/"))
		fprintf(fp, "KEYMAP=%s\n", strstr(layout, "/")+1);
	fprintf(fp,"\n# specify the console font\nFONT=lat1-16.psfu.gz\n");
	FREE(layout);
	fclose(fp);

	data_put(config, "vconsole.conf", fn);
	return(0);
}