Skip to content

Commit

Permalink
Merge branch 'srn-skov-dk-master' (PR #64 with fixes)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejoerns committed Aug 18, 2016
2 parents 80d3e70 + a7e4e3f commit ec55aac
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static void r_context_configure(void) {

vars = g_hash_table_new(g_str_hash, g_str_equal);

g_print("Getting Systeminfo: %s\n", context->config->systeminfo_handler);
g_message("Getting Systeminfo: %s\n", context->config->systeminfo_handler);
res = launch_and_wait_variables_handler(context->config->systeminfo_handler, vars, &ierror);
if (!res) {
g_error("Failed to read system-info variables%s", ierror->message);
Expand Down
1 change: 1 addition & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ static gboolean info_start(int argc, char **argv)
}

g_print("Compatible String:\t'%s'\n", manifest->update_compatible);
g_print("Update version: \t'%s'\n", manifest->update_version);

cnt = g_list_length(manifest->images);
g_print("%d Image%s%s\n", cnt, cnt == 1 ? "" : "s", cnt > 0 ? ":" : "");
Expand Down
12 changes: 12 additions & 0 deletions src/rauc-installer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
<arg name="source" type="s"/>
</method>

<!--
Info: D-Bus variant of rauc info <bundle>
@bundle: full path to the queried bundle.
@compatile: the compatible string from the bundle
@version: the version string from the bundle
-->
<method name="Info">
<arg name="bundle" type="s" direction="in" />
<arg name="compatible" type="s" direction="out" />
<arg name="version" type="s" direction="out" />
</method>

<property name="Operation" type="s" access="read"/>
<property name="LastError" type="s" access="read"/>
<property name="Progress" type="(isi)" access="read"/>
Expand Down
74 changes: 74 additions & 0 deletions src/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <context.h>
#include <install.h>
#include <service.h>
#include <bundle.h>
#include <utils.h>
#include "rauc-installer-generated.h"

GMainLoop *service_loop = NULL;
Expand Down Expand Up @@ -85,6 +87,74 @@ static gboolean r_on_handle_install(RInstaller *interface,
return TRUE;
}


static gboolean r_on_handle_info(RInstaller *interface,
GDBusMethodInvocation *invocation,
const gchar *arg_bundle)
{
gchar* tmpdir = NULL;
gchar* bundledir = NULL;
gchar* manifestpath = NULL;
RaucManifest *manifest = NULL;
GError *error = NULL;
gboolean res = TRUE;

g_print("bundle: %s\n", arg_bundle);

res = !r_context_get_busy();
if (!res)
goto out;

tmpdir = g_dir_make_tmp("bundle-XXXXXX", &error);
if (!tmpdir) {
g_warning("%s", error->message);
g_clear_error(&error);
res = FALSE;
goto out;
}

bundledir = g_build_filename(tmpdir, "bundle-content", NULL);
manifestpath = g_build_filename(bundledir, "manifest.raucm", NULL);

res = extract_file_from_bundle(arg_bundle, bundledir, "manifest.raucm", TRUE, &error);
if (!res) {
g_warning("%s", error->message);
g_clear_error(&error);
goto out;
}

res = load_manifest_file(manifestpath, &manifest, &error);
if (!res) {
g_warning("%s", error->message);
g_clear_error(&error);
goto out;
}

out:
if (tmpdir)
rm_tree(tmpdir, NULL);

g_clear_pointer(&tmpdir, g_free);
g_clear_pointer(&bundledir, g_free);
g_clear_pointer(&manifestpath, g_free);

if (res) {
r_installer_complete_info(
interface,
invocation,
manifest->update_compatible,
manifest->update_version ? manifest->update_version : "");
} else {
g_dbus_method_invocation_return_error(invocation,
G_IO_ERROR,
G_IO_ERROR_FAILED_HANDLED,
"rauc info error");
}

return TRUE;
}


static gboolean auto_install(const gchar *source) {
RaucInstallArgs *args = install_args_new();
gboolean res = TRUE;
Expand Down Expand Up @@ -145,6 +215,10 @@ static void r_on_bus_acquired(GDBusConnection *connection,
G_CALLBACK(r_on_handle_install),
NULL);

g_signal_connect(r_installer, "handle-info",
G_CALLBACK(r_on_handle_info),
NULL);

r_context_register_progress_callback(send_progress_callback);

if (!g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(r_installer),
Expand Down
39 changes: 39 additions & 0 deletions test/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,41 @@ static void service_test_status(ServiceFixture *fixture, gconstpointer user_data
g_clear_pointer(&installer, g_object_unref);
}

static void service_test_info(ServiceFixture *fixture, gconstpointer user_data)
{
RInstaller *installer = NULL;
GError *error = NULL;
gchar *compatible;
gchar *version;

installer = r_installer_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
"de.pengutronix.rauc",
"/",
NULL,
NULL);

if (installer == NULL) {
g_error("failed to install proxy");
goto out;
}

r_installer_call_info_sync(installer,
"test/good-bundle.raucb",
&compatible,
&version,
NULL,
&error);
g_assert_no_error(error);
g_assert_cmpstr(compatible, ==, "Test Config");
g_assert_cmpstr(version, ==, "2011.03-2");

out:
g_clear_pointer(&installer, g_object_unref);
g_free(compatible);
g_free(version);
}

int main(int argc, char *argv[])
{
setlocale(LC_ALL, "C");
Expand All @@ -73,5 +108,9 @@ int main(int argc, char *argv[])
service_fixture_set_up, service_test_status,
service_fixture_tear_down);

g_test_add("/service/info", ServiceFixture, NULL,
service_fixture_set_up, service_test_info,
service_fixture_tear_down);

return g_test_run();
}

0 comments on commit ec55aac

Please sign in to comment.