summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--opkg_configure.c8
-rw-r--r--opkg_download.c6
-rw-r--r--opkg_install.c7
-rw-r--r--opkg_state.c29
-rw-r--r--opkg_state.h6
5 files changed, 52 insertions, 4 deletions
diff --git a/opkg_configure.c b/opkg_configure.c
index 16f8347..8309e40 100644
--- a/opkg_configure.c
+++ b/opkg_configure.c
@@ -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 @@ int opkg_configure(opkg_conf_t *conf, pkg_t *pkg)
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 @@ int opkg_configure(opkg_conf_t *conf, pkg_t *pkg)
}
opkg_state_changed++;
+ opkg_set_current_state (OPKG_STATE_NONE, NULL);
return 0;
}
diff --git a/opkg_download.c b/opkg_download.c
index c3fa44c..2bdbb00 100644
--- a/opkg_download.c
+++ b/opkg_download.c
@@ -201,6 +201,7 @@ int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir)
{
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 @@ int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir)
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 @@ int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir)
err = opkg_download(conf, url, pkg->local_filename);
free(url);
+ opkg_set_current_state (OPKG_STATE_NONE, NULL);
return err;
}
diff --git a/opkg_install.c b/opkg_install.c
index b278724..599ae4d 100644
--- a/opkg_install.c
+++ b/opkg_install.c
@@ -34,6 +34,7 @@ typedef void (*sighandler_t)(int);
#include "opkg_utils.h"
#include "opkg_message.h"
+#include "opkg_state.h"
#include "sprintf_alloc.h"
#include "file_util.h"
@@ -751,6 +752,7 @@ int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
abstract_pkg_t *ab_pkg = NULL;
int old_state_flag;
char* file_md5;
+ char *pkgid;
if ( from_upgrade )
@@ -851,6 +853,10 @@ int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
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 @@ int opkg_install_pkg(opkg_conf_t *conf, pkg_t *pkg, int from_upgrade)
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)
diff --git a/opkg_state.c b/opkg_state.c
index ded9683..3dbd6c6 100644
--- a/opkg_state.c
+++ b/opkg_state.c
@@ -16,6 +16,22 @@
*/
#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;
@@ -27,10 +43,19 @@ opkg_set_current_state (opkg_state_t state, const char *data)
{
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
diff --git a/opkg_state.h b/opkg_state.h
index fc37675..36dd28e 100644
--- a/opkg_state.h
+++ b/opkg_state.h
@@ -15,7 +15,8 @@
General Public License for more details.
*/
-
+#ifndef OPKG_STATE_H
+#define OPKG_STATE_H
typedef enum _opkg_state {
OPKG_STATE_NONE,
@@ -25,6 +26,7 @@ typedef enum _opkg_state {
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 */