Deleted Added
full compact
dist.c (8820) dist.c (8837)
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last program in the `sysinstall' line - the next
5 * generation being essentially a complete rewrite.
6 *
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last program in the `sysinstall' line - the next
5 * generation being essentially a complete rewrite.
6 *
7 * $Id: dist.c,v 1.30 1995/05/28 09:43:36 jkh Exp $
7 * $Id: dist.c,v 1.31 1995/05/28 20:28:11 jkh Exp $
8 *
9 * Copyright (c) 1995
10 * Jordan Hubbard. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright

--- 229 unchanged lines hidden (view full) ---

245 }
246
247 dist = me[i].my_name;
248 path = parent ? parent : me[i].my_name;
249
250 snprintf(buf, 512, "%s/%s.tgz", path, dist);
251 fd = (*mediaDevice->get)(buf);
252 if (fd != -1) {
8 *
9 * Copyright (c) 1995
10 * Jordan Hubbard. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright

--- 229 unchanged lines hidden (view full) ---

245 }
246
247 dist = me[i].my_name;
248 path = parent ? parent : me[i].my_name;
249
250 snprintf(buf, 512, "%s/%s.tgz", path, dist);
251 fd = (*mediaDevice->get)(buf);
252 if (fd != -1) {
253 status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd);
253 msgNotify("Extracting %s into %s directory...", me[i].my_name, me[i].my_dir);
254 status = mediaExtractDist(me[i].my_dir, fd);
254 if (mediaDevice->close)
255 (*mediaDevice->close)(mediaDevice, fd);
256 else
257 close(fd);
258 goto done;
259 }
260
261 snprintf(buf, sizeof buf, "/stand/info/%s/%s.inf", path, dist);
262 if (!access(buf, R_OK)) {
255 if (mediaDevice->close)
256 (*mediaDevice->close)(mediaDevice, fd);
257 else
258 close(fd);
259 goto done;
260 }
261
262 snprintf(buf, sizeof buf, "/stand/info/%s/%s.inf", path, dist);
263 if (!access(buf, R_OK)) {
263 msgDebug("Parsing attributes file for %s\n", dist);
264 if (isDebug())
265 msgDebug("Parsing attributes file for %s\n", dist);
264 dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS);
265 if (attr_parse(&dist_attr, buf) == 0) {
266 msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist);
267 return FALSE;
268 }
269
266 dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS);
267 if (attr_parse(&dist_attr, buf) == 0) {
268 msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist);
269 return FALSE;
270 }
271
270 msgDebug("Looking for attribute `pieces'\n");
272 if (isDebug())
273 msgDebug("Looking for attribute `pieces'\n");
271 tmp = attr_match(dist_attr, "pieces");
272 if (tmp)
273 numchunks = atoi(tmp);
274 else
275 numchunks = 0;
276 }
277 else
278 numchunks = 0;
279
274 tmp = attr_match(dist_attr, "pieces");
275 if (tmp)
276 numchunks = atoi(tmp);
277 else
278 numchunks = 0;
279 }
280 else
281 numchunks = 0;
282
280 msgDebug("Attempting to extract distribution from %u chunks.\n", numchunks);
283 if (isDebug())
284 msgDebug("Attempting to extract distribution from %u chunks.\n", numchunks);
281
282 if (numchunks < 2 ) {
283 snprintf(buf, 512, "%s/%s", path, dist);
284 if (numchunks)
285 strcat(buf,".aa");
286 fd = (*mediaDevice->get)(buf);
287 if (fd == -1) {
288 status = FALSE;
289 } else {
285
286 if (numchunks < 2 ) {
287 snprintf(buf, 512, "%s/%s", path, dist);
288 if (numchunks)
289 strcat(buf,".aa");
290 fd = (*mediaDevice->get)(buf);
291 if (fd == -1) {
292 status = FALSE;
293 } else {
290 status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd);
294 msgNotify("Extracting %s into %s directory...", me[i].my_name, me[i].my_dir);
295 status = mediaExtractDist(me[i].my_dir, fd);
291 if (mediaDevice->close)
292 (*mediaDevice->close)(mediaDevice, fd);
293 else
294 close(fd);
295 }
296 goto done;
297 }
298
296 if (mediaDevice->close)
297 (*mediaDevice->close)(mediaDevice, fd);
298 else
299 close(fd);
300 }
301 goto done;
302 }
303
299 mediaExtractDistBegin(dist, me[i].my_dir, &fd2, &zpid, &cpid);
304 mediaExtractDistBegin(me[i].my_dir, &fd2, &zpid, &cpid);
305 dialog_clear();
300 for (chunk = 0; chunk < numchunks; chunk++) {
301 int n, retval;
306 for (chunk = 0; chunk < numchunks; chunk++) {
307 int n, retval;
308 char prompt[80];
302
303 snprintf(buf, 512, "%s/%s.%c%c", path, dist, (chunk / 26) + 'a', (chunk % 26) + 'a');
304 fd = (*mediaDevice->get)(buf);
305 if (fd < 0) {
306 msgConfirm("failed to retreive piece file %s!\nAborting the transfer", buf);
307 goto punt;
308 }
309
310 snprintf(buf, 512, "%s/%s.%c%c", path, dist, (chunk / 26) + 'a', (chunk % 26) + 'a');
311 fd = (*mediaDevice->get)(buf);
312 if (fd < 0) {
313 msgConfirm("failed to retreive piece file %s!\nAborting the transfer", buf);
314 goto punt;
315 }
316 snprintf(prompt, 80, "Extracting %s into %s directory...", me[i].my_name, me[i].my_dir);
317 dialog_gauge(" Progress ", prompt, 8, 10, 10, 40, (numchunks / (chunk + 1)));
309 while ((n = read(fd, buf, sizeof buf)) > 0) {
310 retval = write(fd2, buf, n);
311 if (retval != n)
312 {
313 if (mediaDevice->close)
314 (*mediaDevice->close)(mediaDevice, fd);
315 else
316 close(fd);

--- 32 unchanged lines hidden (view full) ---

349 mediaDevice = NULL;
350 }
351 return status;
352}
353
354void
355distExtractAll(void)
356{
318 while ((n = read(fd, buf, sizeof buf)) > 0) {
319 retval = write(fd2, buf, n);
320 if (retval != n)
321 {
322 if (mediaDevice->close)
323 (*mediaDevice->close)(mediaDevice, fd);
324 else
325 close(fd);

--- 32 unchanged lines hidden (view full) ---

358 mediaDevice = NULL;
359 }
360 return status;
361}
362
363void
364distExtractAll(void)
365{
357 distExtract(NULL, DistTable);
366 while (Dists)
367 distExtract(NULL, DistTable);
358}
368}