FreeBSD Bugzilla – Attachment 177357 Details for
Bug 202058
bsdinstall - Disable dialog(3) for distfetch/checksum/distextract targets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for -CURRENT (r309088)
patch-nonInteractive-r309088.txt (text/plain), 9.72 KB, created by
Ganael LAPLANCHE
on 2016-11-24 14:11:07 UTC
(
hide
)
Description:
Patch for -CURRENT (r309088)
Filename:
MIME Type:
Creator:
Ganael LAPLANCHE
Created:
2016-11-24 14:11:07 UTC
Size:
9.72 KB
patch
obsolete
>Index: usr.sbin/bsdinstall/distextract/distextract.c >=================================================================== >--- usr.sbin/bsdinstall/distextract/distextract.c (revision 309088) >+++ usr.sbin/bsdinstall/distextract/distextract.c (working copy) >@@ -41,6 +41,9 @@ > #include <string.h> > #include <unistd.h> > >+/* Enable/disable dialog(3) */ >+static uint8_t interactive = 1; >+ > /* Data to process */ > static char *distdir = NULL; > static struct archive *archive = NULL; >@@ -56,7 +59,7 @@ > archive_read_support_compression_all(x) > #endif > >-#define _errx(...) (end_dialog(), errx(__VA_ARGS__)) >+#define _errx(...) { if (interactive) end_dialog(); errx(__VA_ARGS__); } > > int > main(void) >@@ -76,6 +79,9 @@ > struct sigaction act; > char error[PATH_MAX + 512]; > >+ if (getenv("nonInteractive") != NULL) >+ interactive = 0; >+ > if ((distributions = getenv("DISTRIBUTIONS")) == NULL) > errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set"); > if ((distdir = getenv("BSDINSTALL_DISTDIR")) == NULL) >@@ -82,12 +88,16 @@ > distdir = __DECONST(char *, ""); > > /* Initialize dialog(3) */ >- init_dialog(stdin, stdout); >- dialog_vars.backtitle = backtitle; >- dlg_put_backtitle(); >+ if (interactive) { >+ init_dialog(stdin, stdout); >+ dialog_vars.backtitle = backtitle; >+ dlg_put_backtitle(); > >- dialog_msgbox("", >- "Checking distribution archives.\nPlease wait...", 4, 35, FALSE); >+ dialog_msgbox("", >+ "Checking distribution archives.\nPlease wait...", 4, 35, >+ FALSE); >+ } else >+ printf("Checking distribution archives. Please wait...\n"); > > /* > * Parse $DISTRIBUTIONS into dpv(3) linked-list >@@ -125,7 +135,8 @@ > /* Set initial length in files (-1 == error) */ > dist->length = count_files(dist->path); > if (dist->length < 0) { >- end_dialog(); >+ if (interactive) >+ end_dialog(); > return (EXIT_FAILURE); > } > >@@ -138,8 +149,11 @@ > snprintf(error, sizeof(error), > "Could not change to directory %s: %s\n", > chrootdir, strerror(errno)); >- dialog_msgbox("Error", error, 0, 0, TRUE); >- end_dialog(); >+ if (interactive) { >+ dialog_msgbox("Error", error, 0, 0, TRUE); >+ end_dialog(); >+ } else >+ fprintf(stderr, "%s", error); > return (EXIT_FAILURE); > } > >@@ -163,7 +177,10 @@ > "%10lli files read @ %'9.1f files/sec."; > config->status_many = > "%10lli files read @ %'9.1f files/sec. [%i/%i busy/wait]"; >- end_dialog(); >+ if (interactive) >+ end_dialog(); >+ else >+ config->display_type = DPV_DISPLAY_STDOUT; > retval = dpv(config, dists); > > dpv_free(); >@@ -235,7 +252,10 @@ > 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); >+ if (interactive) >+ dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE); >+ else >+ fprintf(stderr, "%s", errormsg); > return (-1); > } > archive_read_support_format_all(archive); >@@ -246,7 +266,10 @@ > snprintf(errormsg, sizeof(errormsg), > "Error while extracting %s: %s\n", file, > archive_error_string(archive)); >- dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE); >+ if (interactive) >+ dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE); >+ else >+ fprintf(stderr, "%s", errormsg); > archive = NULL; > return (-1); > } >@@ -273,7 +296,11 @@ > 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); >+ if (interactive) >+ dialog_msgbox("Extract Error", errormsg, 0, 0, >+ TRUE); >+ else >+ fprintf(stderr, "%s", errormsg); > dpv_abort = 1; > return (-1); > } >@@ -285,7 +312,11 @@ > snprintf(errormsg, sizeof(errormsg), > "Error opening %s: %s\n", file->name, > archive_error_string(archive)); >- dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE); >+ if (interactive) >+ dialog_msgbox("Extract Error", errormsg, 0, 0, >+ TRUE); >+ else >+ fprintf(stderr, "%s", errormsg); > file->status = DPV_STATUS_FAILED; > dpv_abort = 1; > return (-1); >@@ -312,7 +343,10 @@ > snprintf(errormsg, sizeof(errormsg), > "Error while extracting %s: %s\n", file->name, > archive_error_string(archive)); >- dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE); >+ if (interactive) >+ dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE); >+ else >+ fprintf(stderr, "%s", errormsg); > file->status = DPV_STATUS_FAILED; > dpv_abort = 1; > return (-1); >Index: usr.sbin/bsdinstall/distfetch/distfetch.c >=================================================================== >--- usr.sbin/bsdinstall/distfetch/distfetch.c (revision 309088) >+++ usr.sbin/bsdinstall/distfetch/distfetch.c (working copy) >@@ -39,6 +39,9 @@ > #include <string.h> > #include <unistd.h> > >+/* Enable/disable dialog(3) */ >+static uint8_t interactive = 1; >+ > static int fetch_files(int nfiles, char **urls); > > int >@@ -51,6 +54,9 @@ > int nfetched; > char error[PATH_MAX + 512]; > >+ if (getenv("nonInteractive") != NULL) >+ interactive = 0; >+ > if (getenv("DISTRIBUTIONS") == NULL) > errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set"); > >@@ -66,9 +72,11 @@ > errx(EXIT_FAILURE, "Out of memory!"); > } > >- init_dialog(stdin, stdout); >- dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer"); >- dlg_put_backtitle(); >+ if (interactive) { >+ init_dialog(stdin, stdout); >+ dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer"); >+ dlg_put_backtitle(); >+ } > > for (i = 0; i < ndists; i++) { > urls[i] = malloc(PATH_MAX); >@@ -80,14 +88,18 @@ > snprintf(error, sizeof(error), > "Could not change to directory %s: %s\n", > getenv("BSDINSTALL_DISTDIR"), strerror(errno)); >- dialog_msgbox("Error", error, 0, 0, TRUE); >- end_dialog(); >+ if (interactive) { >+ dialog_msgbox("Error", error, 0, 0, TRUE); >+ end_dialog(); >+ } else >+ fprintf(stderr, "%s", error); > return (EXIT_FAILURE); > } > > nfetched = fetch_files(ndists, urls); > >- end_dialog(); >+ if (interactive) >+ end_dialog(); > > free(diststring); > for (i = 0; i < ndists; i++) >@@ -130,7 +142,10 @@ > items[i*2 + 1] = "Pending"; > } > >- dialog_msgbox("", "Connecting to server.\nPlease wait...", 0, 0, FALSE); >+ if (interactive) >+ dialog_msgbox("", "Connecting to server.\nPlease wait...", 0, 0, FALSE); >+ else >+ printf("Connecting to server. Please wait...\n"); > > /* Try to stat all the files */ > total_bytes = 0; >@@ -145,6 +160,10 @@ > if (total_bytes == 0) > progress = (i*100)/nfiles; > >+ if (!interactive) { >+ printf("Fetching %s\n", urls[i]); >+ fflush(stdout); >+ } > fetchLastErrCode = 0; > fetch_out = fetchXGetURL(urls[i], &ustat, ""); > if (fetch_out == NULL) { >@@ -152,8 +171,11 @@ > "Error while fetching %s: %s\n", urls[i], > fetchLastErrString); > items[i*2 + 1] = "Failed"; >- dialog_msgbox("Fetch Error", errormsg, 0, 0, >- TRUE); >+ if (interactive) >+ dialog_msgbox("Fetch Error", errormsg, 0, 0, >+ TRUE); >+ else >+ fprintf(stderr, "%s", errormsg); > continue; > } > >@@ -165,8 +187,11 @@ > "Error while fetching %s: %s\n", > urls[i], strerror(errno)); > items[i*2 + 1] = "Failed"; >- dialog_msgbox("Fetch Error", errormsg, 0, 0, >- TRUE); >+ if (interactive) >+ dialog_msgbox("Fetch Error", errormsg, 0, 0, >+ TRUE); >+ else >+ fprintf(stderr, "%s", errormsg); > fclose(fetch_out); > continue; > } >@@ -190,7 +215,7 @@ > items[i*2 + 1] = status; > } > >- if (progress > last_progress) >+ if (interactive && (progress > last_progress)) > dialog_mixedgauge("Fetching Distribution", > "Fetching distribution files...", 0, 0, > progress, nfiles, >@@ -207,8 +232,11 @@ > "Error while fetching %s: %s\n", > urls[i], fetchLastErrString); > items[i*2 + 1] = "Failed"; >- dialog_msgbox("Fetch Error", errormsg, 0, 0, >- TRUE); >+ if (interactive) >+ dialog_msgbox("Fetch Error", errormsg, 0, 0, >+ TRUE); >+ else >+ fprintf(stderr, "%s", errormsg); > } else { > items[i*2 + 1] = "Done"; > nsuccess++; >Index: usr.sbin/bsdinstall/scripts/checksum >=================================================================== >--- usr.sbin/bsdinstall/scripts/checksum (revision 309088) >+++ usr.sbin/bsdinstall/scripts/checksum (working copy) >@@ -28,6 +28,11 @@ > > test -f $BSDINSTALL_DISTDIR/MANIFEST || exit 0 > >+BSDCFG_SHARE="/usr/share/bsdconfig" >+. $BSDCFG_SHARE/common.subr || exit 1 >+f_dprintf "%s: loading includes..." "$0" >+f_include $BSDCFG_SHARE/variable.subr >+ > percentage=0 > for dist in $DISTRIBUTIONS; do > distname=$(basename $dist .txz) >@@ -37,9 +42,13 @@ > for i in $DISTRIBUTIONS; do > items="$items $i `eval echo \\\${status_$(basename $i .txz):-Pending}`" > done >- dialog --backtitle "FreeBSD Installer" --title "Checksum Verification" \ >- --mixedgauge "Verifying checksums of selected distributions." \ >- 0 0 $percentage $items >+ if f_interactive; then >+ dialog --backtitle "FreeBSD Installer" --title "Checksum Verification" \ >+ --mixedgauge "Verifying checksums of selected distributions." \ >+ 0 0 $percentage $items >+ else >+ printf "Verifying checksum of %s\n" "$dist" >+ fi > > CK=`sha256 -q $BSDINSTALL_DISTDIR/$dist` > awk -v checksum=$CK -v dist=$dist -v found=0 '{ >@@ -62,8 +71,12 @@ > percentage=$(echo $percentage + 100/`echo $DISTRIBUTIONS | wc -w` | bc) > else > eval "status_$distname=1" >- dialog --backtitle "FreeBSD Installer" --title "Error" \ >- --msgbox "The checksum for $dist does not match. It may have become corrupted, and should be redownloaded." 0 0 >+ if f_interactive; then >+ dialog --backtitle "FreeBSD Installer" --title "Error" \ >+ --msgbox "The checksum for $dist does not match. It may have become corrupted, and should be redownloaded." 0 0 >+ else >+ f_err "The checksum for %s does not match. It may have become corrupted, and should be redownloaded.\n" "$dist" >+ fi > exit 1 > fi > done
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 202058
:
159488
|
177357
|
177485
|
177486