Exemplo n.º 1
0
char *selformatmode(char *dev)
{
	int modenum=3;
	char *ret=NULL;
	char *title=NULL;
	char *msg=NULL;
	char *modes[] =
	{
		"format", _("Quick format with no bad block checking"),
		"check", _("Slow format that checks for bad blocks"),
		"noformat", _("Do not format, just mount the partition")
	};

	dialog_vars.backtitle=gen_backtitle(_("Formatting partitions"));
	dlg_put_backtitle();
	dlg_clear();
	title = g_strdup_printf(_("Format %s"), dev);
	msg = g_strdup_printf(_("If %s has not been formatted, you should "
		"format it.\n"
		"NOTE: This will erase all data on %s. Would you like to "
		"format this partition?"), dev, dev);
	if (fw_menu(title,msg,0,0,0,modenum,modes) != -1)
		ret = dialog_vars.input_result;
	FREE(title);
	FREE(msg);

	return ret;
}
Exemplo n.º 2
0
char *selfs(char *dev)
{
#ifndef ARCH_PPC
	int fsnum=7;
#else
	int fsnum=4;
#endif
	char *fss[] =
	{
		"ext2", _("Standard Linux ext2fs filesystem"),
		"ext3", _("Journaling version of the ext2 filesystem"),
		"ext4", _("The evolution of the ext3 filesystem"),
#ifndef ARCH_PPC
		"reiserfs", _("Hans Reiser's journaling filesystem"),
#endif
		"jfs", _("Journaled File System"),
		"xfs", _("SGI's journaling filesystem"),
		"btrfs", _("B-tree file system (EXPERIMENTAL)")
	};

	dialog_vars.backtitle=gen_backtitle(_("Formatting partitions"));
	dlg_put_backtitle();
	dlg_clear();
	dialog_vars.default_item=strdup("ext4");
	if(fw_menu(g_strdup_printf(_("Selecting filesystem for %s"), dev),
		g_strdup_printf(_("Please select the type of filesystem to "
		"use for %s."), dev), 0, 0, 0, fsnum, fss) == -1)
		return(NULL);
	FREE(dialog_vars.default_item);

	return(strdup(dialog_vars.input_result));
}
Exemplo n.º 3
0
void MainWindow::reinitScreen()
{
    /* FIXME: there must be a better way to do this */
    end_dialog();
    erase();
    init_dialog(stdin, stdout);
    dlg_put_backtitle();
}
Exemplo n.º 4
0
char *selrootdev()
{
	char **array;

	array = glist2dialog(parts);
	dialog_vars.backtitle=gen_backtitle(_("Setting up the root partition"));
	dlg_put_backtitle();
	if(fw_menu(_("Select the Linux installation partition"),
		_("Please select a partition from the following list to use "
		"for your root (/) partition. The following ones "
		"are available:"), 0, 0, 0, g_list_length(parts)/2, array) == -1)
		return(NULL);
	return(strdup(dialog_vars.input_result));
}
Exemplo n.º 5
0
GList *selswap(void)
{
	char **arraychk;
	GList *partlist;

	arraychk = glist2dialog(partschk);

	dialog_vars.backtitle=gen_backtitle(_("Setting up swap space"));
	dlg_put_backtitle();
	dlg_clear();
	partlist = fw_checklist(_("Setting up swap partitions"),
		_("Please select which swap partitions you want Frugalware "
		"to use:"), 0, 0, 0, g_list_length(partschk)/3, arraychk,
		FLAG_CHECK);
	return(partlist);
}
Exemplo n.º 6
0
int run(GList **config)
{
	char *version = get_version();
	char *title=NULL;

	asprintf(&title, _("Welcome to %s"), version);

	dialog_vars.backtitle=gen_backtitle(_("Welcome"));
	dlg_put_backtitle();
	dlg_clear();
	dialog_msgbox(title, _("Welcome among the users of Frugalware!\n\n"
		"The aim of creating Frugalware was to help you to do your work "
		"faster and simpler. We hope that you will like our "
		"product.\n\n"
		"The Frugalware Developer Team"), 0, 0, 1);
	FREE(version);

	return(0);
}
Exemplo n.º 7
0
int
main(int argc, const char **argv)
{
	struct partition_metadata *md;
	const char *prompt;
	struct partedit_item *items = NULL;
	struct gmesh mesh;
	int i, op, nitems, nscroll;
	int error;

	if (strcmp(basename(argv[0]), "sade") == 0)
		sade_mode = 1;

	TAILQ_INIT(&part_metadata);

	init_fstab_metadata();

	init_dialog(stdin, stdout);
	if (!sade_mode)
		dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer");
	dialog_vars.item_help = TRUE;
	nscroll = i = 0;

	/* Revert changes on SIGINT */
	signal(SIGINT, sigint_handler);

	if (strcmp(basename(argv[0]), "autopart") == 0) { /* Guided */
		prompt = "Please review the disk setup. When complete, press "
		    "the Finish button.";
		/* Experimental ZFS autopartition support */
		if (argc > 1 && strcmp(argv[1], "zfs") == 0) {
			part_wizard("zfs");
		} else {
			part_wizard("ufs");
		}
	} else if (strcmp(basename(argv[0]), "scriptedpart") == 0) {
		error = scripted_editor(argc, argv);
		prompt = NULL;
		if (error != 0) {
			end_dialog();
			return (error);
		}
	} else {
		prompt = "Create partitions for FreeBSD. No changes will be "
		    "made until you select Finish.";
	}

	/* Show the part editor either immediately, or to confirm wizard */
	while (prompt != NULL) {
		dlg_clear();
		dlg_put_backtitle();

		error = geom_gettree(&mesh);
		if (error == 0)
			items = read_geom_mesh(&mesh, &nitems);
		if (error || items == NULL) {
			dialog_msgbox("Error", "No disks found. If you need to "
			    "install a kernel driver, choose Shell at the "
			    "installation menu.", 0, 0, TRUE);
			break;
		}
			
		get_mount_points(items, nitems);

		if (i >= nitems)
			i = nitems - 1;
		op = diskeditor_show("Partition Editor", prompt,
		    items, nitems, &i, &nscroll);

		switch (op) {
		case 0: /* Create */
			gpart_create((struct gprovider *)(items[i].cookie),
			    NULL, NULL, NULL, NULL, 1);
			break;
		case 1: /* Delete */
			gpart_delete((struct gprovider *)(items[i].cookie));
			break;
		case 2: /* Modify */
			gpart_edit((struct gprovider *)(items[i].cookie));
			break;
		case 3: /* Revert */
			gpart_revert_all(&mesh);
			while ((md = TAILQ_FIRST(&part_metadata)) != NULL) {
				if (md->fstab != NULL) {
					free(md->fstab->fs_spec);
					free(md->fstab->fs_file);
					free(md->fstab->fs_vfstype);
					free(md->fstab->fs_mntops);
					free(md->fstab->fs_type);
					free(md->fstab);
				}
				if (md->newfs != NULL)
					free(md->newfs);
				free(md->name);

				TAILQ_REMOVE(&part_metadata, md, metadata);
				free(md);
			}
			init_fstab_metadata();
			break;
		case 4: /* Auto */
			part_wizard("ufs");
			break;
		}

		error = 0;
		if (op == 5) { /* Finished */
			dialog_vars.ok_label = __DECONST(char *, "Commit");
			dialog_vars.extra_label =
			    __DECONST(char *, "Revert & Exit");
			dialog_vars.extra_button = TRUE;
			dialog_vars.cancel_label = __DECONST(char *, "Back");
			op = dialog_yesno("Confirmation", "Your changes will "
			    "now be written to disk. If you have chosen to "
			    "overwrite existing data, it will be PERMANENTLY "
			    "ERASED. Are you sure you want to commit your "
			    "changes?", 0, 0);
			dialog_vars.ok_label = NULL;
			dialog_vars.extra_button = FALSE;
			dialog_vars.cancel_label = NULL;

			if (op == 0 && validate_setup()) { /* Save */
				error = apply_changes(&mesh);
				if (!error)
					apply_workaround(&mesh);
				break;
			} else if (op == 3) { /* Quit */
				gpart_revert_all(&mesh);
				error =	-1;
				break;
			}
		}

		geom_deletetree(&mesh);
		free(items);
	}
Exemplo n.º 8
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);
}
Exemplo n.º 9
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);
}
Exemplo n.º 10
0
int run(GList **config)
{
#ifdef GTK
	GtkWidget *label;
	GtkWidget *tv;
	GtkTreeIter iter;
	int i = 0;
#endif

#ifdef DIALOG
	dialog_vars.backtitle=gen_backtitle("Selecting language");
	dlg_put_backtitle();
	dlg_clear();
	dialog_vars.default_item=strdup("en_US");
	if(fw_menu("Please select your language",
		"Please select your language from the list. If your language "
		"is not in the list, you should probably choose English.",
		0, 0, 0, LANGSNUM, langs) == -1)
		return(-1);
	FREE(dialog_vars.default_item);

	LOG("selected language: '%s'", dialog_vars.input_result);
	setenv("LC_ALL", dialog_vars.input_result, 1);
	setenv("LANG",   dialog_vars.input_result, 1);
	setlocale(LC_ALL, dialog_vars.input_result);
	bindtextdomain("setup", "/usr/share/locale");
	
	if(!strcmp("en_US", dialog_vars.input_result))
		setenv("CHARSET", "iso-8859-1", 1);
	else if(!strcmp("es_AR", dialog_vars.input_result))
	{
		setenv("CHARSET", "iso-8859-1", 1);
		setcharset("lat1-16.psfu.gz", config);
	}
	else if(!strcmp("de_DE", dialog_vars.input_result))
		setenv("CHARSET", "iso-8859-15", 1);
	else if(!strcmp("fr_FR", dialog_vars.input_result))
		setenv("CHARSET", "iso-8859-15", 1);
        else if(!strcmp("id_ID", dialog_vars.input_result))
		setenv("CHARSET", "iso-8859-1", 1);
	else if(!strcmp("it_IT", dialog_vars.input_result))
	{
		setenv("CHARSET", "iso-8859-1", 1);
		setcharset("lat9w-16.psfu.gz", config);
	}
	else if(!strcmp("cs_CZ", dialog_vars.input_result))
	{
		setenv("CHARSET", "iso-8859-2", 1);
		setcharset("lat2-16.psfu.gz", config);
	}
	else if(!strcmp("hu_HU", dialog_vars.input_result))
	{
		setenv("CHARSET", "iso-8859-2", 1);
		setcharset("lat2a-16.psfu.gz", config);
	}
	else if(!strcmp("nl_NL", dialog_vars.input_result))
		setenv("CHARSET", "iso-8859-1", 1);
	else if(!strcmp("pl_PL", dialog_vars.input_result))
	{
		setenv("CHARSET", "iso-8859-2", 1);
		setcharset("lat2-16.psfu.gz", config);
	}
	else if(!strcmp("pt_PT", dialog_vars.input_result))
	{
		setenv("CHARSET", "iso-8859-1", 1);
		setcharset("lat1-16.psfu.gz", config);
	}
	else if(!strcmp("sk_SK", dialog_vars.input_result))
	{
		setenv("CHARSET", "iso-8859-2", 1);
		setcharset("lat2-16.psfu.gz", config);
	}
#endif

#ifdef GTK
	tv = create_asklang_view();
	gtk_container_add(GTK_CONTAINER(frame), tv);
	while (i <= LANGSNUM * 2) {
		gtk_list_store_append(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tv))), &iter);
		gtk_list_store_set(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tv))), &iter,
			0, langs[i], 1, langs[i+1], -1);
		i = i+2;
	}
	gtk_widget_show_all(tv);
#endif
	textdomain("setup");
	return(0);
}
Exemplo n.º 11
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);
}
Exemplo n.º 12
0
int
main(void)
{
	char *chrootdir;
	char *distributions;
	int retval;
	size_t config_size = sizeof(struct dpv_config);
	size_t file_node_size = sizeof(struct dpv_file_node);
	size_t span;
	struct dpv_config *config;
	struct dpv_file_node *dist = dists;
	static char backtitle[] = "FreeBSD Installer";
	static char title[] = "Archive Extraction";
	static char aprompt[] = "\n  Overall Progress:";
	static char pprompt[] = "Extracting distribution files...\n";
	struct sigaction act;
	char error[PATH_MAX + 512];

	if ((distributions = getenv("DISTRIBUTIONS")) == NULL)
		errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set");
	if ((distdir = getenv("BSDINSTALL_DISTDIR")) == NULL)
		distdir = __DECONST(char *, "");

	/* Initialize dialog(3) */
	init_dialog(stdin, stdout);
	dialog_vars.backtitle = backtitle;
	dlg_put_backtitle();

	dialog_msgbox("",
	    "Checking distribution archives.\nPlease wait...", 4, 35, FALSE);

	/*
	 * Parse $DISTRIBUTIONS into dpv(3) linked-list
	 */
	while (*distributions != '\0') {
		span = strcspn(distributions, "\t\n\v\f\r ");
		if (span < 1) { /* currently on whitespace */
			distributions++;
			continue;
		}

		/* Allocate a new struct for the distribution */
		if (dist == NULL) {
			if ((dist = calloc(1, file_node_size)) == NULL)
				_errx(EXIT_FAILURE, "Out of memory!");
			dists = dist;
		} else {
			dist->next = calloc(1, file_node_size);
			if (dist->next == NULL)
				_errx(EXIT_FAILURE, "Out of memory!");
			dist = dist->next;
		}

		/* Set path */
		if ((dist->path = malloc(span + 1)) == NULL)
			_errx(EXIT_FAILURE, "Out of memory!");
		snprintf(dist->path, span + 1, "%s", distributions);
		dist->path[span] = '\0';

		/* Set display name */
		dist->name = strrchr(dist->path, '/');
		if (dist->name == NULL)
			dist->name = dist->path;

		/* Set initial length in files (-1 == error) */
		dist->length = count_files(dist->path);
		if (dist->length < 0) {
			end_dialog();
			return (EXIT_FAILURE);
		}

		distributions += span;
	}

	/* Optionally chdir(2) into $BSDINSTALL_CHROOT */
	chrootdir = getenv("BSDINSTALL_CHROOT");
	if (chrootdir != NULL && chdir(chrootdir) != 0) {
		snprintf(error, sizeof(error),
		    "Could not change to directory %s: %s\n",
		    chrootdir, strerror(errno));
		dialog_msgbox("Error", error, 0, 0, TRUE);
		end_dialog();
		return (EXIT_FAILURE);
	}

	/* Set cleanup routine for Ctrl-C action */
	act.sa_handler = sig_int;
	sigaction(SIGINT, &act, 0);

	/*
	 * Hand off to dpv(3)
	 */
	if ((config = calloc(1, config_size)) == NULL)
		_errx(EXIT_FAILURE, "Out of memory!");
	config->backtitle	= backtitle;
	config->title		= title;
	config->pprompt		= pprompt;
	config->aprompt		= aprompt;
	config->options		|= DPV_WIDE_MODE;
	config->label_size	= -1;
	config->action		= extract_files;
	config->status_solo	=
	    "%10lli files read @ %'9.1f files/sec.";
	config->status_many	= 
	    "%10lli files read @ %'9.1f files/sec. [%i/%i busy/wait]";
	end_dialog();
	retval = dpv(config, dists);

	dpv_free();
	while ((dist = dists) != NULL) {
		dists = dist->next;
		if (dist->path != NULL)
			free(dist->path);
		free(dist);
	}

	return (retval);
}