Commit ec50954e authored by J Shane Culpepper's avatar J Shane Culpepper

Added a simple command line implementation of nautilus-installer.

parent 731950d1
2000-05-22 J Shane Culpepper <pepper@eazel.com>
* components/services/install/lib/eazel-install-rpm-glue.c:
(install_new_packages):
* configure.in:
* nautilus-installer/.cvsignore:
* nautilus-installer/Makefile:
* nautilus-installer/Makefile.am:
* nautilus-installer/helixcode-utils.c: (xml_get_value),
(prune_xml), (check_for_root_user), (check_for_redhat),
(determine_redhat_version), (determine_mandrake_version),
(determine_turbolinux_version), (determine_suse_version),
(determine_debian_version), (determine_distribution_type),
(get_distribution_name):
* nautilus-installer/helixcode-utils.h:
* nautilus-installer/nautilus-installer.c: (show_usage),
(show_license), (init_default_iopts), (init_default_topts),
(create_temporary_directory), (fetch_remote_package_list), (main):
Adding a simple implementation of the nautilus-installer. Beginning
of the fix for Bug # 863. This is a statically linked command line
implementation only right now.
2000-05-22 Eskil Heyn Olsen <eskil@eazel.om>
* src/ntl-app.c (display_prototype_caveat): Changed to simply use
......
......@@ -92,6 +92,7 @@ install_new_packages (InstallOptions* iopts, TransferOptions* topts) {
problem_filter = 0;
if (iopts->mode_test == TRUE) {
g_print ("Dry Run Mode Activated. Packages will not actually be installed ...\n");
install_flags |= RPMTRANS_FLAG_TEST;
}
......@@ -160,8 +161,7 @@ install_new_packages (InstallOptions* iopts, TransferOptions* topts) {
g_print ("Downloading %s...\n", rpmname);
rv = http_fetch_remote_file (url, targetname);
if (rv != TRUE) {
fprintf (stderr, "***Failed to retreive %s !***\n", url);
exit (1);
g_error ("*** Failed to retreive %s! ***\n", url);
}
g_free (rpmname);
......
......@@ -353,7 +353,6 @@ components/services/install/Makefile
components/services/install/lib/Makefile
components/services/install/command-line/Makefile
components/services/install/nautilus-view/Makefile
nautilus-installer/Makefile
helper-utilities/Makefile
helper-utilities/authenticate/Makefile
po/Makefile.in
......
Makefile
Makefile.in
.deps
.libs
nautilus-installer
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
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)
/* -*- 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 */
/* -*- 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__ */
/* -*- 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"