mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-09-06 05:32:01 +00:00
Consolidate functions to track bundles
Currently we have two functions to track bundles, bundles should always be tracked in the same location, if there is an exception to this rule then it should be handled separately. Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit is contained in:
committed by
Otavio Pontes
parent
7e921eca64
commit
ca2601efc7
+8
-1
@@ -1285,7 +1285,14 @@ brick_the_system_and_clean_curl:
|
||||
/* make sure the bundle was in fact valid and will
|
||||
* be installed before creating the tracking file */
|
||||
if (list_search(bundles_subs, bundle, cmp_sub_component_string)) {
|
||||
track_bundle_in_statedir(bundle, new_os_statedir);
|
||||
char *tracking_file = sys_path_join("%s/bundles/%s", new_os_statedir, bundle);
|
||||
int fd = open(tracking_file, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
if (fd) {
|
||||
close(fd);
|
||||
} else {
|
||||
debug("The tracking file %s failed to be created\n", tracking_file);
|
||||
}
|
||||
FREE(tracking_file);
|
||||
}
|
||||
}
|
||||
FREE(new_os_statedir);
|
||||
|
||||
+3
-12
@@ -208,17 +208,14 @@ int required_by(struct list **reqd_by, const char *bundle_name, struct manifest
|
||||
return count;
|
||||
}
|
||||
|
||||
void track_bundle_in_statedir(const char *bundle_name, const char *state_dir)
|
||||
void track_bundle(const char *bundle_name)
|
||||
{
|
||||
int ret = 0;
|
||||
int fd;
|
||||
char *tracking_dir;
|
||||
char *tracking_file;
|
||||
|
||||
tracking_dir = sys_path_join("%s/%s", state_dir, "bundles");
|
||||
tracking_file = sys_path_join("%s/%s", tracking_dir, bundle_name);
|
||||
|
||||
/* touch a tracking file */
|
||||
tracking_file = statedir_get_tracking_file(bundle_name);
|
||||
fd = open(tracking_file, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
if (fd < 0) {
|
||||
ret = -1;
|
||||
@@ -228,17 +225,11 @@ void track_bundle_in_statedir(const char *bundle_name, const char *state_dir)
|
||||
|
||||
out:
|
||||
if (ret) {
|
||||
debug("Issue creating tracking file in %s for %s\n", tracking_dir, bundle_name);
|
||||
debug("Issue creating tracking file %s for %s\n", tracking_file, bundle_name);
|
||||
}
|
||||
FREE(tracking_dir);
|
||||
FREE(tracking_file);
|
||||
}
|
||||
|
||||
void track_bundle(const char *bundle_name)
|
||||
{
|
||||
track_bundle_in_statedir(bundle_name, globals.state_dir);
|
||||
}
|
||||
|
||||
static char *get_bundles_dir(void)
|
||||
{
|
||||
return sys_path_join("%s/%s", globals.path_prefix, BUNDLES_DIR);
|
||||
|
||||
+2
-13
@@ -43,22 +43,11 @@ bool is_tracked_bundle(const char *bundle_name);
|
||||
int required_by(struct list **reqd_by, const char *bundle_name, struct manifest *mom, int recursion, struct list *exclusions, char *msg, bool include_optional);
|
||||
|
||||
/**
|
||||
* @brief Creates a tracking file in the tracking directory within the
|
||||
* specified state directory.
|
||||
* If there are no tracked files in that directory (directory is empty
|
||||
* or does not exist), copy the tracking directory at
|
||||
* path_prefix/usr/share/clear/bundles to the tracking directory to
|
||||
* initiate the tracking files.
|
||||
* @brief Creates a tracking file in the tracking directory.
|
||||
|
||||
* This function does not return an error code because weird state in this
|
||||
* directory must be handled gracefully whenever encountered.
|
||||
* @param bundle_name The name of the bundle.
|
||||
* @param state_dir The path to the state directory.
|
||||
*/
|
||||
void track_bundle_in_statedir(const char *bundle_name, const char *state_dir);
|
||||
|
||||
/**
|
||||
* @brief Similar to track_bundle_in_statedir() but uses the global state_dir.
|
||||
* @param bundle_name The name of the bundle.
|
||||
*/
|
||||
void track_bundle(const char *bundle_name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user