Commit 40781c05 authored by Ian McKellar's avatar Ian McKellar Committed by Ian McKellar
Browse files

reviewed by: Eskil Heyn Olsen <eskil@eazel.com>

2001-02-22  Ian McKellar  <ian@eazel.com>

        reviewed by: Eskil Heyn Olsen  <eskil@eazel.com>

        * components/services/install/command-line/eazel-test-packsys.c:
        (test_database_mtime), (main):
        * components/services/install/lib/eazel-package-system-dpkg.c:
        (load_package_callback), (query_callback),
        (eazel_package_system_dpkg_query),
        (eazel_package_system_dpkg_install),
        (eazel_package_system_dpkg_compare_version),
        (eazel_package_system_dpkg_database_mtime),
        (eazel_package_system_implementation):
        * components/services/install/lib/eazel-package-system-private.h:
        * components/services/install/lib/eazel-package-system-rpm3-private
        .h:
        * components/services/install/lib/eazel-package-system-rpm3.c:
        (eazel_package_system_rpm3_database_mtime),
        (eazel_package_system_implementation):
        * components/services/install/lib/eazel-package-system-rpm4.c:
        (eazel_package_system_implementation):
        * components/services/install/lib/eazel-package-system-skeleton.c:
        (eazel_package_system_skeleton_compare_version):
        * components/services/install/lib/eazel-package-system.c:
        (eazel_package_system_database_mtime):
        * components/services/install/lib/eazel-package-system.h:
        Added a function to retrieve the package database modification time.

        * components/services/inventory/eazel-inventory-collect-hardware.c:
        (eazel_inventory_collect_scsi), (eazel_inventory_collect_hardware):
        Cleanups, fixes...

        * components/services/inventory/eazel-inventory-utils.c:
        (get_software_inventory), (eazel_create_configuration_metafile):
        Cache the software inventory (because the RPM query is slow).

        * user-guide/C/Makefile.am:
        Build fix for systems without scrollkeeper.
parent c217952b
2001-02-22 Ian McKellar <ian@eazel.com>
reviewed by: Eskil Heyn Olsen <eskil@eazel.com>
* components/services/install/command-line/eazel-test-packsys.c:
(test_database_mtime), (main):
* components/services/install/lib/eazel-package-system-dpkg.c:
(load_package_callback), (query_callback),
(eazel_package_system_dpkg_query),
(eazel_package_system_dpkg_install),
(eazel_package_system_dpkg_compare_version),
(eazel_package_system_dpkg_database_mtime),
(eazel_package_system_implementation):
* components/services/install/lib/eazel-package-system-private.h:
* components/services/install/lib/eazel-package-system-rpm3-private
.h:
* components/services/install/lib/eazel-package-system-rpm3.c:
(eazel_package_system_rpm3_database_mtime),
(eazel_package_system_implementation):
* components/services/install/lib/eazel-package-system-rpm4.c:
(eazel_package_system_implementation):
* components/services/install/lib/eazel-package-system-skeleton.c:
(eazel_package_system_skeleton_compare_version):
* components/services/install/lib/eazel-package-system.c:
(eazel_package_system_database_mtime):
* components/services/install/lib/eazel-package-system.h:
Added a function to retrieve the package database modification time.
* components/services/inventory/eazel-inventory-collect-hardware.c:
(eazel_inventory_collect_scsi), (eazel_inventory_collect_hardware):
Cleanups, fixes...
* components/services/inventory/eazel-inventory-utils.c:
(get_software_inventory), (eazel_create_configuration_metafile):
Cache the software inventory (because the RPM query is slow).
* user-guide/C/Makefile.am:
Build fix for systems without scrollkeeper.
2001-02-22 Mike Fleming <mfleming@eazel.com>
Embedded Mozilla User Agent string "Nautilus/1.0PR3" -> "Nautilus/1.0Final"
......@@ -345,6 +384,7 @@ Thu Feb 22 04:13:13 2001 George Lebl <jirka@5z.com>
downgrade at the same time, since it's perfectly capable of doing
that (covering all bases) and it's useful to labs.
>>>>>>> 1.3885
2001-02-22 Arlo Rose <arlo@eazel.com>
* icons/druid_header.png:
......
......@@ -22,6 +22,7 @@
*/
#include <config.h>
#include <time.h>
#include <gnome.h>
#include <eazel-package-system.h>
......@@ -32,6 +33,21 @@
#define OWNED_BY_ONLY_ONE "/bin/sh"
#define NEEDED_BY_MANY "glibc"
static void
test_database_mtime (EazelPackageSystem *packsys)
{
time_t mtime = eazel_package_system_database_mtime (packsys);
char *tmp;
if (mtime == 0) {
g_message ("Couldn't get package system database mtime.\n");
} else {
tmp = ctime (&mtime);
g_message ("Package system database mtime: %s\n", tmp);
g_free (tmp);
}
}
static void
test_is_installed (EazelPackageSystem *packsys)
{
......@@ -594,6 +610,7 @@ int main(int argc, char *argv[]) {
eazel_package_system_set_debug (packsys, arg_debug);
test_database_mtime (packsys);
test_is_installed (packsys);
test_version_compare (packsys);
test_package_load (packsys, filename);
......
......@@ -28,9 +28,13 @@
#include "eazel-package-system-private.h"
#include <libtrilobite/trilobite-core-utils.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define MAX_LINE_LEN 4096
#define ROOT "su -c "
#define DPKG_STATUS_FILE "/var/lib/dpkg/status"
typedef struct {
char *name;
......@@ -196,8 +200,8 @@ load_package_callback (const DebPackage *package,
{
PackageData *pdata = data;
g_print ("cb: %s\n", package->name);
g_print ("cb desc: %s\n", package->description);
//g_print ("cb: %s\n", package->name);
//g_print ("cb desc: %s\n", package->description);
debpackage_fill_packagedata (package, pdata);
return TRUE;
}
......@@ -249,15 +253,15 @@ query_callback (const DebPackage *package,
struct QueryData *query_data = data;
PackageData *pd;
g_print ("cb: %s\n", package->name);
//g_print ("cb: %s\n", package->name);
if ( (package->status == NULL) ||
strcmp (package->status, "install ok installed")) {
/* hmm - not actually installed */
g_print ("cb discarding\n");
//g_print ("cb discarding\n");
return TRUE;
}
g_print ("cb keeping\n");
//g_print ("cb keeping\n");
/* FIXME: umm - actually check that it matches */
......@@ -287,7 +291,7 @@ eazel_package_system_dpkg_query (EazelPackageSystemDpkg *system,
/* FIMXE: lock db! */
status = fopen ("/var/lib/dpkg/status", "rt");
status = fopen (DPKG_STATUS_FILE, "rt");
if (status == NULL) return NULL;
......@@ -318,17 +322,13 @@ eazel_package_system_dpkg_install (EazelPackageSystemDpkg *epsystem,
dpkg_cmd = g_strdup_printf (ROOT "dpkg --unpack %s",
pdata->filename);
g_print ("[YAK] running: %s\n", dpkg_cmd);
result = system (dpkg_cmd);
g_print ("[YAK] result: %d\n", result);
g_free (dpkg_cmd);
/* FIXME: erm - perhaps pop up some kind of zvt???? */
dpkg_cmd = g_strdup_printf (ROOT "dpkg --configure %s",
pdata->name);
g_print ("[YAK] running: %s\n", dpkg_cmd);
result = system (dpkg_cmd);
g_print ("[YAK] result: %d\n", result);
g_free (dpkg_cmd);
g_free (dpkg_cmd);
......@@ -360,7 +360,7 @@ eazel_package_system_dpkg_verify (EazelPackageSystemDpkg *system,
}
static int
eazel_package_system_dpkg_compare_version (EazelPackageSystem *system,
eazel_package_system_dpkg_compare_version (EazelPackageSystemDpkg *system,
const char *a,
const char *b)
{
......@@ -372,6 +372,23 @@ eazel_package_system_dpkg_compare_version (EazelPackageSystem *system,
}
/************************************
Database mtime implementation
************************************/
static time_t
eazel_package_system_dpkg_database_mtime (EazelPackageSystemDpkg *system)
{
struct stat st;
if (stat (DPKG_STATUS_FILE, &st) == 0) {
return st.st_mtime;
} else {
return (time_t)0;
}
}
/*****************************************
GTK+ object stuff
*****************************************/
......@@ -473,5 +490,8 @@ eazel_package_system_implementation (GList *dbpaths)
result->private->compare_version
= (EazelPackageSystemCompareVersionFunc)eazel_package_system_dpkg_compare_version;
result->private->database_mtime
= (EazelPackageSystemDatabaseMtimeFunc)eazel_package_system_dpkg_database_mtime;
return result;
}
......@@ -67,6 +67,7 @@ typedef gboolean (*EazelPackageSytemVerifyFunc) (EazelPackageSystem*,
typedef int (*EazelPackageSystemCompareVersionFunc) (EazelPackageSystem*,
const char *,
const char *);
typedef time_t (*EazelPackageSystemDatabaseMtimeFunc) (EazelPackageSystem*);
struct _EazelPackageSystemPrivate {
EazelPackageSytemLoadPackageFunc load_package;
......@@ -75,6 +76,7 @@ struct _EazelPackageSystemPrivate {
EazelPackageSytemUninstallFunc uninstall;
EazelPackageSytemVerifyFunc verify;
EazelPackageSystemCompareVersionFunc compare_version;
EazelPackageSystemDatabaseMtimeFunc database_mtime;
EazelPackageSystemDebug debug;
};
......
......@@ -77,6 +77,7 @@ void eazel_package_system_rpm3_query_requires_feature (EazelPackageSystemRpm3 *s
const gpointer *key,
int detail_level,
GList **result);
time_t eazel_package_system_rpm3_database_mtime (EazelPackageSystemRpm3 *system);
struct RpmQueryPiggyBag {
EazelPackageSystemRpm3 *system;
......
......@@ -1814,6 +1814,23 @@ eazel_package_system_rpm3_compare_version (EazelPackageSystem *system,
return result;
}
/************************************
Database mtime implementation
************************************/
time_t
eazel_package_system_rpm3_database_mtime (EazelPackageSystemRpm3 *system)
{
struct stat st;
if (stat (DEFAULT_DB_PATH "/" A_DB_FILE, &st) == 0) {
return st.st_mtime;
} else {
return (time_t)0;
}
}
/*****************************************
GTK+ object stuff
*****************************************/
......@@ -1928,6 +1945,8 @@ eazel_package_system_implementation (GList *dbpaths)
result->private->verify = (EazelPackageSytemVerifyFunc)eazel_package_system_rpm3_verify;
result->private->compare_version =
(EazelPackageSystemCompareVersionFunc)eazel_package_system_rpm3_compare_version;
result->private->database_mtime =
(EazelPackageSystemDatabaseMtimeFunc)eazel_package_system_rpm3_database_mtime;
return result;
}
......
......@@ -304,6 +304,8 @@ eazel_package_system_implementation (GList *dbpaths)
result->private->verify = (EazelPackageSytemVerifyFunc)eazel_package_system_rpm3_verify;
result->private->compare_version =
(EazelPackageSystemCompareVersionFunc)eazel_package_system_rpm3_compare_version;
result->private->database_mtime =
(EazelPackageSystemDatabaseMtimeFunc)eazel_package_system_rpm3_database_mtime;
return result;
}
......
......@@ -97,7 +97,7 @@ eazel_package_system_skeleton_verify (EazelPackageSystemSkeleton *system,
}
static int
eazel_package_system_skeleton_compare_version (EazelPackageSystem *system,
eazel_package_system_skeleton_compare_version (EazelPackageSystemSkeleton *system,
const char *a,
const char *b)
{
......
......@@ -354,6 +354,18 @@ eazel_package_system_compare_version (EazelPackageSystem *system,
return result;
}
time_t
eazel_package_system_database_mtime (EazelPackageSystem *system)
{
time_t result;
EPS_SANE_VAL (system, 0);
if (system->private->database_mtime == NULL) {
return 0;
}
result = (*system->private->database_mtime) (system);
return result;
}
/******************************************
The private emitter functions
*******************************************/
......
......@@ -158,5 +158,7 @@ gboolean eazel_package_system_verify (EazelPackageSystem *packag
int eazel_package_system_compare_version (EazelPackageSystem *package_system,
const char *a,
const char *b);
time_t eazel_package_system_database_mtime (EazelPackageSystem *package_system);
#endif /* EAZEL_PACKAGE_SYSTEM_PUBLIC_H */
......@@ -341,6 +341,9 @@ Host: scsi0 Channel: 00 Id: 04 Lun: 00
*/
scsi_file = fopen (SCSI_DEVICES_FILE, "rt");
if (scsi_file == NULL) {
return bus_node;
}
while (!feof (scsi_file) && !ferror (scsi_file)) {
fgets (line, MAX_LINE_LEN, scsi_file);
......@@ -533,7 +536,7 @@ eazel_inventory_collect_hardware (void) {
xmlNodePtr node = xmlNewNode (NULL, "HARDWARE");
xmlAddChild (node, eazel_inventory_collect_cpu ());
xmlAddChild (node, eazel_inventory_collect_memory ());
xmlAddChild (node, eazel_inventory_collect_memory ());
xmlAddChild (node, eazel_inventory_collect_pci ());
xmlAddChild (node, eazel_inventory_collect_ide ());
xmlAddChild (node, eazel_inventory_collect_usb ());
......
......@@ -48,7 +48,7 @@
#define DIGEST_GCONF_PATH "/apps/eazel-trilobite/inventory-digest"
#define DIGEST_GCONF_KEY "inventory_digest_value"
#define PACKAGE_DB_MTIME_KEY "package-db-mtime"
static GConfEngine *conf_engine = NULL;
......@@ -81,6 +81,76 @@ check_gconf_init (void)
}
}
/* return the (optionally cached) software inventory */
static xmlNodePtr
get_software_inventory (void)
{
EazelPackageSystem *package_system;
time_t previous_mtime, database_mtime;
gboolean regenerate = TRUE;
xmlNodePtr result = NULL;
xmlDocPtr software_inventory_cache;
GError *error;
char *cache_path = g_strdup_printf
("%s/.nautilus/software-inventory-cache.xml",
g_get_home_dir ());
check_gconf_init ();
previous_mtime = gconf_engine_get_int (conf_engine,
DIGEST_GCONF_PATH PACKAGE_DB_MTIME_KEY, &error);
package_system = eazel_package_system_new (NULL);
database_mtime = eazel_package_system_database_mtime (package_system);
gtk_object_unref (GTK_OBJECT (package_system));
if (error == NULL || previous_mtime == 0) {
g_print ("database mtime not set.\n");
regenerate = TRUE;
} else {
if (database_mtime != previous_mtime) {
g_print ("database has changed\n");
regenerate = TRUE;
} else {
g_print ("database hasn't changed\n");
regenerate = FALSE;
}
}
gconf_engine_set_int (conf_engine,
DIGEST_GCONF_PATH PACKAGE_DB_MTIME_KEY, database_mtime,
&error);
if (!regenerate) {
g_print ("using cached software inventory\n");
software_inventory_cache = xmlParseFile (cache_path);
if (software_inventory_cache == NULL) {
g_print ("couldn't load cache\n");
regenerate = TRUE;
} else {
g_print ("duplicating cache\n");
result = xmlCopyNode (software_inventory_cache->root,
1);
g_print ("freeing cache\n");
xmlFreeDoc (software_inventory_cache);
}
}
if (regenerate) {
g_print ("generating software inventory\n");
result = eazel_inventory_collect_software ();
software_inventory_cache = xmlNewDoc ("1.0");
xmlDocSetRootElement (software_inventory_cache,
xmlCopyNode (result, 1));
xmlSaveFile (cache_path, software_inventory_cache);
xmlFreeDoc (software_inventory_cache);
}
g_print ("returning result (%p)\n", result);
return result;
}
/* create the configuration metafile and add package and hardware configuration info to it */
static xmlDocPtr
......@@ -115,7 +185,7 @@ eazel_create_configuration_metafile (void)
g_free (time_string);
/* add the software info */
xmlAddChild (container_node, eazel_inventory_collect_software ());
xmlAddChild (container_node, get_software_inventory ());
/* add the hardware info */
xmlAddChild (container_node, eazel_inventory_collect_hardware ());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment