#include <string.h>
#include "cmd_parser.h"
+#include "compression_wrapper.h"
#include "misc.h"
#define DEFAULT_UNIQUE_MD_FILENAMES TRUE
-struct CmdOptions _cmd_options = { .changelog_limit = DEFAULT_CHANGELOG_LIMIT,
- .checksum = NULL,
- .workers = DEFAULT_WORKERS,
- .unique_md_filenames = DEFAULT_UNIQUE_MD_FILENAMES };
+struct CmdOptions _cmd_options = {
+ .changelog_limit = DEFAULT_CHANGELOG_LIMIT,
+ .checksum = NULL,
+ .workers = DEFAULT_WORKERS,
+ .unique_md_filenames = DEFAULT_UNIQUE_MD_FILENAMES,
+ .checksum_type = PKG_CHECKSUM_SHA256,
+ .compression_type = UNKNOWN_COMPRESSION
+ };
"Number of workers to spawn to read rpms.", NULL },
{ "xz", 0, 0, G_OPTION_ARG_NONE, &(_cmd_options.xz_compression),
"Use xz for repodata compression.", NULL },
+ { "compress-type", 0, 0, G_OPTION_ARG_STRING, &(_cmd_options.compress_type),
+ "Which compression type to use.", "<compress_type>" },
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
return FALSE;
}
g_string_free(checksum_str, TRUE);
- } else {
- options->checksum = g_strdup("sha256");
- options->checksum_type = PKG_CHECKSUM_SHA256;
}
+ // Check and set compression type
+ if (options->compress_type) {
+ GString *compress_str = g_string_ascii_down(g_string_new(options->compress_type));
+ if (!strcmp(compress_str->str, "gz")) {
+ options->compression_type = GZ_COMPRESSION;
+ } else if (!strcmp(compress_str->str, "bz2")) {
+ options->compression_type = BZ2_COMPRESSION;
+ } else if (!strcmp(compress_str->str, "xz")) {
+ options->compression_type = XZ_COMPRESSION;
+ } else {
+ g_string_free(compress_str, TRUE);
+ g_critical("Unknown/Unsupported compression type \"%s\"", options->compress_type);
+ return FALSE;
+ }
+ g_string_free(compress_str, TRUE);
+ }
int x;
g_free(options->outputdir);
g_free(options->pkglist);
g_free(options->checksum);
+ g_free(options->compress_type);
g_free(options->groupfile);
g_free(options->groupfile_fullpath);
#include <glib.h>
#include "constants.h"
+#include "compression_wrapper.h"
/**
gboolean database; /*!< create sqlite database metadata - Not implemented yet!!! :( */
gboolean no_database; /*!< do not create database - Implemented ;) */
char *checksum; /*!< type of checksum */
+ char *compress_type; /*!< which compression type to use */
gboolean skip_symlinks; /*!< ignore symlinks of packages */
int changelog_limit; /*!< number of changelog messages in other.(xml|sqlite) */
gboolean unique_md_filenames; /*!< include the file checksums in the filenames */
GSList *include_pkgs; /*!< list of packages to include (build from includepkg options and pkglist file) */
GSList *l_update_md_paths; /*!< list of repos from update_md_paths (remote repos are downloaded) */
ChecksumType checksum_type; /*!< checksum type */
+ CompressionType compression_type; /*!< compression type */
};
DbFilelistsStatements fil_statements;
DbOtherStatements oth_statements;
int changelog_limit;
- char *location_base;
+ const char *location_base;
int repodir_name_len;
- char *checksum_type_str;
+ const char *checksum_type_str;
ChecksumType checksum_type;
gboolean quiet;
gboolean verbose;
struct PoolTask *task = (struct PoolTask *) data;
// get location_href without leading part of path (path to repo) including '/' char
- char *location_href = (gchar *) task->full_path + udata->repodir_name_len;
+ const char *location_href = task->full_path + udata->repodir_name_len;
- char *location_base = udata->location_base;
+ const char *location_base = udata->location_base;
// Get stat info about file
struct stat stat_buf;
if (old_used) {
// We have usable old data, but we have to set locations (href and base)
- md->location_href = location_href;
- md->location_base = location_base;
+ md->location_href = (char *) location_href;
+ md->location_base = (char *) location_base;
}
}
}
- // Create and open new compressed files
+ // Setup compression types
const char *sqlite_compression_suffix = NULL;
CompressionType sqlite_compression = BZ2_COMPRESSION;
CompressionType groupfile_compression = GZ_COMPRESSION;
+
+ if (cmd_options->compression_type != UNKNOWN_COMPRESSION) {
+ sqlite_compression = cmd_options->compression_type;
+ groupfile_compression = cmd_options->compression_type;
+ }
+
if (cmd_options->xz_compression) {
- sqlite_compression = XZ_COMPRESSION;
+ sqlite_compression = XZ_COMPRESSION;
groupfile_compression = XZ_COMPRESSION;
}
+
sqlite_compression_suffix = get_suffix(sqlite_compression);
+
+ // Create and open new compressed files
+
CW_FILE *pri_cw_file;
CW_FILE *fil_cw_file;
CW_FILE *oth_cw_file;
user_data.oth_statements = oth_statements;
user_data.changelog_limit = cmd_options->changelog_limit;
user_data.location_base = cmd_options->location_base;
- user_data.checksum_type_str = cmd_options->checksum;
+ user_data.checksum_type_str = get_checksum_name_str(cmd_options->checksum_type);
user_data.checksum_type = cmd_options->checksum_type;
user_data.quiet = cmd_options->quiet;
user_data.verbose = cmd_options->verbose;