summaryrefslogtreecommitdiff
path: root/nautilus-installer
diff options
context:
space:
mode:
authorJ Shane Culpepper <pepper@src.gnome.org>2000-05-23 02:38:55 +0000
committerJ Shane Culpepper <pepper@src.gnome.org>2000-05-23 02:38:55 +0000
commitec50954e82f8b00061ce9c75a8e226d46ed3a70c (patch)
treea5faa19735c7d98c50798f7fe78f230795648ae4 /nautilus-installer
parent731950d1c93c4337179c3e9957d98a6a15358bec (diff)
downloadnautilus-ec50954e82f8b00061ce9c75a8e226d46ed3a70c.tar.gz
Added a simple command line implementation of nautilus-installer.
Diffstat (limited to 'nautilus-installer')
-rw-r--r--nautilus-installer/.cvsignore4
-rwxr-xr-xnautilus-installer/Makefile27
-rw-r--r--nautilus-installer/Makefile.am33
-rw-r--r--nautilus-installer/helixcode-utils.c413
-rw-r--r--nautilus-installer/helixcode-utils.h65
-rw-r--r--nautilus-installer/nautilus-installer.c293
6 files changed, 798 insertions, 37 deletions
diff --git a/nautilus-installer/.cvsignore b/nautilus-installer/.cvsignore
index 716fe6e77..d848e06a9 100644
--- a/nautilus-installer/.cvsignore
+++ b/nautilus-installer/.cvsignore
@@ -1,5 +1 @@
-Makefile
-Makefile.in
-.deps
-.libs
nautilus-installer
diff --git a/nautilus-installer/Makefile b/nautilus-installer/Makefile
new file mode 100755
index 000000000..873788b01
--- /dev/null
+++ b/nautilus-installer/Makefile
@@ -0,0 +1,27 @@
+CC=gcc
+EAZEL_CFLAGS=-I../components/services/install/lib
+EAZEL_LIBS=../components/services/install/lib/libinstall.a
+GNET_CFLAGS=`gnet-config --cflags`
+GNET_LIBS=/gnome/lib/libgnet.a
+GHTTP_CFLAGS=`ghttp-config --cflags`
+GHTTP_LIBS=/gnome/lib/libghttp.a
+RPM_CFLAGS=-I/usr/include/rpm
+RPM_LIBS=/usr/lib/librpm.a
+XML_CFLAGS=`xml-config --cflags`
+XML_LIBS=/gnome/lib/libxml.a
+SHAREDIR=/gnome/share/eazel
+
+all: nautilus-installer
+
+nautilus-installer: nautilus-installer.o helixcode-utils.o
+ $(CC) -static -g -O2 -o nautilus-installer nautilus-installer.o helixcode-utils.o -L/gnome/lib $(EAZEL_LIBS) $(RPM_LIBS) $(GNET_LIBS) $(GHTTP_LIBS) $(XML_LIBS) `/gnome/bin/gnome-config --libs gnomeui` -lz
+
+helixcode-utils.o: helixcode-utils.c
+ $(CC) -Wall -g -c -o helixcode-utils.o helixcode-utils.c -I. -I.. `/gnome/bin/gnome-config --cflags gnomeui`
+
+nautilus-installer.o: nautilus-installer.c
+ $(CC) -Wall -g -c -o nautilus-installer.o nautilus-installer.c -I. -I.. $(EAZEL_CFLAGS) `/gnome/bin/gnome-config --cflags gnomeui`
+
+
+clean:
+ rm -f nautilus-installer *.o
diff --git a/nautilus-installer/Makefile.am b/nautilus-installer/Makefile.am
deleted file mode 100644
index 1f1e41b99..000000000
--- a/nautilus-installer/Makefile.am
+++ /dev/null
@@ -1,33 +0,0 @@
-NULL =
-
-CPPFLAGS = \
- -DPREFIX=\"$(prefix)\" \
- -DG_LOG_DOMAIN=\"Nautilus-Services\"
-
-INCLUDES = \
- -I$(top_srcdir) \
- -I$(top_builddir) \
- $(GNET_CFLAGS) \
- $(GCONF_CFLAGS) \
- $(GNOMEUI_CFLAGS) \
- $(OAF_CFLAGS) \
- $(XML_CFLAGS) \
- $(WERROR) \
- $(NULL)
-
-gnorbadir = $(sysconfdir)/CORBA/servers
-
-bin_PROGRAMS = nautilus-installer
-
-nautilus_installer_SOURCES = \
- nautilus-installer.c \
- $(NULL)
-
-nautilus_installer_LDFLAGS = \
- $(GCONF_LIBS) \
- $(GNOMEUI_LIBS) \
- $(OAF_LIBS) \
- $(XML_LIBS) \
- $(GNET_LIBS) \
- $(RPM_LIBS) \
- $(NULL)
diff --git a/nautilus-installer/helixcode-utils.c b/nautilus-installer/helixcode-utils.c
new file mode 100644
index 000000000..5103a6777
--- /dev/null
+++ b/nautilus-installer/helixcode-utils.c
@@ -0,0 +1,413 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2000 Helix Code, Inc
+ * Copyright (C) 2000 Eazel, Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Joe Shaw <joe@helixcode.com>
+ * J. Shane Culpepper <pepper@eazel.com>
+ */
+
+/* Most of this code is taken directly from Joe Shaw's Helix Code install / Updater
+ * with a few very minor changes made by me. */
+
+#include <config.h>
+#include "helixcode-utils.h"
+
+static float determine_redhat_version (void);
+static float determine_mandrake_version (void);
+static float determine_turbolinux_version (void);
+static float determine_suse_version (void);
+static float determine_debian_version (void);
+
+char*
+xml_get_value (xmlNode* node, const char* name)
+{
+ char* ret;
+ xmlNode *child;
+
+ ret = xmlGetProp (node, name);
+ if (ret) {
+ return ret;
+ }
+ child = node->childs;
+ while (child) {
+ if (g_strcasecmp (child->name, name) == 0) {
+ ret = xmlNodeGetContent (child);
+ if (ret) {
+ return ret;
+ }
+ }
+ child = child->next;
+ }
+ return NULL;
+} /* end xml_get_value */
+
+xmlDocPtr
+prune_xml (char* xmlbuf)
+{
+ xmlDocPtr doc;
+ char* newbuf;
+ int length;
+ int i;
+
+ newbuf = strstr(xmlbuf, "<?xml");
+ if (!newbuf) {
+ return NULL;
+ }
+ length = strlen (newbuf);
+ for (i = 0; i < length; i++) {
+ if (newbuf[i] == '\0') {
+ newbuf[i] = ' ';
+ }
+ }
+ newbuf[length] = '\0';
+ doc = xmlParseMemory (newbuf, length);
+
+ if (!doc) {
+ fprintf(stderr, "***Could not prune package file !***\n");
+ return NULL;
+ }
+
+ return doc;
+} /* end prune_xml */
+
+gboolean
+check_for_root_user (void)
+{
+ uid_t uid;
+
+ uid = getuid ();
+ if (uid == 0) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+} /* end check_for_root_user */
+
+gboolean
+check_for_redhat (void)
+{
+ if (g_file_exists ("/etc/redhat-release") != 0) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+} /* end check_for_redhat */
+
+/* FIXME bugzilla.eazel.com 908: - the following functions are not
+ * closing fd correctly. This needs to be fixed and the functions
+ * need to be cleaned up. They are ugly right now.
+ */
+static float
+determine_redhat_version (void)
+{
+
+ int fd;
+ char buf[1024];
+ char* text;
+ char* v;
+ float version;
+
+ fd = open ("/etc/redhat-release", O_RDONLY);
+ g_return_val_if_fail (fd != -1, 0);
+ read (fd, buf, 1023);
+ close (fd);
+ buf[1023] = '\0';
+ /* These check for LinuxPPC. For whatever reason, they use
+ /etc/redhat-release */
+ text = strstr (buf, "1999");
+ if (text)
+ return 1999;
+ text = strstr (buf, "2000");
+ if (text)
+ return 2000;
+ text = strstr (buf, "6.0");
+ if (text)
+ return 6.0;
+ text = strstr (buf, "6.");
+ if (text) {
+ v = g_strndup (text, 3);
+ sscanf (v, "%f", &version);
+ g_free (v);
+ return version;
+ }
+ text = strstr (buf, "5.");
+ if (text) {
+ v = g_strndup (text, 3);
+ sscanf (v, "%f", &version);
+ g_free (v);
+ return version;
+ }
+ return 0.0;
+} /* determine_redhat_version */
+
+static float
+determine_mandrake_version (void)
+{
+ int fd;
+ char buf[1024];
+ char* text;
+ char* v;
+ float version;
+
+ fd = open ("/etc/mandrake-release", O_RDONLY);
+ g_return_val_if_fail (fd != -1, 0);
+ read (fd, buf, 1023);
+ close (fd);
+ buf[1023] = '\0';
+ text = strstr (buf, "6.0");
+ if (text)
+ return 6.0;
+ text = strstr (buf, "6.");
+ if (text) {
+ v = g_strndup (text, 3);
+ sscanf (v, "%f", &version);
+ g_free (v);
+ return version;
+ }
+ text = strstr (buf, "7.");
+ if (text) {
+ v = g_strndup (text, 3);
+ sscanf (v, "%f", &version);
+ g_free (v);
+ return version;
+ }
+ return 0.0;
+} /* determine_mandrake_version */
+
+static float
+determine_turbolinux_version (void)
+{
+ int fd;
+ char buf[1024];
+ char* text;
+ char* v;
+ float version;
+
+ fd = open ("/etc/turbolinux-release", O_RDONLY);
+ g_return_val_if_fail (fd != -1, 0);
+ read (fd, buf, 1023);
+ close (fd);
+ buf[1023] = '\0';
+ text = strstr (buf, "7.");
+ if (text)
+ return 7;
+ text = strstr (buf, "6.");
+ if (text) {
+ v = g_strndup (text, 3);
+ sscanf (v, "%f", &version);
+ g_free (v);
+ return version;
+ }
+ text = strstr (buf, "4.");
+ if (text) {
+ v = g_strndup (text, 3);
+ sscanf (v, "%f", &version);
+ g_free (v);
+ return version;
+ }
+ return 0.0;
+} /* determine_turbolinux_version */
+
+static float
+determine_suse_version (void)
+{
+ int fd;
+ char buf[1024];
+ char* text;
+ char* v;
+ float version;
+
+ fd = open ("/etc/SuSE-release", O_RDONLY);
+ g_return_val_if_fail (fd != -1, 0);
+ read (fd, buf, 1023);
+ close (fd);
+ buf[1023] = '\0';
+ text = strstr (buf, "6.");
+ if (!text)
+ return 0.0;
+ v = g_strndup (text, 3);
+ if (!v)
+ return 0.0;
+ sscanf (v, "%f", &version);
+ g_free (v);
+ if (version >= 2.2)
+ return version;
+ else
+ return 0.0;
+} /* determine_suse_version */
+
+static float
+determine_debian_version (void)
+{
+
+ int fd;
+ char buf[1024];
+ float version;
+
+ fd = open ("/etc/debian_version", O_RDONLY);
+ g_return_val_if_fail (fd != -1, 0);
+ read (fd, buf, 1023);
+ close (fd);
+ buf[1023] = '\0';
+ sscanf (buf, "%f", &version);
+ if (version < 2.1)
+ return 0.0;
+ return version;
+} /* determine_debian_version */
+
+DistributionType
+determine_distribution_type (void)
+{
+ float version;
+ DistributionType rv;
+
+ /* Check for TurboLinux */
+ if (g_file_exists ("/etc/turbolinux-release")) {
+ version = determine_turbolinux_version ();
+ if (version >= 7) {
+ rv = DISTRO_TURBOLINUX_6;
+ }
+ else if (version >= 6) {
+ rv = DISTRO_TURBOLINUX_6;
+ }
+ else if (version >= 4) {
+ rv = DISTRO_TURBOLINUX_4;
+ }
+ return rv;
+ }
+ /* Check for Mandrake */
+ if (g_file_exists ("/etc/mandrake-release")) {
+ version = determine_mandrake_version ();
+ if (version >= 7) {
+ rv = DISTRO_MANDRAKE_7;
+ }
+ else if (version > 6) {
+ rv = DISTRO_MANDRAKE_6_1;
+ }
+ else {
+ rv = DISTRO_UNKNOWN;
+ }
+ return rv;
+ }
+ /* Check for SuSE */
+ else if (g_file_exists ("/etc/SuSE-release")) {
+ version = determine_suse_version ();
+ if (version) {
+ rv = DISTRO_SUSE;
+ }
+ else {
+ rv = DISTRO_UNKNOWN;
+ }
+ return rv;
+ }
+ /* Check for Corel */
+ else if (g_file_exists ("/etc/environment.corel")) {
+ rv = DISTRO_COREL;
+ return rv;
+ }
+ /* Check for Debian */
+ else if (g_file_exists ("/etc/debian_version")) {
+ version = determine_debian_version ();
+ if (version == 2.1) {
+ rv = DISTRO_DEBIAN_2_1;
+ }
+ else if (version >= 2.2) {
+ rv = DISTRO_DEBIAN_2_2;
+ }
+ else {
+ rv = DISTRO_UNKNOWN;
+ }
+ return rv;
+ }
+ /* Check for Caldera */
+ else if (g_file_exists ("/etc/coas")) {
+ rv = DISTRO_CALDERA;
+ return rv;
+ }
+ /* Check for Red Hat/LinuxPPC */
+ /* This has to be checked last because many of the Red Hat knockoff
+ distros keep /etc/redhat-release around. */
+ if (g_file_exists ("/etc/redhat-release")) {
+ version = determine_redhat_version ();
+ if (version >= 1999) {
+ rv = DISTRO_LINUXPPC;
+ }
+ else if (version == 6.0) {
+ rv = DISTRO_REDHAT_6;
+ }
+ else if (version == 6.1) {
+ rv = DISTRO_REDHAT_6_1;
+ }
+ else if (version >= 6.2) {
+ rv = DISTRO_REDHAT_6_2;
+ }
+ else if (version >= 5) {
+ rv = DISTRO_REDHAT_5;
+ }
+ else {
+ rv = DISTRO_UNKNOWN;
+ }
+ return rv;
+ }
+ /* If all fail... */
+ rv = DISTRO_UNKNOWN;
+ return rv;
+} /* determine_distribution_type */
+
+char *
+get_distribution_name (const DistributionType* dtype)
+{
+ switch ((int) dtype) {
+ case DISTRO_REDHAT_5:
+ return g_strdup ("RedHat Linux 5.x");
+ case DISTRO_REDHAT_6:
+ return g_strdup ("RedHat Linux 6.0");
+ case DISTRO_REDHAT_6_1:
+ return g_strdup ("RedHat Linux 6.1");
+ case DISTRO_REDHAT_6_2:
+ return g_strdup ("RedHat Linux 6.2");
+ case DISTRO_MANDRAKE_6_1:
+ return g_strdup ("Mandrake Linux 6.2");
+ case DISTRO_MANDRAKE_7:
+ return g_strdup ("Mandrake Linux 7.x");
+ case DISTRO_CALDERA:
+ return g_strdup ("Caldera OpenLinux");
+ case DISTRO_SUSE:
+ return g_strdup ("SuSe Linux");
+ case DISTRO_LINUXPPC:
+ return g_strdup ("LinuxPPC");
+ case DISTRO_TURBOLINUX_4:
+ return g_strdup ("TurboLinux 4.x");
+ case DISTRO_TURBOLINUX_6:
+ return g_strdup ("TurboLinux 6.x");
+ case DISTRO_COREL:
+ return g_strdup ("Corel Linux");
+ case DISTRO_DEBIAN_2_1:
+ return g_strdup ("Debian GNU/Linux 2.1");
+ case DISTRO_DEBIAN_2_2:
+ return g_strdup ("Debian GNU/Linux 2.2");
+ case DISTRO_UNKNOWN:
+ return g_strdup ("unknown Linux distribution");
+ default:
+ fprintf (stderr, "Invalid DistributionType !\n");
+ exit (1);
+ }
+} /* end get_distribution_name */
diff --git a/nautilus-installer/helixcode-utils.h b/nautilus-installer/helixcode-utils.h
new file mode 100644
index 000000000..3aad9e73e
--- /dev/null
+++ b/nautilus-installer/helixcode-utils.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2000 Helix Code, Inc
+ * Copyright (C) 2000 Eazel, Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Joe Shaw <joe@helixcode.com>
+ * J. Shane Culpepper <pepper@eazel.com>
+ */
+
+/* Most of this code is taken directly from Joe Shaw's Helix Code install / Updater
+ * with a few very minor changes made by me. */
+
+#ifndef __HELIXCODE_INSTALL_UTILS_H__
+#define __HELIXCODE_INSTALL_UTILS_H__
+
+#include <gnome.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <gnome-xml/tree.h>
+#include <gnome-xml/parser.h>
+
+typedef enum _DistributionType DistributionType;
+
+enum _DistributionType {
+ DISTRO_REDHAT_5, /* Red Hat 5.x (glibc 2.0) */
+ DISTRO_REDHAT_6, /* Red Hat 6.0 (glibc 2.1) */
+ DISTRO_REDHAT_6_1, /* Red Hat 6.1 (glibc 2.1) */
+ DISTRO_REDHAT_6_2, /* Red Hat 6.2 (glibc 2.1) */
+ DISTRO_MANDRAKE_6_1, /* Mandrake 6.1 (glibc 2.1) */
+ DISTRO_MANDRAKE_7, /* Mandrake 7.0 */
+ DISTRO_CALDERA, /* Caldera */
+ DISTRO_SUSE, /* SuSE */
+ DISTRO_LINUXPPC, /* LinuxPPC */
+ DISTRO_TURBOLINUX_4, /* TurboLinux 4 */
+ DISTRO_TURBOLINUX_6, /* TurboLinux 6 */
+ DISTRO_COREL, /* Corel Linux */
+ DISTRO_DEBIAN_2_1, /* Debian Linux 2.1 */
+ DISTRO_DEBIAN_2_2, /* Debian Linux 2.2 */
+ DISTRO_UNKNOWN /* Everything Else */
+};
+
+char* xml_get_value (xmlNode* node, const char* name);
+xmlDocPtr prune_xml (char* xmlbuf);
+gboolean check_for_root_user (void);
+gboolean check_for_redhat (void);
+DistributionType determine_distribution_type (void);
+char* get_distribution_name (const DistributionType* dtype);
+
+#endif /* __HELIXCODE_INSTALL_UTILS_H__ */
diff --git a/nautilus-installer/nautilus-installer.c b/nautilus-installer/nautilus-installer.c
new file mode 100644
index 000000000..1122cfc8e
--- /dev/null
+++ b/nautilus-installer/nautilus-installer.c
@@ -0,0 +1,293 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2000 Eazel, Inc
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: J Shane Culpepper <pepper@eazel.com>
+ *
+ */
+
+/* nautilus-installer - A very simple bootstrap installer for nautilus and
+ * its dependancies.
+ */
+
+#include "eazel-install-types.h"
+#include "eazel-install-protocols.h"
+#include "eazel-install-rpm-glue.h"
+#include "eazel-install-xml-package-list.h"
+#include "eazel-install-metadata.h"
+#include "helixcode-utils.h"
+#include <config.h>
+#include <popt-gnome.h>
+
+/* Here are the values to change if the internal server changes location or
+ * storage locations. You can also change these if you want to play with the
+ * installer locally.
+ */
+
+#define REMOTE_SERVER_NAME "10.1.1.5"
+#define REMOTE_PKG_LIST_PATH "/package-list.xml"
+#define REMOTE_RPM_DIR "/RPMS"
+#define PATH_TO_RPMRC "/usr/lib/rpm/rpmrc"
+#define LOCAL_PKG_LIST_PATH "/tmp/package-list.xml"
+#define DEFAULT_TMP_DIR "/tmp/eazel-install"
+
+/* Forward Function Declarations */
+static void show_usage (int exitcode, char* error);
+static void show_license (int exitcode, char* error);
+static TransferOptions* init_default_topts (void);
+static InstallOptions* init_default_iopts (void);
+static void create_temporary_directory (const char* tmpdir);
+static void fetch_remote_package_list (const char* pkg_list,
+ TransferOptions* topts);
+
+/* Show options available for the bootstrap installer */
+static void
+show_usage (int exitcode, char* error) {
+ fprintf (stderr, "Usage: nautilus-installer [options]\n"
+ "Valid options are:\n"
+ " --help : show help\n"
+ " --License : show license\n"
+ " --test : dry run - don't actually install\n"
+ " --force : force package to install/uninstall\n"
+ " --tmpdir <dir> : temporary directory to store rpms\n"
+ "\nExample: nautilus-installer --force --tmpdir /tmp\n\n");
+
+ if (error) {
+ fprintf (stderr, "%s\n", error);
+ }
+
+ exit (exitcode);
+
+} /* end usage */
+
+/* Print the GPL license if --license option is given */
+static void
+show_license (int exitcode, char* error) {
+ fprintf (stderr, "nautilus-installer: a bootstrap installer for nautilus and its dependancies\n\n"
+ "Copyright (C) 2000 Eazel, Inc.\n\n"
+ "This program is free software; you can redistribute it and/or\n"
+ "modify it under the terms of the GNU General Public License as\n"
+ "published by the Free Software Foundation; either version 2 of the\n"
+ "License, or (at your option) any later version.\n\n"
+ "This program is distributed in the hope that it will be useful,\n"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
+ "General Public License for more details.\n\n"
+ "You should have received a copy of the GNU General Public License\n"
+ "along with this program; if not, write to the Free Software\n"
+ "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n");
+
+ if (error) {
+ fprintf(stderr, "%s\n", error);
+ }
+
+ exit(exitcode);
+
+} /* end show_license */
+
+/* Initialize the InstallOptions struct with default values */
+static InstallOptions*
+init_default_iopts () {
+
+ InstallOptions* rv;
+
+ rv = g_new0 (InstallOptions, 1);
+ rv->protocol = PROTOCOL_HTTP;
+ rv->pkg_list = g_strdup (LOCAL_PKG_LIST_PATH);
+ rv->mode_verbose = TRUE;
+ rv->mode_silent = FALSE;
+ rv->mode_debug = FALSE;
+ rv->mode_test = FALSE;
+ rv->mode_force = FALSE;
+ rv->mode_depend = FALSE;
+ rv->mode_update = TRUE;
+ rv->mode_uninstall = FALSE;
+ rv->mode_downgrade = FALSE;
+
+ g_assert (rv != NULL);
+
+ return rv;
+
+} /* end init_default_iopts */
+
+/* Initialize the TransferOptions struct with default values */
+static TransferOptions*
+init_default_topts () {
+
+ TransferOptions* rv;
+
+ rv = g_new0 (TransferOptions, 1);
+ rv->hostname = g_strdup (REMOTE_SERVER_NAME);
+ rv->port_number = 80;
+ rv->pkg_list_storage_path = g_strdup (REMOTE_PKG_LIST_PATH);
+ rv->rpm_storage_path = g_strdup (REMOTE_RPM_DIR);
+ rv->tmp_dir = g_strdup (DEFAULT_TMP_DIR);
+ rv->rpmrc_file = g_strdup (PATH_TO_RPMRC);
+
+ g_assert (rv != NULL);
+
+ return rv;
+
+} /* end init_default_topts */
+
+/* Create the local storage location if it does not currently exist */
+static void
+create_temporary_directory (const char* tmpdir) {
+
+ int retval;
+
+ g_print("Creating temporary download directory ...\n");
+
+ retval = mkdir (tmpdir, 0755);
+ if (retval < 0) {
+ if (errno != EEXIST) {
+ g_error ("*** Could not create temporary directory ! ***\n");
+ }
+ }
+} /* end create_temporary_directory */
+
+/* Fetch the package-list.xml file from the remote server to know what needs
+ * to be installed.
+ */
+static void
+fetch_remote_package_list (const char* pkg_list, TransferOptions* topts) {
+
+ gboolean retval;
+
+ g_print ("Getting package-list.xml from remote server ...\n");
+
+ retval = http_fetch_xml_package_list (topts->hostname,
+ topts->port_number,
+ topts->pkg_list_storage_path,
+ pkg_list);
+ if (retval == FALSE) {
+ g_error ("*** Unable to retrieve package-list.xml! ***\n");
+ }
+} /* end fetch_remote_package_list */
+
+int
+main (int argc, char* argv[]) {
+ char opt;
+ gboolean retval;
+ gboolean TEST_MODE, FORCE_MODE;
+ InstallOptions* iopts;
+ TransferOptions* topts;
+ poptContext pctx;
+ char* config_file;
+ char* popt_tmpdir;
+
+ struct poptOption optionsTable[] = {
+ { "help", 'h', 0, NULL, 'h' },
+ { "License", 'L', 0, NULL, 'L' },
+ { "force", 'F', 0, NULL, 'F' },
+ { "test", 't', 0, NULL, 't' },
+ { "tmpdir", 'T', POPT_ARG_STRING, &popt_tmpdir, 'T' },
+ { NULL, '\0', 0, NULL, 0 }
+ };
+
+ retval = FALSE;
+ FORCE_MODE = FALSE;
+ TEST_MODE = FALSE;
+ popt_tmpdir = NULL;
+
+ pctx = poptGetContext ("nautilus-installer", argc, argv, optionsTable, 0);
+
+ while ( (opt = poptGetNextOpt (pctx)) >= 0) {
+ switch (opt) {
+ case 'h':
+ show_usage (0, NULL);
+ break;
+ case 'L':
+ show_license (0, NULL);
+ break;
+ case 'F':
+ FORCE_MODE = TRUE;
+ break;
+ case 't':
+ TEST_MODE = TRUE;
+ break;
+ case 'T':
+ break;
+ }
+ }
+
+ if (opt < -1) {
+
+ /* Error generated during option processing */
+
+ fprintf (stderr, "*** Option = %s: %s ***\n",
+ poptBadOption (pctx, POPT_BADOPTION_NOALIAS),
+ poptStrerror (opt));
+ exit (1);
+ }
+
+ poptFreeContext (pctx);
+
+ /* This is the for internal usage only warning. It will be removed once
+ * we are ready for primetime.
+ */
+ g_print ("WARNING: The nautilus bootstrap installer is for internal\n"
+ "use at Eazel, Inc. only. It should not be redistributed\n"
+ "until we are ready to release Nautilus 1.0. This installer\n"
+ "is by no means complete in it's current form so be prepared\n" "for unpredictable behavior.\n");
+
+ retval = check_for_root_user ();
+ if (retval == FALSE) {
+ g_error ("*** You must run nautilus-installer as root! ***\n");
+ }
+
+ retval = check_for_redhat ();
+ if (retval == FALSE) {
+ g_error ("*** nautilus-installer can only be used on RedHat! ***\n");
+ }
+
+ /* Populate iopts and topts with eazel defaults */
+ iopts = init_default_iopts ();
+ topts = init_default_topts ();
+
+ if (TEST_MODE == TRUE) {
+ iopts->mode_test = TRUE;
+ }
+
+ if (FORCE_MODE == TRUE) {
+ iopts->mode_force = TRUE;
+ }
+
+ if (popt_tmpdir) {
+ topts->tmp_dir = g_strdup_printf ("%s", popt_tmpdir);
+ }
+
+ if (!g_file_exists (topts->tmp_dir)) {
+ create_temporary_directory (topts->tmp_dir);
+ }
+
+ if (iopts->protocol == PROTOCOL_HTTP) {
+ fetch_remote_package_list (iopts->pkg_list, topts);
+ }
+
+ retval = install_new_packages (iopts, topts);
+ if (retval == FALSE) {
+ g_error ("*** The install failed! ***\n");
+ }
+
+ g_print ("Install completed normally...\n");
+ g_free (iopts);
+ g_free (topts);
+ exit (0);
+}
+