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

Adding the eazel-install skeleton for install services. Very rough prototype

right now.
parent 58617d69
2000-04-18 Shane Culpepper <pepper@eazel.com>
adding the eazel-installer skelton. very rough prototype right now
but it works with my local configuration data. Will be updated alot
over the next few days.
Location is components/services/install. It is not part of the default
build right now.
2000-04-18 Andy Hertzfeld <andy@eazel.com>
made clicking on gmc-style URL files redirect to the specified URL.
......
SUBDIRS = startup
SUBDIRS = startup install
NULL=
CPPFLAGS = \
-DPREFIX=\"$(prefix)\"
-DG_LOG_DOMAIN=\"Nautilus-Services\"
INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir) \
-I/usr/include/rpm \
$(GNOMEUI_CFLAGS) \
$(WERROR) \
$(NULL)
gnorbadir = $(sysconfdir)/CORBA/servers
bin_PROGRAMS = \
eazel-install
eazel_install_SOURCES = \
eazel-install-lib-util.c \
eazel-install-lib-debug.c \
eazel-install-lib-xml.c \
eazel-install-lib-rpm.c \
eazel-install.c \
$(NULL)
eazel_install_LDFLAGS = \
$(GNOMEUI_LIBS) \
-lrpm \
-lpopt \
-lxml \
$(NULL)
/* -*- 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>
*/
/* eazel-install - services command line install/update/uninstall
* component. This program will parse the eazel-configuration.xml
* file and install a services generated packages.xml.
*/
#include "eazel-install-lib.h"
InstallOptions*
init_default_install_configuration_test () {
InstallOptions* rv;
/* A temporary hack for now. Will eventually read information from a
* configuration file
*/
rv = g_new0 (InstallOptions, 1);
rv->protocol = PROTOCOL_LOCAL;
rv->mode_debug = TRUE;
rv->mode_test = FALSE;
rv->mode_verbose = FALSE;
rv->mode_silent = FALSE;
rv->mode_depend = FALSE;
rv->mode_uninstall = FALSE;
rv->mode_update = FALSE;
rv->port_number = 0;
rv->rpmrc_file = g_strdup ("/usr/lib/rpm/rpmrc");
rv->pkg_list_file = g_strdup ("/home/pepper/tmp/packages.xml");
rv->rpm_storage_dir = g_strdup ("/home/pepper/tmp");
rv->install_tmpdir = g_strdup ("/tmp/eazel_install");
g_assert (rv != NULL);
return rv;
} /* end init_default_install_configuration */
void
dump_install_options (InstallOptions* iopts) {
g_print ("***Begin iopts dump***\n");
g_print ("protocol = %d\n", iopts->protocol);
g_print ("debug = %d\n", iopts->mode_debug);
g_print ("test = %d\n", iopts->mode_test);
g_print ("verbose = %d\n", iopts->mode_verbose);
g_print ("silent = %d\n", iopts->mode_silent);
g_print ("depend = %d\n", iopts->mode_depend);
g_print ("uninstall = %d\n", iopts->mode_uninstall);
g_print ("update = %d\n", iopts->mode_update);
g_print ("rpmrc_file = %s\n", iopts->rpmrc_file);
g_print ("pkg_list = %s\n", iopts->pkg_list_file);
g_print ("rpm_storage_dir = %s\n", iopts->rpm_storage_dir);
g_print ("tmpdir = %s\n", iopts->install_tmpdir);
g_print ("***End iopts dump***\n");
} /* end dump_install_options */
void
dump_package_list (PackageData* pkg) {
g_print ("***Begin pkg dump***\n");
g_print ("rpm_name = %s\n", pkg->rpm_name);
g_print ("name = %s\n", pkg->name);
g_print ("summary = %s\n", pkg->summary);
g_print ("version = %s\n", pkg->version);
g_print ("srcfile = %d\n", pkg->srcfile);
g_print ("bytesize = %d\n", pkg->bytesize);
g_print ("***End pkg dump***\n");
} /* end dump_package_list */
/* -*- 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>
*/
/* eazel-install - services command line install/update/uninstall
* component. This program will parse the eazel-configuration.xml
* file and install a services generated packages.xml.
*/
#include "eazel-install-lib.h"
gboolean
install_new_packages (InstallOptions* iopts) {
GList *categories;
gboolean rv;
rpmSetVerbosity(RPMMESS_FATALERROR);
rpmReadConfigFiles (iopts->rpmrc_file, NULL);
categories = NULL;
categories = fetch_xml_package_list_local (iopts->pkg_list_file);
while (categories) {
CategoryData* c = categories->data;
GList* t = c->Packages;
g_print ("Install Category - %s\n", c->name);
while (t) {
PackageData* pack = t->data;
const char* pkg;
int retval;
retval = 0;
pkg = g_strdup_printf ("%s/%s", iopts->rpm_storage_dir, pack->rpm_name);
g_print ("Installing Package = %s\n", pkg);
retval = rpmInstall ("/", &pkg, 0, INSTALL_UPGRADE | INSTALL_HASH,
RPMPROB_FILTER_REPLACEPKG | RPMPROB_FILTER_OLDPACKAGE |
RPMPROB_FILTER_REPLACEOLDFILES, NULL);
if (retval > 0) {
g_print ("Package install successful!\n");
rv = TRUE;
}
else {
g_print ("Package install failed !\n");
rv = FALSE;
}
t = t->next;
}
categories = categories->next;
}
free_categories (categories);
return rv;
} /* end install_new_packages */
gboolean
install_update_packages (InstallOptions* iopts) {
fprintf (stderr, "***Sorry update not supported yet!***\n");
return TRUE;
} /* end install_update_packages */
gboolean
uninstall_packages (InstallOptions* iopts) {
fprintf (stderr, "***Sorry uninstall not supported yet!***\n");
return TRUE;
} /* end install_new_packages */
/* -*- 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>
*/
/* eazel-install - services command line install/update/uninstall
* component. This program will parse the eazel-configuration.xml
* file and install a services generated packages.xml.
*/
#include "eazel-install-lib.h"
gboolean
check_for_root_user () {
uid_t uid;
uid = getuid ();
if (uid == 0) {
return TRUE;
}
else {
return FALSE;
}
} /* end check_for_root_user */
gboolean
check_for_redhat () {
if (g_file_exists ("/etc/redhat-release") != 0) {
return TRUE;
}
else {
return FALSE;
}
} /* end check_for_redhat */
/* -*- 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>
*/
/* eazel-install - services command line install/update/uninstall
* component. This program will parse the eazel-configuration.xml
* file and install a services generated packages.xml.
*/
#include "eazel-install-lib.h"
static PackageData* parse_package (xmlNode* package);
static CategoryData* parse_category (xmlNode* cat);
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 */
InstallOptions*
init_default_install_configuration (const char* config_file) {
InstallOptions* rv;
xmlDocPtr doc;
xmlNodePtr base;
char* tmpbuf;
doc = xmlParseFile (config_file);
if (doc == NULL) {
fprintf (stderr, "***Unable to open config file!***\n");
xmlFreeDoc (doc);
g_assert (doc != NULL);
}
base = doc->root;
if (base == NULL) {
fprintf (stderr, "***The config file contains no data!***\n");
xmlFreeDoc (doc);
g_assert (base != NULL);
}
if (g_strcasecmp (base->name, "EAZEL_INSTALLER")) {
fprintf (stderr, "***Cannot find the EAZEL_INSTALLER xmlnode!***\n");
xmlFreeDoc (doc);
g_error ("***Bailing from xmlparse!***\n");
}
rv = g_new0 (InstallOptions, 1);
tmpbuf = xml_get_value (base, "PROTOCOL");
if (tmpbuf[0] == 'l' || tmpbuf[0] == 'L') {
rv->protocol = PROTOCOL_LOCAL;
}
else if (tmpbuf[0] == 'h' || tmpbuf[0] == 'H') {
rv->protocol = PROTOCOL_HTTP;
}
else if (tmpbuf[0] == 'f' || tmpbuf[0] == 'F') {
rv->protocol = PROTOCOL_FTP;
}
tmpbuf = xml_get_value (base, "DEBUG");
if (tmpbuf[0] == 't' || tmpbuf[0] == 'T') {
rv->mode_debug = TRUE;
}
else if (tmpbuf[0] == 'f' || tmpbuf[0] == 'T') {
rv->mode_debug = FALSE;
}
tmpbuf = xml_get_value (base, "DRY_RUN");
if (tmpbuf[0] == 't' || tmpbuf[0] == 'T') {
rv->mode_test = TRUE;
}
else if (tmpbuf[0] == 'f' || tmpbuf[0] == 'T') {
rv->mode_test = FALSE;
}
tmpbuf = xml_get_value (base, "VERBOSE");
if (tmpbuf[0] == 't' || tmpbuf[0] == 'T') {
rv->mode_verbose = TRUE;
}
else if (tmpbuf[0] == 'f' || tmpbuf[0] == 'T') {
rv->mode_verbose = FALSE;
}
tmpbuf = xml_get_value (base, "SILENT");
if (tmpbuf[0] == 't' || tmpbuf[0] == 'T') {
rv->mode_silent = TRUE;
}
else if (tmpbuf[0] == 'f' || tmpbuf[0] == 'T') {
rv->mode_silent = FALSE;
}
tmpbuf = xml_get_value (base, "DEPEND");
if (tmpbuf[0] == 't' || tmpbuf[0] == 'T') {
rv->mode_depend = TRUE;
}
else if (tmpbuf[0] == 'f' || tmpbuf[0] == 'T') {
rv->mode_depend = FALSE;
}
tmpbuf = xml_get_value (base, "UNINSTALL");
if (tmpbuf[0] == 't' || tmpbuf[0] == 'T') {
rv->mode_uninstall = TRUE;
}
else if (tmpbuf[0] == 'f' || tmpbuf[0] == 'T') {
rv->mode_uninstall = FALSE;
}
tmpbuf = xml_get_value (base, "UPDATE");
if (tmpbuf[0] == 't' || tmpbuf[0] == 'T') {
rv->mode_update = TRUE;
}
else if (tmpbuf[0] == 'f' || tmpbuf[0] == 'T') {
rv->mode_update = FALSE;
}
rv->port_number = atoi (xml_get_value (base, "PORT"));
rv->rpmrc_file = g_strdup (xml_get_value (base, "RPMRC_FILE"));
rv->pkg_list_file = g_strdup (xml_get_value (base, "PKG_LIST_FILE"));
rv->rpm_storage_dir = g_strdup (xml_get_value (base, "RPM_STORAGE_DIR"));
rv->install_tmpdir = g_strdup (xml_get_value (base, "TMPDIR"));
g_free (tmpbuf);
xmlFreeDoc (doc);
return rv;
}
static PackageData*
parse_package (xmlNode* package) {
xmlNode* dep;
PackageData* rv;
char* tmp;
rv = g_new0 (PackageData, 1);
rv->rpm_name = g_strdup (xml_get_value (package, "RPM_NAME"));
rv->name = g_strdup (xml_get_value (package, "NAME"));
rv->summary = g_strdup (xml_get_value (package, "SUMMARY"));
rv->version = g_strdup (xml_get_value (package, "VERSION"));
tmp = xml_get_value (package, "SOURCE");
if (tmp[0] == 't' || tmp[0] == 'T') {
rv->srcfile = TRUE;
}
else if (tmp[0] == 'f' || tmp[0] == 'F') {
rv->srcfile = FALSE;
}
rv->bytesize = atoi (xml_get_value (package, "BYTESIZE"));
/* Dependency Lists */
rv->SoftDepends = NULL;
rv->HardDepends = NULL;
dep = package->childs;
while (dep) {
if (g_strcasecmp (dep->name, "SOFT_DEPEND") == 0) {
PackageData* depend;
depend = parse_package (dep);
rv->SoftDepends = g_list_append (rv->SoftDepends, depend);
}
else if (g_strcasecmp (dep->name, "HARD_DEPEND") == 0) {
PackageData* depend;
depend = parse_package (dep);
rv->HardDepends = g_list_append (rv->HardDepends, depend);
}
dep = dep->next;
}
dump_package_list (rv);
return rv;
} /* end parse package */
static CategoryData*
parse_category (xmlNode* cat) {
CategoryData* category;
xmlNode* pkg;
category = g_new0 (CategoryData, 1);
category->name = xmlGetProp (cat, "name");
g_print ("Category Name = %s\n", category->name);
pkg = cat->childs->childs;
if (pkg == NULL) {
fprintf (stderr, "***No package nodes!***\n");
g_free (category);
g_error ("***Bailing from package parse!***\n");
}
while (pkg) {
PackageData* pakdat;
pakdat = parse_package (pkg);
category->Packages = g_list_append (category->Packages, pakdat);
pkg = pkg->next;
}
return category;
} /* end parse_category */
GList*
fetch_xml_package_list_local (const char* pkg_list_file) {
GList* rv;
xmlDocPtr doc;
xmlNodePtr base;
xmlNodePtr category;
rv = NULL;
doc = xmlParseFile (pkg_list_file);
if (doc == NULL) {
fprintf (stderr, "***Unable to open pkg list file!***\n");
xmlFreeDoc (doc);
g_assert (doc != NULL);
}
base = doc->root;
if (base == NULL) {
fprintf (stderr, "***The pkg list file contains no data!***\n");
xmlFreeDoc (doc);
g_assert (base != NULL);
}
if (g_strcasecmp (base->name, "CATEGORIES")) {
fprintf (stderr, "***Cannot find the CATEGORIES xmlnode!***\n");
xmlFreeDoc (doc);
g_error ("***Bailing from categories parse!***\n");
}
category = doc->root->childs;
if(category == NULL) {
fprintf (stderr, "***No Categories!***\n");
xmlFreeDoc (doc);
g_error ("***Bailing from category parse!***\n");
}
while (category) {
CategoryData* catdat;
catdat = parse_category (category);
rv = g_list_append (rv, catdat);
category = category->next;
}
xmlFreeDoc (doc);
return rv;
} /*end fetch_xml_packages_local */
void
free_categories (GList* categories) {
while (categories) {
CategoryData* c = categories->data;
GList* t = c->Packages;
while (t) {
PackageData* pack = t->data;
GList* temp;
temp = pack->SoftDepends;
while (temp) {
g_free (temp->data);
temp = temp->next;
}
g_list_free(pack->SoftDepends);
temp = pack->HardDepends;
while (temp) {
g_free (temp->data);
temp = temp->next;
}
g_list_free (pack->HardDepends);
g_free (t->data);
t = t->next;
}
g_list_free (c->Packages);
g_free (c);
categories = categories->next;
}
g_list_free (categories);
} /* end free_categories */
/* -*- 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.
*