FreeBSD Bugzilla – Attachment 177486 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 distfetch r309246
patch-notty-distfetch-r309246.txt (text/plain), 4.61 KB, created by
Ganael LAPLANCHE
on 2016-11-28 14:43:37 UTC
(
hide
)
Description:
Patch for distfetch r309246
Filename:
MIME Type:
Creator:
Ganael LAPLANCHE
Created:
2016-11-28 14:43:37 UTC
Size:
4.61 KB
patch
obsolete
>Index: usr.sbin/bsdinstall/distfetch/Makefile >=================================================================== >--- usr.sbin/bsdinstall/distfetch/Makefile (revision 309246) >+++ usr.sbin/bsdinstall/distfetch/Makefile (working copy) >@@ -1,9 +1,16 @@ > # $FreeBSD$ > >+.include <src.opts.mk> >+ > BINDIR= ${LIBEXECDIR}/bsdinstall > PROG= distfetch >-LIBADD= fetch ncursesw dialog m >+LIBADD= fetch m > >+.if ${MK_DIALOG} != no >+CFLAGS+= -DHAVE_DIALOG >+LIBADD+= ncursesw dialog >+.endif >+ > WARNS?= 6 > MAN= > >Index: usr.sbin/bsdinstall/distfetch/distfetch.c >=================================================================== >--- usr.sbin/bsdinstall/distfetch/distfetch.c (revision 309246) >+++ usr.sbin/bsdinstall/distfetch/distfetch.c (working copy) >@@ -31,14 +31,22 @@ > #include <sys/param.h> > #include <ctype.h> > #include <err.h> >+#ifdef HAVE_DIALOG > #include <dialog.h> >+#endif > #include <errno.h> >+#include <stdio.h> > #include <fetch.h> >-#include <stdio.h> > #include <stdlib.h> > #include <string.h> > #include <unistd.h> > >+#ifdef HAVE_DIALOG >+/* Enable/disable dialog(3) */ >+static uint8_t notty = 0; >+#define _hastty (!notty) >+#endif >+ > static int fetch_files(int nfiles, char **urls); > > int >@@ -51,6 +59,11 @@ > int nfetched; > char error[PATH_MAX + 512]; > >+#ifdef HAVE_DIALOG >+ if ((getenv("noTty") != NULL) || !isatty(fileno(stdout))) >+ notty = 1; >+#endif >+ > if (getenv("DISTRIBUTIONS") == NULL) > errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set"); > >@@ -66,9 +79,13 @@ > errx(EXIT_FAILURE, "Out of memory!"); > } > >- init_dialog(stdin, stdout); >- dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer"); >- dlg_put_backtitle(); >+#ifdef HAVE_DIALOG >+ if (_hastty) { >+ init_dialog(stdin, stdout); >+ dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer"); >+ dlg_put_backtitle(); >+ } >+#endif > > for (i = 0; i < ndists; i++) { > urls[i] = malloc(PATH_MAX); >@@ -80,14 +97,22 @@ > 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(); >+#ifdef HAVE_DIALOG >+ if (_hastty) { >+ dialog_msgbox("Error", error, 0, 0, TRUE); >+ end_dialog(); >+ } else >+#endif >+ fprintf(stderr, "%s", error); > return (EXIT_FAILURE); > } > > nfetched = fetch_files(ndists, urls); > >- end_dialog(); >+#ifdef HAVE_DIALOG >+ if (_hastty) >+ end_dialog(); >+#endif > > free(diststring); > for (i = 0; i < ndists; i++) >@@ -130,7 +155,13 @@ > items[i*2 + 1] = "Pending"; > } > >- dialog_msgbox("", "Connecting to server.\nPlease wait...", 0, 0, FALSE); >+#ifdef HAVE_DIALOG >+ if (_hastty) >+ dialog_msgbox("", >+ "Connecting to server.\nPlease wait...", 0, 0, FALSE); >+ else >+#endif >+ printf("Connecting to server. Please wait...\n"); > > /* Try to stat all the files */ > total_bytes = 0; >@@ -145,6 +176,14 @@ > if (total_bytes == 0) > progress = (i*100)/nfiles; > >+#ifdef HAVE_DIALOG >+ if (!_hastty) { >+#endif >+ printf("Fetching %s\n", urls[i]); >+ fflush(stdout); >+#ifdef HAVE_DIALOG >+ } >+#endif > fetchLastErrCode = 0; > fetch_out = fetchXGetURL(urls[i], &ustat, ""); > if (fetch_out == NULL) { >@@ -152,8 +191,13 @@ > "Error while fetching %s: %s\n", urls[i], > fetchLastErrString); > items[i*2 + 1] = "Failed"; >- dialog_msgbox("Fetch Error", errormsg, 0, 0, >- TRUE); >+#ifdef HAVE_DIALOG >+ if (_hastty) >+ dialog_msgbox("Fetch Error", errormsg, 0, 0, >+ TRUE); >+ else >+#endif >+ fprintf(stderr, "%s", errormsg); > continue; > } > >@@ -165,8 +209,13 @@ > "Error while fetching %s: %s\n", > urls[i], strerror(errno)); > items[i*2 + 1] = "Failed"; >- dialog_msgbox("Fetch Error", errormsg, 0, 0, >- TRUE); >+#ifdef HAVE_DIALOG >+ if (_hastty) >+ dialog_msgbox("Fetch Error", errormsg, 0, 0, >+ TRUE); >+ else >+#endif >+ fprintf(stderr, "%s", errormsg); > fclose(fetch_out); > continue; > } >@@ -190,11 +239,13 @@ > items[i*2 + 1] = status; > } > >- if (progress > last_progress) >+#ifdef HAVE_DIALOG >+ if (_hastty && (progress > last_progress)) > dialog_mixedgauge("Fetching Distribution", > "Fetching distribution files...", 0, 0, > progress, nfiles, > __DECONST(char **, items)); >+#endif > } > > if (ustat.size > 0 && fsize < ustat.size) { >@@ -207,8 +258,13 @@ > "Error while fetching %s: %s\n", > urls[i], fetchLastErrString); > items[i*2 + 1] = "Failed"; >- dialog_msgbox("Fetch Error", errormsg, 0, 0, >- TRUE); >+#ifdef HAVE_DIALOG >+ if (_hastty) >+ dialog_msgbox("Fetch Error", errormsg, 0, 0, >+ TRUE); >+ else >+#endif >+ fprintf(stderr, "%s", errormsg); > } else { > items[i*2 + 1] = "Done"; > nsuccess++;
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