.md_max_age = 0,
.cachedir = NULL,
.local_sqlite = DEFAULT_LOCAL_SQLITE,
+ .cut_dirs = 0,
+ .location_prefix = NULL,
.deltas = FALSE,
.oldpackagedirs = NULL,
"This option could lead to a higher memory consumption "
"if TMPDIR is set to /tmp or not set at all, because then the /tmp is "
"used and /tmp dir is often a ramdisk.", NULL },
+ { "cut-dirs", 0, 0, G_OPTION_ARG_INT, &(_cmd_options.cut_dirs),
+ "Ignore NUM of directory components in location_href during repodata "
+ "generation", "NUM" },
+ { "location-prefix", 0, 0, G_OPTION_ARG_FILENAME, &(_cmd_options.location_prefix),
+ "Append this prefix before location_href in output repodata", "PREFIX" },
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL },
};
x++;
}
+ // Check cut_dirs
+ if (options->cut_dirs < 0) {
+ g_set_error(err, ERR_DOMAIN, CRE_BADARG,
+ "--cur-dirs value must be possitive integer");
+ return FALSE;
+ }
+
return TRUE;
}
temporary files.
For situations when sqlite has a trouble
to gen DBs on NFS mounts. */
+ gint cut_dirs; /*!< Ignore *num* of directory components
+ during repodata generation in location
+ href value. */
+ gchar *location_prefix; /*!< Append this prefix into location_href
+ during repodata generation. */
/* Items filled by check_arguments() */
user_data.max_delta_rpm_size= cmd_options->max_delta_rpm_size;
user_data.mutex_deltatargetpackages = g_mutex_new();
user_data.deltatargetpackages = NULL;
+ user_data.cut_dirs = cmd_options->cut_dirs;
+ user_data.location_prefix = cmd_options->location_prefix;
g_debug("Thread pool user data ready");
#include <sys/types.h>
#include <sys/stat.h>
#include "checksum.h"
+#include "cleanup.h"
#include "deltarpms.h"
#include "dumper_thread.h"
#include "error.h"
// get location_href without leading part of path (path to repo)
// including '/' char
- const char *location_href = task->full_path + udata->repodir_name_len;
- const char *location_base = udata->location_base;
+ const gchar *location_base = udata->location_base;
+ _cleanup_free_ gchar *location_href = NULL;
+ location_href = g_strdup(task->full_path + udata->repodir_name_len);
+
+ // User requested modification of the location href
+ if (udata->cut_dirs) {
+ gchar *tmp = location_href;
+ location_href = g_strdup(cr_cut_dirs(location_href, udata->cut_dirs));
+ g_free(tmp);
+ }
+
+ if (udata->location_prefix) {
+ gchar *tmp = location_href;
+ location_href = g_build_filename(udata->location_prefix, tmp, NULL);
+ g_free(tmp);
+ }
// If --cachedir is used, load signatures and hdrid from packages too
if (udata->checksum_cachedir)
// We have usable old data, but we have to set proper locations
// WARNING! This two lines destructively modifies content of
// packages in old metadata.
- md->location_href = (char *) location_href;
- md->location_base = (char *) location_base;
+ md->location_href = location_href;
+ md->location_base = location_base;
}
}
}
// deltarpm against
GMutex *mutex_deltatargetpackages; // Mutex
GSList *deltatargetpackages; // List of cr_DeltaTargetPackages
+
+ // Location href modifiers
+ gint cut_dirs; // Ignore *num* of directory components
+ // in location href path
+ gchar *location_prefix; // Append this prefix into location_href
+ // during repodata generation
};