View | Details | Raw Unified | Return to bug 202058 | Differences between
and this patch

Collapse All | Expand All

(-)usr.sbin/bsdinstall/distextract/distextract.c (-15 / +49 lines)
Lines 41-46 Link Here
41
#include <string.h>
41
#include <string.h>
42
#include <unistd.h>
42
#include <unistd.h>
43
43
44
/* Enable/disable dialog(3) */
45
static uint8_t interactive = 1;
46
44
/* Data to process */
47
/* Data to process */
45
static char *distdir = NULL;
48
static char *distdir = NULL;
46
static struct archive *archive = NULL;
49
static struct archive *archive = NULL;
Lines 56-62 Link Here
56
	archive_read_support_compression_all(x)
59
	archive_read_support_compression_all(x)
57
#endif
60
#endif
58
61
59
#define _errx(...) (end_dialog(), errx(__VA_ARGS__))
62
#define _errx(...) { if (interactive) end_dialog(); errx(__VA_ARGS__); }
60
63
61
int
64
int
62
main(void)
65
main(void)
Lines 76-81 Link Here
76
	struct sigaction act;
79
	struct sigaction act;
77
	char error[PATH_MAX + 512];
80
	char error[PATH_MAX + 512];
78
81
82
	if (getenv("nonInteractive") != NULL)
83
		interactive = 0;
84
79
	if ((distributions = getenv("DISTRIBUTIONS")) == NULL)
85
	if ((distributions = getenv("DISTRIBUTIONS")) == NULL)
80
		errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set");
86
		errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set");
81
	if ((distdir = getenv("BSDINSTALL_DISTDIR")) == NULL)
87
	if ((distdir = getenv("BSDINSTALL_DISTDIR")) == NULL)
Lines 82-93 Link Here
82
		distdir = __DECONST(char *, "");
88
		distdir = __DECONST(char *, "");
83
89
84
	/* Initialize dialog(3) */
90
	/* Initialize dialog(3) */
85
	init_dialog(stdin, stdout);
91
	if (interactive) {
86
	dialog_vars.backtitle = backtitle;
92
		init_dialog(stdin, stdout);
87
	dlg_put_backtitle();
93
		dialog_vars.backtitle = backtitle;
94
		dlg_put_backtitle();
88
95
89
	dialog_msgbox("",
96
		dialog_msgbox("",
90
	    "Checking distribution archives.\nPlease wait...", 4, 35, FALSE);
97
		    "Checking distribution archives.\nPlease wait...", 4, 35,
98
		    FALSE);
99
	} else
100
		printf("Checking distribution archives. Please wait...\n");
91
101
92
	/*
102
	/*
93
	 * Parse $DISTRIBUTIONS into dpv(3) linked-list
103
	 * Parse $DISTRIBUTIONS into dpv(3) linked-list
Lines 125-131 Link Here
125
		/* Set initial length in files (-1 == error) */
135
		/* Set initial length in files (-1 == error) */
126
		dist->length = count_files(dist->path);
136
		dist->length = count_files(dist->path);
127
		if (dist->length < 0) {
137
		if (dist->length < 0) {
128
			end_dialog();
138
			if (interactive)
139
				end_dialog();
129
			return (EXIT_FAILURE);
140
			return (EXIT_FAILURE);
130
		}
141
		}
131
142
Lines 138-145 Link Here
138
		snprintf(error, sizeof(error),
149
		snprintf(error, sizeof(error),
139
		    "Could not change to directory %s: %s\n",
150
		    "Could not change to directory %s: %s\n",
140
		    chrootdir, strerror(errno));
151
		    chrootdir, strerror(errno));
141
		dialog_msgbox("Error", error, 0, 0, TRUE);
152
		if (interactive) {
142
		end_dialog();
153
			dialog_msgbox("Error", error, 0, 0, TRUE);
154
			end_dialog();
155
		} else
156
			fprintf(stderr, "%s", error);
143
		return (EXIT_FAILURE);
157
		return (EXIT_FAILURE);
144
	}
158
	}
145
159
Lines 163-169 Link Here
163
	    "%10lli files read @ %'9.1f files/sec.";
177
	    "%10lli files read @ %'9.1f files/sec.";
164
	config->status_many	= 
178
	config->status_many	= 
165
	    "%10lli files read @ %'9.1f files/sec. [%i/%i busy/wait]";
179
	    "%10lli files read @ %'9.1f files/sec. [%i/%i busy/wait]";
166
	end_dialog();
180
	if (interactive)
181
		end_dialog();
182
	else
183
		config->display_type = DPV_DISPLAY_STDOUT;
167
	retval = dpv(config, dists);
184
	retval = dpv(config, dists);
168
185
169
	dpv_free();
186
	dpv_free();
Lines 235-241 Link Here
235
	if ((archive = archive_read_new()) == NULL) {
252
	if ((archive = archive_read_new()) == NULL) {
236
		snprintf(errormsg, sizeof(errormsg),
253
		snprintf(errormsg, sizeof(errormsg),
237
		    "Error: %s\n", archive_error_string(NULL));
254
		    "Error: %s\n", archive_error_string(NULL));
238
		dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
255
		if (interactive)
256
			dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
257
		else
258
			fprintf(stderr, "%s", errormsg);
239
		return (-1);
259
		return (-1);
240
	}
260
	}
241
	archive_read_support_format_all(archive);
261
	archive_read_support_format_all(archive);
Lines 246-252 Link Here
246
		snprintf(errormsg, sizeof(errormsg),
266
		snprintf(errormsg, sizeof(errormsg),
247
		    "Error while extracting %s: %s\n", file,
267
		    "Error while extracting %s: %s\n", file,
248
		    archive_error_string(archive));
268
		    archive_error_string(archive));
249
		dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
269
		if (interactive)
270
			dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
271
		else
272
			fprintf(stderr, "%s", errormsg);
250
		archive = NULL;
273
		archive = NULL;
251
		return (-1);
274
		return (-1);
252
	}
275
	}
Lines 273-279 Link Here
273
		if ((archive = archive_read_new()) == NULL) {
296
		if ((archive = archive_read_new()) == NULL) {
274
			snprintf(errormsg, sizeof(errormsg),
297
			snprintf(errormsg, sizeof(errormsg),
275
			    "Error: %s\n", archive_error_string(NULL));
298
			    "Error: %s\n", archive_error_string(NULL));
276
			dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
299
			if (interactive)
300
				dialog_msgbox("Extract Error", errormsg, 0, 0,
301
				    TRUE);
302
			else
303
				fprintf(stderr, "%s", errormsg);
277
			dpv_abort = 1;
304
			dpv_abort = 1;
278
			return (-1);
305
			return (-1);
279
		}
306
		}
Lines 285-291 Link Here
285
			snprintf(errormsg, sizeof(errormsg),
312
			snprintf(errormsg, sizeof(errormsg),
286
			    "Error opening %s: %s\n", file->name,
313
			    "Error opening %s: %s\n", file->name,
287
			    archive_error_string(archive));
314
			    archive_error_string(archive));
288
			dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
315
			if (interactive)
316
				dialog_msgbox("Extract Error", errormsg, 0, 0,
317
				    TRUE);
318
			else
319
				fprintf(stderr, "%s", errormsg);
289
			file->status = DPV_STATUS_FAILED;
320
			file->status = DPV_STATUS_FAILED;
290
			dpv_abort = 1;
321
			dpv_abort = 1;
291
			return (-1);
322
			return (-1);
Lines 312-318 Link Here
312
		snprintf(errormsg, sizeof(errormsg),
343
		snprintf(errormsg, sizeof(errormsg),
313
		    "Error while extracting %s: %s\n", file->name,
344
		    "Error while extracting %s: %s\n", file->name,
314
		    archive_error_string(archive));
345
		    archive_error_string(archive));
315
		dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
346
		if (interactive)
347
			dialog_msgbox("Extract Error", errormsg, 0, 0, TRUE);
348
		else
349
			fprintf(stderr, "%s", errormsg);
316
		file->status = DPV_STATUS_FAILED;
350
		file->status = DPV_STATUS_FAILED;
317
		dpv_abort = 1;
351
		dpv_abort = 1;
318
		return (-1);
352
		return (-1);
(-)usr.sbin/bsdinstall/distfetch/distfetch.c (-14 / +42 lines)
Lines 39-44 Link Here
39
#include <string.h>
39
#include <string.h>
40
#include <unistd.h>
40
#include <unistd.h>
41
41
42
/* Enable/disable dialog(3) */
43
static uint8_t interactive = 1;
44
42
static int fetch_files(int nfiles, char **urls);
45
static int fetch_files(int nfiles, char **urls);
43
46
44
int
47
int
Lines 51-56 Link Here
51
	int nfetched;
54
	int nfetched;
52
	char error[PATH_MAX + 512];
55
	char error[PATH_MAX + 512];
53
56
57
	if (getenv("nonInteractive") != NULL)
58
		interactive = 0;
59
54
	if (getenv("DISTRIBUTIONS") == NULL)
60
	if (getenv("DISTRIBUTIONS") == NULL)
55
		errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set");
61
		errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set");
56
62
Lines 66-74 Link Here
66
		errx(EXIT_FAILURE, "Out of memory!");
72
		errx(EXIT_FAILURE, "Out of memory!");
67
	}
73
	}
68
74
69
	init_dialog(stdin, stdout);
75
	if (interactive) {
70
	dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer");
76
		init_dialog(stdin, stdout);
71
	dlg_put_backtitle();
77
		dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer");
78
		dlg_put_backtitle();
79
	}
72
80
73
	for (i = 0; i < ndists; i++) {
81
	for (i = 0; i < ndists; i++) {
74
		urls[i] = malloc(PATH_MAX);
82
		urls[i] = malloc(PATH_MAX);
Lines 80-93 Link Here
80
		snprintf(error, sizeof(error),
88
		snprintf(error, sizeof(error),
81
		    "Could not change to directory %s: %s\n",
89
		    "Could not change to directory %s: %s\n",
82
		    getenv("BSDINSTALL_DISTDIR"), strerror(errno));
90
		    getenv("BSDINSTALL_DISTDIR"), strerror(errno));
83
		dialog_msgbox("Error", error, 0, 0, TRUE);
91
		if (interactive) {
84
		end_dialog();
92
			dialog_msgbox("Error", error, 0, 0, TRUE);
93
			end_dialog();
94
		} else
95
			fprintf(stderr, "%s", error);
85
		return (EXIT_FAILURE);
96
		return (EXIT_FAILURE);
86
	}
97
	}
87
98
88
	nfetched = fetch_files(ndists, urls);
99
	nfetched = fetch_files(ndists, urls);
89
100
90
	end_dialog();
101
	if (interactive)
102
		end_dialog();
91
103
92
	free(diststring);
104
	free(diststring);
93
	for (i = 0; i < ndists; i++) 
105
	for (i = 0; i < ndists; i++) 
Lines 130-136 Link Here
130
		items[i*2 + 1] = "Pending";
142
		items[i*2 + 1] = "Pending";
131
	}
143
	}
132
144
133
	dialog_msgbox("", "Connecting to server.\nPlease wait...", 0, 0, FALSE);
145
	if (interactive)
146
		dialog_msgbox("", "Connecting to server.\nPlease wait...", 0, 0, FALSE);
147
	else
148
		printf("Connecting to server. Please wait...\n");
134
149
135
	/* Try to stat all the files */
150
	/* Try to stat all the files */
136
	total_bytes = 0;
151
	total_bytes = 0;
Lines 145-150 Link Here
145
		if (total_bytes == 0)
160
		if (total_bytes == 0)
146
			progress = (i*100)/nfiles;
161
			progress = (i*100)/nfiles;
147
162
163
		if (!interactive) {
164
			printf("Fetching %s\n", urls[i]);
165
			fflush(stdout);
166
		}
148
		fetchLastErrCode = 0;
167
		fetchLastErrCode = 0;
149
		fetch_out = fetchXGetURL(urls[i], &ustat, "");
168
		fetch_out = fetchXGetURL(urls[i], &ustat, "");
150
		if (fetch_out == NULL) {
169
		if (fetch_out == NULL) {
Lines 152-159 Link Here
152
			    "Error while fetching %s: %s\n", urls[i],
171
			    "Error while fetching %s: %s\n", urls[i],
153
			    fetchLastErrString);
172
			    fetchLastErrString);
154
			items[i*2 + 1] = "Failed";
173
			items[i*2 + 1] = "Failed";
155
			dialog_msgbox("Fetch Error", errormsg, 0, 0,
174
			if (interactive)
156
			    TRUE);
175
				dialog_msgbox("Fetch Error", errormsg, 0, 0,
176
				    TRUE);
177
			else
178
				fprintf(stderr, "%s", errormsg);
157
			continue;
179
			continue;
158
		}
180
		}
159
181
Lines 165-172 Link Here
165
			    "Error while fetching %s: %s\n",
187
			    "Error while fetching %s: %s\n",
166
			    urls[i], strerror(errno));
188
			    urls[i], strerror(errno));
167
			items[i*2 + 1] = "Failed";
189
			items[i*2 + 1] = "Failed";
168
			dialog_msgbox("Fetch Error", errormsg, 0, 0,
190
			if (interactive)
169
			    TRUE);
191
				dialog_msgbox("Fetch Error", errormsg, 0, 0,
192
				    TRUE);
193
			else
194
				fprintf(stderr, "%s", errormsg);
170
			fclose(fetch_out);
195
			fclose(fetch_out);
171
			continue;
196
			continue;
172
		}
197
		}
Lines 190-196 Link Here
190
				items[i*2 + 1] = status;
215
				items[i*2 + 1] = status;
191
			}
216
			}
192
217
193
			if (progress > last_progress)
218
			if (interactive && (progress > last_progress))
194
				dialog_mixedgauge("Fetching Distribution",
219
				dialog_mixedgauge("Fetching Distribution",
195
				    "Fetching distribution files...", 0, 0,
220
				    "Fetching distribution files...", 0, 0,
196
				    progress, nfiles,
221
				    progress, nfiles,
Lines 207-214 Link Here
207
				    "Error while fetching %s: %s\n",
232
				    "Error while fetching %s: %s\n",
208
				    urls[i], fetchLastErrString);
233
				    urls[i], fetchLastErrString);
209
			items[i*2 + 1] = "Failed";
234
			items[i*2 + 1] = "Failed";
210
			dialog_msgbox("Fetch Error", errormsg, 0, 0,
235
			if (interactive)
211
				    TRUE);
236
				dialog_msgbox("Fetch Error", errormsg, 0, 0,
237
					    TRUE);
238
			else
239
				fprintf(stderr, "%s", errormsg);
212
		} else {
240
		} else {
213
			items[i*2 + 1] = "Done";
241
			items[i*2 + 1] = "Done";
214
			nsuccess++;
242
			nsuccess++;
(-)usr.sbin/bsdinstall/scripts/checksum (-5 / +18 lines)
Lines 28-33 Link Here
28
28
29
test -f $BSDINSTALL_DISTDIR/MANIFEST || exit 0
29
test -f $BSDINSTALL_DISTDIR/MANIFEST || exit 0
30
30
31
BSDCFG_SHARE="/usr/share/bsdconfig"
32
. $BSDCFG_SHARE/common.subr || exit 1
33
f_dprintf "%s: loading includes..." "$0"
34
f_include $BSDCFG_SHARE/variable.subr
35
31
percentage=0
36
percentage=0
32
for dist in $DISTRIBUTIONS; do
37
for dist in $DISTRIBUTIONS; do
33
	distname=$(basename $dist .txz)
38
	distname=$(basename $dist .txz)
Lines 37-45 Link Here
37
	for i in $DISTRIBUTIONS; do
42
	for i in $DISTRIBUTIONS; do
38
		items="$items $i `eval echo \\\${status_$(basename $i .txz):-Pending}`"
43
		items="$items $i `eval echo \\\${status_$(basename $i .txz):-Pending}`"
39
	done
44
	done
40
	dialog --backtitle "FreeBSD Installer" --title "Checksum Verification" \
45
	if f_interactive; then
41
	    --mixedgauge "Verifying checksums of selected distributions." \
46
		dialog --backtitle "FreeBSD Installer" --title "Checksum Verification" \
42
	    0 0 $percentage $items
47
		    --mixedgauge "Verifying checksums of selected distributions." \
48
		    0 0 $percentage $items
49
	else
50
		printf "Verifying checksum of %s\n" "$dist"
51
	fi
43
52
44
	CK=`sha256 -q $BSDINSTALL_DISTDIR/$dist`
53
	CK=`sha256 -q $BSDINSTALL_DISTDIR/$dist`
45
	awk -v checksum=$CK -v dist=$dist -v found=0 '{
54
	awk -v checksum=$CK -v dist=$dist -v found=0 '{
Lines 62-69 Link Here
62
		percentage=$(echo $percentage + 100/`echo $DISTRIBUTIONS | wc -w` | bc)
71
		percentage=$(echo $percentage + 100/`echo $DISTRIBUTIONS | wc -w` | bc)
63
	else
72
	else
64
		eval "status_$distname=1"
73
		eval "status_$distname=1"
65
		dialog --backtitle "FreeBSD Installer" --title "Error" \
74
		if f_interactive; then
66
		    --msgbox "The checksum for $dist does not match. It may have become corrupted, and should be redownloaded." 0 0
75
			dialog --backtitle "FreeBSD Installer" --title "Error" \
76
			    --msgbox "The checksum for $dist does not match. It may have become corrupted, and should be redownloaded." 0 0
77
		else
78
			f_err "The checksum for %s does not match. It may have become corrupted, and should be redownloaded.\n" "$dist"
79
		fi
67
		exit 1
80
		exit 1
68
	fi
81
	fi
69
done
82
done

Return to bug 202058