Removing current installer to checkin the new version

This commit is contained in:
J Shane Culpepper 2000-04-26 08:22:25 +00:00
parent a6d15cdefd
commit 0be10106d3
10 changed files with 15 additions and 1101 deletions

View file

@ -1,3 +1,18 @@
2000-04-26 J. Shane Culpepper <pepper@eazel.com>
* components/services/install/eazel-install-lib.h
* components/services/install/eazel-install-lib-xml.c
* components/services/install/eazel-install-lib-xml.h
* components/services/install/eazel-install-lib-rpm.c
* components/services/install/eazel-install-lib-rpm.h
* components/services/install/eazel-install-lib-debug.c
* components/services/install/eazel-install-lib-debug.h
* components/services/install/eazel-install-lib-util.h
* components/services/install/eazel-install-lib-util.c
Removing current installer in order to checkin the new structure
2000-04-25 Ramiro Estrugo <ramiro@eazel.com>
Simplified preferences api by letting gconf do most of the work.

View file

@ -1,89 +0,0 @@
/* -*- 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-services-config.xml
* file and install a services generated package-list.xml.
*/
#include "eazel-install-lib-debug.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 ("port_number = %d\n", iopts->port_number);
g_print ("hostname = %s\n", iopts->hostname);
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 ("name = %s\n", pkg->name);
g_print ("version = %s\n", pkg->version);
g_print ("minor = %s\n", pkg->minor);
g_print ("archtype = %s\n", pkg->archtype);
g_print ("bytesize = %d\n", pkg->bytesize);
g_print ("summary = %s\n", pkg->summary);
g_print ("***End pkg dump***\n");
} /* end dump_package_list */

View file

@ -1,37 +0,0 @@
/* -*- 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-services-config.xml
* file and install a services generated package-list.xml.
*/
#ifndef __EAZEL_INSTALL_LIB_DEBUG_H__
#define __EAZEL_INSTALL_LIB_DEBUG_H__
#include "eazel-install-lib.h"
InstallOptions* init_default_install_configuration_test (void);
void dump_install_options (InstallOptions* iopts);
void dump_package_list (PackageData* pkg);
#endif /* __EAZEL_INSTALL_LIB_DEBUG_H__ */

View file

@ -1,216 +0,0 @@
/* -*- 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-services-config.xml
* file and install a services generated package-list.xml.
*/
#include "eazel-install-lib-rpm.h"
gboolean
install_new_packages (InstallOptions* iopts) {
GList *categories;
gboolean rv;
int installFlags, interfaceFlags, probFilter;
categories = NULL;
installFlags = 0;
interfaceFlags = 0;
probFilter = 0;
if (iopts->mode_test == TRUE) {
installFlags |= RPMTRANS_FLAG_TEST;
}
if (iopts->mode_update == TRUE) {
interfaceFlags |= INSTALL_UPGRADE;
}
if (iopts->mode_verbose == TRUE) {
interfaceFlags |= INSTALL_HASH;
rpmSetVerbosity (RPMMESS_VERBOSE);
}
else {
rpmSetVerbosity (RPMMESS_NORMAL);
}
/* FIXME This needs to be setup as an option. Forcing everything right now. */
probFilter |= RPMPROB_FILTER_REPLACEPKG |
RPMPROB_FILTER_REPLACEOLDFILES |
RPMPROB_FILTER_REPLACENEWFILES |
RPMPROB_FILTER_OLDPACKAGE;
rpmReadConfigFiles (iopts->rpmrc_file, NULL);
g_print ("Reading the install package list ...\n");
categories = parse_local_xml_package_list (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[2];
char *tmpbuf;
int retval;
retval = 0;
tmpbuf = g_strdup_printf ("%s/%s-%s-%s.%s.rpm", iopts->install_tmpdir,
pack->name,
pack->version,
pack->minor,
pack->archtype);
if (iopts->protocol == PROTOCOL_HTTP) {
int rv;
char* rpmname;
char* targetname;
char* url;
rpmname = g_strdup_printf ("%s-%s-%s.%s.rpm", pack->name,
pack->version,
pack->minor,
pack->archtype);
targetname = g_strdup_printf ("%s/%s", iopts->install_tmpdir, rpmname);
url = g_strdup_printf ("http://%s%s/%s", iopts->hostname,
iopts->rpm_storage_dir,
rpmname);
g_print ("Downloading %s...\n", rpmname);
rv = urlGetFile (url, targetname);
if (rv != 0) {
fprintf (stderr, "***Failed to retreive %s !***\n", url);
exit (1);
}
g_free (rpmname);
g_free (targetname);
g_free (url);
}
pkg[0] = tmpbuf;
pkg[1] = NULL;
g_print ("Installing %s\n", pack->summary);
retval = rpmInstall ("/", pkg, installFlags, interfaceFlags,
probFilter, NULL);
if (retval == 0) {
g_print ("Package install successful !\n");
rv = TRUE;
}
else {
g_print ("Package install failed !\n");
rv = FALSE;
}
g_free(tmpbuf);
t = t->next;
}
categories = categories->next;
}
free_categories (categories);
return rv;
} /* end install_new_packages */
gboolean
uninstall_packages (InstallOptions* iopts) {
GList *categories;
gboolean rv;
int uninstallFlags, interfaceFlags;
categories = NULL;
uninstallFlags = 0;
interfaceFlags = 0;
if (iopts->mode_test == TRUE) {
uninstallFlags |= RPMTRANS_FLAG_TEST;
}
if (iopts->mode_verbose == TRUE) {
interfaceFlags |= INSTALL_HASH;
rpmSetVerbosity (RPMMESS_VERBOSE);
}
else {
rpmSetVerbosity (RPMMESS_NORMAL);
}
rpmReadConfigFiles (iopts->rpmrc_file, NULL);
g_print ("Reading the uninstall package list ...\n");
categories = parse_local_xml_package_list (iopts->pkg_list_file);
while (categories) {
CategoryData* c = categories->data;
GList* t = c->Packages;
g_print ("Uninstall Category - %s\n", c->name);
while (t) {
PackageData* pack = t->data;
const char* pkg[2];
char *tmpbuf;
int retval;
retval = 0;
if (g_strcasecmp (pack->archtype, "src") != 0) {
tmpbuf = g_strdup_printf ("%s-%s-%s", pack->name,
pack->version,
pack->minor);
pkg[0] = tmpbuf;
pkg[1] = NULL;
g_print ("Uninstalling %s\n", pack->summary);
retval = rpmErase ("/", pkg, uninstallFlags, interfaceFlags);
if (retval == 0) {
g_print ("Package uninstall successful !\n");
rv = TRUE;
}
else {
g_print ("Package uninstall failed !\n");
rv = FALSE;
}
g_free(tmpbuf);
}
else {
tmpbuf = g_strdup_printf ("%s-%s-%s", pack->name,
pack->version,
pack->minor);
g_print ("%s seems to be a source package. Skipping ...\n", tmpbuf);
g_free(tmpbuf);
}
t = t->next;
}
categories = categories->next;
}
free_categories (categories);
return rv;
} /* end install_new_packages */

View file

@ -1,40 +0,0 @@
/* -*- 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-services-config.xml
* file and install a services generated package-list.xml.
*/
#ifndef __EAZEL_INSTALL_LIB_RPM_H__
#define __EAZEL_INSTALL_LIB_RPM_H__
#include <rpm/rpmlib.h>
#include <rpm/rpmurl.h>
#include "eazel-install-lib.h"
#include "eazel-install-lib-xml.h"
gboolean install_new_packages (InstallOptions* iopts);
gboolean uninstall_packages (InstallOptions* iopts);
#endif /* __EAZEL_INSTALL_LIB_RPM_H__ */

View file

@ -1,53 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
* Copyright (C) 2000 Helix Code, 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>
* Joe Shaw <joe@helixcode.com>
*/
/* eazel-install - services command line install/update/uninstall
* component. This program will parse the eazel-services-config.xml
* file and install a services generated package-list.xml.
*/
#include "eazel-install-lib-util.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 */

View file

@ -1,39 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
* Copyright (C) 2000 Helix Code, 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>
* Joe Shaw <joe@helixcode.com>
*/
/* eazel-install - services command line install/update/uninstall
* component. This program will parse the eazel-services-config.xml
* file and install a services generated package-list.xml.
*/
#ifndef __EAZEL_INSTALL_LIB_UTIL_H__
#define __EAZEL_INSTALL_LIB_UTIL_H__
#include "eazel-install-lib.h"
gboolean check_for_root_user (void);
gboolean check_for_redhat (void);
#endif /* __EAZEL_INSTALL_LIB_UTIL_H__ */

View file

@ -1,495 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
* Copyright (C) 2000 Helix Code, 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>
* Joe Shaw <joe@helixcode.com>
*/
/* eazel-install - services command line install/update/uninstall
* component. This program will parse the eazel-services-config.xml
* file and install a services generated package-list.xml.
*/
#include "eazel-install-lib.h"
#include "eazel-install-lib-xml.h"
static PackageData* parse_package (xmlNode* package);
static CategoryData* parse_category (xmlNode* cat);
static xmlDoc* prune_xml (char* xmlbuf);
static gboolean create_default_configuration_metafile (const char* target_file);
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;
if (!g_file_exists (config_file)) {
gboolean rv;
int retval;
g_print("Creating default configuration file ...\n");
retval = mkdir ("/etc/eazel/services", 0755);
if (retval < 0) {
if (errno != EEXIST) {
fprintf (stderr, "***Could not create services directory !***\n");
exit (1);
}
}
rv = create_default_configuration_metafile(config_file);
if (rv == FALSE) {
fprintf(stderr, "***Could not create the default configuration file !***\n");
exit (1);
}
}
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->hostname = g_strdup (xml_get_value (base, "HOSTNAME"));
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;
rv = g_new0 (PackageData, 1);
rv->name = g_strdup (xml_get_value (package, "NAME"));
rv->version = g_strdup (xml_get_value (package, "VERSION"));
rv->minor = g_strdup (xml_get_value (package, "MINOR"));
rv->archtype = g_strdup (xml_get_value (package, "ARCH"));
rv->bytesize = atoi (xml_get_value (package, "BYTESIZE"));
rv->summary = g_strdup (xml_get_value (package, "SUMMARY"));
/* 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;
}
/* For debugging only
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*
parse_local_xml_package_list (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 */
static xmlDoc*
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
http_fetch_xml_package_list (const char* hostname,
int port,
const char* path,
const char* pkg_list_file) {
GInetAddr* addr;
GTcpSocket* socket;
GIOChannel* iochannel;
char* request;
char* xmlbuf;
GIOError error;
guint bytes;
xmlDocPtr doc;
xmlbuf = "";
/* Create the socket address */
addr = gnet_inetaddr_new (hostname, port);
g_assert (addr != NULL);
/* Create the socket */
socket = gnet_tcp_socket_new (addr);
g_assert (socket != NULL);
/* Get an IOChannel */
iochannel = gnet_tcp_socket_get_iochannel (socket);
g_assert (iochannel != NULL);
/* Make the request */
request = g_strdup_printf ("GET %s HTTP/1.0\r\n\r\n", path);
error = gnet_io_channel_writen (iochannel, request, strlen(request), &bytes);
g_free(request);
if (error != G_IO_ERROR_NONE) {
g_warning("Unable to connect to host: %d\n", error);
}
/* Read the returned info */
while (1) {
char* buffer;
buffer = g_new0(char, 1024);
error = g_io_channel_read(iochannel, buffer, sizeof(buffer), &bytes);
if (error != G_IO_ERROR_NONE) {
g_warning ("Read Error: %d\n", error);
break;
}
if (bytes == 0) {
break;
}
xmlbuf = g_strconcat (xmlbuf, buffer, NULL);
g_free (buffer);
}
g_io_channel_unref (iochannel);
gnet_tcp_socket_delete (socket);
if (strstr (xmlbuf, "HTTP1.0 404") || strstr (xmlbuf, "HTTP/1.1 404")) {
fprintf (stderr, "***File %s not found !***\n", path);
return FALSE;
}
if (strstr (xmlbuf, "HTTP1.0 403") || strstr (xmlbuf, "HTTP/1.1 403")) {
fprintf (stderr, "***Server denied access !***\n");
return FALSE;
}
if (strstr (xmlbuf, "HTTP1.0 400") || strstr (xmlbuf, "HTTP/1.1 400")) {
fprintf (stderr, "***Server could not understand the request !***\n");
return FALSE;
}
doc = prune_xml (xmlbuf);
if (!doc) {
fprintf (stderr, "***Unable to read package file !***\n");
return FALSE;
}
xmlSaveFile (pkg_list_file, doc);
xmlFreeDoc (doc);
return TRUE;
} /* end http_fetch_xml_package_list */
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 */
static gboolean
create_default_configuration_metafile (const char* target_file) {
xmlDocPtr doc;
xmlNodePtr tree;
doc = xmlNewDoc ("1.0");
doc->root = xmlNewDocNode (doc, NULL, "EAZEL_INSTALLER", NULL);
tree = xmlNewChild (doc->root, NULL, "PROTOCOL", "LOCAL");
tree = xmlNewChild (doc->root, NULL, "DEBUG", "TRUE");
tree = xmlNewChild (doc->root, NULL, "DRY_RUN", "FALSE");
tree = xmlNewChild (doc->root, NULL, "VERBOSE", "TRUE");
tree = xmlNewChild (doc->root, NULL, "SILENT", "FALSE");
tree = xmlNewChild (doc->root, NULL, "DEPEND", "FALSE");
tree = xmlNewChild (doc->root, NULL, "UNINSTALL", "FALSE");
tree = xmlNewChild (doc->root, NULL, "UPDATE", "TRUE");
tree = xmlNewChild (doc->root, NULL, "PORT", "80");
tree = xmlNewChild (doc->root, NULL, "HOSTNAME", "10.1.1.5");
tree = xmlNewChild (doc->root, NULL, "RPMRC_FILE", "/usr/lib/rpm/rpmrc");
tree = xmlNewChild (doc->root, NULL, "PKG_LIST_FILE", "/etc/eazel/services/package-list.xml");
tree = xmlNewChild (doc->root, NULL, "RPM_STORAGE_DIR", "/RPMS");
tree = xmlNewChild (doc->root, NULL, "TMPDIR", "/tmp/eazel-install");
if (doc == NULL) {
fprintf (stderr, "***Error generating default configuration file !***\n");
xmlFreeDoc (doc);
exit (1);
}
xmlSaveFile (target_file, doc);
xmlFreeDoc (doc);
return TRUE;
} /* end create_default_configuration_metafile */

View file

@ -1,50 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
* Copyright (C) 2000 Helix Code, 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>
* Joe Shaw <joe@helixcode.com>
*/
/* eazel-install - services command line install/update/uninstall
* component. This program will parse the eazel-services-config.xml
* file and install a services generated package-list.xml.
*/
#ifndef __EAZEL_INSTALL_LIB_XML_H__
#define __EAZEL_INSTALL_LIB_XML_H__
#include <errno.h>
#include <sys/stat.h>
#include <gnet/gnet.h>
#include <gnome-xml/tree.h>
#include <gnome-xml/parser.h>
#include "eazel-install-lib.h"
char* xml_get_value (xmlNode* node, const char* name);
InstallOptions* init_default_install_configuration (const char* config_file);
GList* parse_local_xml_package_list (const char* pkg_list_file);
gboolean http_fetch_xml_package_list (const char* hostname,
int port,
const char* path,
const char* pkg_list_file);
void free_categories (GList* categories);
#endif /* __EAZEL_INSTALL_LIB_XML_H__ */

View file

@ -1,82 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc
* Copyright (C) 2000 Helix Code, 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>
* Joe Shaw <joe@helixcode.com>
*/
/* eazel-install - services command line install/update/uninstall
* component. This program will parse the eazel-services-config.xml
* file and install a services generated package-list.xml.
*/
#ifndef __EAZEL_INSTALL_LIB_H__
#define __EAZEL_INSTALL_LIB_H__
#include <gnome.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
typedef enum _URLType URLType;
typedef struct _InstallOptions InstallOptions;
typedef struct _CategoryData CategoryData;
typedef struct _PackageData PackageData;
enum _URLType {
PROTOCOL_LOCAL,
PROTOCOL_HTTP,
PROTOCOL_FTP
};
struct _InstallOptions {
URLType protocol; /* Specifies local, ftp, or http */
gboolean mode_debug; /* Internal testing mode for debugging */
gboolean mode_test; /* dry run mode */
gboolean mode_verbose; /* print extra information */
gboolean mode_silent; /* FIXME print all information to a logfile */
gboolean mode_depend; /* FIXME print all dependancies */
gboolean mode_uninstall; /* Uninstall the package list */
gboolean mode_update; /* If package is already installed, update it */
guint port_number; /* Connection port */
char* hostname;
char* rpmrc_file; /* Points to the rpmrc file */
char* pkg_list_file; /* Absolute path to package-list.xml */
char* rpm_storage_dir; /* Absolute path to remote RPM directory */
char* install_tmpdir; /* Location to copy rpm downloads before installing */
};
struct _CategoryData {
char* name;
GList* Packages;
};
struct _PackageData {
char* name;
char* version;
char* minor;
char* archtype;
int bytesize;
char* summary;
GList* SoftDepends;
GList* HardDepends;
};
#endif /* __EAZEL_INSTALL_LIB_H__ */