Skip to content

Commit

Permalink
Merge pull request #72 from ejoerns/v0/topic/slot-hooks
Browse files Browse the repository at this point in the history
Introduce Hooks
  • Loading branch information
jluebbe committed Sep 7, 2016
2 parents aece736 + d55f9af commit e32b3d2
Show file tree
Hide file tree
Showing 17 changed files with 1,515 additions and 78 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ AC_CONFIG_LINKS([test/services/de.pengutronix.rauc.service.in:test/services/de.p
AC_CONFIG_LINKS([test/sharness.sh:test/sharness.sh])
AC_CONFIG_LINKS([test/install-content/appfs.img:test/install-content/appfs.img])
AC_CONFIG_LINKS([test/install-content/rootfs.img:test/install-content/rootfs.img])
AC_CONFIG_LINKS([test/install-content/hook.sh:test/install-content/hook.sh])
AC_CONFIG_LINKS([test/install-content/custom_handler.sh:test/install-content/custom_handler.sh])
AC_CONFIG_LINKS([test/install-content/manifest.raucm:test/install-content/manifest.raucm])

Expand Down
5 changes: 5 additions & 0 deletions include/config_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,8 @@ gboolean save_slot_status(const gchar *filename, RaucSlotStatus *ss, GError **er
* @param slotstatus a RaucSlotStatus
*/
void free_slot_status(RaucSlotStatus *slotstatus);

/**
* Frees the memory allocated by a RaucSlot
*/
void r_free_slot(gpointer value);
17 changes: 17 additions & 0 deletions include/install.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@

#include "manifest.h"

#define R_INSTALL_ERROR r_install_error_quark ()
GQuark r_install_error_quark (void);

typedef enum {
R_INSTALL_ERROR_FAILED,
R_INSTALL_ERROR_NOSRC,
R_INSTALL_ERROR_NODST,
R_INSTALL_ERROR_COMPAT_MISMATCH,
R_INSTALL_ERROR_REJECTED,
R_INSTALL_ERROR_MARK_BOOTABLE,
R_INSTALL_ERROR_MARK_NONBOOTABLE,
R_INSTALL_ERROR_TARGET_GROUP,
R_INSTALL_ERROR_DOWNLOAD_MF,
R_INSTALL_ERROR_HANDLER,
R_INSTALL_ERROR_NO_SUPPORTED
} RInstallError;

typedef struct {
gchar *name;
GSourceFunc notify;
Expand Down
24 changes: 24 additions & 0 deletions include/manifest.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@

#include <config_file.h>

typedef struct {
gboolean install_check;
} InstallHooks;

typedef struct {
gboolean pre_install;
gboolean install;
gboolean post_install;
} SlotHooks;

typedef struct {
gchar* slotclass;
RaucChecksum checksum;
gchar* filename;
SlotHooks hooks;
} RaucImage;

typedef struct {
Expand All @@ -28,6 +39,9 @@ typedef struct {
gchar *handler_name;
gchar *handler_args;

gchar *hook_name;
InstallHooks hooks;

GList *images;
GList *files;
} RaucManifest;
Expand Down Expand Up @@ -106,3 +120,13 @@ gboolean update_manifest(const gchar *dir, gboolean signature, GError **error);
* @return TRUE on success, FALSE if an error occurred
*/
gboolean verify_manifest(const gchar *dir, RaucManifest **output, gboolean signature, GError **error);

/**
* Frees a rauc image
*/
void r_free_image(gpointer data);

/**
* Frees a rauc file
*/
void r_free_file(gpointer data);
11 changes: 10 additions & 1 deletion include/update_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

#include "manifest.h"

typedef gboolean (*img_to_slot_handler) (RaucImage *image, RaucSlot *dest_slot, GError **error);
#define R_UPDATE_ERROR r_update_error_quark()

GQuark r_update_error_quark(void);

typedef enum {
R_UPDATE_ERROR_FAILED,
R_UPDATE_ERROR_NO_HANDLER
} RUpdateError;

typedef gboolean (*img_to_slot_handler) (RaucImage *image, RaucSlot *dest_slot, const gchar *hook_name, GError **error);

img_to_slot_handler get_update_handler(RaucImage *mfimage, RaucSlot *dest_slot, GError **error);
6 changes: 4 additions & 2 deletions src/config_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ G_DEFINE_QUARK(r-config-error-quark, r_config_error)

#define RAUC_SLOT_PREFIX "slot"

static void free_slot(gpointer value) {
void r_free_slot(gpointer value) {
RaucSlot *slot = (RaucSlot*)value;

g_clear_pointer(&slot->description, g_free);
Expand Down Expand Up @@ -105,9 +105,11 @@ gboolean load_config(const gchar *filename, RaucConfig **config, GError **error)
c->keyring_path = resolve_path(filename,
g_key_file_get_string(key_file, "keyring", "path", NULL));

/* parse [autoinstall] section */
c->autoinstall_path = resolve_path(filename,
g_key_file_get_string(key_file, "autoinstall", "path", NULL));

/* parse [handlers] section */
c->systeminfo_handler = resolve_path(filename,
g_key_file_get_string(key_file, "handlers", "system-info", NULL));

Expand All @@ -118,7 +120,7 @@ gboolean load_config(const gchar *filename, RaucConfig **config, GError **error)
g_key_file_get_string(key_file, "handlers", "post-install", NULL));

/* parse [slot.*.#] sections */
slots = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, free_slot);
slots = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, r_free_slot);

groups = g_key_file_get_groups(key_file, &group_count);
for (gsize i = 0; i < group_count; i++) {
Expand Down

0 comments on commit e32b3d2

Please sign in to comment.