r4017 - trunk/src/target/opkg
thomas at sita.openmoko.org
thomas at sita.openmoko.org
Tue Feb 5 11:11:02 CET 2008
Author: thomas
Date: 2008-02-05 11:11:00 +0100 (Tue, 05 Feb 2008)
New Revision: 4017
Modified:
trunk/src/target/opkg/opkg_configure.c
trunk/src/target/opkg/opkg_download.c
trunk/src/target/opkg/opkg_install.c
trunk/src/target/opkg/opkg_state.c
trunk/src/target/opkg/opkg_state.h
Log:
opkg: add downloading, configuring and installing state changes
Modified: trunk/src/target/opkg/opkg_configure.c
===================================================================
--- trunk/src/target/opkg/opkg_configure.c 2008-02-05 09:25:03 UTC (rev 4016)
+++ trunk/src/target/opkg/opkg_configure.c 2008-02-05 10:11:00 UTC (rev 4017)
@@ -18,6 +18,7 @@
#include "opkg.h"
#include "opkg_configure.h"
+#include "opkg_state.h"
int opkg_configure(opkg_conf_t *conf, pkg_t *pkg)
{
@@ -28,6 +29,12 @@
end of opkg_install(). Do we care? */
/* DPKG_INCOMPATIBILITY:
dpkg actually includes a version number to this script call */
+
+ char *pkgid;
+ sprintf_alloc (&pkgid, "%s;%s;%s;", pkg->name, pkg->version, pkg->architecture);
+ opkg_set_current_state (OPKG_STATE_CONFIGURING_PKG, pkgid);
+ free (pkgid);
+
err = pkg_run_script(conf, pkg, "postinst", "configure");
if (err) {
printf("ERROR: %s.postinst returned %d\n", pkg->name, err);
@@ -35,6 +42,7 @@
}
opkg_state_changed++;
+ opkg_set_current_state (OPKG_STATE_NONE, NULL);
return 0;
}
Modified: trunk/src/target/opkg/opkg_download.c
===================================================================
--- trunk/src/target/opkg/opkg_download.c 2008-02-05 09:25:03 UTC (rev 4016)
+++ trunk/src/target/opkg/opkg_download.c 2008-02-05 10:11:00 UTC (rev 4017)
@@ -201,6 +201,7 @@
{
int err;
char *url;
+ char *pkgid;
if (pkg->src == NULL) {
opkg_message(conf,OPKG_ERROR, "ERROR: Package %s (parent %s) is not available from any configured src.\n",
@@ -208,6 +209,10 @@
return -1;
}
+ sprintf_alloc (&pkgid, "%s;%s;%s;", pkg->name, pkg->version, pkg->architecture);
+ opkg_set_current_state (OPKG_STATE_DOWNLOADING_PKG, pkgid);
+ free (pkgid);
+
sprintf_alloc(&url, "%s/%s", pkg->src->value, pkg->filename);
/* XXX: BUG: The pkg->filename might be something like
@@ -219,6 +224,7 @@
err = opkg_download(conf, url, pkg->local_filename);
free(url);
+ opkg_set_current_state (OPKG_STATE_NONE, NULL);
return err;
}
Modified: trunk/src/target/opkg/opkg_install.c
===================================================================
--- trunk/src/target/opkg/opkg_install.c 2008-02-05 09:25:03 UTC (rev 4016)
+++ trunk/src/target/opkg/opkg_install.c 2008-02-05 10:11:00 UTC (rev 4017)
@@ -34,6 +34,7 @@
#include "opkg_utils.h"
#include "opkg_message.h"
+#include "opkg_state.h"
#include "sprintf_alloc.h"
#include "file_util.h"
@@ -751,6 +752,7 @@
abstract_pkg_t *ab_pkg = NULL;
int old_state_flag;
char* file_md5;
+ char *pkgid;
if ( from_upgrade )
@@ -851,6 +853,10 @@
replacees = pkg_vec_alloc();
pkg_get_installed_replacees(conf, pkg, replacees);
+ sprintf_alloc (&pkgid, "%s;%s;%s;", pkg->name, pkg->version, pkg->architecture);
+ opkg_set_current_state (OPKG_STATE_INSTALLING_PKG, pkgid);
+ free (pkgid);
+
/* this next section we do with SIGINT blocked to prevent inconsistency between opkg database and filesystem */
{
sigset_t newset, oldset;
@@ -991,6 +997,7 @@
return err;
}
+ opkg_set_current_state (OPKG_STATE_NONE, NULL);
}
static int prerm_upgrade_old_pkg(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
Modified: trunk/src/target/opkg/opkg_state.c
===================================================================
--- trunk/src/target/opkg/opkg_state.c 2008-02-05 09:25:03 UTC (rev 4016)
+++ trunk/src/target/opkg/opkg_state.c 2008-02-05 10:11:00 UTC (rev 4017)
@@ -16,7 +16,23 @@
*/
#include "libopkg.h"
+#include "opkg_state.h"
+
+static char *state_strings[] =
+{
+ "None",
+ "Downloading Package",
+ "Installing Package",
+ "Configuring Package",
+ "Upgrading Package",
+ "Removing Package",
+ "Downloading Repository",
+ "Verifying Repository Signature"
+};
+
+
+
opkg_state_changed_callback opkg_cb_state;
static opkg_state_t opkg_state = 0;
@@ -27,10 +43,19 @@
{
if (opkg_state_data)
free (opkg_state_data);
- opkg_state_data = malloc (strlen (data));
- strcpy (opkg_state_data, data);
+ if (data)
+ {
+ opkg_state_data = malloc (strlen (data));
+ strcpy (opkg_state_data, data);
+ }
+ else
+ {
+ opkg_state_data = NULL;
+ }
opkg_state = state;
+
+ printf ("opkg state set to %s: %s\n", state_strings[state], data);
}
void
Modified: trunk/src/target/opkg/opkg_state.h
===================================================================
--- trunk/src/target/opkg/opkg_state.h 2008-02-05 09:25:03 UTC (rev 4016)
+++ trunk/src/target/opkg/opkg_state.h 2008-02-05 10:11:00 UTC (rev 4017)
@@ -15,8 +15,9 @@
General Public License for more details.
*/
+#ifndef OPKG_STATE_H
+#define OPKG_STATE_H
-
typedef enum _opkg_state {
OPKG_STATE_NONE,
OPKG_STATE_DOWNLOADING_PKG,
@@ -25,6 +26,7 @@
OPKG_STATE_UPGRADING_PKG,
OPKG_STATE_REMOVING_PKG,
OPKG_STATE_DOWNLOADING_REPOSITORY,
- OPKG_STATE_VERIFYING_REPOSITORY_SIGNITURE
+ OPKG_STATE_VERIFYING_REPOSITORY_SIGNATURE
} opkg_state_t;
+#endif /* OPKG_STATE_H */
More information about the commitlog
mailing list