socsvn commit: r278250 - in soc2014/kczekirda/pxe-fai-head: head/usr.sbin/bsdinstall head/usr.sbin/bsdinstall/distextract head/usr.sbin/bsdinstall/distfetch head/usr.sbin/bsdinstall/partedit head/u...

kczekirda at FreeBSD.org kczekirda at FreeBSD.org
Sun Feb 8 10:18:23 UTC 2015


Author: kczekirda
Date: Sun Feb  8 10:18:17 2015
New Revision: 278250
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=278250

Log:
  merge to head and TOFILE deleted

Modified:
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/bsdinstall
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/bsdinstall.8
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distextract/Makefile
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distextract/distextract.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distfetch/Makefile
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distfetch/distfetch.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/Makefile
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/diskeditor.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/diskeditor.h
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/gpart_ops.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/part_wizard.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/partedit.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/partedit.h
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/partedit_generic.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/partedit_pc98.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/partedit_sparc64.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/partedit_x86.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/sade.8
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/scripted.c
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/auto
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/config
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/hostname
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/jail
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/keymap
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/mirrorselect
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/netconfig
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/netconfig_ipv4
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/netconfig_ipv6
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/script
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/services
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/time
  soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/scripts/zfsboot
  soc2014/kczekirda/pxe-fai-head/others/template.input

Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/bsdinstall
==============================================================================
--- soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/bsdinstall	Sun Dec 21 17:27:05 2014	(r278249)
+++ soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/bsdinstall	Sun Feb  8 10:18:17 2015	(r278250)
@@ -58,18 +58,6 @@
 done
 shift $(( $OPTIND - 1 ))
 
-# when option "tofile" - only simulation
-if [ "$1" = "tofile" ]; then
-	if [ "$2" ]; then
-		export TOFILE="$2"
-		shift 2 # need delete option and path
-		echo "# installer configuration file from bsdinstall" > "$TOFILE"
-	else
-		echo "missing path - tofile parameter"
-		exit
-	fi
-fi
-
 # What are we here to do?
 VERB="${1:-auto}"; shift
 

Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/bsdinstall.8
==============================================================================
--- soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/bsdinstall.8	Sun Dec 21 17:27:05 2014	(r278249)
+++ soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/bsdinstall.8	Sun Feb  8 10:18:17 2015	(r278250)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 15, 2013
+.Dd October 31, 2014
 .Dt BSDINSTALL 8
 .Os
 .Sh NAME
@@ -73,10 +73,6 @@
 .Bl -tag -width ".Cm jail Ar destination"
 .It Cm auto
 Run the standard interactive installation, including disk partitioning.
-.It Cm entropy
-Reads a small amount of data from
-.Pa /dev/random
-and stores it in a file in the new system's root directory.
 .It Cm jail Ar destination
 Sets up a new chroot system at
 .Pa destination ,
@@ -95,6 +91,8 @@
 .It Cm keymap
 If the current controlling TTY is a
 .Xr syscons 4
+or
+.Xr vt 4
 console, asks the user to set the current keymap, and saves the result to the
 new system's
 .Pa rc.conf .
@@ -117,32 +115,28 @@
 is set, also configures the network interfaces of the current system to match.
 .It Cm autopart
 Provides the installer's interactive guided disk partitioner for single-disk
-installations. Partitions disks, runs
-.Xr newfs 8 ,
-and writes the new system's
-.Pa fstab .
+installations. Defaults to UFS.
 .It Cm zfsboot
-Provides the installer's
-.Pq experimental
-interactive/scriptable ZFS partitioner for multi-disk installations.
+Provides an alternative ZFS-only automatic interactive disk partitioner.
 Creates a single
 .Ic zpool
-with datasets and writes to the new system's
-.Pa rc.conf ,
-.Pa loader.conf ,
+with separate datasets for
+.Pa /tmp ,
+.Pa /usr ,
+.Pa /usr/home ,
+.Pa /usr/ports ,
+.Pa /usr/src ,
 and
-.Pa fstab .
-Supports
-.Xr geli 8 ,
-.Xr gnop 8 ,
-and many other features.
+.Pa /var .
+Optionally can set up
+.Xr geli 8 
+to encrypt the disk.
 .It Cm partedit
-Provides the installer's interactive manual disk partitioner, with support
-for multi disk setups, non-UFS file systems, and manual selection of
-partition schemes. Partitions disks, runs
-.Xr newfs 8 ,
-and writes the new system's
-.Pa fstab .
+Provides the installer's interactive manual disk partitioner with an interface
+identical to
+.Xr sade 8 .
+Supports multiple disks as well as UFS, ZFS, and FAT file systems. ZFS
+is set up with one pool and dataset per partition.
 .It Cm scriptedpart Ar parameters
 Sets up disks like
 .Cm autopart
@@ -188,13 +182,19 @@
 .Ar type
 option chooses the
 .Xr gpart 8
-filesystem type (e.g. freebsd-ufs or freebsd-swap).
+filesystem type (e.g. freebsd-ufs, freebsd-zfs, or freebsd-swap).
 The optional
 .Ar mount point
 argument sets where the created partition is to be mounted in the installed
 system. As an example, a typical invocation looks like:
 .Pp
 bsdinstall scriptedpart ada0 { 20G freebsd-ufs /, 4G freebsd-swap, 20G freebsd-ufs /var, auto freebsd-ufs /usr }
+.Pp
+A shorter invocation to use the default partitioning (as
+.Cm autopart
+would have used) on the same disk:
+.Pp
+bsdinstall scriptedpart ada0
 .It Cm mount
 Mounts the file systems previously configured by
 .Cm autopart ,
@@ -233,6 +233,10 @@
 Queries the user for the system daemons to begin at system startup,
 writing the result into the new system's
 .Pa rc.conf .
+.It Cm entropy
+Reads a small amount of data from
+.Pa /dev/random
+and stores it in a file in the new system's root directory.
 .It Cm config
 Installs the configuration files destined for the new system (e.g. rc.conf
 fragments generated by
@@ -344,14 +348,14 @@
 .Cm scriptedpart
 target to control disk setup.
 Alternatively,
+to use
+.Cm zfsboot
 instead of
-.Ev PARTITIONS ,
+.Cm partedit ,
 the preamble can contain the variable
 .Ev ZFSBOOT_DATASETS
-which is parsed by the
-.Pq experimental
-.Cm zfsboot
-target to control ZFS datasets/options of the boot pool setup.
+instead of 
+.Ev PARTITIONS .
 .Ss SETUP SCRIPT
 Following the preamble is an optional shell script, beginning with a #!
 declaration. This script will be run at the end of the installation process
@@ -367,5 +371,4 @@
 first appeared in
 .Fx 9.0 .
 .Sh AUTHORS
-.An -nosplit
-.An Nathan Whitehorn Aq nwhitehorn at FreeBSD.org
+.An Nathan Whitehorn Aq Mt nwhitehorn at FreeBSD.org

Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distextract/Makefile
==============================================================================
--- soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distextract/Makefile	Sun Dec 21 17:27:05 2014	(r278249)
+++ soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distextract/Makefile	Sun Feb  8 10:18:17 2015	(r278250)
@@ -1,9 +1,8 @@
-# $FreeBSD$
+# $FreeBSD: mirror/FreeBSD/head/usr.sbin/bsdinstall/distextract/Makefile 277604 2014-11-25 16:57:27Z bapt $
 
 BINDIR= /usr/libexec/bsdinstall
 PROG=	distextract
-DPADD=	${LIBARCHIVE} ${LIBNCURSESW} ${LIBDIALOG} ${LIBM}
-LDADD=	-larchive -lncursesw -ldialog -lm
+LIBADD=	archive ncursesw dialog m
 
 WARNS?=	6
 MAN=

Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distextract/distextract.c
==============================================================================
--- soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distextract/distextract.c	Sun Dec 21 17:27:05 2014	(r278249)
+++ soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distextract/distextract.c	Sun Feb  8 10:18:17 2015	(r278250)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2011 Nathan Whitehorn
+ * Copyright (c) 2014 Devin Teske <dteske at FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -22,114 +23,199 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * $FreeBSD$
  */
 
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: mirror/FreeBSD/head/usr.sbin/bsdinstall/distextract/distextract.c 274929 2014-10-01 18:59:57Z dteske $");
+
 #include <sys/param.h>
-#include <stdio.h>
-#include <errno.h>
-#include <limits.h>
 #include <archive.h>
+#include <ctype.h>
 #include <dialog.h>
+#include <err.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* Data to process */
+static char *distdir = NULL;
+struct file_node {
+	char	*path;
+	char	*name;
+	int	length;
+	struct file_node *next;
+};
+static struct file_node *dists = NULL;
+
+/* Function prototypes */
+static int	count_files(const char *file);
+static int	extract_files(int nfiles, struct file_node *files);
+
+#if __FreeBSD_version <= 1000008 /* r232154: bump for libarchive update */
+#define archive_read_support_filter_all(x) \
+	archive_read_support_compression_all(x)
+#endif
 
-static int extract_files(int nfiles, const char **files);
+#define _errx(...) (end_dialog(), errx(__VA_ARGS__))
 
 int
 main(void)
 {
-	char *diststring;
-	const char **dists;
-	int i, retval, ndists = 0;
-
-	if (getenv("DISTRIBUTIONS") == NULL) {
-		fprintf(stderr, "DISTRIBUTIONS variable is not set\n");
-		return (1);
-	}
-
-	diststring = strdup(getenv("DISTRIBUTIONS"));
-	for (i = 0; diststring[i] != 0; i++)
-		if (isspace(diststring[i]) && !isspace(diststring[i+1]))
-			ndists++;
-	ndists++; /* Last one */
-
-	dists = calloc(ndists, sizeof(const char *));
-	if (dists == NULL) {
-		fprintf(stderr, "Out of memory!\n");
-		free(diststring);
-		return (1);
-	}
-
-	for (i = 0; i < ndists; i++)
-		dists[i] = strsep(&diststring, " \t");
+	char *chrootdir;
+	char *distributions;
+	int ndists = 0;
+	int retval;
+	size_t file_node_size = sizeof(struct file_node);
+	size_t span;
+	struct file_node *dist = dists;
+	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 = __DECONST(char *, "FreeBSD Installer");
 	dlg_put_backtitle();
 
-	if (chdir(getenv("BSDINSTALL_CHROOT")) != 0) {
-		char error[512];
-		sprintf(error, "Could could change to directory %s: %s\n",
-		    getenv("BSDINSTALL_DISTDIR"), strerror(errno));
+	dialog_msgbox("",
+	    "Checking distribution archives.\nPlease wait...", 4, 35, FALSE);
+
+	/*
+	 * Parse $DISTRIBUTIONS into linked-list
+	 */
+	while (*distributions != '\0') {
+		span = strcspn(distributions, "\t\n\v\f\r ");
+		if (span < 1) { /* currently on whitespace */
+			distributions++;
+			continue;
+		}
+		ndists++;
+
+		/* 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 (1);
+		return (EXIT_FAILURE);
 	}
 
 	retval = extract_files(ndists, dists);
 
 	end_dialog();
 
-	free(diststring);
-	free(dists);
+	while ((dist = dists) != NULL) {
+		dists = dist->next;
+		if (dist->path != NULL)
+			free(dist->path);
+		free(dist);
+	}
 
 	return (retval);
 }
 
+/*
+ * Returns number of files in archive file. Parses $BSDINSTALL_DISTDIR/MANIFEST
+ * if it exists, otherwise uses archive(3) to read the archive file.
+ */
 static int
 count_files(const char *file)
 {
+	static FILE *manifest = NULL;
+	char *p;
+	int file_count;
+	int retval;
+	size_t span;
 	struct archive *archive;
 	struct archive_entry *entry;
-	static FILE *manifest = NULL;
-	char path[MAXPATHLEN];
-	char errormsg[512];
-	int file_count, err;
+	char line[512];
+	char path[PATH_MAX];
+	char errormsg[PATH_MAX + 512];
 
 	if (manifest == NULL) {
-		sprintf(path, "%s/MANIFEST", getenv("BSDINSTALL_DISTDIR"));
+		snprintf(path, sizeof(path), "%s/MANIFEST", distdir);
 		manifest = fopen(path, "r");
 	}
 
 	if (manifest != NULL) {
-		char line[512];
-		char *tok1, *tok2;
-
 		rewind(manifest);
 		while (fgets(line, sizeof(line), manifest) != NULL) {
-			tok2 = line;
-			tok1 = strsep(&tok2, "\t");
-			if (tok1 == NULL || strcmp(tok1, file) != 0)
+			p = &line[0];
+			span = strcspn(p, "\t") ;
+			if (span < 1 || strncmp(p, file, span) != 0)
 				continue;
 
 			/*
 			 * We're at the right manifest line. The file count is
 			 * in the third element
 			 */
-			tok1 = strsep(&tok2, "\t");
-			tok1 = strsep(&tok2, "\t");
-			if (tok1 != NULL)
-				return atoi(tok1);
+			span = strcspn(p += span + (*p != '\0' ? 1 : 0), "\t");
+			span = strcspn(p += span + (*p != '\0' ? 1 : 0), "\t");
+			if (span > 0) {
+				file_count = (int)strtol(p, (char **)NULL, 10);
+				if (file_count == 0 && errno == EINVAL)
+					continue;
+				return (file_count);
+			}
 		}
 	}
 
-	/* Either we didn't have a manifest, or this archive wasn't there */
-	archive = archive_read_new();
+	/*
+	 * Either no manifest, or manifest didn't mention this archive.
+	 * Use archive(3) to read the archive, counting files within.
+	 */
+	if ((archive = archive_read_new()) == NULL) {
+		snprintf(errormsg, sizeof(errormsg),
+		    "Error: %s\n", archive_error_string(NULL));
+		dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
+		return (-1);
+	}
 	archive_read_support_format_all(archive);
 	archive_read_support_filter_all(archive);
-	sprintf(path, "%s/%s", getenv("BSDINSTALL_DISTDIR"), file);
-	err = archive_read_open_filename(archive, path, 4096);
-	if (err != ARCHIVE_OK) {
+	snprintf(path, sizeof(path), "%s/%s", distdir, file);
+	retval = archive_read_open_filename(archive, path, 4096);
+	if (retval != ARCHIVE_OK) {
 		snprintf(errormsg, sizeof(errormsg),
 		    "Error while extracting %s: %s\n", file,
 		    archive_error_string(archive));
@@ -146,76 +232,83 @@
 }
 
 static int
-extract_files(int nfiles, const char **files)
+extract_files(int nfiles, struct file_node *files)
 {
-	const char *items[nfiles*2];
-	char path[PATH_MAX];
+	int archive_file;
 	int archive_files[nfiles];
-	int total_files, current_files, archive_file;
+	int current_files = 0;
+	int i;
+	int last_progress;
+	int progress = 0;
+	int retval;
+	int total_files = 0;
 	struct archive *archive;
 	struct archive_entry *entry;
-	char errormsg[512];
+	struct file_node *file;
 	char status[8];
-	int i, err, progress, last_progress;
+	static char title[] = "Archive Extraction";
+	static char pprompt[] = "Extracting distribution files...\n";
+	char path[PATH_MAX];
+	char errormsg[PATH_MAX + 512];
+	const char *items[nfiles*2];
 
-	err = 0;
-	progress = 0;
-	
 	/* Make the transfer list for dialog */
-	for (i = 0; i < nfiles; i++) {
-		items[i*2] = strrchr(files[i], '/');
-		if (items[i*2] != NULL)
-			items[i*2]++;
-		else
-			items[i*2] = files[i];
+	i = 0;
+	for (file = files; file != NULL; file = file->next) {
+		items[i*2] = file->name;
 		items[i*2 + 1] = "Pending";
-	}
-
-	dialog_msgbox("",
-	    "Checking distribution archives.\nPlease wait...", 0, 0, FALSE);
+		archive_files[i] = file->length;
 
-	/* Count all the files */
-	total_files = 0;
-	for (i = 0; i < nfiles; i++) {
-		archive_files[i] = count_files(files[i]);
-		if (archive_files[i] < 0)
-			return (-1);
-		total_files += archive_files[i];
+		total_files += file->length;
+		i++;
 	}
 
-	current_files = 0;
-
-	for (i = 0; i < nfiles; i++) {
-		archive = archive_read_new();
+	i = 0;
+	for (file = files; file != NULL; file = file->next) {
+		if ((archive = archive_read_new()) == NULL) {
+			snprintf(errormsg, sizeof(errormsg),
+			    "Error: %s\n", archive_error_string(NULL));
+			dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
+			return (EXIT_FAILURE);
+		}
 		archive_read_support_format_all(archive);
 		archive_read_support_filter_all(archive);
-		sprintf(path, "%s/%s", getenv("BSDINSTALL_DISTDIR"), files[i]);
-		err = archive_read_open_filename(archive, path, 4096);
+		snprintf(path, sizeof(path), "%s/%s", distdir, file->path);
+		retval = archive_read_open_filename(archive, path, 4096);
+		if (retval != 0) {
+			snprintf(errormsg, sizeof(errormsg),
+			    "Error opening %s: %s\n", file->name,
+			    archive_error_string(archive));
+			dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
+			return (EXIT_FAILURE);
+		}
 
 		items[i*2 + 1] = "In Progress";
 		archive_file = 0;
 
-		while ((err = archive_read_next_header(archive, &entry)) ==
+		dialog_mixedgauge(title, pprompt, 0, 0, progress, nfiles,
+		    __DECONST(char **, items));
+
+		while ((retval = archive_read_next_header(archive, &entry)) ==
 		    ARCHIVE_OK) {
 			last_progress = progress;
 			progress = (current_files*100)/total_files; 
 
-			sprintf(status, "-%d",
+			snprintf(status, sizeof(status), "-%d",
 			    (archive_file*100)/archive_files[i]);
 			items[i*2 + 1] = status;
 
 			if (progress > last_progress)
-				dialog_mixedgauge("Archive Extraction",
-				    "Extracting distribution files...", 0, 0,
+				dialog_mixedgauge(title, pprompt, 0, 0,
 				    progress, nfiles,
 				    __DECONST(char **, items));
 
-			err = archive_read_extract(archive, entry,
+			retval = archive_read_extract(archive, entry,
 			    ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_OWNER |
 			    ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL |
 			    ARCHIVE_EXTRACT_XATTR | ARCHIVE_EXTRACT_FFLAGS);
 
-			if (err != ARCHIVE_OK)
+			if (retval != ARCHIVE_OK)
 				break;
 
 			archive_file++;
@@ -224,18 +317,22 @@
 
 		items[i*2 + 1] = "Done";
 
-		if (err != ARCHIVE_EOF) {
+		if (retval != ARCHIVE_EOF) {
 			snprintf(errormsg, sizeof(errormsg),
 			    "Error while extracting %s: %s\n", items[i*2],
 			    archive_error_string(archive));
 			items[i*2 + 1] = "Failed";
-			dialog_msgbox("Extract Error", errormsg, 0, 0,
-			    TRUE);
-			return (err);
+			dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
+			return (retval);
 		}
 
+		progress = (current_files*100)/total_files; 
+		dialog_mixedgauge(title, pprompt, 0, 0, progress, nfiles,
+		    __DECONST(char **, items));
+
 		archive_read_free(archive);
+		i++;
 	}
 
-	return (0);
+	return (EXIT_SUCCESS);
 }

Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distfetch/Makefile
==============================================================================
--- soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distfetch/Makefile	Sun Dec 21 17:27:05 2014	(r278249)
+++ soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distfetch/Makefile	Sun Feb  8 10:18:17 2015	(r278250)
@@ -1,9 +1,8 @@
-# $FreeBSD$
+# $FreeBSD: mirror/FreeBSD/head/usr.sbin/bsdinstall/distfetch/Makefile 277604 2014-11-25 16:57:27Z bapt $
 
 BINDIR= /usr/libexec/bsdinstall
 PROG=	distfetch
-DPADD=	${LIBFETCH} ${LIBNCURSESW} ${LIBDIALOG} ${LIBM}
-LDADD=	-lfetch -lncursesw -ldialog -lm
+LIBADD=	fetch ncursesw dialog m
 
 WARNS?=	6
 MAN=

Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distfetch/distfetch.c
==============================================================================
--- soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distfetch/distfetch.c	Sun Dec 21 17:27:05 2014	(r278249)
+++ soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/distfetch/distfetch.c	Sun Feb  8 10:18:17 2015	(r278250)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2011 Nathan Whitehorn
+ * Copyright (c) 2014 Devin Teske <dteske at FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -22,15 +23,21 @@
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * $FreeBSD$
  */
 
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: mirror/FreeBSD/head/usr.sbin/bsdinstall/distfetch/distfetch.c 274929 2014-10-01 18:59:57Z dteske $");
+
 #include <sys/param.h>
-#include <stdio.h>
+#include <ctype.h>
+#include <err.h>
+#include <dialog.h>
 #include <errno.h>
 #include <fetch.h>
-#include <dialog.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
 static int fetch_files(int nfiles, char **urls);
 
@@ -39,12 +46,13 @@
 {
 	char *diststring;
 	char **urls;
-	int i, nfetched, ndists = 0;
+	int i;
+	int ndists = 0;
+	int nfetched;
+	char error[PATH_MAX + 512];
 
-	if (getenv("DISTRIBUTIONS") == NULL) {
-		fprintf(stderr, "DISTRIBUTIONS variable is not set\n");
-		return (1);
-	}
+	if (getenv("DISTRIBUTIONS") == NULL)
+		errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set");
 
 	diststring = strdup(getenv("DISTRIBUTIONS"));
 	for (i = 0; diststring[i] != 0; i++)
@@ -54,9 +62,8 @@
 
 	urls = calloc(ndists, sizeof(const char *));
 	if (urls == NULL) {
-		fprintf(stderr, "Out of memory!\n");
 		free(diststring);
-		return (1);
+		errx(EXIT_FAILURE, "Out of memory!");
 	}
 
 	init_dialog(stdin, stdout);
@@ -65,17 +72,17 @@
 
 	for (i = 0; i < ndists; i++) {
 		urls[i] = malloc(PATH_MAX);
-		sprintf(urls[i], "%s/%s", getenv("BSDINSTALL_DISTSITE"),
-		    strsep(&diststring, " \t"));
+		snprintf(urls[i], PATH_MAX, "%s/%s",
+		    getenv("BSDINSTALL_DISTSITE"), strsep(&diststring, " \t"));
 	}
 
 	if (chdir(getenv("BSDINSTALL_DISTDIR")) != 0) {
-		char error[512];
-		sprintf(error, "Could could change to directory %s: %s\n",
+		snprintf(error, sizeof(error),
+		    "Could could change to directory %s: %s\n",
 		    getenv("BSDINSTALL_DISTDIR"), strerror(errno));
 		dialog_msgbox("Error", error, 0, 0, TRUE);
 		end_dialog();
-		return (1);
+		return (EXIT_FAILURE);
 	}
 
 	nfetched = fetch_files(ndists, urls);
@@ -87,31 +94,32 @@
 		free(urls[i]);
 	free(urls);
 
-	return ((nfetched == ndists) ? 0 : 1);
+	return ((nfetched == ndists) ? EXIT_SUCCESS : EXIT_FAILURE);
 }
 
 static int
 fetch_files(int nfiles, char **urls)
 {
+	FILE *fetch_out;
+	FILE *file_out;
 	const char **items;
-	FILE *fetch_out, *file_out;
-	struct url_stat ustat;
-	off_t total_bytes, current_bytes, fsize;
+	int i;
+	int last_progress;
+	int nsuccess = 0; /* Number of files successfully downloaded */
+	int progress = 0;
+	size_t chunk;
+	off_t current_bytes;
+	off_t fsize;
+	off_t total_bytes;
 	char status[8];
-	char errormsg[512];
+	struct url_stat ustat;
+	char errormsg[PATH_MAX + 512];
 	uint8_t block[4096];
-	size_t chunk;
-	int i, progress, last_progress;
-	int nsuccess = 0; /* Number of files successfully downloaded */
 
-	progress = 0;
-	
 	/* Make the transfer list for dialog */
 	items = calloc(sizeof(char *), nfiles * 2);
-	if (items == NULL) {
-		fprintf(stderr, "Out of memory!\n");
-		return (-1);
-	}
+	if (items == NULL)
+		errx(EXIT_FAILURE, "Out of memory!");
 
 	for (i = 0; i < nfiles; i++) {
 		items[i*2] = strrchr(urls[i], '/');
@@ -177,7 +185,8 @@
 			}
 
 			if (ustat.size > 0) {
-				sprintf(status, "-%jd", (fsize*100)/ustat.size);
+				snprintf(status, sizeof(status), "-%jd",
+				    (fsize*100)/ustat.size);
 				items[i*2 + 1] = status;
 			}
 
@@ -212,4 +221,3 @@
 	free(items);
 	return (nsuccess);
 }
-

Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/Makefile
==============================================================================
--- soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/Makefile	Sun Dec 21 17:27:05 2014	(r278249)
+++ soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/Makefile	Sun Feb  8 10:18:17 2015	(r278250)
@@ -1,12 +1,11 @@
-# $FreeBSD$
+# $FreeBSD: mirror/FreeBSD/head/usr.sbin/bsdinstall/partedit/Makefile 277604 2014-11-25 16:57:27Z bapt $
 
 BINDIR= /usr/libexec/bsdinstall
 PROG=	partedit
 LINKS= ${BINDIR}/partedit ${BINDIR}/autopart \
        ${BINDIR}/partedit ${BINDIR}/scriptedpart
 SYMLINKS= ${BINDIR}/partedit /usr/sbin/sade
-DPADD=	${LIBGEOM} ${LIBNCURSESW} ${LIBUTIL} ${LIBDIALOG} ${LIBM}
-LDADD=	-lgeom -lncursesw -lutil -ldialog -lm
+LIBADD+=	geom ncursesw util dialog m
 
 PARTEDIT_ARCH= ${MACHINE}
 .if ${MACHINE} == "i386" || ${MACHINE} == "amd64"

Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/diskeditor.c
==============================================================================
--- soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/diskeditor.c	Sun Dec 21 17:27:05 2014	(r278249)
+++ soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/diskeditor.c	Sun Feb  8 10:18:17 2015	(r278250)
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: mirror/FreeBSD/head/usr.sbin/bsdinstall/partedit/diskeditor.c 253091 2013-06-17 15:16:14Z bapt $
  */
 
 #include <stdio.h>

Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/diskeditor.h
==============================================================================
--- soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/diskeditor.h	Sun Dec 21 17:27:05 2014	(r278249)
+++ soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/diskeditor.h	Sun Feb  8 10:18:17 2015	(r278250)
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: mirror/FreeBSD/head/usr.sbin/bsdinstall/partedit/diskeditor.h 218842 2011-02-18 14:54:34Z nwhitehorn $
  */
 
 #ifndef _PARTEDIT_DISKEDITOR_H

Modified: soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/gpart_ops.c
==============================================================================
--- soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/gpart_ops.c	Sun Dec 21 17:27:05 2014	(r278249)
+++ soc2014/kczekirda/pxe-fai-head/head/usr.sbin/bsdinstall/partedit/gpart_ops.c	Sun Feb  8 10:18:17 2015	(r278250)
@@ -23,10 +23,11 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: mirror/FreeBSD/head/usr.sbin/bsdinstall/partedit/gpart_ops.c 274081 2014-09-13 18:24:54Z nwhitehorn $
  */
 
 #include <sys/param.h>
+#include <sys/stat.h>
 #include <errno.h>
 #include <libutil.h>
 #include <inttypes.h>
@@ -119,6 +120,53 @@
 			else if (strcmp(items[i].name, "TRIM") == 0)
 				strcat(command, "-t ");
 		}
+	} else if (strcmp(fstype, "freebsd-zfs") == 0) {
+		int i;
+		DIALOG_LISTITEM items[] = {
+			{"fletcher4", "checksum algorithm: fletcher4",
+			    "Use fletcher4 for data integrity checking. "
+			    "(default)", 1 },
+			{"fletcher2", "checksum algorithm: fletcher2",
+			    "Use fletcher2 for data integrity checking. "
+			    "(not recommended)", 0 },
+			{"sha256", "checksum algorithm: sha256",
+			    "Use sha256 for data integrity checking. "
+			    "(not recommended)", 0 },
+			{"atime", "Update atimes for files",
+			    "Disable atime update", 0 },
+		};
+
+		if (!use_default) {
+			int choice;
+			choice = dlg_checklist("ZFS Options", "", 0, 0, 0,
+			    sizeof(items)/sizeof(items[0]), items, NULL,
+			    FLAG_CHECK, &i);
+			if (choice == 1) /* Cancel */
+				return;
+		}
+
+		strcpy(command, "zpool create -f -m none ");
+		if (getenv("BSDINSTALL_TMPBOOT") != NULL) {
+			char zfsboot_path[MAXPATHLEN];
+			sprintf(zfsboot_path, "%s/zfs",
+			    getenv("BSDINSTALL_TMPBOOT"));
+			mkdir(zfsboot_path, S_IRWXU | S_IRGRP | S_IXGRP |
+			    S_IROTH | S_IXOTH);
+			sprintf(command, "%s -o cachefile=%s/zpool.cache ",
+			    command, zfsboot_path);
+		}
+		for (i = 0; i < (int)(sizeof(items)/sizeof(items[0])); i++) {
+			if (items[i].state == 0)
+				continue;
+			if (strcmp(items[i].name, "fletcher4") == 0)
+				strcat(command, "-O checksum=fletcher4 ");
+			else if (strcmp(items[i].name, "fletcher2") == 0)
+				strcat(command, "-O checksum=fletcher2 ");
+			else if (strcmp(items[i].name, "sha256") == 0)
+				strcat(command, "-O checksum=sha256 ");
+			else if (strcmp(items[i].name, "atime") == 0)
+				strcat(command, "-O atime=off ");
+		}
 	} else if (strcmp(fstype, "fat32") == 0 || strcmp(fstype, "efi") == 0) {
 		int i;
 		DIALOG_LISTITEM items[] = {
@@ -329,7 +377,7 @@
 }
 
 static void
-gpart_partcode(struct gprovider *pp)
+gpart_partcode(struct gprovider *pp, const char *fstype)
 {
 	struct gconfig *gc;
 	const char *scheme;
@@ -344,7 +392,7 @@
 	}
 
 	/* Make sure this partition scheme needs partcode on this platform */
-	if (partcode_path(scheme) == NULL)
+	if (partcode_path(scheme, fstype) == NULL)
 		return;
 
 	LIST_FOREACH(gc, &pp->lg_config, lg_config) {
@@ -356,7 +404,7 @@
 
 	/* Shell out to gpart for partcode for now */
 	sprintf(command, "gpart bootcode -p %s -i %s %s",
-	    partcode_path(scheme), indexstr, pp->lg_geom->lg_name);
+	    partcode_path(scheme, fstype), indexstr, pp->lg_geom->lg_name);
 	if (system(command) != 0) {
 		sprintf(message, "Error installing partcode on partition %s",
 		    pp->lg_name);
@@ -416,15 +464,15 @@
 	const char *errstr, *oldtype, *scheme;
 	struct partition_metadata *md;
 	char sizestr[32];
-	char newfs[64];
+	char newfs[255];
 	intmax_t idx;
 	int hadlabel, choice, junk, nitems;
 	unsigned i;
 
 	DIALOG_FORMITEM items[] = {
 		{0, "Type:", 5, 0, 0, FALSE, "", 11, 0, 12, 15, 0,
-		    FALSE, "Filesystem type (e.g. freebsd-ufs, freebsd-swap)",
-		    FALSE},
+		    FALSE, "Filesystem type (e.g. freebsd-ufs, freebsd-zfs, "
+		    "freebsd-swap)", FALSE},
 		{0, "Size:", 5, 1, 0, FALSE, "", 11, 1, 12, 0, 0,
 		    FALSE, "Partition size. Append K, M, G for kilobytes, "
 		    "megabytes or gigabytes.", FALSE},
@@ -565,6 +613,8 @@
     const char *type, const char *mountpoint, const char *newfs)
 {
 	struct partition_metadata *md;
+	char *zpool_name = NULL;
+	int i;
 
 	/* Set part metadata */
 	md = get_part_metadata(name, 1);
@@ -577,8 +627,18 @@
 
 		if (newfs != NULL && newfs[0] != '\0') {
 			md->newfs = malloc(strlen(newfs) + strlen(" /dev/") +
-			    strlen(name) + 1);
-			sprintf(md->newfs, "%s /dev/%s", newfs, name);
+			    strlen(mountpoint) + 5 + strlen(name) + 1);
+			if (strcmp("freebsd-zfs", type) == 0) {
+				zpool_name = strdup((strlen(mountpoint) == 1) ?
+				    "root" : &mountpoint[1]);
+				for (i = 0; zpool_name[i] != 0; i++)
+					if (!isalnum(zpool_name[i]))
+						zpool_name[i] = '_';
+				sprintf(md->newfs, "%s %s /dev/%s", newfs,
+				    zpool_name, name);
+			} else {
+				sprintf(md->newfs, "%s /dev/%s", newfs, name);
+			}
 		}
 	}
 
@@ -587,8 +647,9 @@
 	if (strcmp(type, bootpart_type(scheme)) == 0)
 		md->bootcode = 1;
 
-	/* VTOC8 needs partcode in UFS partitions */
-	if (strcmp(scheme, "VTOC8") == 0 && strcmp(type, "freebsd-ufs") == 0)
+	/* VTOC8 needs partcode at the start of partitions */
+	if (strcmp(scheme, "VTOC8") == 0 && (strcmp(type, "freebsd-ufs") == 0
+	    || strcmp(type, "freebsd-zfs") == 0))
 		md->bootcode = 1;
 
 	if (mountpoint == NULL || mountpoint[0] == '\0') {
@@ -611,8 +672,13 @@
 			free(md->fstab->fs_mntops);
 			free(md->fstab->fs_type);
 		}
-		md->fstab->fs_spec = malloc(strlen(name) + 6);
-		sprintf(md->fstab->fs_spec, "/dev/%s", name);
+		if (strcmp("freebsd-zfs", type) == 0) {
+			md->fstab->fs_spec = strdup(zpool_name);
+		} else {
+			md->fstab->fs_spec = malloc(strlen(name) +
+			    strlen("/dev/") + 1);
+			sprintf(md->fstab->fs_spec, "/dev/%s", name);
+		}
 		md->fstab->fs_file = strdup(mountpoint);
 		/* Get VFS from text after freebsd-, if possible */
 		if (strncmp("freebsd-", type, 8) == 0)
@@ -625,6 +691,10 @@
 			md->fstab->fs_type = strdup(FSTAB_SW);
 			md->fstab->fs_freq = 0;
 			md->fstab->fs_passno = 0;
+		} else if (strcmp(type, "freebsd-zfs") == 0) {
+			md->fstab->fs_type = strdup(FSTAB_RW);
+			md->fstab->fs_freq = 0;
+			md->fstab->fs_passno = 0;
 		} else {
 			md->fstab->fs_type = strdup(FSTAB_RW);
 			if (strcmp(mountpoint, "/") == 0) {
@@ -637,6 +707,9 @@
 		}
 		md->fstab->fs_mntops = strdup(md->fstab->fs_type);
 	}
+
+	if (zpool_name != NULL)
+		free(zpool_name);
 }
 
 static
@@ -748,7 +821,7 @@
 	struct ggeom *geom;
 	const char *errstr, *scheme;
 	char sizestr[32], startstr[32], output[64], *newpartname;
-	char newfs[64], options_fstype[64];
+	char newfs[255], options_fstype[64];
 	intmax_t maxsize, size, sector, firstfree, stripe;
 	uint64_t bytes;
 	int nitems, choice, junk;
@@ -756,8 +829,8 @@
 
 	DIALOG_FORMITEM items[] = {

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-soc-all mailing list