|
From: <ow...@us...> - 2008-01-23 21:08:05
|
Revision: 1024
http://ipcop.svn.sourceforge.net/ipcop/?rev=1024&view=rev
Author: owes
Date: 2008-01-23 13:08:10 -0800 (Wed, 23 Jan 2008)
Log Message:
-----------
Use progressbar for untarring.
If someone knows how to get usable progress indicators for busybox-wget
and mke2fs, I'm all ears.
Change variable string -> command
Modified Paths:
--------------
ipcop/trunk/src/installer/partition.c
Modified: ipcop/trunk/src/installer/partition.c
===================================================================
--- ipcop/trunk/src/installer/partition.c 2008-01-23 20:59:19 UTC (rev 1023)
+++ ipcop/trunk/src/installer/partition.c 2008-01-23 21:08:10 UTC (rev 1024)
@@ -36,6 +36,7 @@
#include <newt.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <sys/stat.h>
#include <parted/parted.h>
@@ -57,7 +58,7 @@
int retcode = 1; /* ERROR */
long int swap_file, boot_partition, log_partition;
long int start_partition, current_free, root_partition;
- char string[STRING_SIZE];
+ char command[STRING_SIZE];
char device[STRING_SIZE];
PedDevice *ped_dev;
PedDisk *ped_disk;
@@ -106,8 +107,8 @@
statuswindow(72, 5, ipcop_gettext("TR_TITLE_DISK"), ipcop_gettext("TR_MAKING_PARTITIONS"));
- snprintf(string, STRING_SIZE, "/bin/dd if=/dev/zero of=%s bs=512 count=1", device );
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/dd if=/dev/zero of=%s bs=512 count=1", device );
+ mysystem(command);
mysystem("/bin/sync");
ped_dev = ped_device_get(device);
@@ -401,11 +402,13 @@
*/
int make_disk(char *dev, int *bootpartexist)
{
+ char command[STRING_SIZE];
char string[STRING_SIZE];
FILE *handle;
struct dirent **names;
int i;
char tarball_location[STRING_SIZE] = "/tmp";
+ newtComponent *f;
// Get existing partitions names
@@ -440,13 +443,13 @@
}
else if ( !strcmp(partition_label[i], "swap") )
{
- sprintf(string, "/sbin/mkswap /dev/%s", partitions[i]);
- mysystem(string);
+ sprintf(command, "/sbin/mkswap /dev/%s", partitions[i]);
+ mysystem(command);
fprintf(handle, "/dev/%s\tnone%s\tswap\n", partitions[i], partition_label[i]);
mysystem("/bin/swapon -a");
} else {
- sprintf(string, "/usr/bin/mke2fs -L %s -q -j /dev/%s", partition_label[i], partitions[i]);
- mysystem(string);
+ sprintf(command, "/usr/bin/mke2fs -L %s -q -j /dev/%s", partition_label[i], partitions[i]);
+ mysystem(command);
fprintf(handle, "/dev/%s\t/harddisk%s\text3\n", partitions[i], partition_label[i]);
}
}
@@ -477,8 +480,8 @@
}
else
{
- sprintf(string, "/bin/mkdir -p /harddisk%s", partition_label[i]);
- mysystem(string);
+ sprintf(command, "/bin/mkdir -p /harddisk%s", partition_label[i]);
+ mysystem(command);
if ( !strcmp(partition_label[i], "/boot") )
{
*bootpartexist = i + 1;
@@ -504,17 +507,17 @@
/* download needed files */
statuswindow(72, 5, ipcop_gettext("TR_TITLE_DISK"), ipcop_gettext("TR_DOWNLOADING_IMAGE"));
mysystem("mkdir -p /harddisk/tmp");
- snprintf(string, STRING_SIZE,
+ snprintf(command, STRING_SIZE,
"/bin/wget -O /harddisk/tmp/"TARBALL_VARLOG " %s/"TARBALL_VARLOG, network_source);
- if ( !mysystem(string) )
+ if ( !mysystem(command) )
{
- snprintf(string, STRING_SIZE,
+ snprintf(command, STRING_SIZE,
"/bin/wget -O /harddisk/tmp/"TARBALL_CONFIG " %s/"TARBALL_CONFIG, network_source);
- if ( !mysystem(string) )
+ if ( !mysystem(command) )
{
- snprintf(string, STRING_SIZE,
+ snprintf(command, STRING_SIZE,
"/bin/wget -O /harddisk/tmp/"TARBALL_IPCOP " %s/"TARBALL_IPCOP, network_source);
- if ( !mysystem(string) )
+ if ( !mysystem(command) )
{
strcpy(tarball_location, "/harddisk/tmp");
}
@@ -528,19 +531,19 @@
break;
}
- statuswindow(72, 5, ipcop_gettext("TR_TITLE_DISK"), ipcop_gettext("TR_INSTALLING_FILES"));
- snprintf(string, STRING_SIZE, "/bin/tar -C /harddisk -xpzf %s/"TARBALL_VARLOG, tarball_location);
- if ( mysystem(string) )
+ f = (newtComponent *)statuswindow_progress(72, 5, ipcop_gettext("TR_TITLE_DISK"), ipcop_gettext("TR_INSTALLING_FILES"));
+ snprintf(command, STRING_SIZE, "/bin/tar -C /harddisk -xpzf %s/"TARBALL_VARLOG, tarball_location);
+ if ( mysystem(command) )
{
newtWinMessage(get_title(), ipcop_gettext("TR_OK"), "tar error");
}
- snprintf(string, STRING_SIZE, "/bin/tar -C /harddisk -xpzf %s/"TARBALL_CONFIG, tarball_location);
- if ( mysystem(string) )
+ snprintf(command, STRING_SIZE, "/bin/tar -C /harddisk -vxpzf %s/"TARBALL_CONFIG, tarball_location);
+ if ( mysystem_progress(command, f, 1, 3, 70, 4500, 0) )
{
newtWinMessage(get_title(), ipcop_gettext("TR_OK"), "tar error");
}
- snprintf(string, STRING_SIZE, "/bin/tar -C /harddisk -xpzf %s/"TARBALL_IPCOP, tarball_location);
- if ( mysystem(string) )
+ snprintf(command, STRING_SIZE, "/bin/tar -C /harddisk -vxpzf %s/"TARBALL_IPCOP, tarball_location);
+ if ( mysystem_progress(command, f, 1, 3, 70, 4500, 500) )
{
newtWinMessage(get_title(), ipcop_gettext("TR_OK"), "tar error");
}
@@ -549,6 +552,9 @@
delete_tarballs();
+ newtFormDestroy(*f);
+
+
/* complete fstab */
if ( (handle = fopen("/harddisk/etc/fstab", "w")) )
{
@@ -648,7 +654,7 @@
*/
void make_bootable(char *dev, int bootpartexist)
{
- char string[STRING_SIZE];
+ char command[STRING_SIZE];
char device[STRING_SIZE];
statuswindow(72, 5, ipcop_gettext("TR_TITLE_DISK"), ipcop_gettext("TR_MAKING_BOOTABLE"));
@@ -658,12 +664,12 @@
#if defined (__i386__)
mysystem("/bin/cp -f /harddisk/boot/grub/grubbatch /harddisk/tmp");
- snprintf(string, STRING_SIZE, "/bin/sed -i -e 's+DEVICE+%s+g' /harddisk/tmp/grubbatch", device);
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/sed -i -e 's+DEVICE+%s+g' /harddisk/tmp/grubbatch", device);
+ mysystem(command);
/* replace the ROOT_DEV with the real device, partition 2 */
- snprintf(string, STRING_SIZE, "/bin/sed -i -e 's+ROOT_DEV+%s2+g' /harddisk/boot/grub/menu.lst", device);
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/sed -i -e 's+ROOT_DEV+%s2+g' /harddisk/boot/grub/menu.lst", device);
+ mysystem(command);
/* /boot is not a partition. Just correct grub load location */
if (!bootpartexist)
@@ -711,42 +717,42 @@
if(newworld)
{
fprintf(flog, "Configuring Open Firmware (NewWorld)\n");
- snprintf(string, STRING_SIZE, "/bin/chroot /harddisk /usr/sbin/mkofboot --force -b %s2", device);
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/chroot /harddisk /usr/sbin/mkofboot --force -b %s2", device);
+ mysystem(command);
/* replace the ROOT_DEV with the real device, partition 2 */
- snprintf(string, STRING_SIZE, "/bin/sed -i -e 's+BOOTSTRAP_DEV+%s2+g' /harddisk/etc/yaboot.conf", device);
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/sed -i -e 's+BOOTSTRAP_DEV+%s2+g' /harddisk/etc/yaboot.conf", device);
+ mysystem(command);
- snprintf(string, STRING_SIZE, "/bin/sed -i -e 's+ROOT_DEV+%s4+g' /harddisk/etc/yaboot.conf", device);
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/sed -i -e 's+ROOT_DEV+%s4+g' /harddisk/etc/yaboot.conf", device);
+ mysystem(command);
fprintf(flog, "Running ybin\n");
- snprintf(string, STRING_SIZE, "/bin/chroot /harddisk /usr/sbin/ybin");
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/chroot /harddisk /usr/sbin/ybin");
+ mysystem(command);
} else {
fprintf(flog, "Configuring Open Firmware (OldWorld)\n");
- snprintf(string, STRING_SIZE, "/bin/chroot /harddisk /usr/local/bin/install-quik.sh %s3 %s4", device, device);
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/chroot /harddisk /usr/local/bin/install-quik.sh %s3 %s4", device, device);
+ mysystem(command);
}
#endif
#if defined (__sparc__) || defined (__sparc64__)
fprintf(flog, "Installing silo\n");
/* replace the ROOT_DEV with the real device, partition 2 */
- snprintf(string, STRING_SIZE, "/bin/sed -i -e 's+ROOT_DEV+%s2+g' /harddisk/etc/silo.conf", device);
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/sed -i -e 's+ROOT_DEV+%s2+g' /harddisk/etc/silo.conf", device);
+ mysystem(command);
/* We need to mount /proc/openprom so we can rewrite the boot-device prom variable */
- snprintf(string, STRING_SIZE, "/bin/chroot /harddisk /bin/mount /proc/openprom");
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/chroot /harddisk /bin/mount /proc/openprom");
+ mysystem(command);
- snprintf(string, STRING_SIZE, "/bin/chroot /harddisk /sbin/silo");
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/chroot /harddisk /sbin/silo");
+ mysystem(command);
/* We can unmount /proc/openprom now */
- snprintf(string, STRING_SIZE, "/bin/chroot /harddisk /bin/umount /proc/openprom");
- mysystem(string);
+ snprintf(command, STRING_SIZE, "/bin/chroot /harddisk /bin/umount /proc/openprom");
+ mysystem(command);
#endif
#if defined(__alpha__)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|