From owner-svn-src-user@FreeBSD.ORG Sun Dec 26 20:18:51 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 45674106564A; Sun, 26 Dec 2010 20:18:51 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 35AAC8FC0A; Sun, 26 Dec 2010 20:18:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBQKIpb0098639; Sun, 26 Dec 2010 20:18:51 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBQKIpV3098637; Sun, 26 Dec 2010 20:18:51 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201012262018.oBQKIpV3098637@svn.freebsd.org> From: Doug Barton Date: Sun, 26 Dec 2010 20:18:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216723 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Dec 2010 20:18:51 -0000 Author: dougb Date: Sun Dec 26 20:18:50 2010 New Revision: 216723 URL: http://svn.freebsd.org/changeset/base/216723 Log: Fix some bugs with -r: 1. In certain situations dependent ports that were otherwise up to date would be missed. 2. For the purpose of not rebuilding the parent port when -R is used we only care about the dependencies of the parent port being up to date. So determine the value of PM_RBP_NEEDS_UPGRADE before entering the MASTER_RB_LIST loop, then only test PM_RBP_NEEDS_UPGRADE at the end and ignore NO_DEP_UPDATES since at that point it could refer to dependencies of the dependent ports. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sun Dec 26 19:08:41 2010 (r216722) +++ user/dougb/portmaster/portmaster Sun Dec 26 20:18:50 2010 (r216723) @@ -1453,6 +1453,10 @@ check_state () { check_force_multi () { if [ -n "$PM_FORCE" ]; then check_restart_and_udf $1 || return 1 + elif [ -n "$URB_YES" ]; then + case "$MASTER_RB_LIST" in + *" $1 "*) check_restart_and_udf $1 || return 1 ;; + esac elif [ -n "$PM_MULTI_PORTS" ]; then case "$PM_MULTI_PORTS" in *:${1}:*) return 1 ;; @@ -2461,7 +2465,7 @@ post_first_pass () { local action if [ -n "$UPDATE_REQ_BYS" -a -n "$RESTART" ]; then - if [ -z "$NO_DEP_UPDATES" -o -n "$PM_RBP_NEEDS_UPGRADE" ]; then + if [ -n "$PM_RBP_NEEDS_UPGRADE" ]; then echo "===>>> $PM_RBP and/or dependencies are out of date, forcing rebuild" else echo "===>>> $PM_RBP is up to date, skipping rebuild due to -R flag" @@ -3136,6 +3140,7 @@ if [ -n "$PM_FIRST_PASS" ]; then safe_exit elif [ -n "$UPDATE_REQ_BYS" ]; then + [ -z "$NO_DEP_UPDATES" ] && PM_RBP_NEEDS_UPGRADE=pm_rbp_needs_upgrade export URB_YES=urb_yes echo '' echo "===>>> Checking ports that depend on $upg_port" From owner-svn-src-user@FreeBSD.ORG Tue Dec 28 19:22:53 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 97D391065744; Tue, 28 Dec 2010 19:22:53 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8785C8FC12; Tue, 28 Dec 2010 19:22:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBSJMrtr074629; Tue, 28 Dec 2010 19:22:53 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBSJMrXv074627; Tue, 28 Dec 2010 19:22:53 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201012281922.oBSJMrXv074627@svn.freebsd.org> From: Doug Barton Date: Tue, 28 Dec 2010 19:22:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216770 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Dec 2010 19:22:53 -0000 Author: dougb Date: Tue Dec 28 19:22:53 2010 New Revision: 216770 URL: http://svn.freebsd.org/changeset/base/216770 Log: Fix the discovery of WRKDIRPREFIX so that it works with multiport() and -a Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Tue Dec 28 18:58:15 2010 (r216769) +++ user/dougb/portmaster/portmaster Tue Dec 28 19:22:53 2010 (r216770) @@ -790,6 +790,7 @@ if [ "$$" -eq "$PM_PARENT_PID" ]; then fi if [ -n "$pd" ]; then + pm_cd_pd && PM_WRKDIRPREFIX=`pm_make_b -V WRKDIRPREFIX` export pd else if [ -n "$EXPUNGE" -o -n "$CLEAN_STALE" ]; then @@ -3051,11 +3052,7 @@ fi # Do these things first time through if [ -z "$PM_INDEX_ONLY" -a -z "$PM_BUILDING" -a -z "$SHOW_WORK" -a -z "$NO_ACTION" ]; then # Do not start this in the background until we are sure we are going to build - if [ "$$" -eq "$PM_PARENT_PID" ]; then - [ -n "$DI_FILES" ] && (read_distinfos)& - - PM_WRKDIRPREFIX=`pm_make_b -V WRKDIRPREFIX` - fi + [ "$$" -eq "$PM_PARENT_PID" -a -n "$DI_FILES" ] && (read_distinfos)& # Handle the problem of manual fetching [ -z "$PM_PACKAGES" ] && master_sites=`pm_make -V MASTER_SITES` From owner-svn-src-user@FreeBSD.ORG Fri Dec 31 02:19:39 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3930B106564A; Fri, 31 Dec 2010 02:19:39 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 26EAA8FC08; Fri, 31 Dec 2010 02:19:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBV2JdQS058029; Fri, 31 Dec 2010 02:19:39 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBV2JcPa058007; Fri, 31 Dec 2010 02:19:38 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201012310219.oBV2JcPa058007@svn.freebsd.org> From: Nathan Whitehorn Date: Fri, 31 Dec 2010 02:19:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216834 - in user/nwhitehorn/bsdinstall: . distextract distfetch libexec partedit scripts X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Dec 2010 02:19:39 -0000 Author: nwhitehorn Date: Fri Dec 31 02:19:38 2010 New Revision: 216834 URL: http://svn.freebsd.org/changeset/base/216834 Log: Add a simple installer I wrote in a few days last week. It is capable of installing a booting system on 3 of the 6 platforms currently using sysinstall (amd64, i386, and powerpc). This is intended to replace sysinstall, but not to take the place of more full-featured installers like pc-sysinstall. The installer is shell- and dialog-based, but requires the new, vastly improved version of libdialog available from Thomas Dickey. Hopefully this can be imported into base once we no longer need the existing libdialog's consumers (sysinstall, sade, and tzsetup). Many features still needed. Slippery when wet. Etc. Added: user/nwhitehorn/bsdinstall/ user/nwhitehorn/bsdinstall/NOTES user/nwhitehorn/bsdinstall/README user/nwhitehorn/bsdinstall/bsdinstall (contents, props changed) user/nwhitehorn/bsdinstall/distextract/ user/nwhitehorn/bsdinstall/distextract/Makefile user/nwhitehorn/bsdinstall/distextract/distextract.c user/nwhitehorn/bsdinstall/distfetch/ user/nwhitehorn/bsdinstall/distfetch/Makefile user/nwhitehorn/bsdinstall/distfetch/distfetch.c user/nwhitehorn/bsdinstall/libexec/ user/nwhitehorn/bsdinstall/libexec/auto (contents, props changed) user/nwhitehorn/bsdinstall/libexec/config (contents, props changed) user/nwhitehorn/bsdinstall/libexec/distextract (contents, props changed) user/nwhitehorn/bsdinstall/libexec/distfetch (contents, props changed) user/nwhitehorn/bsdinstall/libexec/hostname (contents, props changed) user/nwhitehorn/bsdinstall/libexec/mediaselect (contents, props changed) user/nwhitehorn/bsdinstall/libexec/mount (contents, props changed) user/nwhitehorn/bsdinstall/libexec/netconfig (contents, props changed) user/nwhitehorn/bsdinstall/libexec/partedit (contents, props changed) user/nwhitehorn/bsdinstall/partedit/ user/nwhitehorn/bsdinstall/partedit/Makefile user/nwhitehorn/bsdinstall/partedit/diskeditor.c user/nwhitehorn/bsdinstall/partedit/diskeditor.h user/nwhitehorn/bsdinstall/partedit/gpart_ops.c user/nwhitehorn/bsdinstall/partedit/partedit.c user/nwhitehorn/bsdinstall/partedit/partedit.h user/nwhitehorn/bsdinstall/partedit/partedit_powerpc.c user/nwhitehorn/bsdinstall/partedit/partedit_x86.c user/nwhitehorn/bsdinstall/scripts/ user/nwhitehorn/bsdinstall/scripts/auto (contents, props changed) user/nwhitehorn/bsdinstall/scripts/config (contents, props changed) user/nwhitehorn/bsdinstall/scripts/hostname (contents, props changed) user/nwhitehorn/bsdinstall/scripts/mediaselect (contents, props changed) user/nwhitehorn/bsdinstall/scripts/mount (contents, props changed) user/nwhitehorn/bsdinstall/scripts/netconfig (contents, props changed) Added: user/nwhitehorn/bsdinstall/NOTES ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/NOTES Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1,3 @@ +Targets for tarballs: installkernel installworld (distrib-dirs distribution) + +Tools used in scripts: dialog sh awk sort cp dd ifconfig sysctl xargs mkdir mount cat uname netstat newfs Added: user/nwhitehorn/bsdinstall/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/README Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1,28 @@ +FreeBSD Stopgap Installer +========================= +Nathan Whitehorn +December 30, 2010 + +This is designed to be a lightweight replacement for sysinstall until future +installers show up, but more modular and easily extended. It is scriptable +from shell scripts. The full installer can be run by executing bsdinstall auto, +and is intended to be run from a live environment (e.g. a live CD or PXE boot). +bsdinstall must be in PATH. In addition to base tools, Thomas Dickey's new +dialog must be installed (devel/cdialog). + +Status: +- Installs working, bootable systems on powerpc, amd64, and i386 + +Missing features: +- Distfile fetching not entirely hooked up +- Root password configuration and user adding not yet added +- Network configuration sets up networking for the new system, but not (yet) + the current one + +Goals: +- Reinvent as few wheels as possible +- Extensability +- Scriptability without a scripting language -- the installer itself should + be a script a user can modify +- Minimal grubbing around in outputs of shell commands with awk, sed, etc. + Added: user/nwhitehorn/bsdinstall/bsdinstall ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/bsdinstall Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1,12 @@ +#!/bin/sh + +DISTRIBUTIONS="kernel world distribution"; export DISTRIBUTIONS +BSDINSTALL_LOG="/tmp/bsdinstall_log"; export BSDINSTALL_LOG +PATH_FSTAB="/tmp/fstab"; export PATH_FSTAB +BSDINSTALL_DISTDIR="/var/dist"; export BSDINSTALL_DISTDIR +BSDINSTALL_CHROOT="/mnt"; export BSDINSTALL_CHROOT + +VERB=$1 + +$(dirname $0)/libexec/$VERB + Added: user/nwhitehorn/bsdinstall/distextract/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/distextract/Makefile Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1,10 @@ +# $FreeBSD $ + +PROG= distextract +LDADD= -larchive -lncursesw -L/usr/local/lib -lcdialog +CFLAGS= -I/usr/local/include + +WARNS?= 6 +NO_MAN= true + +.include Added: user/nwhitehorn/bsdinstall/distextract/distextract.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/distextract/distextract.c Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1,174 @@ +#include +#include +#include +#include +#include + +static int extract_files(int nfiles, const char **files); + +int +main(void) +{ + char *diststring = strdup(getenv("DISTRIBUTIONS")); + const char **dists; + int i, retval, ndists = 0; + 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 *)); + for (i = 0; i < ndists; i++) + dists[i] = strsep(&diststring, " \t"); + + chdir(getenv("BSDINSTALL_CHROOT")); + retval = extract_files(ndists, dists); + + free(diststring); + free(dists); + + return (retval); +} + +static int +extract_files(int nfiles, const char **files) +{ + const char *items[nfiles*2]; + char path[PATH_MAX]; + int archive_files[nfiles]; + int total_files, current_files, archive_file; + struct archive *archive, *disk; + struct archive_entry *entry; + char errormsg[512]; + char status[8]; + const void *block; + size_t bsize; + off_t offset; + int i, err, progress, last_progress; + + err = 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]; + items[i*2 + 1] = "Pending"; + } + + init_dialog(stdin, stdout); + dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer"); + dlg_put_backtitle(); + dialog_msgbox("", + "Checking distribution archives.\nPlease wait...", 0, 0, FALSE); + + /* Open all the archives */ + total_files = 0; + for (i = 0; i < nfiles; i++) { + archive = archive_read_new(); + archive_read_support_format_all(archive); + archive_read_support_compression_all(archive); + sprintf(path, "%s/%s.tgz", getenv("BSDINSTALL_DISTDIR"), + files[i]); + err = archive_read_open_filename(archive, path, 4096); + if (err != ARCHIVE_OK) { + 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); + goto exit; + } + archive_files[i] = 0; + while (archive_read_next_header(archive, &entry) == ARCHIVE_OK) + archive_files[i]++; + total_files += archive_files[i]; + archive_read_free(archive); + } + + current_files = 0; + disk = archive_write_disk_new(); + archive_write_disk_set_options(disk, ARCHIVE_EXTRACT_TIME | + ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL | + ARCHIVE_EXTRACT_FFLAGS | ARCHIVE_EXTRACT_OWNER | + ARCHIVE_EXTRACT_XATTR); + archive_write_disk_set_standard_lookup(disk); + + for (i = 0; i < nfiles; i++) { + archive = archive_read_new(); + archive_read_support_format_all(archive); + archive_read_support_compression_all(archive); + sprintf(path, "%s/%s.tgz", getenv("BSDINSTALL_DISTDIR"), + files[i]); + err = archive_read_open_filename(archive, path, 4096); + + items[i*2 + 1] = "In Progress"; + archive_file = 0; + + while ((err = archive_read_next_header(archive, &entry)) == + ARCHIVE_OK) { + last_progress = progress; + progress = (current_files*100)/total_files; + + sprintf(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, + progress, nfiles, + __DECONST(char **, items)); + + err = archive_write_header(disk, entry); + if (err != ARCHIVE_OK) + break; + + while (1) { + err = archive_read_data_block(archive, + &block, &bsize, &offset); + if (err != ARCHIVE_OK) + break; + err = archive_write_data_block(disk, + block, bsize, offset); + if (err != ARCHIVE_OK) + break; + } + + if (err != ARCHIVE_EOF) + break; + archive_write_finish_entry(disk); + + archive_file++; + current_files++; + } + + items[i*2 + 1] = "Done"; + + if (err != ARCHIVE_EOF) { + const char *errstring; + if (archive_errno(archive) != 0) + errstring = archive_error_string(archive); + else + errstring = archive_error_string(disk); + + snprintf(errormsg, sizeof(errormsg), + "Error while extracting %s: %s\n", items[i*2], + errstring); + items[i*2 + 1] = "Failed"; + dialog_msgbox("Extract Error", errormsg, 0, 0, + TRUE); + goto exit; + } + + archive_read_free(archive); + } + +exit: + end_dialog(); + + return (err); +} Added: user/nwhitehorn/bsdinstall/distfetch/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/distfetch/Makefile Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1,10 @@ +# $FreeBSD $ + +PROG= distfetch +LDADD= -lfetch -lncursesw -L/usr/local/lib -lcdialog +CFLAGS= -I/usr/local/include + +WARNS?= 6 +NO_MAN= true + +.include Added: user/nwhitehorn/bsdinstall/distfetch/distfetch.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/distfetch/distfetch.c Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1,132 @@ +#include +#include +#include +#include +#include + +static int fetch_files(int nfiles, const char **urls); + +int +main(void) +{ + return (fetch_files(argc - 1, &argv[1])); +} + +static int +fetch_files(int nfiles, const char **urls) +{ + const char **items; + FILE *fetch_out, *file_out; + struct url_stat ustat; + off_t total_bytes, current_bytes; + char status[8]; + char errormsg[512]; + uint8_t block[4096]; + size_t chunk, fsize; + int i, progress, last_progress; + + /* Make the transfer list for dialog */ + items = calloc(sizeof(char *), nfiles * 2); + for (i = 0; i < nfiles; i++) { + items[i*2] = strrchr(urls[i], '/'); + if (items[i*2] != NULL) + items[i*2]++; + else + items[i*2] = urls[i]; + items[i*2 + 1] = "Pending"; + } + + init_dialog(stdin, stdout); + dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer"); + dlg_put_backtitle(); + + dialog_msgbox("", "Connecting to server.\nPlease wait...", 0, 0, FALSE); + + /* Try to stat all the files */ + total_bytes = 0; + for (i = 0; i < nfiles; i++) { + if (fetchStatURL(urls[i], &ustat, "") == 0 && ustat.size > 0) + total_bytes += ustat.size; + } + + current_bytes = 0; + for (i = 0; i < nfiles; i++) { + last_progress = progress; + if (total_bytes == 0) + progress = (i*100)/nfiles; + + fetchLastErrCode = 0; + fetch_out = fetchXGetURL(urls[i], &ustat, ""); + if (fetch_out == NULL) { + snprintf(errormsg, sizeof(errormsg), + "Error while fetching %s: %s\n", urls[i], + fetchLastErrString); + items[i*2 + 1] = "Failed"; + dialog_msgbox("Fetch Error", errormsg, 0, 0, + TRUE); + continue; + } + + items[i*2 + 1] = "In Progress"; + fsize = 0; + file_out = fopen(items[i*2], "w+"); + if (file_out == NULL) { + snprintf(errormsg, sizeof(errormsg), + "Error while fetching %s: %s\n", + urls[i], strerror(errno)); + items[i*2 + 1] = "Failed"; + dialog_msgbox("Fetch Error", errormsg, 0, 0, + TRUE); + fclose(fetch_out); + continue; + } + + while ((chunk = fread(block, 1, sizeof(block), fetch_out)) + > 0) { + if (fwrite(block, 1, chunk, file_out) < chunk) + break; + + current_bytes += chunk; + fsize += chunk; + + if (total_bytes > 0) { + last_progress = progress; + progress = (current_bytes*100)/total_bytes; + } + + if (ustat.size > 0) { + sprintf(status, "-%ld", (fsize*100)/ustat.size); + items[i*2 + 1] = status; + } + + if (progress > last_progress) + dialog_mixedgauge("Fetching Distribution", + "Fetching distribution files...", 0, 0, + progress, nfiles, + __DECONST(char **, items)); + } + + items[i*2 + 1] = "Done"; + + if (ustat.size > 0 && fsize < (size_t)ustat.size) { + if (fetchLastErrCode == 0) + snprintf(errormsg, sizeof(errormsg), + "Error while fetching %s: %s\n", + urls[i], strerror(errno)); + else + snprintf(errormsg, sizeof(errormsg), + "Error while fetching %s: %s\n", + urls[i], fetchLastErrString); + items[i*2 + 1] = "Failed"; + dialog_msgbox("Fetch Error", errormsg, 0, 0, + TRUE); + } + + fclose(fetch_out); + fclose(file_out); + } + end_dialog(); + + free(items); + return (0); +} Added: user/nwhitehorn/bsdinstall/libexec/auto ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/libexec/auto Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1 @@ +link ../scripts/auto \ No newline at end of file Added: user/nwhitehorn/bsdinstall/libexec/config ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/libexec/config Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1 @@ +link ../scripts/config \ No newline at end of file Added: user/nwhitehorn/bsdinstall/libexec/distextract ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/libexec/distextract Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1 @@ +link ../distextract/distextract \ No newline at end of file Added: user/nwhitehorn/bsdinstall/libexec/distfetch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/libexec/distfetch Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1 @@ +link ../distfetch/distfetch \ No newline at end of file Added: user/nwhitehorn/bsdinstall/libexec/hostname ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/libexec/hostname Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1 @@ +link ../scripts/hostname \ No newline at end of file Added: user/nwhitehorn/bsdinstall/libexec/mediaselect ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/libexec/mediaselect Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1 @@ +link ../scripts/mediaselect \ No newline at end of file Added: user/nwhitehorn/bsdinstall/libexec/mount ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/libexec/mount Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1 @@ +link ../scripts/mount \ No newline at end of file Added: user/nwhitehorn/bsdinstall/libexec/netconfig ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/libexec/netconfig Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1 @@ +link ../scripts/netconfig \ No newline at end of file Added: user/nwhitehorn/bsdinstall/libexec/partedit ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/libexec/partedit Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1 @@ +link ../partedit/partedit \ No newline at end of file Added: user/nwhitehorn/bsdinstall/partedit/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/partedit/Makefile Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1,20 @@ +# $FreeBSD $ + +PROG= partedit +LDADD= -lgeom -lncursesw -lutil -L/usr/local/lib -lcdialog +CFLAGS= -I/usr/local/include + +PARTEDIT_ARCH= ${MACHINE} +.if ${MACHINE} == "i386" || ${MACHINE} == "amd64" +PARTEDIT_ARCH= x86 +.endif +.if !exists(partedit_${PARTEDIT_ARCH}.c) +PARTEDIT_ARCH= generic +.endif + +SRCS= diskeditor.c partedit.c gpart_ops.c partedit_${PARTEDIT_ARCH}.c + +WARNS?= 3 +NO_MAN= true + +.include Added: user/nwhitehorn/bsdinstall/partedit/diskeditor.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/partedit/diskeditor.c Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1,233 @@ +#include +#include +#include +#include +#include + +#include "diskeditor.h" + +static void +print_partedit_item(WINDOW *partitions, struct partedit_item *items, + int item, int scroll, int selected) +{ + chtype attr = A_NORMAL; + char sizetext[16]; + int y = item - scroll + 1; + + wattrset(partitions, selected ? item_selected_attr : item_attr); + wmove(partitions, y, MARGIN + items[item].indentation*2); + dlg_print_text(partitions, items[item].name, 8, &attr); + wmove(partitions, y, 15); + wattrset(partitions, item_attr); + + humanize_number(sizetext, 7, items[item].size, "B", HN_AUTOSCALE, + HN_DECIMAL); + dlg_print_text(partitions, sizetext, 8, &attr); + wmove(partitions, y, 25); + dlg_print_text(partitions, items[item].type, 15, &attr); + wmove(partitions, y, 40); + if (items[item].mountpoint != NULL) + dlg_print_text(partitions, items[item].mountpoint, 8, &attr); +} + +int +diskeditor_show(const char *title, const char *cprompt, + struct partedit_item *items, int nitems, int *selected, int *scroll) +{ + WINDOW *dialog, *partitions; + char *prompt; + const char *buttons[] = + { "Create", "Delete", "Edit", "Revert", "Finished", NULL }; + int x, y; + int i; + int height, width, min_width; + int partlist_height, partlist_width, min_partlist_width; + int cur_scroll = 0; + int key, fkey; + int cur_button = 0, cur_part = 0; + int result = DLG_EXIT_UNKNOWN; + + static DLG_KEYS_BINDING binding[] = { + ENTERKEY_BINDINGS, + DLG_KEYS_DATA( DLGK_ENTER, ' ' ), + DLG_KEYS_DATA( DLGK_ITEM_NEXT, KEY_DOWN ), + DLG_KEYS_DATA( DLGK_ITEM_PREV, KEY_UP ), + DLG_KEYS_DATA( DLGK_FIELD_NEXT, KEY_RIGHT ), + DLG_KEYS_DATA( DLGK_FIELD_NEXT, TAB ), + DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_BTAB ), + DLG_KEYS_DATA( DLGK_FIELD_PREV, KEY_LEFT ), + + SCROLLKEY_BINDINGS, + END_KEYS_BINDING + }; + + /* + * Set up editor window. + */ + prompt = dlg_strclone(cprompt); + + min_width = 50; + height = width = 0; + partlist_height = 10; + min_partlist_width = 0; + dlg_tab_correct_str(prompt); + dlg_button_layout(buttons, &min_width); + dlg_auto_size(title, prompt, &height, &width, 2, min_width); + height += partlist_height; + partlist_width = width - 2*MARGIN; + dlg_print_size(height, width); + dlg_ctl_size(height, width); + + x = dlg_box_x_ordinate(width); + y = dlg_box_y_ordinate(height); + + dialog = dlg_new_window(height, width, y, x); + dlg_register_window(dialog, "diskeditorbox", binding); + dlg_register_buttons(dialog, "diskeditorbox", buttons); + + dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + dlg_draw_bottom_box(dialog); + dlg_draw_title(dialog, title); + wattrset(dialog, dialog_attr); + + /* Partition list sub-window */ + partitions = dlg_sub_window(dialog, partlist_height, partlist_width, + y + 3, x + 1); + dlg_register_window(partitions, "partlist", binding); + dlg_register_buttons(partitions, "partlist", buttons); + wattrset(partitions, menubox_attr); + + dlg_draw_buttons(dialog, height - 2*MARGIN, 0, buttons, + cur_button, FALSE, width); + dlg_print_autowrap(dialog, prompt, height, width); + + if (selected != NULL) + cur_part = *selected; + if (scroll != NULL) + cur_scroll = *scroll; + if (cur_part - cur_scroll >= partlist_height - 2 || + cur_part - cur_scroll < 0) + cur_scroll = cur_part; + +repaint: + dlg_draw_box(dialog, 3, 1, partlist_height, partlist_width, + menubox_border_attr, menubox_attr); + for (i = cur_scroll; i < MIN(cur_scroll + partlist_height - 2, nitems); + i++) + print_partedit_item(partitions, items, i, cur_scroll, + i == cur_part); + if (nitems > partlist_height - 2) + dlg_draw_arrows(partitions, cur_scroll > 0, + nitems > cur_scroll + partlist_height - 2, + partlist_width - 5, 0, partlist_height - 1); + wrefresh(partitions); + + while (result == DLG_EXIT_UNKNOWN) { + key = dlg_mouse_wgetch(dialog, &fkey); + if ((i = dlg_char_to_button(key, buttons)) >= 0) { + cur_button = i; + dlg_draw_buttons(dialog, height - 2*MARGIN, 0, buttons, + cur_button, FALSE, width); + break; + } + + if (!fkey) + continue; + + switch (key) { + case DLGK_FIELD_NEXT: + cur_button = dlg_next_button(buttons, cur_button); + if (cur_button < 0) + cur_button = 0; + dlg_draw_buttons(dialog, height - 2*MARGIN, 0, buttons, + cur_button, FALSE, width); + break; + case DLGK_FIELD_PREV: + cur_button = dlg_prev_button(buttons, cur_button); + if (cur_button < 0) + cur_button = 0; + dlg_draw_buttons(dialog, height - 2*MARGIN, 0, buttons, + cur_button, FALSE, width); + break; + case DLGK_ITEM_NEXT: + if (cur_part == nitems - 1) + break; /* End of list */ + + /* Deselect old item */ + print_partedit_item(partitions, items, cur_part, + cur_scroll, 0); + /* Select new item */ + cur_part++; + if (cur_part - cur_scroll >= partlist_height - 2) { + cur_scroll = cur_part; + goto repaint; + } + print_partedit_item(partitions, items, cur_part, + cur_scroll, 1); + wrefresh(partitions); + break; + case DLGK_ITEM_PREV: + if (cur_part == 0) + break; /* Start of list */ + + /* Deselect old item */ + print_partedit_item(partitions, items, cur_part, + cur_scroll, 0); + /* Select new item */ + cur_part--; + if (cur_part - cur_scroll < 0) { + cur_scroll = cur_part; + goto repaint; + } + print_partedit_item(partitions, items, cur_part, + cur_scroll, 1); + wrefresh(partitions); + break; + case DLGK_PAGE_NEXT: + cur_scroll += (partlist_height - 2); + if (cur_scroll + partlist_height - 2 >= nitems) + cur_scroll = nitems - (partlist_height - 2); + if (cur_part < cur_scroll) + cur_part = cur_scroll; + goto repaint; + case DLGK_PAGE_PREV: + cur_scroll -= (partlist_height - 2); + if (cur_scroll < 0) + cur_scroll = 0; + if (cur_part >= cur_scroll + partlist_height - 2) + cur_part = cur_scroll; + goto repaint; + case DLGK_PAGE_FIRST: + cur_scroll = 0; + cur_part = cur_scroll; + goto repaint; + case DLGK_PAGE_LAST: + cur_scroll = nitems - (partlist_height - 2); + cur_part = cur_scroll; + goto repaint; + case DLGK_ENTER: + goto done; + default: + if (is_DLGK_MOUSE(key)) { + cur_button = key - M_EVENT; + dlg_draw_buttons(dialog, height - 2*MARGIN, 0, + buttons, cur_button, FALSE, width); + goto done; + } + break; + } + } + +done: + if (selected != NULL) + *selected = cur_part; + if (scroll != NULL) + *scroll = cur_scroll; + + dlg_del_window(partitions); + dlg_del_window(dialog); + dlg_mouse_free_regions(); + + return (cur_button); +} + Added: user/nwhitehorn/bsdinstall/partedit/diskeditor.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/partedit/diskeditor.h Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1,13 @@ +struct partedit_item { + int indentation; + const char *name; + size_t size; + const char *type; + char *mountpoint; + + void *cookie; +}; + +int diskeditor_show(const char *title, const char *prompt, + struct partedit_item *items, int nitems, int *selected, int *scroll); + Added: user/nwhitehorn/bsdinstall/partedit/gpart_ops.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/nwhitehorn/bsdinstall/partedit/gpart_ops.c Fri Dec 31 02:19:38 2010 (r216834) @@ -0,0 +1,775 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include "partedit.h" + +#define GPART_FLAGS "x" /* Do not commit changes by default */ + +static void set_part_metadata(const char *name, const char *type, + const char *mountpoint, int newfs); + +static void +gpart_show_error(const char *title, const char *explanation, const char *errstr) +{ + char *errmsg; + char message[512]; + int error; + + if (explanation == NULL) + explanation = ""; + + error = strtol(errstr, &errmsg, 0); + if (errmsg != errstr) { + while (errmsg[0] == ' ') + errmsg++; + if (errmsg[0] != '\0') + sprintf(message, "%s%s. %s", explanation, + strerror(error), errmsg); + else + sprintf(message, "%s%s", explanation, strerror(error)); + } else { + sprintf(message, "%s%s", explanation, errmsg); + } + + dialog_msgbox(title, message, 0, 0, TRUE); +} + +static int +gpart_partition(struct gprovider *pp, const char *scheme) +{ + int cancel, choice; + struct gctl_req *r; + const char *errstr; + + DIALOG_LISTITEM items[] = { + {"APM", "Apple Partition Map", + "Bootable on PowerPC Apple Hardware", 0 }, + {"BSD", "BSD Labels", + "Bootable on most x86 systems", 0 }, + {"GPT", "GUID Partition Table", + "Bootable on most x86 systems", 0 }, + {"MBR", "DOS Partitions", + "Bootable on most x86 systems", 0 }, + {"PC98", "NEC PC9801 Partition Table", + "Bootable on NEC PC9801 systems", 0 }, + {"VTOC8", "Sun VTOC8 Partition Table", + "Bootable on Sun SPARC systems", 0 }, + }; + +schememenu: + if (scheme == NULL) { + cancel = dlg_menu("Partition Scheme", + "Select a partition scheme for this volume:", 0, 0, 0, + sizeof(items) / sizeof(items[0]), items, &choice, NULL); + + if (cancel) + return (-1); + + if (!is_scheme_bootable(items[choice].name)) { + char message[512]; + sprintf(message, "This partition scheme (%s) is not " + "bootable on this platform. Are you sure you want " + "to proceed?", items[choice].name); + dialog_vars.defaultno = TRUE; + cancel = dialog_yesno("Warning", message, 0, 0); + dialog_vars.defaultno = FALSE; + if (cancel) /* cancel */ + goto schememenu; + } + + scheme = items[choice].name; + } + + r = gctl_get_handle(); + gctl_ro_param(r, "class", -1, "PART"); + gctl_ro_param(r, "arg0", -1, pp->lg_geom->lg_name); + gctl_ro_param(r, "flags", -1, GPART_FLAGS); + gctl_ro_param(r, "scheme", -1, scheme); + gctl_ro_param(r, "verb", -1, "create"); + + errstr = gctl_issue(r); + if (errstr != NULL && errstr[0] != '\0') { + gpart_show_error("Error", NULL, errstr); + gctl_free(r); + scheme = NULL; + goto schememenu; + } + gctl_free(r); + + if (bootcode_path(scheme) != NULL) + get_part_metadata(pp->lg_geom->lg_name, 1)->bootcode = 1; + return (0); +} + +static void +gpart_bootcode(struct ggeom *gp) +{ + const char *bootcode; + struct gconfig *gc; + struct gctl_req *r; + const char *errstr, *scheme; + uint8_t *boot; + size_t bootsize, bytes; + int bootfd; + + /* + * Write default bootcode to the newly partitioned disk, if that + * applies on this platform. + */ + LIST_FOREACH(gc, &gp->lg_config, lg_config) { + if (strcmp(gc->lg_name, "scheme") == 0) { + scheme = gc->lg_val; + break; + } + } + + bootcode = bootcode_path(scheme); + if (bootcode == NULL) + return; + + bootfd = open(bootcode, O_RDONLY); + if (bootfd <= 0) { + dialog_msgbox("Bootcode Error", strerror(errno), 0, 0, + TRUE); + return; + } + + bootsize = lseek(bootfd, 0, SEEK_END); + boot = malloc(bootsize); + lseek(bootfd, 0, SEEK_SET); + bytes = 0; + while (bytes < bootsize) + bytes += read(bootfd, boot + bytes, bootsize - bytes); + close(bootfd); + + r = gctl_get_handle(); + gctl_ro_param(r, "class", -1, "PART"); + gctl_ro_param(r, "arg0", -1, gp->lg_name); + gctl_ro_param(r, "verb", -1, "bootcode"); + gctl_ro_param(r, "bootcode", bootsize, boot); + + errstr = gctl_issue(r); + if (errstr != NULL && errstr[0] != '\0') + gpart_show_error("Bootcode Error", NULL, errstr); + gctl_free(r); + free(boot); +} + +static void +gpart_partcode(struct gprovider *pp) +{ + struct gconfig *gc; + const char *scheme; + const char *indexstr; + char message[255], command[255]; + + LIST_FOREACH(gc, &pp->lg_geom->lg_config, lg_config) { + if (strcmp(gc->lg_name, "scheme") == 0) { + scheme = gc->lg_val; + break; + } + } + + LIST_FOREACH(gc, &pp->lg_config, lg_config) { + if (strcmp(gc->lg_name, "index") == 0) { + indexstr = gc->lg_val; + break; + } + } + + /* 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); + if (system(command) != 0) { + sprintf(message, "Error installing partcode on partition %s", + pp->lg_name); + dialog_msgbox("Error", message, 0, 0, TRUE); + } +} + +void +gpart_edit(struct gprovider *pp) +{ + struct gctl_req *r; + struct gconfig *gc; + struct gconsumer *cp; + struct gprovider *spp; + struct ggeom *geom; + const char *errstr, *oldtype; + struct partition_metadata *md; + char sizestr[32]; + intmax_t index; + int hadlabel, choice, junk; + 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}, + {0, "Size:", 5, 1, 0, FALSE, "", 11, 1, 12, 0, 0, + FALSE, "Partition size. Append K, M, G for kilobytes, " + "megabytes or gigabytes.", FALSE}, + {0, "Label:", 7, 2, 0, FALSE, "", 11, 2, 12, 15, 0, FALSE, + "Partition name. Not all partition schemes support this.", + FALSE}, + {0, "Mountpoint:", 11, 3, 0, FALSE, "", 11, 3, 12, 15, 0, + FALSE, "Path at which to mount this partition (leave blank " + "for swap)", FALSE}, + }; + + /* + * Find the PART geom we are manipulating. This may be a consumer of + * this provider, or its parent. Check the consumer case first. + */ + geom = NULL; + LIST_FOREACH(cp, &pp->lg_consumers, lg_consumers) + if (strcmp(cp->lg_geom->lg_class->lg_name, "PART") == 0) { + char message[512]; + /* + * The PART object is a consumer, so the user wants to + * edit the partition table. gpart doesn't really + * support this, so we have to hose the whole table + * first. + */ + + sprintf(message, "Changing the partition scheme on " + "this disk (%s) requires deleting all existing " + "partitions on this drive. This will PERMANENTLY " + "ERASE any data stored here. Are you sure you want " + "to proceed?", cp->lg_geom->lg_name); + dialog_vars.defaultno = TRUE; + choice = dialog_yesno("Warning", message, 0, 0); + dialog_vars.defaultno = FALSE; + + if (choice == 1) /* cancel */ + return; + + /* Begin with the hosing: delete all partitions */ + LIST_FOREACH(spp, &cp->lg_geom->lg_provider, + lg_provider) + gpart_delete(spp); + + /* Now destroy the geom itself */ + r = gctl_get_handle(); + gctl_ro_param(r, "class", -1, "PART"); + gctl_ro_param(r, "arg0", -1, cp->lg_geom->lg_name); + gctl_ro_param(r, "flags", -1, GPART_FLAGS); + gctl_ro_param(r, "verb", -1, "destroy"); + errstr = gctl_issue(r); + if (errstr != NULL && errstr[0] != '\0') + gpart_show_error("Error", NULL, errstr); + gctl_free(r); + + /* And any metadata */ + delete_part_metadata(cp->lg_geom->lg_name); + + /* Now re-partition and return */ + gpart_partition(pp, NULL); + return; + } + + if (geom == NULL && strcmp(pp->lg_geom->lg_class->lg_name, "PART") == 0) + geom = pp->lg_geom; + + if (geom == NULL) { + /* Disk not partitioned, so partition it */ + gpart_partition(pp, NULL); + return; + } + + /* Edit editable parameters of a partition */ + hadlabel = 0; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Fri Dec 31 11:18:55 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C85B1065670; Fri, 31 Dec 2010 11:18:55 +0000 (UTC) (envelope-from bruce@cran.org.uk) Received: from muon.cran.org.uk (muon.cran.org.uk [IPv6:2a01:348:0:15:5d59:5c40:0:1]) by mx1.freebsd.org (Postfix) with ESMTP id DEC0D8FC1F; Fri, 31 Dec 2010 11:18:54 +0000 (UTC) Received: from muon.cran.org.uk (localhost [127.0.0.1]) by muon.cran.org.uk (Postfix) with ESMTP id 97B7AE8A9F; Fri, 31 Dec 2010 11:18:53 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cran.org.uk; h=date:from :to:cc:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=mail; bh=dx4w/CRxBCmm Xc6vGfpCQqsXKUQ=; b=keuFKKESdVPQCC2CtzysiN+8M92tH+ST8T9m3Lc4dl7y ruczQGWsYaZO0EX1iN36AmogJch72snWIh85qNH0wyccs8pFaj6C/cr74Bq53+xj dCh+P0yyhMkbDlls1ScAKO8oVvut5gSxEW5//+YmWRnqLkemAwcUn8jjhK8DZUo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=cran.org.uk; h=date:from:to :cc:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; q=dns; s=mail; b=yAB1+C DP6/a2WBhju9i4lHoYXOAmO1ijleDfudO0cNrXR+Wp95ULXorqOq9mrsrP5/H4kp rzSVkxZcbkQolNnj77x/qss5Yz4BWO5LZkqoZSR7Zz2PVx/2t4unkg+BfR52YfRY Rw6zHKyIFW/KjZUgFPZ0BoHMIYPuxB3I+Oh6w= Received: from unknown (client-86-27-23-77.glfd.adsl.virginmedia.com [86.27.23.77]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by muon.cran.org.uk (Postfix) with ESMTPSA id 46052E625D; Fri, 31 Dec 2010 11:18:53 +0000 (GMT) Date: Fri, 31 Dec 2010 11:18:51 +0000 From: Bruce Cran To: Nathan Whitehorn Message-ID: <20101231111851.0000757f@unknown> In-Reply-To: <201012310219.oBV2JcPa058007@svn.freebsd.org> References: <201012310219.oBV2JcPa058007@svn.freebsd.org> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.16.0; i586-pc-mingw32msvc) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r216834 - in user/nwhitehorn/bsdinstall: . distextract distfetch libexec partedit scripts X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Dec 2010 11:18:55 -0000 On Fri, 31 Dec 2010 02:19:38 +0000 (UTC) Nathan Whitehorn wrote: > Author: nwhitehorn > Date: Fri Dec 31 02:19:38 2010 > New Revision: 216834 > URL: http://svn.freebsd.org/changeset/base/216834 > > Log: > Add a simple installer I wrote in a few days last week. It is > capable of installing a booting system on 3 of the 6 platforms > currently using sysinstall (amd64, i386, and powerpc). This is > intended to replace sysinstall, but not to take the place of more > full-featured installers like pc-sysinstall. +- Extensability Should be 'Extensibility'. Doesn't sysinstall have more features than pc-sysinstall? -- Bruce Cran From owner-svn-src-user@FreeBSD.ORG Fri Dec 31 15:08:53 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 324B71065670 for ; Fri, 31 Dec 2010 15:08:53 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from mail.icecube.wisc.edu (trout.icecube.wisc.edu [128.104.255.119]) by mx1.freebsd.org (Postfix) with ESMTP id 086068FC13 for ; Fri, 31 Dec 2010 15:08:52 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.icecube.wisc.edu (Postfix) with ESMTP id 0C00358133; Fri, 31 Dec 2010 08:50:23 -0600 (CST) X-Virus-Scanned: amavisd-new at icecube.wisc.edu Received: from mail.icecube.wisc.edu ([127.0.0.1]) by localhost (trout.icecube.wisc.edu [127.0.0.1]) (amavisd-new, port 10030) with ESMTP id g6sxEfJhevpM; Fri, 31 Dec 2010 08:50:22 -0600 (CST) Received: from comporellon.tachypleus.net (unknown [76.210.75.5]) by mail.icecube.wisc.edu (Postfix) with ESMTP id 6FF655811F; Fri, 31 Dec 2010 08:50:22 -0600 (CST) Message-ID: <4D1DEDAD.1080104@freebsd.org> Date: Fri, 31 Dec 2010 08:50:21 -0600 From: Nathan Whitehorn User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.13) Gecko/20101214 Thunderbird/3.1.7 MIME-Version: 1.0 To: Bruce Cran References: <201012310219.oBV2JcPa058007@svn.freebsd.org> <20101231111851.0000757f@unknown> In-Reply-To: <20101231111851.0000757f@unknown> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r216834 - in user/nwhitehorn/bsdinstall: . distextract distfetch libexec partedit scripts X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Dec 2010 15:08:53 -0000 On 12/31/10 05:18, Bruce Cran wrote: > On Fri, 31 Dec 2010 02:19:38 +0000 (UTC) > Nathan Whitehorn wrote: > >> Author: nwhitehorn >> Date: Fri Dec 31 02:19:38 2010 >> New Revision: 216834 >> URL: http://svn.freebsd.org/changeset/base/216834 >> >> Log: >> Add a simple installer I wrote in a few days last week. It is >> capable of installing a booting system on 3 of the 6 platforms >> currently using sysinstall (amd64, i386, and powerpc). This is >> intended to replace sysinstall, but not to take the place of more >> full-featured installers like pc-sysinstall. > +- Extensability > Should be 'Extensibility'. > > Doesn't sysinstall have more features than pc-sysinstall? > Yes, I can't spell apparently. Sysinstall may have more features than pc-sysinstall, but I don't have a lot of experience with pc-sysinstall -- it seemed more complicated, at least. This installer certainly has fewer features than either... -Nathan From owner-svn-src-user@FreeBSD.ORG Fri Dec 31 15:16:19 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 859AB106564A; Fri, 31 Dec 2010 15:16:19 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 73DCC8FC15; Fri, 31 Dec 2010 15:16:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBVFGJ3A078048; Fri, 31 Dec 2010 15:16:19 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBVFGJW6078040; Fri, 31 Dec 2010 15:16:19 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201012311516.oBVFGJW6078040@svn.freebsd.org> From: Nathan Whitehorn Date: Fri, 31 Dec 2010 15:16:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216842 - in user/nwhitehorn/bsdinstall: . distextract distfetch scripts X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Dec 2010 15:16:19 -0000 Author: nwhitehorn Date: Fri Dec 31 15:16:18 2010 New Revision: 216842 URL: http://svn.freebsd.org/changeset/base/216842 Log: Fix a spelling error pointed out by brucec, repair distfetch so it works again, and improve documentation. Modified: user/nwhitehorn/bsdinstall/NOTES user/nwhitehorn/bsdinstall/README user/nwhitehorn/bsdinstall/bsdinstall user/nwhitehorn/bsdinstall/distextract/distextract.c user/nwhitehorn/bsdinstall/distfetch/distfetch.c user/nwhitehorn/bsdinstall/scripts/auto Modified: user/nwhitehorn/bsdinstall/NOTES ============================================================================== --- user/nwhitehorn/bsdinstall/NOTES Fri Dec 31 14:03:57 2010 (r216841) +++ user/nwhitehorn/bsdinstall/NOTES Fri Dec 31 15:16:18 2010 (r216842) @@ -1,3 +1,15 @@ Targets for tarballs: installkernel installworld (distrib-dirs distribution) Tools used in scripts: dialog sh awk sort cp dd ifconfig sysctl xargs mkdir mount cat uname netstat newfs + +Environment variables affecting modules: +- DISTRIBUTIONS: List of tarballs to unpack, including .tgz extension +- BSDINSTALL_DISTDIR: Files system location at which to download distfiles and + from which to extract them +- BSDINSTALL_DISTSITE: Base URL for downloading distfiles. Will be downloaded + from $BSDINSTALL_DISTSITE/$DIST +- BSDINSTALL_LOG: Log file path for installation log +- PATH_FSTAB: fstab file to use. Need not exist yet. +- BSDINSTALL_CHROOT: Destination location for the installation. File systems + are mounted here and files installed to this path. + Modified: user/nwhitehorn/bsdinstall/README ============================================================================== --- user/nwhitehorn/bsdinstall/README Fri Dec 31 14:03:57 2010 (r216841) +++ user/nwhitehorn/bsdinstall/README Fri Dec 31 15:16:18 2010 (r216842) @@ -21,7 +21,7 @@ Missing features: Goals: - Reinvent as few wheels as possible -- Extensability +- Extensibility - Scriptability without a scripting language -- the installer itself should be a script a user can modify - Minimal grubbing around in outputs of shell commands with awk, sed, etc. Modified: user/nwhitehorn/bsdinstall/bsdinstall ============================================================================== --- user/nwhitehorn/bsdinstall/bsdinstall Fri Dec 31 14:03:57 2010 (r216841) +++ user/nwhitehorn/bsdinstall/bsdinstall Fri Dec 31 15:16:18 2010 (r216842) @@ -1,6 +1,6 @@ #!/bin/sh -DISTRIBUTIONS="kernel world distribution"; export DISTRIBUTIONS +DISTRIBUTIONS="kernel.tgz world.tgz distribution.tgz"; export DISTRIBUTIONS BSDINSTALL_LOG="/tmp/bsdinstall_log"; export BSDINSTALL_LOG PATH_FSTAB="/tmp/fstab"; export PATH_FSTAB BSDINSTALL_DISTDIR="/var/dist"; export BSDINSTALL_DISTDIR Modified: user/nwhitehorn/bsdinstall/distextract/distextract.c ============================================================================== --- user/nwhitehorn/bsdinstall/distextract/distextract.c Fri Dec 31 14:03:57 2010 (r216841) +++ user/nwhitehorn/bsdinstall/distextract/distextract.c Fri Dec 31 15:16:18 2010 (r216842) @@ -70,8 +70,7 @@ extract_files(int nfiles, const char **f archive = archive_read_new(); archive_read_support_format_all(archive); archive_read_support_compression_all(archive); - sprintf(path, "%s/%s.tgz", getenv("BSDINSTALL_DISTDIR"), - files[i]); + sprintf(path, "%s/%s", getenv("BSDINSTALL_DISTDIR"), files[i]); err = archive_read_open_filename(archive, path, 4096); if (err != ARCHIVE_OK) { snprintf(errormsg, sizeof(errormsg), @@ -101,8 +100,7 @@ extract_files(int nfiles, const char **f archive = archive_read_new(); archive_read_support_format_all(archive); archive_read_support_compression_all(archive); - sprintf(path, "%s/%s.tgz", getenv("BSDINSTALL_DISTDIR"), - files[i]); + sprintf(path, "%s/%s", getenv("BSDINSTALL_DISTDIR"), files[i]); err = archive_read_open_filename(archive, path, 4096); items[i*2 + 1] = "In Progress"; Modified: user/nwhitehorn/bsdinstall/distfetch/distfetch.c ============================================================================== --- user/nwhitehorn/bsdinstall/distfetch/distfetch.c Fri Dec 31 14:03:57 2010 (r216841) +++ user/nwhitehorn/bsdinstall/distfetch/distfetch.c Fri Dec 31 15:16:18 2010 (r216842) @@ -4,16 +4,37 @@ #include #include -static int fetch_files(int nfiles, const char **urls); +static int fetch_files(int nfiles, char **urls); int main(void) { - return (fetch_files(argc - 1, &argv[1])); + char *diststring = strdup(getenv("DISTRIBUTIONS")); + char **urls; + int i, retval, ndists = 0; + for (i = 0; diststring[i] != 0; i++) + if (isspace(diststring[i]) && !isspace(diststring[i+1])) + ndists++; + ndists++; /* Last one */ + + urls = calloc(ndists, sizeof(const char *)); + for (i = 0; i < ndists; i++) { + urls[i] = malloc(PATH_MAX); + sprintf(urls[i], "%s/%s", getenv("BSDINSTALL_DISTSITE"), + strsep(&diststring, " \t")); + } + + chdir(getenv("BSDINSTALL_DISTDIR")); + retval = fetch_files(ndists, urls); + + free(diststring); + for (i = 0; i < ndists; i++) + free(urls[i]); + free(urls); } static int -fetch_files(int nfiles, const char **urls) +fetch_files(int nfiles, char **urls) { const char **items; FILE *fetch_out, *file_out; Modified: user/nwhitehorn/bsdinstall/scripts/auto ============================================================================== --- user/nwhitehorn/bsdinstall/scripts/auto Fri Dec 31 14:03:57 2010 (r216841) +++ user/nwhitehorn/bsdinstall/scripts/auto Fri Dec 31 15:16:18 2010 (r216842) @@ -8,7 +8,7 @@ bsdinstall hostname FETCH_DISTRIBUTIONS="" for dist in $DISTRIBUTIONS; do - if [ ! -f $BSDINSTALL_DISTDIR/$dist.tgz ]; then + if [ ! -f $BSDINSTALL_DISTDIR/$dist ]; then FETCH_DISTRIBUTIONS="$FETCH_DISTRIBUTIONS $dist" fi done From owner-svn-src-user@FreeBSD.ORG Fri Dec 31 20:39:27 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AB949106564A; Fri, 31 Dec 2010 20:39:27 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9AA0B8FC0A; Fri, 31 Dec 2010 20:39:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBVKdROp087734; Fri, 31 Dec 2010 20:39:27 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBVKdR32087732; Fri, 31 Dec 2010 20:39:27 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201012312039.oBVKdR32087732@svn.freebsd.org> From: Nathan Whitehorn Date: Fri, 31 Dec 2010 20:39:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216854 - user/nwhitehorn/bsdinstall/partedit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Dec 2010 20:39:27 -0000 Author: nwhitehorn Date: Fri Dec 31 20:39:27 2010 New Revision: 216854 URL: http://svn.freebsd.org/changeset/base/216854 Log: Add support for MBR+bsdlabel installations, in addition to the already- supported GPT. Modified: user/nwhitehorn/bsdinstall/partedit/gpart_ops.c Modified: user/nwhitehorn/bsdinstall/partedit/gpart_ops.c ============================================================================== --- user/nwhitehorn/bsdinstall/partedit/gpart_ops.c Fri Dec 31 18:36:07 2010 (r216853) +++ user/nwhitehorn/bsdinstall/partedit/gpart_ops.c Fri Dec 31 20:39:27 2010 (r216854) @@ -41,7 +41,7 @@ gpart_show_error(const char *title, cons } static int -gpart_partition(struct gprovider *pp, const char *scheme) +gpart_partition(const char *lg_name, const char *scheme) { int cancel, choice; struct gctl_req *r; @@ -88,7 +88,7 @@ schememenu: r = gctl_get_handle(); gctl_ro_param(r, "class", -1, "PART"); - gctl_ro_param(r, "arg0", -1, pp->lg_geom->lg_name); + gctl_ro_param(r, "arg0", -1, lg_name); gctl_ro_param(r, "flags", -1, GPART_FLAGS); gctl_ro_param(r, "scheme", -1, scheme); gctl_ro_param(r, "verb", -1, "create"); @@ -103,11 +103,58 @@ schememenu: gctl_free(r); if (bootcode_path(scheme) != NULL) - get_part_metadata(pp->lg_geom->lg_name, 1)->bootcode = 1; + get_part_metadata(lg_name, 1)->bootcode = 1; return (0); } static void +gpart_activate(struct gprovider *pp) +{ + struct gconfig *gc; + struct gctl_req *r; + const char *errstr, *scheme; + const char *attribute = NULL; + intmax_t index; + + /* + * Some partition scemes need this partition to be marked 'active' + * for it to be bootable. + */ + LIST_FOREACH(gc, &pp->lg_geom->lg_config, lg_config) { + if (strcmp(gc->lg_name, "scheme") == 0) { + scheme = gc->lg_val; + break; + } + } + + if (strcmp(scheme, "MBR") == 0 || strcmp(scheme, "EBR") == 0 || + strcmp(scheme, "PC98") == 0) + attribute = "active"; + else + return; + + LIST_FOREACH(gc, &pp->lg_config, lg_config) { + if (strcmp(gc->lg_name, "index") == 0) { + index = atoi(gc->lg_val); + break; + } + } + + r = gctl_get_handle(); + gctl_ro_param(r, "class", -1, "PART"); + gctl_ro_param(r, "arg0", -1, pp->lg_geom->lg_name); + gctl_ro_param(r, "verb", -1, "set"); + gctl_ro_param(r, "attrib", -1, attribute); + gctl_ro_param(r, "index", sizeof(index), &index); + + errstr = gctl_issue(r); + if (errstr != NULL && errstr[0] != '\0') + gpart_show_error("Error", "Error marking partition active:", + errstr); + gctl_free(r); +} + +static void gpart_bootcode(struct ggeom *gp) { const char *bootcode; @@ -270,7 +317,7 @@ gpart_edit(struct gprovider *pp) delete_part_metadata(cp->lg_geom->lg_name); /* Now re-partition and return */ - gpart_partition(pp, NULL); + gpart_partition(cp->lg_geom->lg_name, NULL); return; } @@ -279,7 +326,7 @@ gpart_edit(struct gprovider *pp) if (geom == NULL) { /* Disk not partitioned, so partition it */ - gpart_partition(pp, NULL); + gpart_partition(pp->lg_geom->lg_name, NULL); return; } @@ -375,6 +422,8 @@ set_part_metadata(const char *name, cons if (strcmp(type, "freebsd-swap") == 0) mountpoint = "none"; + if (strcmp(type, "freebsd-boot") == 0) + md->bootcode = 1; if (mountpoint != NULL && mountpoint[0] != '\0') { if (md->fstab == NULL) { @@ -461,7 +510,7 @@ gpart_create(struct gprovider *pp) geom = pp->lg_geom; if (geom == NULL) { - if (gpart_partition(pp, NULL) == 0) + if (gpart_partition(pp->lg_geom->lg_name, NULL) == 0) dialog_msgbox("", "The partition table has been successfully created." " Please press Create again to create partitions.", @@ -522,7 +571,7 @@ gpart_create(struct gprovider *pp) items[1].text = sizestr; /* Special-case the MBR default type for nested partitions */ - if (strcmp("scheme", "MBR") == 0) + if (strcmp(scheme, "MBR") == 0) items[0].text = "freebsd"; addpartform: @@ -611,6 +660,8 @@ addpartform: if (strcmp(items[0].text, "freebsd-boot") == 0) get_part_metadata(strtok(output, " "), 1)->bootcode = 1; + else if (strcmp(items[0].text, "freebsd") == 0) + gpart_partition(strtok(output, " "), "BSD"); else set_part_metadata(strtok(output, " "), items[0].text, items[3].text, 1); @@ -734,6 +785,7 @@ gpart_commit(struct gmesh *mesh) struct partition_metadata *md; struct gclass *classp; struct ggeom *gp; + struct gconsumer *cp; struct gprovider *pp; struct gctl_req *r; const char *errstr; @@ -754,6 +806,25 @@ gpart_commit(struct gmesh *mesh) if (md != NULL && md->bootcode) gpart_bootcode(gp); + /* Now install partcode on its partitions, if necessary */ + LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { + md = get_part_metadata(pp->lg_name, 0); + if (md == NULL || !md->bootcode) + continue; + + /* Mark this partition active if that's required */ + gpart_activate(pp); + + /* Check if the partition has sub-partitions */ + LIST_FOREACH(cp, &pp->lg_consumers, lg_consumers) + if (strcmp(cp->lg_geom->lg_class->lg_name, + "PART") == 0) + break; + + if (cp == NULL) /* No sub-partitions */ + gpart_partcode(pp); + } + r = gctl_get_handle(); gctl_ro_param(r, "class", -1, "PART"); gctl_ro_param(r, "arg0", -1, gp->lg_name); @@ -763,13 +834,6 @@ gpart_commit(struct gmesh *mesh) if (errstr != NULL && errstr[0] != '\0') gpart_show_error("Error", NULL, errstr); gctl_free(r); - - /* Now install partcode on its partitions, if necessary */ - LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { - md = get_part_metadata(pp->lg_name, 0); - if (md != NULL && md->bootcode) - gpart_partcode(pp); - } } }