示例#1
0
static int
cmd_detect_run( char *params[] )
{
	if (cmd_params( params ) != 1)
		return -1;

	if (!cmd_test_cable())
		return 1;

	buses_free();
	parts_free( chain->parts );
	chain->parts = NULL;
	detect_parts( chain, JTAG_DATA_DIR );
	if (!chain->parts)
		return 1;
	if (!chain->parts->len) {
		parts_free( chain->parts );
		chain->parts = NULL;
		return 1;
	}
	parts_set_instruction( chain->parts, "SAMPLE/PRELOAD" );
	chain_shift_instructions( chain );
	chain_shift_data_registers( chain, 1 );
	parts_set_instruction( chain->parts, "BYPASS" );
	chain_shift_instructions( chain );

	return 1;
}
示例#2
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);
}
示例#3
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);
}