Too much to list it all. Basically it now tries to do what apt-get has

* components/services/docs/installer-dep-check:
	(set_parameters_from_command_line), (eazel_progress_signal),
	(download_failed), (install_failed), (dep_check), (create_package),
	(main):
	* components/services/install/lib/Makefile.am:
	* components/services/install/lib/eazel-install-object.c:
	(eazel_install_set_arg), (eazel_install_class_initialize),
	(eazel_install_initialize),
	(eazel_install_fetch_remote_package_list),
	(eazel_install_emit_install_failed),
	(eazel_install_emit_dependency_check),
	(eazel_install_install_packages), (eazel_install_uninstall):
	* components/services/install/lib/eazel-install-private.h:
	* components/services/install/lib/eazel-install-protocols.c:
	(http_fetch_remote_file), (ftp_fetch_remote_file),
	(local_fetch_remote_file), (eazel_install_fetch_file),
	(eazel_install_fetch_package):
	* components/services/install/lib/eazel-install-protocols.h:
	* components/services/install/lib/eazel-install-public.h:
	* components/services/install/lib/eazel-install-rpm-glue.c:
	(install_new_packages), (download_all_packages),
	(install_all_packages), (uninstall_packages),
	(uninstall_a_package), (build_packagedata_list_from_deps),
	(do_rpm_install), (do_rpm_uninstall),
	(eazel_install_prune_packages_helper),
	(eazel_install_prune_packages), (eazel_install_load_rpm_headers),
	(eazel_install_load_headers), (eazel_install_free_rpm_system),
	(eazel_install_prepare_rpm_system),
	(eazel_install_prepare_package_system),
	(eazel_install_free_package_system),
	(eazel_install_add_headers_to_rpm_set),
	(eazel_install_add_headers_to_set),
	(eazel_install_package_name_compare),
	(eazel_install_package_conflict_compare),
	(eazel_install_add_to_extras_foreach),
	(eazel_install_fetch_rpm_dependencies),
	(eazel_install_fetch_dependencies), (print_package_list),
	(eazel_install_ensure_deps), (rpm_install):
	* components/services/install/lib/eazel-install-rpm-glue.h:
	* components/services/install/lib/eazel-install-types.c:
	(protocol_as_string), (packagedata_new),
	(packagedata_new_from_rpm_conflict),
	(packagedata_new_from_rpm_conflict_reversed),
	(packagedata_new_from_rpm_header),
	(packagedata_fill_from_rpm_header), (packagedata_destroy_foreach),
	(packagedata_destroy), (rpmfilename_from_packagedata),
	(packagedata_hash), (packagedata_equal):
	* components/services/install/lib/eazel-install-types.h:
	* components/services/install/lib/eazel-install-xml-package-list.c:
	(parse_package), (parse_local_xml_package_list):
	* components/services/trilobite/libtrilobite/helixcode-utils.c:
	(xml_get_value):
	Too much to list it all. Basically it now tries to do what apt-get
	has done for ages. Given a list of packages to install, it
	recursively traverses the packagelist, fetches missing
	dependencies (no remote fetch yet, requires a search script on the
	server side) untill all deps are satisfies. If deps failed, it
	prunes the tree and emit signals.
	I've tried to do it modular enough to add support for other
	package systems then rpm, but rpm calls are still strewm about.

	* components/services/install/command-line/Makefile.am:
	* components/services/install/command-line/eazel-alt-install.c:
	Now takes random package names at commandline and should
	ideally try to download them from the server.

	* nautilus-installer/src/Makefile:
	* nautilus-installer/src/Makefile.am:
	* nautilus-installer/src/installer.c: (eazel_download_progress),
	(install_failed_helper), (install_failed), (installer):
	Fixed to work the new stuff in libinstall. Also generates
	prettier (but still ugly) error reports.
This commit is contained in:
Eskil Heyn Olsen 2000-06-09 00:52:29 +00:00
parent b5734b371d
commit 8dbc1bad6d
19 changed files with 1539 additions and 474 deletions

View file

@ -1,3 +1,76 @@
2000-06-08 Eskil Heyn Olsen <eskil@eazel.com>
* components/services/docs/installer-dep-check:
(set_parameters_from_command_line), (eazel_progress_signal),
(download_failed), (install_failed), (dep_check), (create_package),
(main):
* components/services/install/lib/Makefile.am:
* components/services/install/lib/eazel-install-object.c:
(eazel_install_set_arg), (eazel_install_class_initialize),
(eazel_install_initialize),
(eazel_install_fetch_remote_package_list),
(eazel_install_emit_install_failed),
(eazel_install_emit_dependency_check),
(eazel_install_install_packages), (eazel_install_uninstall):
* components/services/install/lib/eazel-install-private.h:
* components/services/install/lib/eazel-install-protocols.c:
(http_fetch_remote_file), (ftp_fetch_remote_file),
(local_fetch_remote_file), (eazel_install_fetch_file),
(eazel_install_fetch_package):
* components/services/install/lib/eazel-install-protocols.h:
* components/services/install/lib/eazel-install-public.h:
* components/services/install/lib/eazel-install-rpm-glue.c:
(install_new_packages), (download_all_packages),
(install_all_packages), (uninstall_packages),
(uninstall_a_package), (build_packagedata_list_from_deps),
(do_rpm_install), (do_rpm_uninstall),
(eazel_install_prune_packages_helper),
(eazel_install_prune_packages), (eazel_install_load_rpm_headers),
(eazel_install_load_headers), (eazel_install_free_rpm_system),
(eazel_install_prepare_rpm_system),
(eazel_install_prepare_package_system),
(eazel_install_free_package_system),
(eazel_install_add_headers_to_rpm_set),
(eazel_install_add_headers_to_set),
(eazel_install_package_name_compare),
(eazel_install_package_conflict_compare),
(eazel_install_add_to_extras_foreach),
(eazel_install_fetch_rpm_dependencies),
(eazel_install_fetch_dependencies), (print_package_list),
(eazel_install_ensure_deps), (rpm_install):
* components/services/install/lib/eazel-install-rpm-glue.h:
* components/services/install/lib/eazel-install-types.c:
(protocol_as_string), (packagedata_new),
(packagedata_new_from_rpm_conflict),
(packagedata_new_from_rpm_conflict_reversed),
(packagedata_new_from_rpm_header),
(packagedata_fill_from_rpm_header), (packagedata_destroy_foreach),
(packagedata_destroy), (rpmfilename_from_packagedata),
(packagedata_hash), (packagedata_equal):
* components/services/install/lib/eazel-install-types.h:
* components/services/install/lib/eazel-install-xml-package-list.c:
(parse_package), (parse_local_xml_package_list):
* components/services/trilobite/libtrilobite/helixcode-utils.c:
(xml_get_value):
Too much to list it all. Basically it now tries to do what apt-get
has done for ages. Given a list of packages to install, it
recursively traverses the packagelist, fetches missing
dependencies (no remote fetch yet, requires a search script on the
server side) untill all deps are satisfies. If deps failed, it
prunes the tree and emit signals.
* components/services/install/command-line/Makefile.am:
* components/services/install/command-line/eazel-alt-install.c:
Now takes random package names at commandline and should
ideally try to download them from the server.
* nautilus-installer/src/Makefile:
* nautilus-installer/src/Makefile.am:
* nautilus-installer/src/installer.c: (eazel_download_progress),
(install_failed_helper), (install_failed), (installer):
Fixed to work the new stuff in libinstall. Also generates
prettier (but still ugly) error reports.
2000-06-08 John Sullivan <sullivan@eazel.com>
Fixed bug 542 (context menus in directory view sometimes

View file

@ -1,7 +1,29 @@
rpm_install (GList filenames)
ensure_deps_helper (GList &packages, GList &failedpackages)
1. load package headers for unloaded, bind packages[x] to header[x], set state to unresolved
2. add to transaction set
3. depcheck
4. if ok - return (failedpackages = NULL)
if fail - ensure_deps_are_fetched (packages, &tmp_extra, &tmp_failed)
5. add tmp_extra to packages
6. if tmp_failed - prune_packages (tmp_failed, packages, failedpacakges)
7 call ensure_deps_helper (packages, &failedpackages)
ensure_deps (GList &packages, GList &failedpackages)
1. copy pacakges into tmp
2. ensure_deps_helper (tmp, tmp_failed)
3. for each (packages) if in tmp_failed
4 emit_signal
5 remove from tmp_failed
6 move from packages to failedpackages
7. for each (tmp_failed)
8. delete
rpm_install (GList packages)
|
|- while ( (state = ensure_deps (&filenames, &out_files)) == rerun) {
| | merge filenames with outfiles
|- while ( (state = ensure_deps (&packages, &out_files)) == rerun) {
| | merge packages with outfiles
| | free outfiles
| | }
| |
@ -17,12 +39,12 @@ rpm_install (GList filenames)
| | | |- http_fetch or such, dep on topts
| | |- if (state == no_matching)
| | | |- emit signal install_failed (package, DEP_FAIL)
| | | |- remove from filenames
| | | |- remove from packages
| | |- if (state == ok)
| | |- add conflicts to out_files
| |- return rerun
|
|- do_rpm_install (filenames)
|- do_rpm_install (packages)
|- read headers
| if (source)
| |- emit signal install_failed (package, DEP_SRC_NO_SUPPORTED)
@ -31,10 +53,21 @@ rpm_install (GList filenames)
|- run transaction set
bool ensure_deps (service, GList **filenames, GList **output_files) {
GList *load_rpm_headers (GList *packages) {
}
bool rpm_install (service, GList *filenames) {
free_rpm_header_list (GList *headers);
gboolean is_source_rpm (struct header header) {
}
add_headers_to_transaction_set (GList *headers, rpmTransactionSet set) {
}
bool ensure_deps_are_fetched (service, GList **packages, GList **output_files) {
}
bool rpm_install (service, GList *packages) {
}
bool fetch_deps (service, struct DepConflicts, int num_conflicts) {
@ -42,3 +75,11 @@ bool fetch_deps (service, struct DepConflicts, int num_conflicts) {
bool do_rpm_install (service, GList filename) {
}
-----------------------
fetch_packages (service, packages, conflicts, &failedpackages)
|
|-for_each conflict {
|- packagedata *pack = packagedata from packages that matches conflict[0];
|- call http_fetch_file_with_special_tricky_url

View file

@ -4,8 +4,8 @@ CPPFLAGS = \
-DPREFIX=\"$(prefix)\" \
-DG_LOG_DOMAIN=\"Nautilus-Services\"
CFLAGS = -O
LDFLAGS = -static
## CFLAGS = -O -g
## LDFLAGS = -static
INCLUDES = \
-I$(top_srcdir) \

View file

@ -34,6 +34,7 @@ gcc -static -g -Wall -Wno-uninitialized -Wchar-subscripts -Wmissing-declarations
#include <gnome.h>
#include <liboaf/liboaf.h>
#include <bonobo.h>
#include <sys/utsname.h>
#include "eazel-install-public.h"
#include <libtrilobite/helixcode-utils.h>
@ -50,19 +51,25 @@ gcc -static -g -Wall -Wno-uninitialized -Wchar-subscripts -Wmissing-declarations
#define DEFAULT_REMOTE_RPM_DIR "/RPMS"
#define DEFAULT_LOG_FILE "/tmp/eazel-install/log"
#define ASSUME_ix86_IS_i386
int arg_dry_run,
arg_http,
arg_ftp,
arg_local;
arg_local,
arg_debug;
char *arg_server,
*arg_config_file;
*arg_config_file,
*arg_local_list;
static const struct poptOption options[] = {
{"dry", 'd', POPT_ARG_NONE, &arg_dry_run, 0, N_("Test run"), NULL},
{"debug", 0, POPT_ARG_NONE, &arg_debug, 0 , N_("Show debug output"), NULL},
{"test", 't', POPT_ARG_NONE, &arg_dry_run, 0, N_("Test run"), NULL},
{"server", '\0', POPT_ARG_STRING, &arg_server, 0, N_("Specify server"), NULL},
{"http", 'h', POPT_ARG_NONE, &arg_http, 0, N_("Use http"), NULL},
{"ftp", 'f', POPT_ARG_NONE, &arg_ftp, 0, N_("Use ftp"), NULL},
{"local", 'l', POPT_ARG_NONE, &arg_local, 0, N_("Use local"), NULL},
{"packagelist", '\0', POPT_ARG_STRING, &arg_local_list, 0, N_("Specify package list to use (/var/eazel/service/package-list.xml"), NULL},
{"config", '\0', POPT_ARG_STRING, &arg_config_file, 0, N_("Specify config file"), NULL},
{NULL, '\0', 0, NULL, 0}
};
@ -84,51 +91,133 @@ set_parameters_from_command_line (EazelInstall *service)
} else if (arg_local) {
eazel_install_set_protocol (service, PROTOCOL_LOCAL);
}
fprintf (stdout, "protocol is %d\n", eazel_install_get_protocol (service));
fprintf (stdout, "tmpdir is %s\n", eazel_install_get_tmp_dir (service));
fprintf (stdout, "pkg_list is %s\n", eazel_install_get_package_list (service));
}
static void
eazel_install_progress (EazelInstall *service,
const char *name,
int amount,
int total,
gpointer data)
eazel_progress_signal (EazelInstall *service,
const char *name,
int amount,
int total,
char *title)
{
fprintf (stdout, "INSTALL Progress - %% %f\r", (total ? ((float)
((((float) amount) / total) * 100))
: 100.0));
fprintf (stdout, "%s - %s %% %f\r", title, name, (total ? ((float)
((((float) amount) / total) * 100))
: 100.0));
fflush (stdout);
if (amount == total) {
if (amount == total && total!=0) {
fprintf (stdout, "\n");
}
}
static void
eazel_download_progress (EazelInstall *service,
const char *name,
int amount,
int total,
gpointer data)
static void
download_failed (EazelInstall *service,
const char *name,
const gpointer info,
gpointer unused)
{
fprintf (stdout, "DOWNLOAD Progress - %% %f\r", (total ? ((float)
((((float) amount) / total) * 100))
: 100.0));
fflush (stdout);
if (amount == total) {
fprintf (stdout, "\n");
fprintf (stdout, "Download of %s FAILED\n", name);
}
static void
install_failed (EazelInstall *service,
const PackageData *pd,
gchar *indent)
{
GList *iterator;
if (pd->toplevel) {
fprintf (stdout, "\n***The package %s failed. Here's the dep tree\n", pd->name);
}
switch (pd->status) {
case PACKAGE_DEPENDENCY_FAIL:
fprintf (stdout, "%s-%s FAILED\n", indent, rpmfilename_from_packagedata (pd));
break;
case PACKAGE_CANNOT_OPEN:
fprintf (stdout, "%s-%s NOT FOUND\n", indent, rpmfilename_from_packagedata (pd));
break;
case PACKAGE_SOURCE_NOT_SUPPORTED:
fprintf (stdout, "%s-%s is a source package\n", indent, rpmfilename_from_packagedata (pd));
break;
case PACKAGE_BREAKS_DEPENDENCY:
fprintf (stdout, "%s-%s breaks\n", indent, rpmfilename_from_packagedata (pd));
break;
default:
fprintf (stdout, "%s-%s\n", indent, rpmfilename_from_packagedata (pd));
break;
}
for (iterator = pd->soft_depends; iterator; iterator = iterator->next) {
PackageData *pack;
char *indent2;
indent2 = g_strconcat (indent, iterator->next ? " |" : " " , NULL);
pack = (PackageData*)iterator->data;
install_failed (service, pack, indent2);
g_free (indent2);
}
for (iterator = pd->breaks; iterator; iterator = iterator->next) {
PackageData *pack;
char *indent2;
indent2 = g_strconcat (indent, iterator->next ? " |" : " " , NULL);
pack = (PackageData*)iterator->data;
install_failed (service, pack, indent2);
g_free (indent2);
}
}
static void
dep_check (EazelInstall *service,
const PackageData *package,
const PackageData *needs,
gpointer unused)
{
fprintf (stdout, "Doing dependency check for %s - need %s\n", package->name, needs->name);
}
static PackageData*
create_package (char *name)
{
struct utsname buf;
PackageData *pack;
uname (&buf);
pack = packagedata_new ();
pack->name = g_strdup (name);
pack->archtype = g_strdup (buf.machine);
#ifdef ASSUME_ix86_IS_i386
if (strlen (pack->archtype)==4 && pack->archtype[0]=='i' &&
pack->archtype[1]>='3' && pack->archtype[1]<='9' &&
pack->archtype[2]=='8' && pack->archtype[3]=='6') {
g_free (pack->archtype);
pack->archtype = g_strdup ("i386");
}
#endif
pack->distribution = determine_distribution_type ();
pack->toplevel = TRUE;
return pack;
}
int main(int argc, char *argv[]) {
EazelInstall *service;
poptContext ctxt;
GList *packages;
GList *categories;
char *str;
gnome_init_with_popt_table ("trilobite-eazel-time-service-cli", "1.0",argc, argv, options, 0, &ctxt);
gnome_init_with_popt_table ("trilobite-eazel-time-service-cli", "1.0",argc, argv, options, 0, NULL);
packages = NULL;
categories = NULL;
while ((str = poptGetArg (ctxt)) != NULL) {
packages = g_list_prepend (packages, create_package (str));
}
if (packages) {
CategoryData *category;
category = g_new0 (CategoryData, 1);
category->packages = packages;
categories = g_list_prepend (NULL, category);
} else {
g_message ("Using remote list ");
}
if (check_for_root_user() == FALSE) {
fprintf (stderr, "*** This tool requires root access.\n");
@ -144,10 +233,15 @@ int main(int argc, char *argv[]) {
service = eazel_install_new_with_config (arg_config_file);
g_assert (service != NULL);
gtk_signal_connect (GTK_OBJECT (service), "download_progress", eazel_download_progress, NULL);
gtk_signal_connect (GTK_OBJECT (service), "install_progress", eazel_install_progress, NULL);
gtk_signal_connect (GTK_OBJECT (service), "download_progress", eazel_progress_signal, "Download progress");
gtk_signal_connect (GTK_OBJECT (service), "install_progress", eazel_progress_signal, "Install progress");
gtk_signal_connect (GTK_OBJECT (service), "install_failed", install_failed, "");
gtk_signal_connect (GTK_OBJECT (service), "download_failed", download_failed, NULL);
gtk_signal_connect (GTK_OBJECT (service), "dependency_check", dep_check, NULL);
eazel_install_open_log (service, DEFAULT_LOG_FILE);
if (!arg_debug) {
eazel_install_open_log (service, DEFAULT_LOG_FILE);
}
eazel_install_set_hostname (service, DEFAULT_HOSTNAME);
eazel_install_set_rpmrc_file (service, DEFAULT_RPMRC);
eazel_install_set_package_list_storage_path (service, DEFAULT_REMOTE_PACKAGE_LIST);
@ -155,10 +249,17 @@ int main(int argc, char *argv[]) {
eazel_install_set_tmp_dir (service, DEFAULT_TMP_DIR);
eazel_install_set_port_number (service, DEFAULT_PORT_NUMBER);
eazel_install_set_protocol (service, DEFAULT_PROTOCOL);
if (arg_dry_run) {
eazel_install_set_test (service, TRUE);
}
if (arg_local_list) {
eazel_install_set_package_list (service, arg_local_list);
}
set_parameters_from_command_line (service);
eazel_install_new_packages (service);
eazel_install_install_packages (service, categories);
eazel_install_destroy (GTK_OBJECT (service));

View file

@ -2,7 +2,7 @@ NULL =
CPPFLAGS = \
-DPREFIX=\"$(prefix)\" \
-DG_LOG_DOMAIN=\"Eazel-Install\" \
-DG_LOG_DOMAIN=\"eazel-install\" \
-DSTANDALONE \
$(NULL)

View file

@ -46,6 +46,8 @@ enum {
INSTALL_FAILED,
UNINSTALL_FAILED,
DEPENDENCY_CHECK,
LAST_SIGNAL
};
@ -67,6 +69,8 @@ enum {
ARG_RPM_STORAGE_PATH,
ARG_PACKAGE_LIST_STORAGE_PATH,
ARG_PACKAGE_LIST,
ARG_ROOT_DIR,
ARG_PACKAGE_SYSTEM,
ARG_PORT_NUMBER
};
@ -200,29 +204,15 @@ eazel_install_set_arg (GtkObject *object,
case ARG_PORT_NUMBER:
eazel_install_set_port_number (service, GTK_VALUE_UINT(*arg));
break;
case ARG_PACKAGE_SYSTEM:
eazel_install_set_package_system (service, GTK_VALUE_ENUM(*arg));
break;
case ARG_ROOT_DIR:
eazel_install_set_root_dir (service, (char*)GTK_VALUE_POINTER(*arg));
break;
}
}
typedef gint (*GtkSignal_NONE__POINTER_ENUM_POINTER) (GtkObject * object,
gpointer arg1,
gint arg2,
gpointer arg3,
gpointer user_data);
static void
gtk_marshal_NONE__POINTER_ENUM_POINTER (GtkObject * object,
GtkSignalFunc func,
gpointer func_data,
GtkArg * args)
{
GtkSignal_NONE__POINTER_ENUM_POINTER rfunc;
rfunc = (GtkSignal_NONE__POINTER_ENUM_POINTER) func;
(*rfunc) (object,
GTK_VALUE_POINTER (args[0]),
GTK_VALUE_ENUM (args[1]),
GTK_VALUE_POINTER (args[2]),
func_data);
}
static void
eazel_install_class_initialize (EazelInstallClass *klass)
{
@ -268,8 +258,8 @@ eazel_install_class_initialize (EazelInstallClass *klass)
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (EazelInstallClass, install_failed),
gtk_marshal_NONE__POINTER_ENUM_POINTER,
GTK_TYPE_NONE, 3, GTK_TYPE_POINTER, GTK_TYPE_ENUM, GTK_TYPE_POINTER);
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);
signals[UNINSTALL_FAILED] =
gtk_signal_new ("uninstall_failed",
GTK_RUN_LAST,
@ -277,6 +267,13 @@ eazel_install_class_initialize (EazelInstallClass *klass)
GTK_SIGNAL_OFFSET (EazelInstallClass, uninstall_failed),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);
signals[DEPENDENCY_CHECK] =
gtk_signal_new ("dependency_check",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (EazelInstallClass, dependency_check),
gtk_marshal_NONE__POINTER_POINTER,
GTK_TYPE_NONE, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
gtk_object_add_arg_type ("EazelInstall::verbose",
@ -343,10 +340,18 @@ eazel_install_class_initialize (EazelInstallClass *klass)
GTK_TYPE_POINTER,
GTK_ARG_READWRITE,
ARG_PACKAGE_LIST);
gtk_object_add_arg_type ("EazelInstall::root_dir",
GTK_TYPE_POINTER,
GTK_ARG_READWRITE,
ARG_ROOT_DIR);
gtk_object_add_arg_type ("EazelInstall::port_number",
GTK_TYPE_UINT,
GTK_ARG_READWRITE,
ARG_PORT_NUMBER);
gtk_object_add_arg_type ("EazelInstall::package_system",
GTK_TYPE_ENUM,
GTK_ARG_READWRITE,
ARG_PACKAGE_SYSTEM);
}
#ifndef STANDALONE
@ -402,6 +407,12 @@ eazel_install_initialize (EazelInstall *service) {
service->private = g_new0 (EazelInstallPrivate,1);
service->private->topts = g_new0 (TransferOptions, 1);
service->private->iopts = g_new0 (InstallOptions, 1);
service->private->root_dir = NULL;
service->private->packsys.rpm.conflicts = NULL;
service->private->packsys.rpm.num_conflicts = 0;
service->private->packsys.rpm.db = NULL;
service->private->packsys.rpm.set = NULL;
service->private->logfile = NULL;
}
GtkType
@ -502,7 +513,7 @@ create_temporary_directory (const char* tmpdir)
} /* end create_temporary_directory */
static gboolean
fetch_remote_package_list (EazelInstall *service)
eazel_install_fetch_remote_package_list (EazelInstall *service)
{
gboolean retval;
char* url;
@ -515,7 +526,7 @@ fetch_remote_package_list (EazelInstall *service)
eazel_install_get_hostname (service),
eazel_install_get_package_list_storage_path (service));
retval = http_fetch_remote_file (service, url, eazel_install_get_package_list (service));
retval = eazel_install_fetch_file (service, url, eazel_install_get_package_list (service));
if (retval == FALSE) {
g_free (url);
@ -557,12 +568,10 @@ eazel_install_emit_download_failed (EazelInstall *service,
void
eazel_install_emit_install_failed (EazelInstall *service,
const PackageData *pd,
RPM_FAIL code,
const gpointer info)
const PackageData *pd)
{
SANITY(service);
gtk_signal_emit (GTK_OBJECT (service), signals[INSTALL_FAILED], pd, code, info);
gtk_signal_emit (GTK_OBJECT (service), signals[INSTALL_FAILED], pd);
}
void
@ -573,6 +582,15 @@ eazel_install_emit_uninstall_failed (EazelInstall *service,
gtk_signal_emit (GTK_OBJECT (service), signals[UNINSTALL_FAILED], pd);
}
void
eazel_install_emit_dependency_check (EazelInstall *service,
const PackageData *package,
const PackageData *needs)
{
SANITY(service);
gtk_signal_emit (GTK_OBJECT (service), signals[DEPENDENCY_CHECK], package, needs);
}
static void
eazel_install_log (const char *domain,
GLogLevelFlags flags,
@ -610,7 +628,7 @@ eazel_install_open_log (EazelInstall *service,
}
void
eazel_install_new_packages (EazelInstall *service)
eazel_install_install_packages (EazelInstall *service, GList *categories)
{
SANITY (service);
@ -620,10 +638,19 @@ eazel_install_new_packages (EazelInstall *service)
create_temporary_directory (eazel_install_get_tmp_dir (service));
}
if (service->private->iopts->protocol == PROTOCOL_HTTP) {
fetch_remote_package_list (service);
if (categories == NULL) {
switch (service->private->iopts->protocol) {
case PROTOCOL_HTTP:
eazel_install_fetch_remote_package_list (service);
break;
case PROTOCOL_FTP:
g_error ("ftp install not supported");
break;
case PROTOCOL_LOCAL:
break;
}
}
if (install_new_packages (service)==FALSE) {
if (install_new_packages (service, categories)==FALSE) {
g_warning ("*** Install failed");
}
}
@ -635,8 +662,15 @@ eazel_install_uninstall (EazelInstall *service)
g_message ("eazel_install_new_packages");
if (service->private->iopts->protocol == PROTOCOL_HTTP) {
fetch_remote_package_list (service);
switch (service->private->iopts->protocol) {
case PROTOCOL_HTTP:
eazel_install_fetch_remote_package_list (service);
break;
case PROTOCOL_FTP:
g_error ("ftp install not supported");
break;
case PROTOCOL_LOCAL:
break;
}
if (uninstall_packages (service)==FALSE) {
g_warning ("*** Uninstall failed");
@ -647,38 +681,52 @@ eazel_install_uninstall (EazelInstall *service)
/* Welcome to define madness. These are all the get/set methods. There is nothing of
interest beyond this point, except for a fucking big dragon*/
ei_mutator_impl (verbose, gboolean, iopts, mode_verbose);
ei_mutator_impl (silent, gboolean, iopts, mode_silent);
ei_mutator_impl (debug, gboolean, iopts, mode_debug);
ei_mutator_impl (test, gboolean, iopts, mode_test);
ei_mutator_impl (force, gboolean, iopts, mode_force);
ei_mutator_impl (depend, gboolean, iopts, mode_depend);
ei_mutator_impl (update, gboolean, iopts, mode_update);
ei_mutator_impl (uninstall, gboolean, iopts, mode_uninstall);
ei_mutator_impl (downgrade, gboolean, iopts, mode_downgrade);
ei_mutator_impl (protocol, URLType, iopts, protocol);
ei_mutator_impl_string (tmp_dir, char*, topts, tmp_dir);
ei_mutator_impl_string (rpmrc_file, char*, topts, rpmrc_file);
ei_mutator_impl_string (hostname, char*, topts, hostname);
ei_mutator_impl_string (rpm_storage_path, char*, topts, rpm_storage_path);
ei_mutator_impl_string (package_list_storage_path, char*, topts, pkg_list_storage_path);
ei_mutator_impl_string (package_list, char*, iopts, pkg_list);
ei_mutator_impl (port_number, guint, topts, port_number);
ei_mutator_impl (verbose, gboolean, iopts->mode_verbose);
ei_mutator_impl (silent, gboolean, iopts->mode_silent);
ei_mutator_impl (debug, gboolean, iopts->mode_debug);
ei_mutator_impl (test, gboolean, iopts->mode_test);
ei_mutator_impl (force, gboolean, iopts->mode_force);
ei_mutator_impl (depend, gboolean, iopts->mode_depend);
ei_mutator_impl (update, gboolean, iopts->mode_update);
ei_mutator_impl (uninstall, gboolean, iopts->mode_uninstall);
ei_mutator_impl (downgrade, gboolean, iopts->mode_downgrade);
ei_mutator_impl (protocol, URLType, iopts->protocol);
ei_mutator_impl_string (tmp_dir, char*, topts->tmp_dir);
ei_mutator_impl_string (rpmrc_file, char*, topts->rpmrc_file);
ei_mutator_impl_string (hostname, char*, topts->hostname);
ei_mutator_impl_string (rpm_storage_path, char*, topts->rpm_storage_path);
ei_mutator_impl_string (package_list_storage_path, char*, topts->pkg_list_storage_path);
ei_mutator_impl_string (package_list, char*, iopts->pkg_list);
ei_mutator_impl_string (root_dir, char*, root_dir);
ei_mutator_impl (port_number, guint, topts->port_number);
ei_access_impl (verbose, gboolean, iopts, mode_verbose, FALSE);
ei_access_impl (silent, gboolean, iopts, mode_silent, FALSE);
ei_access_impl (debug, gboolean, iopts, mode_debug, FALSE);
ei_access_impl (test, gboolean, iopts, mode_test, FALSE);
ei_access_impl (force, gboolean, iopts, mode_force, FALSE);
ei_access_impl (depend, gboolean, iopts, mode_depend, FALSE);
ei_access_impl (update, gboolean, iopts, mode_update, FALSE);
ei_access_impl (uninstall, gboolean, iopts, mode_uninstall, FALSE);
ei_access_impl (downgrade, gboolean, iopts, mode_downgrade, FALSE);
ei_access_impl (protocol, URLType , iopts, protocol, PROTOCOL_LOCAL);
ei_access_impl (tmp_dir, const char*, topts, tmp_dir, NULL);
ei_access_impl (rpmrc_file, const char*, topts, rpmrc_file, NULL);
ei_access_impl (hostname, const char*, topts, hostname, NULL);
ei_access_impl (rpm_storage_path, const char*, topts, rpm_storage_path, NULL);
ei_access_impl (package_list_storage_path, const char*, topts, pkg_list_storage_path, NULL);
ei_access_impl (package_list, const char*, iopts, pkg_list, NULL);
ei_access_impl (port_number, guint, topts, port_number, 0);
ei_mutator_impl (install_flags, int, install_flags);
ei_mutator_impl (interface_flags, int, interface_flags);
ei_mutator_impl (problem_filters, int, problem_filters);
ei_mutator_impl (package_system, int, package_system);
ei_access_impl (verbose, gboolean, iopts->mode_verbose, FALSE);
ei_access_impl (silent, gboolean, iopts->mode_silent, FALSE);
ei_access_impl (debug, gboolean, iopts->mode_debug, FALSE);
ei_access_impl (test, gboolean, iopts->mode_test, FALSE);
ei_access_impl (force, gboolean, iopts->mode_force, FALSE);
ei_access_impl (depend, gboolean, iopts->mode_depend, FALSE);
ei_access_impl (update, gboolean, iopts->mode_update, FALSE);
ei_access_impl (uninstall, gboolean, iopts->mode_uninstall, FALSE);
ei_access_impl (downgrade, gboolean, iopts->mode_downgrade, FALSE);
ei_access_impl (protocol, URLType , iopts->protocol, PROTOCOL_LOCAL);
ei_access_impl (tmp_dir, const char*, topts->tmp_dir, NULL);
ei_access_impl (rpmrc_file, const char*, topts->rpmrc_file, NULL);
ei_access_impl (hostname, const char*, topts->hostname, NULL);
ei_access_impl (rpm_storage_path, const char*, topts->rpm_storage_path, NULL);
ei_access_impl (package_list_storage_path, const char*, topts->pkg_list_storage_path, NULL);
ei_access_impl (package_list, const char*, iopts->pkg_list, NULL);
ei_access_impl (root_dir, const char*, root_dir, NULL);
ei_access_impl (port_number, guint, topts->port_number, 0);
ei_access_impl (install_flags, int, install_flags, 0);
ei_access_impl (interface_flags, int, interface_flags, 0);
ei_access_impl (problem_filters, int, problem_filters, 0);
ei_access_impl (package_system, int, package_system, 0);

View file

@ -24,13 +24,29 @@
#ifndef EAZEL_INSTALL__PRIVATE_H
#define EAZEL_INSTALL__PRIVATE_H
typedef enum {
REQUEST_BY_HTTP
} RequestMethod;
#include "eazel-install-public.h"
struct _EazelInstallPrivate {
TransferOptions *topts;
InstallOptions *iopts;
/* Used in rpm-glue */
char *root_dir;
int install_flags;
int interface_flags;
int problem_filters;
gboolean use_local_package_list;
PackageSystem package_system;
union {
struct {
rpmdb db;
rpmTransactionSet set;
struct rpmDependencyConflict *conflicts;
int num_conflicts;
} rpm;
} packsys;
FILE *logfile;
};

View file

@ -29,6 +29,17 @@
#include "eazel-install-protocols.h"
#include <config.h>
gboolean http_fetch_remote_file (EazelInstall *service,
char* url,
const char* target_file);
gboolean ftp_fetch_remote_file (EazelInstall *service,
char* url,
const char* target_file);
gboolean local_fetch_remote_file (EazelInstall *service,
char* url,
const char* target_file);
gboolean
http_fetch_remote_file (EazelInstall *service,
char* url,
@ -39,6 +50,9 @@ http_fetch_remote_file (EazelInstall *service,
ghttp_status status;
char* body;
FILE* file;
int total_bytes;
g_message ("Downloading %s...", url);
file = fopen (target_file, "wb");
get_failed = 0;
@ -55,32 +69,34 @@ http_fetch_remote_file (EazelInstall *service,
request = ghttp_request_new();
if (!request) {
g_warning (_("Could not create an http request !\n"));
g_warning (_("Could not create an http request !"));
get_failed = 1;
}
if (ghttp_set_uri (request, url) != 0) {
g_warning (_("Invalid uri !\n"));
g_warning (_("Invalid uri !"));
get_failed = 1;
}
ghttp_set_header (request, http_hdr_Connection, "close");
ghttp_set_header (request, http_hdr_User_Agent, USER_AGENT_STRING);
if (ghttp_prepare (request) != 0) {
g_warning (_("Could not prepare http request !\n"));
g_warning (_("Could not prepare http request !"));
get_failed = 1;
}
if (ghttp_set_sync (request, ghttp_async)) {
g_warning (_("Couldn't get async mode \n"));
g_warning (_("Couldn't get async mode "));
get_failed = 1;
}
while ((status = ghttp_process (request)) == ghttp_not_done) {
ghttp_current_status curStat = ghttp_get_status (request);
eazel_install_emit_download_progress (service, target_file, curStat.bytes_read, curStat.bytes_total);
total_bytes = curStat.bytes_total;
eazel_install_emit_download_progress (service, target_file, curStat.bytes_read, curStat.bytes_total);
}
eazel_install_emit_download_progress (service, target_file, total_bytes, total_bytes);
if (ghttp_status_code (request) != 200) {
g_warning ("HTTP error: %d %s\n", ghttp_status_code (request),
g_warning ("HTTP error: %d %s", ghttp_status_code (request),
ghttp_reason_phrase (request));
get_failed = 1;
}
@ -90,7 +106,7 @@ http_fetch_remote_file (EazelInstall *service,
fwrite (body, length, 1, file);
}
else {
g_warning (_("Could not get request body!\n"));
g_warning (_("Could not get request body!"));
get_failed = 1;
}
@ -108,3 +124,98 @@ http_fetch_remote_file (EazelInstall *service,
} /* end http_fetch_remote_file */
gboolean
ftp_fetch_remote_file (EazelInstall *service,
char* url,
const char* target_file)
{
g_message ("Downloading %s...", url);
g_warning (_("FTP not supported yet"));
return FALSE;
}
gboolean
local_fetch_remote_file (EazelInstall *service,
char* url,
const char* target_file)
{
gboolean result;
g_message ("Checking local file %s...", target_file);
result = FALSE;
if (access (target_file, R_OK|W_OK) == 0) {
eazel_install_emit_download_progress (service, target_file, 100, 100);
result = TRUE;
}
return result;
}
gboolean
eazel_install_fetch_file (EazelInstall *service,
char* url,
const char* target_file)
{
gboolean result;
result = FALSE;
g_return_val_if_fail (url!=NULL, FALSE);
g_return_val_if_fail (target_file!=NULL, FALSE);
switch (eazel_install_get_protocol (service)) {
case PROTOCOL_HTTP:
result = http_fetch_remote_file (service, url, target_file);
break;
case PROTOCOL_FTP:
result = ftp_fetch_remote_file (service, url, target_file);
break;
case PROTOCOL_LOCAL:
result = local_fetch_remote_file (service, url, target_file);
break;
}
return result;
}
gboolean
eazel_install_fetch_package (EazelInstall *service,
PackageData* package)
{
gboolean result;
char* url;
char* targetname;
result = FALSE;
url = NULL;
targetname = g_strdup_printf ("%s/%s",
eazel_install_get_tmp_dir (service),
rpmfilename_from_packagedata (package));
switch (eazel_install_get_protocol (service)) {
case PROTOCOL_FTP:
case PROTOCOL_HTTP:
{
url = g_strdup_printf ("%s://%s%s/%s",
protocol_as_string (eazel_install_get_protocol (service)),
eazel_install_get_hostname (service),
eazel_install_get_rpm_storage_path (service),
rpmfilename_from_packagedata (package));
}
break;
case PROTOCOL_LOCAL:
url = g_strdup_printf ("%s", rpmfilename_from_packagedata (package));
break;
};
result = eazel_install_fetch_file (service, url, targetname);
g_free (url);
g_free (targetname);
return result;
}

View file

@ -34,8 +34,11 @@
#define USER_AGENT_STRING "eazel-install/"
gboolean http_fetch_remote_file (EazelInstall *service,
char* url,
const char* target_file);
gboolean eazel_install_fetch_file (EazelInstall *service,
char* url,
const char* target_file);
gboolean eazel_install_fetch_package (EazelInstall *service,
PackageData *package);
#endif /* __EAZEL_SERVICES_PROTOCOLS_H__ */

View file

@ -48,6 +48,10 @@ extern "C" {
#define IS_EAZEL_INSTALL(obj) (GTK_CHECK_TYPE ((obj), TYPE_EAZEL_INSTALL))
#define IS_EAZEL_INSTALL_CLASS(klass)(GTK_CHECK_CLASS_TYPE ((obj), TYPE_EAZEL_INSTALL))
typedef enum {
EAZEL_INSTALL_USE_RPM
} PackageSystem;;
typedef struct _EazelInstall EazelInstall;
typedef struct _EazelInstallClass EazelInstallClass;
@ -61,7 +65,7 @@ struct _EazelInstallClass
/* signal prototypes */
void (*download_progress) (char *file, int amount, int total);
void (*install_progress) (char *name, int amount, int total);
void (*dependency_check) (const PackageData *package, const PackageData *needed );
/*
if the set URLType is PROTOCOL_HTTP, info is a HTTPError struc
*/
@ -71,7 +75,7 @@ struct _EazelInstallClass
RPM_DEP_FAIL, info is a GSList of required packages (PackageData objects)
RPM_NOT_AN_RPM, info is NULL
*/
void (*install_failed) (PackageData *pd, RPM_FAIL code, gpointer info);
void (*install_failed) (PackageData *pd);
void (*uninstall_failed) (PackageData *pd);
#ifndef STANDALONE
gpointer servant_vepv;
@ -115,15 +119,16 @@ void eazel_install_emit_download_failed (EazelInstall *service,
const char *name,
const gpointer info);
void eazel_install_emit_install_failed (EazelInstall *service,
const PackageData *pd,
RPM_FAIL code,
const gpointer info);
const PackageData *pd);
void eazel_install_emit_uninstall_failed (EazelInstall *service,
const PackageData *pd);
void eazel_install_emit_dependency_check (EazelInstall *service,
const PackageData *package,
const PackageData *needed );
/* This is in flux */
void eazel_install_fetch_pockage_list (EazelInstall *service);
void eazel_install_new_packages (EazelInstall *service);
void eazel_install_install_packages (EazelInstall *service, GList *categories);
void eazel_install_uninstall (EazelInstall *service);
/******************************************************************************/
@ -147,29 +152,29 @@ void eazel_install_uninstall (EazelInstall *service);
#define ei_access_decl(name, type) \
type eazel_install_get_##name (EazelInstall *service)
#define ei_access_impl(name, type, str, var, defl) \
#define ei_access_impl(name, type, var, defl) \
type eazel_install_get_##name (EazelInstall *service) { \
SANITY_VAL (service, defl); \
return service->private->##str##->var; \
return service->private->var; \
}
#define ei_mutator_decl(name, type) \
void eazel_install_set_##name (EazelInstall *service, \
type name)
#define ei_mutator_impl(name, type, str, var) \
#define ei_mutator_impl(name, type,var) \
void eazel_install_set_##name (EazelInstall *service, \
type name) { \
SANITY (service); \
service->private->str->var = name; \
service->private->var = name; \
}
#define ei_mutator_impl_string(name, type, str, var) \
#define ei_mutator_impl_string(name, type, var) \
void eazel_install_set_##name (EazelInstall *service, \
type name) { \
SANITY (service); \
g_free (service->private->str->var); \
service->private->str->var = g_strdup ( name ); \
g_free (service->private->var); \
service->private->var = g_strdup ( name ); \
}
ei_mutator_decl (verbose, gboolean);
@ -188,8 +193,15 @@ ei_mutator_decl (hostname, char*);
ei_mutator_decl (rpm_storage_path, char*);
ei_mutator_decl (package_list_storage_path, char*);
ei_mutator_decl (package_list, char*);
ei_mutator_decl (root_dir, char*);
ei_mutator_decl (port_number, guint);
ei_mutator_decl (install_flags, int);
ei_mutator_decl (interface_flags, int);
ei_mutator_decl (problem_filters, int);
ei_mutator_decl (package_system, int);
ei_access_decl (verbose, gboolean);
ei_access_decl (silent, gboolean);
ei_access_decl (debug, gboolean);
@ -206,8 +218,15 @@ ei_access_decl (hostname, const char*);
ei_access_decl (rpm_storage_path, const char*);
ei_access_decl (package_list_storage_path, const char*);
ei_access_decl (package_list, const char*);
ei_access_decl (root_dir, const char*);
ei_access_decl (port_number, guint);
ei_access_decl (install_flags, int);
ei_access_decl (interface_flags, int);
ei_access_decl (problem_filters, int);
ei_access_decl (package_system, int);
#ifdef __cplusplus
}
#endif /* __cplusplus */

File diff suppressed because it is too large Load diff

View file

@ -32,7 +32,7 @@
#include "eazel-install-protocols.h"
#include "eazel-install-public.h"
gboolean install_new_packages (EazelInstall *service);
gboolean install_new_packages (EazelInstall *service, GList *categories);
gboolean uninstall_packages (EazelInstall *service);

View file

@ -29,6 +29,24 @@
#include <config.h>
#include "eazel-install-types.h"
const char*
protocol_as_string (URLType protocol)
{
static char as_string[10];
switch (protocol) {
case PROTOCOL_HTTP:
strcpy (as_string, "http");
break;
case PROTOCOL_FTP:
strcpy (as_string, "ftp");
break;
case PROTOCOL_LOCAL:
strcpy (as_string, "file");
break;
}
return as_string;
}
void
categorydata_destroy_foreach (CategoryData *cd, gpointer ununsed)
{
@ -45,32 +63,74 @@ categorydata_destroy (CategoryData *cd)
}
PackageData*
packagedata_new_from_rpm_header (Header hd)
packagedata_new ()
{
PackageData *pd;
return g_new0 (PackageData, 1);
}
pd = g_new0 (PackageData, 1);
headerGetEntry (hd,
RPMTAG_NAME, NULL,
(void **) &pd->name, NULL);
headerGetEntry (hd,
RPMTAG_VERSION, NULL,
(void **) &pd->version, NULL);
headerGetEntry (hd,
RPMTAG_RELEASE, NULL,
(void **) &pd->minor, NULL);
headerGetEntry (hd,
RPMTAG_ARCH, NULL,
(void **) &pd->archtype, NULL);
headerGetEntry (hd,
RPMTAG_SIZE, NULL,
(void **) &pd->bytesize, NULL);
headerGetEntry (hd,
RPMTAG_SUMMARY, NULL,
(void **) &pd->summary, NULL);
return pd;
PackageData*
packagedata_new_from_rpm_conflict (struct rpmDependencyConflict conflict)
{
PackageData *result;
result = g_new0 (PackageData,1);
result->name = g_strdup (conflict.needsName);
result->version = (conflict.needsVersion && (strlen (conflict.needsVersion) > 1)) ? g_strdup (conflict.needsVersion) : NULL;
return result;
}
PackageData*
packagedata_new_from_rpm_conflict_reversed (struct rpmDependencyConflict conflict)
{
PackageData *result;
result = g_new0 (PackageData,1);
result->name = g_strdup (conflict.byName);
result->version = (conflict.byVersion && (strlen (conflict.byVersion) > 1)) ? g_strdup (conflict.byVersion) : NULL;
return result;
}
PackageData*
packagedata_new_from_rpm_header (Header *hd)
{
PackageData *pack;
pack = g_new0 (PackageData, 1);
packagedata_fill_from_rpm_header (pack, hd);
pack->status = PACKAGE_UNKNOWN_STATUS;
pack->toplevel = FALSE;
return pack;
};
void
packagedata_fill_from_rpm_header (PackageData *pack,
Header *hd)
{
headerGetEntry (*hd,
RPMTAG_NAME, NULL,
(void **) &pack->name, NULL);
headerGetEntry (*hd,
RPMTAG_VERSION, NULL,
(void **) &pack->version, NULL);
headerGetEntry (*hd,
RPMTAG_RELEASE, NULL,
(void **) &pack->minor, NULL);
headerGetEntry (*hd,
RPMTAG_ARCH, NULL,
(void **) &pack->archtype, NULL);
headerGetEntry (*hd,
RPMTAG_SIZE, NULL,
(void **) &pack->bytesize, NULL);
headerGetEntry (*hd,
RPMTAG_SUMMARY, NULL,
(void **) &pack->summary, NULL);
pack->packsys_struc = (gpointer)hd;
}
void
packagedata_destroy_foreach (PackageData *pd, gpointer unused)
{
@ -88,6 +148,7 @@ packagedata_destroy_foreach (PackageData *pd, gpointer unused)
pd->bytesize = 0;
g_list_foreach (pd->soft_depends, (GFunc)packagedata_destroy_foreach, NULL);
g_list_foreach (pd->hard_depends, (GFunc)packagedata_destroy_foreach, NULL);
g_list_foreach (pd->breaks, (GFunc)packagedata_destroy_foreach, NULL);
}
void
@ -95,3 +156,46 @@ packagedata_destroy (PackageData *pd)
{
packagedata_destroy_foreach (pd, NULL);
}
const char*
rpmfilename_from_packagedata (const PackageData *pack)
{
static char *filename = NULL;
g_free (filename);
if (pack->version && pack->minor) {
filename = g_strdup_printf ("%s-%s-%s.%s.rpm",
pack->name,
pack->version,
pack->minor,
pack->archtype);
} else if (pack->archtype) {
filename = g_strdup_printf ("%s.%s.rpm",
pack->name,
pack->archtype);
} else {
filename = g_strconcat (pack->name,".rpm", NULL);
}
return filename;
}
int
packagedata_hash (PackageData *pd)
{
g_assert (pd!=NULL);
g_assert (pd->name!=NULL);
return strlen (pd->name);
}
int
packagedata_equal (PackageData *a,
PackageData *b)
{
g_assert (a!=NULL);
g_assert (a->name!=NULL);
g_assert (b!=NULL);
g_assert (b->name!=NULL);
return strcmp (a->name, b->name);
}

View file

@ -35,6 +35,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <rpm/rpmlib.h>
#include <libtrilobite/helixcode-utils.h>
typedef enum _URLType URLType;
typedef enum _PackageType PackageType;
@ -42,12 +43,17 @@ typedef struct _TransferOptions TransferOptions;
typedef struct _InstallOptions InstallOptions;
typedef struct _CategoryData CategoryData;
typedef struct _PackageData PackageData;
typedef enum _RPM_FAIL RPM_FAIL;
typedef enum _PackageSystemStatus PackageSystemStatus;
enum _RPM_FAIL {
RPM_SRC_NOT_SUPPORTED,
RPM_DEP_FAIL,
RPM_NOT_AN_RPM
enum _PackageSystemStatus {
PACKAGE_UNKNOWN_STATUS=0,
PACKAGE_SOURCE_NOT_SUPPORTED,
PACKAGE_DEPENDENCY_FAIL,
PACKAGE_BREAKS_DEPENDENCY,
PACKAGE_INVALID,
PACKAGE_CANNOT_OPEN,
PACKAGE_PARTLY_RESOLVED,
PACKAGE_RESOLVED
};
struct _HTTPError {
@ -60,6 +66,7 @@ enum _URLType {
PROTOCOL_HTTP,
PROTOCOL_FTP
};
const char *protocol_as_string (URLType protocol);
enum _PackageType {
PACKAGE_TYPE_RPM,
@ -102,13 +109,42 @@ struct _PackageData {
char* version;
char* minor;
char* archtype;
DistributionType distribution;
int bytesize;
char* summary;
GList* soft_depends;
GList* hard_depends;
GList* breaks;
/*
toplevel = TRUE if this a package the user requested.
It's used to ensure that a "install_failed" signal is
only emitted for toplevel packages.
It's set to true during the xml loading (that means
it should be set before given to the eazel_install_ensure_deps
*/
gboolean toplevel;
/*
Identifies the status of the installation
*/
PackageSystemStatus status;
/*
Pointer to keep a structure for the package system
*/
gpointer *packsys_struc;
};
PackageData* packagedata_new_from_rpm_header (Header);
PackageData* packagedata_new (void);
PackageData* packagedata_new_from_rpm_header (Header*);
PackageData* packagedata_new_from_rpm_conflict (struct rpmDependencyConflict);
PackageData* packagedata_new_from_rpm_conflict_reversed (struct rpmDependencyConflict);
void packagedata_fill_from_rpm_header (PackageData *pack, Header*);
const char *rpmfilename_from_packagedata (const PackageData *pack);
void packagedata_destroy_foreach (PackageData *pd, gpointer unused);
void packagedata_destroy (PackageData *pd);
int packagedata_hash (PackageData *pd);
int packagedata_equal (PackageData *a, PackageData *b);
#endif /* __EAZEL_SERVICES_TYPES_H__ */

View file

@ -41,7 +41,7 @@ parse_package (xmlNode* package) {
xmlNodePtr dep;
PackageData* rv;
rv = g_new0 (PackageData, 1);
rv = packagedata_new ();
rv->name = g_strdup (xml_get_value (package, "NAME"));
rv->version = g_strdup (xml_get_value (package, "VERSION"));
@ -49,6 +49,7 @@ parse_package (xmlNode* package) {
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"));
rv->toplevel = TRUE;
/* Dependency Lists */
rv->soft_depends = NULL;
@ -156,45 +157,6 @@ parse_local_xml_package_list (const char* pkg_list_file) {
} /*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->soft_depends;
while (temp) {
g_free (temp->data);
temp = temp->next;
}
g_list_free(pack->soft_depends);
temp = pack->hard_depends;
while (temp) {
g_free (temp->data);
temp = temp->next;
}
g_list_free (pack->hard_depends);
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 */
gboolean
generate_xml_package_list (const char* pkg_template_file,
const char* target_file) {

View file

@ -54,6 +54,7 @@ xml_get_value (xmlNode* node, const char* name)
}
child = child->next;
}
return NULL;
} /* end xml_get_value */

View file

@ -69,9 +69,9 @@ CPP = gcc -E
DATADIRNAME = share
DLLTOOL = @DLLTOOL@
EAZEL_SERVICES = 1
GCONF_CFLAGS = -I/gnome/include
GCONF_CFLAGS = -I/gnome/include -I/gnome/lib/glib/include -I/usr/X11R6/include
GCONF_CONFIG = /gnome/bin/gconf-config
GCONF_LIBS = -L/gnome/lib -lgconf -lgconf-gtk
GCONF_LIBS = -rdynamic -L/gnome/lib -L/usr/X11R6/lib -lgconf -lgconf-gtk -lgtk -lgdk -lgmodule -lglib -ldl -lXext -lX11 -lm
GDK_PIXBUF_CFLAGS = -I/gnome/include -I/gnome/lib/glib/include -I/gnome/include -I/usr/X11R6/include
GDK_PIXBUF_CONFIG = /gnome/bin/gdk-pixbuf-config
GDK_PIXBUF_LIBS = -L/gnome/lib -lgdk_pixbuf -L/gnome/lib -L/usr/X11R6/lib -lgtk -lgdk -rdynamic -lgmodule -lglib -ldl -lXext -lX11 -lm
@ -88,7 +88,7 @@ GNET_CFLAGS = -I/gnome/lib/glib/include -I/gnome/include
GNET_CONFIG = /gnome/bin/gnet-config
GNET_LIBS = -L/gnome/lib -lgnet -lglib
GNOMECANVASPIXBUF_INCLUDEDIR =
GNOMECANVASPIXBUF_LIBS = -rdynamic -L/gnome/lib -lgmodule -lglib -ldl -lgdk_pixbuf -ltiff -ljpeg -lpng -lz -lgnomecanvaspixbuf
GNOMECANVASPIXBUF_LIBS = -rdynamic -L/gnome/lib -L/usr/X11R6/lib -lgdk_pixbuf -ltiff -ljpeg -lpng -lz -lgtk -lgdk -lgmodule -lglib -ldl -lXext -lX11 -lm -lgnomecanvaspixbuf
GNOMEUI_CFLAGS = -I/gnome/include -DNEED_GNOMESUPPORT_H -I/gnome/lib/gnome-libs/include -I/gnome/lib/glib/include -I/usr/X11R6/include
GNOMEUI_LIBS = -rdynamic -L/gnome/lib -L/usr/X11R6/lib -L/usr/lib -lgnomeui -lart_lgpl -lgdk_imlib -lSM -lICE -lgtk -lgdk -lgmodule -lXext -lX11 -lgnome -lgnomesupport -lesd -laudiofile -lm -ldb1 -lglib -ldl
GNOME_CFLAGS = -I/gnome/include -DNEED_GNOMESUPPORT_H -I/gnome/lib/gnome-libs/include -I/gnome/lib/glib/include -I/usr/X11R6/include
@ -125,6 +125,10 @@ OAF_CFLAGS = -I/gnome/include -I/gnome/lib/glib/include
OAF_CONFIG = /gnome/bin/oaf-config
OAF_LIBS = -L/gnome/lib -loaf -lORBitCosNaming -lORBit -lIIOP -lORBitutil -lglib -lnsl -lm
OBJDUMP = @OBJDUMP@
ORBIT_CFLAGS = -I/gnome/lib/glib/include -I/gnome/include
ORBIT_CONFIG = /gnome/bin/orbit-config
ORBIT_IDL = /gnome/bin/orbit-idl
ORBIT_LIBS = -L/gnome/lib -lORBit -lIIOP -lORBitutil -lglib -lnsl -lm
PACKAGE = nautilus
PAM_LIBS = -ldl -lpam -lpam_misc
POFILES = da.po gl.po ja.po ko.po no.po ru.po sv.po tr.po fr.po
@ -147,7 +151,7 @@ l =
NULL =
INCLUDES = -I$(top_srcdir)/components/services/install/lib -I$(top_srcdir)/components/services/trilbite -I/usr/include/rpm $(GNOMEUI_CFLAGS) $(XML_CFLAGS) $(GNET_CFLAGS) $(GHTTP_CFLAGS) $(GNOME_INCLUDEDIR) -DGNOMELOCALEDIR=\""$(datadir)/locale"\" -DG_LOG_DOMAIN=\"Nautilus-Installer\" $(NULL)
INCLUDES = -I$(top_srcdir)/components/services/install/lib -I$(top_srcdir)/components/services/trilobite -I/usr/include/rpm $(GNOMEUI_CFLAGS) $(XML_CFLAGS) $(GNET_CFLAGS) $(GHTTP_CFLAGS) $(GNOME_INCLUDEDIR) -DGNOMELOCALEDIR=\""$(datadir)/locale"\" -DG_LOG_DOMAIN=\"Nautilus-Installer\" $(NULL)
CFLAGS = -g $(WERROR)

View file

@ -4,7 +4,7 @@ NULL =
INCLUDES = \
-I$(top_srcdir)/components/services/install/lib \
-I$(top_srcdir)/components/services/trilbite \
-I$(top_srcdir)/components/services/trilobite \
-I/usr/include/rpm \
$(GNOMEUI_CFLAGS) \
$(XML_CFLAGS) \

View file

@ -23,6 +23,8 @@ static char *package_list[LAST] = {
"/package-uninstall-list.xml",
};
char *failure_info;
static void
eazel_install_progress (EazelInstall *service,
const char *name,
@ -79,118 +81,89 @@ eazel_download_progress (EazelInstall *service,
gtk_progress_bar_update (progressbar, pct/100);
fflush (stdout);
if (amount == total) {
fprintf (stdout, "\n");
if (amount != total) {
gtk_main_iteration ();
}
gtk_main_iteration ();
}
static void
append_string_to_window_list (GtkWidget *widget,
const char *listname,
const char *name)
install_failed_helper (EazelInstall *service,
const PackageData *pd,
char *indent,
char **str)
{
GSList *list;
GList *iterator;
list = (GSList*)gtk_object_get_data (GTK_OBJECT (widget), listname);
list = g_slist_append (list, g_strdup (name));
gtk_object_set_data (GTK_OBJECT (widget), listname, list);
if (pd->toplevel) {
char *tmp;
tmp = g_strdup_printf ("%s\n***The package %s failed. Here's the dep tree\n", *str, pd->name);
g_free (*str);
(*str) = tmp;
}
switch (pd->status) {
case PACKAGE_DEPENDENCY_FAIL: {
char *tmp;
tmp = g_strdup_printf ("%s%s-%s failed\n", *str, indent, rpmfilename_from_packagedata (pd));
g_free (*str);
(*str) = tmp;
break;
}
case PACKAGE_CANNOT_OPEN: {
char *tmp;
tmp = g_strdup_printf ("%s%s-%s NOT FOUND\n", *str, indent, rpmfilename_from_packagedata (pd));
g_free (*str);
(*str) = tmp;
break;
}
case PACKAGE_SOURCE_NOT_SUPPORTED: {
char *tmp;
tmp = g_strdup_printf ("%s%s-%s is a source\n", *str, indent, rpmfilename_from_packagedata (pd));
g_free (*str);
(*str) = tmp;
break;
}
case PACKAGE_BREAKS_DEPENDENCY: {
char *tmp;
tmp = g_strdup_printf ("%s%s-%s breaks\n", *str, indent, rpmfilename_from_packagedata (pd));
g_free (*str);
(*str) = tmp;
break;
}
default: {
char *tmp;
tmp = g_strdup_printf ("%s%s-%s\n", *str, indent, rpmfilename_from_packagedata (pd));
g_free (*str);
(*str) = tmp;
break;
}
}
for (iterator = pd->soft_depends; iterator; iterator = iterator->next) {
PackageData *pack;
char *indent2;
indent2 = g_strconcat (indent, iterator->next ? " |" : " " , NULL);
pack = (PackageData*)iterator->data;
install_failed_helper (service, pack, indent2, str);
g_free (indent2);
}
for (iterator = pd->breaks; iterator; iterator = iterator->next) {
PackageData *pack;
char *indent2;
indent2 = g_strconcat (indent, iterator->next ? " |" : " " , NULL);
pack = (PackageData*)iterator->data;
install_failed_helper (service, pack, indent2, str);
g_free (indent2);
}
}
static void
download_failed (EazelInstall *service,
const char *name,
GtkWidget *window)
{
append_string_to_window_list (window, "download_failed_list", name);
}
static void
install_failed_foreach (PackageData *dep,
GtkWidget *window)
{
char *string;
string = g_strdup_printf (" requires %s %s", dep->name,
dep->version ? dep->version : "");
append_string_to_window_list (window, "install_failed_list", string);
g_free (string);
}
static void
requeue (PackageData *dep,
const PackageData *pd)
{
g_message ("%s-%s failed, requeue and add %s for %s, version >= %s",
pd->name,
pd->version,
dep->name,
dep->archtype,
dep->version);
}
void
install_failed (EazelInstall *service,
const PackageData *pd,
RPM_FAIL code,
GList *deps,
GtkWidget *window)
char **output)
{
append_string_to_window_list (window, "install_failed_list", pd->name);
switch (code) {
case RPM_DEP_FAIL:
g_list_foreach (deps, (GFunc)install_failed_foreach, window);
g_list_foreach (deps, (GFunc)requeue, (gpointer)pd);
break;
case RPM_SRC_NOT_SUPPORTED:
append_string_to_window_list (window, "install_failed_list", "source packaages not supported" );
break;
default:
break;
if (pd->toplevel == TRUE) {
install_failed_helper (service, pd, g_strdup (""), output);
}
}
static void
gen_report (GtkWidget *widget,
const char *listname,
char **text,
const char *title)
{
GSList *list;
list = gtk_object_get_data (GTK_OBJECT (widget), listname);
if (list != NULL) {
GSList *ptr;
if ((*text)==NULL) {
(*text) = g_strdup (title);
} else {
char *tmp;
tmp = g_strconcat ((*text), title, NULL);
g_free ((*text));
(*text) = tmp;
}
ptr = list;
while (ptr) {
char *tmp;
tmp = g_strconcat ((*text), (char*)ptr->data, "\n", NULL);
g_free ((*text));
(*text) = tmp;
ptr = ptr->next;
}
}
}
static void
dump_failure_info (GtkWidget *window)
{
char *text;
text = NULL;
gen_report (window, "download_failed_list", &text, "Download failed for\n");
gen_report (window, "install_failed_list", &text, "Install failed for\n");
gnome_warning_dialog (text);
}
void installer (GtkWidget *window,
@ -240,15 +213,17 @@ void installer (GtkWidget *window,
gtk_signal_connect (GTK_OBJECT (service), "download_progress", eazel_download_progress, window);
gtk_signal_connect (GTK_OBJECT (service), "install_progress", eazel_install_progress, window);
gtk_signal_connect (GTK_OBJECT (service), "download_failed", download_failed, window);
gtk_signal_connect (GTK_OBJECT (service), "install_failed", install_failed, window);
/* gtk_signal_connect (GTK_OBJECT (service), "download_failed", download_failed, window); */
gtk_signal_connect (GTK_OBJECT (service), "install_failed", install_failed, &failure_info);
failure_info = g_new0 (char, 8192);
switch (method) {
case FULL_INST:
case NAUTILUS_ONLY:
case SERVICES_ONLY:
case UPGRADE:
eazel_install_new_packages (service);
eazel_install_install_packages (service, NULL);
break;
case UNINSTALL:
eazel_install_uninstall (service);
@ -262,6 +237,5 @@ void installer (GtkWidget *window,
gtk_label_set_text (package_label, "Completed :");
gtk_progress_bar_update (progressbar, 1);
dump_failure_info (window);
gnome_error_dialog_parented (failure_info, GTK_WINDOW (window));
}