#include "logging.h"
#include "compression_wrapper.h"
-#undef MODULE
-#define MODULE "compression_wrapper: "
-
/*
#define Z_CR_CW_NO_COMPRESSION 0
#define Z_BEST_SPEED 1
cr_CompressionType type = CR_CW_UNKNOWN_COMPRESSION;
if (!g_file_test(filename, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
- g_debug(MODULE"%s: File %s doesn't exists or it's not a regular file",
+ g_debug("%s: File %s doesn't exists or it's not a regular file",
__func__, filename);
return type;
}
magic_t myt = magic_open(MAGIC_MIME);
magic_load(myt, NULL);
if (magic_check(myt, NULL) == -1) {
- g_critical(MODULE"%s: magic_check() failed", __func__);
+ g_critical("%s: magic_check() failed", __func__);
return type;
}
const char *mime_type = magic_file(myt, filename);
if (mime_type) {
- g_debug(MODULE"%s: Detected mime type: %s (%s)", __func__, mime_type,
+ g_debug("%s: Detected mime type: %s (%s)", __func__, mime_type,
filename);
if (g_str_has_prefix(mime_type, "application/x-gzip") ||
type = CR_CW_NO_COMPRESSION;
}
} else {
- g_debug(MODULE"%s: Mime type not detected! (%s)", __func__, filename);
+ g_debug("%s: Mime type not detected! (%s)", __func__, filename);
}
cr_CompressionType type;
if (!filename || (mode != CR_CW_MODE_READ && mode != CR_CW_MODE_WRITE)) {
- g_debug(MODULE"%s: Filename is NULL or bad mode value", __func__);
+ g_debug("%s: Filename is NULL or bad mode value", __func__);
return NULL;
}
if (mode == CR_CW_MODE_WRITE) {
if (comtype == CR_CW_AUTO_DETECT_COMPRESSION) {
- g_debug(MODULE"%s: CR_CW_AUTO_DETECT_COMPRESSION cannot be used if "
+ g_debug("%s: CR_CW_AUTO_DETECT_COMPRESSION cannot be used if "
"mode is CR_CW_MODE_WRITE", __func__);
return NULL;
}
if (comtype == CR_CW_UNKNOWN_COMPRESSION) {
- g_debug(MODULE"%s: CR_CW_UNKNOWN_COMPRESSION cannot be used if mode"
+ g_debug("%s: CR_CW_UNKNOWN_COMPRESSION cannot be used if mode"
" is CR_CW_MODE_WRITE", __func__);
return NULL;
}
}
if (type == CR_CW_UNKNOWN_COMPRESSION) {
- g_debug(MODULE"%s: Cannot detect compression type", __func__);
+ g_debug("%s: Cannot detect compression type", __func__);
return NULL;
}
}
if (gzbuffer((gzFile) file->FILE, GZ_BUFFER_SIZE) == -1) {
- g_debug(MODULE"%s: gzbuffer() call failed", __func__);
+ g_debug("%s: gzbuffer() call failed", __func__);
}
break;
if (ret != LZMA_OK) {
switch (ret) {
case LZMA_MEM_ERROR:
- g_debug(MODULE"%s: XZ: Cannot allocate memory",
+ g_debug("%s: XZ: Cannot allocate memory",
__func__);
break;
case LZMA_OPTIONS_ERROR:
- g_debug(MODULE"%s: XZ: Unsupported flags (options)",
+ g_debug("%s: XZ: Unsupported flags (options)",
__func__);
break;
case LZMA_PROG_ERROR:
- g_debug(MODULE"%s: XZ: One or more of the parameters "
+ g_debug("%s: XZ: One or more of the parameters "
"have values that will never be valid.",
__func__);
break;
default:
- g_debug(MODULE"%s: XZ: Unknown error", __func__);
+ g_debug("%s: XZ: Unknown error", __func__);
}
g_free((void *) xz_file);
break;
// Fill input buffer
if (stream->avail_in == 0) {
if ((lret = fread(xz_file->buffer, 1, XZ_BUFFER_SIZE, xz_file->file)) < 0) {
- g_debug(MODULE"%s: XZ: Error while fread", __func__);
+ g_debug("%s: XZ: Error while fread", __func__);
return CR_CW_ERR; // Error while reading input file
} else if (lret == 0) {
- g_debug(MODULE"%s: EOF", __func__);
+ g_debug("%s: EOF", __func__);
break; // EOF
}
stream->next_in = xz_file->buffer;
// Decode
lret = lzma_code(stream, LZMA_RUN);
if (lret != LZMA_OK && lret != LZMA_STREAM_END) {
- g_debug(MODULE"%s: XZ: Error while decoding (%d)", __func__, lret);
+ g_debug("%s: XZ: Error while decoding (%d)", __func__, lret);
return CR_CW_ERR; // Error while decoding
}
if (lret == LZMA_STREAM_END) {
va_end(vl);
if (ret < 0) {
- g_debug(MODULE"%s: vasprintf() call failed", __func__);
+ g_debug("%s: vasprintf() call failed", __func__);
return CR_CW_ERR;
}
#include "compression_wrapper.h"
#include "locate_metadata.h"
-#undef MODULE
-#define MODULE "load_metadata: "
-
#define STRINGCHUNK_SIZE 16384
#define CHUNK_SIZE 8192
#define PKGS_REALLOC_STEP 2000
} else if (!strcmp(el, "rpm:entry")) {
if (!pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Have <rpm:entry> but pkg object doesn't exist!",
+ g_critical("%s: Have <rpm:entry> but pkg object doesn't exist!",
__func__);
return;
}
dependency->pre = TRUE;
}
} else {
- g_warning(MODULE"%s: Unknown attribute \"%s\"", __func__, attr[i]);
+ g_warning("%s: Unknown attribute \"%s\"", __func__, attr[i]);
}
}
break;
default:
g_free(dependency);
- g_warning(MODULE"%s: Bad context (%d) for rpm:entry", __func__,
+ g_warning("%s: Bad context (%d) for rpm:entry", __func__,
ppd->context);
break;
}
// Check sanity
if (ppd->context != METADATA) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Package element: Bad XML context!", __func__);
+ g_critical("%s: Package element: Bad XML context!", __func__);
return;
}
if (ppd->pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Package element: Pkg pointer is not NULL",
+ g_critical("%s: Package element: Pkg pointer is not NULL",
__func__);
return;
}
} else if (!strcmp(el, "version")) {
if (!pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Have <version> but pkg object doesn't exist!",
+ g_critical("%s: Have <version> but pkg object doesn't exist!",
__func__);
return;
}
} else if (!strcmp(attr[i], "rel")) {
pkg->release = g_string_chunk_insert(pkg->chunk, attr[i+1]);
} else {
- g_warning(MODULE"%s: Unknown attribute \"%s\"", __func__, attr[i]);
+ g_warning("%s: Unknown attribute \"%s\"", __func__, attr[i]);
}
}
if (!pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Have <checksum> but pkg object doesn't exist!",
+ g_critical("%s: Have <checksum> but pkg object doesn't exist!",
__func__);
return;
}
} else if (!strcmp(el, "time")) {
if (!pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Have <time> but pkg object doesn't exist!", __func__);
+ g_critical("%s: Have <time> but pkg object doesn't exist!", __func__);
return;
}
} else if (!strcmp(attr[i], "build")) {
pkg->time_build = g_ascii_strtoll(attr[i+1], NULL, 10);
} else {
- g_warning(MODULE"%s: Unknown attribute \"%s\"", __func__, attr[i]);
+ g_warning("%s: Unknown attribute \"%s\"", __func__, attr[i]);
}
}
} else if (!strcmp(el, "size")) {
if (!pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Have <size> but pkg object doesn't exist!",
+ g_critical("%s: Have <size> but pkg object doesn't exist!",
__func__);
return;
}
} else if (!strcmp(attr[i], "archive")) {
pkg->size_archive = g_ascii_strtoll(attr[i+1], NULL, 10);
} else {
- g_warning(MODULE"%s: Unknown attribute \"%s\"", __func__, attr[i]);
+ g_warning("%s: Unknown attribute \"%s\"", __func__, attr[i]);
}
}
} else if (!strcmp(el, "location")) {
if (!pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Have <location> but pkg object doesn't exist!",
+ g_critical("%s: Have <location> but pkg object doesn't exist!",
__func__);
return;
}
} else if (!strcmp(attr[i], "xml:base")) {
pkg->location_base = g_string_chunk_insert(pkg->chunk, attr[i+1]);
} else {
- g_warning(MODULE"%s: Unknown attribute \"%s\"", __func__, attr[i]);
+ g_warning("%s: Unknown attribute \"%s\"", __func__, attr[i]);
}
}
} else if (!strcmp(el, "rpm:header-range")) {
if (!pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Have <rpm:header-range> but pkg object doesn't exist!",
+ g_critical("%s: Have <rpm:header-range> but pkg object doesn't exist!",
__func__);
return;
}
} else if (!strcmp(attr[i], "end")) {
pkg->rpm_header_end = g_ascii_strtoll(attr[i+1], NULL, 10);
} else {
- g_warning(MODULE"%s: Unknown attribute \"%s\"", __func__, attr[i]);
+ g_warning("%s: Unknown attribute \"%s\"", __func__, attr[i]);
}
}
} else if (!strcmp(el, "metadata")) {
if (ppd->context != ROOT) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Bad context (%d) for %s element", __func__,
+ g_critical("%s: Bad context (%d) for %s element", __func__,
ppd->context, el);
return;
}
// unknown element
} else {
ppd->error = TRUE;
- g_warning(MODULE"%s: Unknown element: %s", __func__, el);
+ g_warning("%s: Unknown element: %s", __func__, el);
}
}
break;
default:
ppd->error = TRUE;
- g_warning(MODULE"%s: Unknown xml element (%d) in primary.xml",
+ g_warning("%s: Unknown xml element (%d) in primary.xml",
__func__, ppd->last_elem);
break;
}
if (key && key[0] != '\0') {
g_hash_table_replace(ppd->hashtable, key, ppd->pkg);
} else {
- g_warning(MODULE"%s: Empty hashtable key!", __func__);
+ g_warning("%s: Empty hashtable key!", __func__);
}
// Reverse lists
if (ppd->context != PACKAGE) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Bad context of <file> element!", __func__);
+ g_critical("%s: Bad context of <file> element!", __func__);
return;
}
if (!pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Have <file> but pkg object doesn't exist!", __func__);
+ g_critical("%s: Have <file> but pkg object doesn't exist!", __func__);
return;
}
ppd->last_elem = FILE_GHOST_ELEM;
}
} else {
- g_warning(MODULE"%s: Unknown attribute \"%s\"", __func__, attr[i]);
+ g_warning("%s: Unknown attribute \"%s\"", __func__, attr[i]);
}
}
// Check sanity
if (ppd->context != FILELISTS) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Package element: Bad XML context!", __func__);
+ g_critical("%s: Package element: Bad XML context!", __func__);
return;
}
if (ppd->pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Package element: Pkg pointer is not NULL", __func__);
+ g_critical("%s: Package element: Pkg pointer is not NULL", __func__);
return;
}
//if (!ppd->pkg) {
// ppd->error = TRUE;
- // g_critical(MODULE"%s: Unknown package (package ID: %s)",
+ // g_critical("%s: Unknown package (package ID: %s)",
// __func__, key);
//}
} else {
ppd->error = TRUE;
- g_critical(MODULE"%s: Package withou pkgid attribute found!", __func__);
+ g_critical("%s: Package withou pkgid attribute found!", __func__);
}
if (ppd->pkg && ppd->chunk)
} else if (!strcmp(el, "filelists")) {
if (ppd->context != ROOT) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Bad context (%d) for %s element", __func__,
+ g_critical("%s: Bad context (%d) for %s element", __func__,
ppd->context, el);
return;
}
// Unknown element
} else {
ppd->error = TRUE;
- g_warning(MODULE"%s: Unknown element: %s", __func__, el);
+ g_warning("%s: Unknown element: %s", __func__, el);
}
}
break;
default:
ppd->error = TRUE;
- g_warning(MODULE"%s: Unknown xml element (%d) in filelists.xml",
+ g_warning("%s: Unknown xml element (%d) in filelists.xml",
__func__, ppd->last_elem);
break;
}
case FILE_DIR_ELEM:
case FILE_GHOST_ELEM:
if (!txt || txtlen == 0) {
- g_warning(MODULE"%s: File with empty filename found!",
+ g_warning("%s: File with empty filename found!",
__func__);
break;
}
default:
ppd->error = TRUE;
- g_warning(MODULE"%s: Bad last xml element state (%d) in filelists.xml",
+ g_warning("%s: Bad last xml element state (%d) in filelists.xml",
__func__, ppd->last_elem);
break;
}
if (ppd->context != PACKAGE) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Bad context of <changelog> element!", __func__);
+ g_critical("%s: Bad context of <changelog> element!", __func__);
return;
}
if (!pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Have <changelog> but pkg object doesn't exist!",
+ g_critical("%s: Have <changelog> but pkg object doesn't exist!",
__func__);
return;
}
} else if (!strcmp(attr[i], "date")) {
changelog_entry->date = g_ascii_strtoll(attr[i+1], NULL, 10);;
} else {
- g_warning(MODULE"%s: Unknown attribute \"%s\"", __func__, attr[i]);
+ g_warning("%s: Unknown attribute \"%s\"", __func__, attr[i]);
}
}
// Check sanity
if (ppd->context != OTHERDATA) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Package element: Bad XML context (%d)!",
+ g_critical("%s: Package element: Bad XML context (%d)!",
__func__, ppd->context);
return;
}
if (ppd->pkg) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Package element: Pkg pointer is not NULL",
+ g_critical("%s: Package element: Pkg pointer is not NULL",
__func__);
return;
}
//if (!ppd->pkg) {
// ppd->error = TRUE;
- // g_critical(MODULE"%s: Unknown package (package ID: %s)",
+ // g_critical("%s: Unknown package (package ID: %s)",
// __func__, key);
//}
} else {
ppd->error = TRUE;
- g_critical(MODULE"%s: Package withou pkgid attribute found!",
+ g_critical("%s: Package withou pkgid attribute found!",
__func__);
}
} else if (!strcmp(el, "otherdata")) {
if (ppd->context != ROOT) {
ppd->error = TRUE;
- g_critical(MODULE"%s: Bad context (%d) for %s element", __func__,
+ g_critical("%s: Bad context (%d) for %s element", __func__,
ppd->context, el);
return;
}
// Unknown element
} else {
ppd->error = TRUE;
- g_warning(MODULE"%s: Unknown element: %s", __func__, el);
+ g_warning("%s: Unknown element: %s", __func__, el);
}
}
break;
default:
ppd->error = TRUE;
- g_warning(MODULE"%s: Unknown xml element (%d) in other.xml",
+ g_warning("%s: Unknown xml element (%d) in other.xml",
__func__, ppd->last_elem);
break;
}
default:
ppd->error = TRUE;
- g_warning(MODULE"%s: Bad last xml element state (%d) in other.xml",
+ g_warning("%s: Bad last xml element state (%d) in other.xml",
__func__, ppd->last_elem);
break;
}
compression_type = cr_detect_compression(primary_xml_path);
if (compression_type == CR_CW_UNKNOWN_COMPRESSION) {
- g_debug(MODULE"%s: Unknown compression", __func__);
+ g_debug("%s: Unknown compression", __func__);
return CR_LOAD_METADATA_ERR;
}
// Open files
if (!(pri_xml_cwfile = cr_open(primary_xml_path, CR_CW_MODE_READ, compression_type))) {
- g_debug(MODULE"%s: Cannot open file: %s", __func__, primary_xml_path);
+ g_debug("%s: Cannot open file: %s", __func__, primary_xml_path);
return CR_LOAD_METADATA_ERR;
}
if (!(fil_xml_cwfile = cr_open(filelists_xml_path, CR_CW_MODE_READ, compression_type))) {
- g_debug(MODULE"%s: Cannot open file: %s", __func__, filelists_xml_path);
+ g_debug("%s: Cannot open file: %s", __func__, filelists_xml_path);
return CR_LOAD_METADATA_ERR;
}
if (!(oth_xml_cwfile = cr_open(other_xml_path, CR_CW_MODE_READ, compression_type))) {
- g_debug(MODULE"%s: Cannot open file: %s", __func__, other_xml_path);
+ g_debug("%s: Cannot open file: %s", __func__, other_xml_path);
return CR_LOAD_METADATA_ERR;
}
pri_buff = XML_GetBuffer(pri_p, CHUNK_SIZE);
if (!pri_buff) {
- g_critical(MODULE"%s: Ran out of memory for parse", __func__);
+ g_critical("%s: Ran out of memory for parse", __func__);
return CR_LOAD_METADATA_ERR;
}
pri_len = cr_read(pri_xml_cwfile, (void *) pri_buff, CHUNK_SIZE);
if (pri_len < 0) {
- g_critical(MODULE"%s: Read error", __func__);
+ g_critical("%s: Read error", __func__);
return CR_LOAD_METADATA_ERR;
}
if (! XML_ParseBuffer(pri_p, pri_len, pri_len == 0)) {
- g_critical(MODULE"%s: Parse error at line: %d (%s)", __func__,
+ g_critical("%s: Parse error at line: %d (%s)", __func__,
(int) XML_GetCurrentLineNumber(pri_p),
(char *) XML_ErrorString(XML_GetErrorCode(pri_p)));
return CR_LOAD_METADATA_ERR;
fil_buff = XML_GetBuffer(fil_p, CHUNK_SIZE);
if (!fil_buff) {
- g_critical(MODULE"%s: Ran out of memory for parse", __func__);
+ g_critical("%s: Ran out of memory for parse", __func__);
return CR_LOAD_METADATA_ERR;
}
fil_len = cr_read(fil_xml_cwfile, (void *) fil_buff, CHUNK_SIZE);
if (fil_len < 0) {
- g_critical(MODULE"%s: Read error", __func__);
+ g_critical("%s: Read error", __func__);
return CR_LOAD_METADATA_ERR;
}
if (! XML_ParseBuffer(fil_p, fil_len, fil_len == 0)) {
- g_critical(MODULE"%s: Parse error at line: %d (%s)", __func__,
+ g_critical("%s: Parse error at line: %d (%s)", __func__,
(int) XML_GetCurrentLineNumber(fil_p),
(char *) XML_ErrorString(XML_GetErrorCode(fil_p)));
return CR_LOAD_METADATA_ERR;
oth_buff = XML_GetBuffer(oth_p, CHUNK_SIZE);
if (!oth_buff) {
- g_critical(MODULE"%s: Ran out of memory for parse", __func__);
+ g_critical("%s: Ran out of memory for parse", __func__);
return CR_LOAD_METADATA_ERR;
}
oth_len = cr_read(oth_xml_cwfile, (void *) oth_buff, CHUNK_SIZE);
if (oth_len < 0) {
- g_critical(MODULE"%s: Read error", __func__);
+ g_critical("%s: Read error", __func__);
return CR_LOAD_METADATA_ERR;
}
if (! XML_ParseBuffer(oth_p, oth_len, oth_len == 0)) {
- g_critical(MODULE"%s: Parse error at line: %d (%s)", __func__,
+ g_critical("%s: Parse error at line: %d (%s)", __func__,
(int) XML_GetCurrentLineNumber(oth_p),
(char *) XML_ErrorString(XML_GetErrorCode(oth_p)));
return CR_LOAD_METADATA_ERR;
md->chunk, md->pkglist_ht);
if (result == CR_LOAD_METADATA_ERR) {
- g_critical(MODULE"%s: Error encountered while parsing", __func__);
+ g_critical("%s: Error encountered while parsing", __func__);
cr_destroy_metadata_hashtable(intern_hashtable);
cr_free_metadata_location(ml);
return result;
}
- g_debug(MODULE"%s: Parsed items: %d", __func__,
+ g_debug("%s: Parsed items: %d", __func__,
g_hash_table_size(intern_hashtable));
// Fill user hashtable and use user selected key
new_key = pkg->name;
break;
default:
- g_critical(MODULE"%s: Unknown hash table key selected",
+ g_critical("%s: Unknown hash table key selected",
__func__);
new_key = pkg->pkgId;
break;
}
if (g_hash_table_lookup(md->ht, new_key)) {
- g_debug(MODULE"%s: Key \"%s\" already exists in hashtable",
+ g_debug("%s: Key \"%s\" already exists in hashtable",
__func__, (char *) new_key);
g_hash_table_iter_remove(&iter);
} else {
#include "misc.h"
#include "locate_metadata.h"
-#undef MODULE
-#define MODULE "locate_metadata: "
-
#define TMPDIR_PATTERN "/tmp/createrepo_c_tmp_repo_XXXXXX"
#define FORMAT_XML 1
}
if (ml->tmp_dir) {
- g_debug(MODULE"%s: Removing %s", __func__, ml->tmp_dir);
+ g_debug("%s: Removing %s", __func__, ml->tmp_dir);
cr_remove_dir(ml->tmp_dir);
}
// Parsing
reader = xmlReaderForFile(repomd_path, NULL, XML_PARSE_NOBLANKS);
if (!reader) {
- g_warning(MODULE"%s: Error while xmlReaderForFile()", __func__);
+ g_warning("%s: Error while xmlReaderForFile()", __func__);
return NULL;
}
ret = xmlTextReaderRead(reader);
name = xmlTextReaderName(reader);
if (g_strcmp0((char *) name, "repomd")) {
- g_warning(MODULE"%s: Bad xml - missing repomd element? (%s)",
+ g_warning("%s: Bad xml - missing repomd element? (%s)",
__func__, name);
xmlFree(name);
xmlFreeTextReader(reader);
ret = xmlTextReaderRead(reader);
name = xmlTextReaderName(reader);
if (g_strcmp0((char *) name, "revision")) {
- g_warning(MODULE"%s: Bad xml - missing revision element? (%s)",
+ g_warning("%s: Bad xml - missing revision element? (%s)",
__func__, name);
xmlFree(name);
xmlFreeTextReader(reader);
if (!ret) {
// No elements left -> Bad xml
- g_warning(MODULE"%s: Bad xml - missing data elements?", __func__);
+ g_warning("%s: Bad xml - missing data elements?", __func__);
xmlFreeTextReader(reader);
return NULL;
}
}
if (!g_file_test(in_repopath, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_DIR)) {
- g_warning(MODULE"%s: %s is not a directory", __func__, in_repopath);
+ g_warning("%s: %s is not a directory", __func__, in_repopath);
return ret;
}
repomd = g_strconcat(repopath, "repodata/repomd.xml", NULL);
if (!g_file_test(repomd, G_FILE_TEST_EXISTS)) {
- g_debug(MODULE"%s: %s doesn't exists", __func__, repomd);
+ g_debug("%s: %s doesn't exists", __func__, repomd);
g_free(repomd);
g_free(repopath);
return ret;
// Create temporary repo in /tmp
if(!mkdtemp(tmp_dir)) {
- g_critical(MODULE"%s: Cannot create a temporary directory: %s",
+ g_critical("%s: Cannot create a temporary directory: %s",
__func__, strerror(errno));
return ret;
}
tmp_repodata = g_strconcat(tmp_dir, "/repodata/", NULL);
if (g_mkdir (tmp_repodata, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)) {
- g_critical(MODULE"%s: Cannot create a temporary directory", __func__);
+ g_critical("%s: Cannot create a temporary directory", __func__);
return ret;
}
tmp_repomd = g_strconcat(tmp_repodata, "repomd.xml", NULL);
f_repomd = fopen(tmp_repomd, "w");
if (!f_repomd) {
- g_critical(MODULE"%s: Cannot open %s", __func__, tmp_repomd);
+ g_critical("%s: Cannot open %s", __func__, tmp_repomd);
goto get_remote_metadata_cleanup;
}
- g_debug(MODULE"%s: Using tmp dir: %s", __func__, tmp_dir);
+ g_debug("%s: Using tmp dir: %s", __func__, tmp_dir);
// Download repo files
// Set error buffer
if (curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, errorbuf) != CURLE_OK) {
- g_critical(MODULE"%s: curl_easy_setopt(CURLOPT_ERRORBUFFER) error", __func__);
+ g_critical("%s: curl_easy_setopt(CURLOPT_ERRORBUFFER) error", __func__);
goto get_remote_metadata_cleanup;
}
// Set URL
if (curl_easy_setopt(handle, CURLOPT_URL, url) != CURLE_OK) {
- g_critical(MODULE"%s: curl_easy_setopt(CURLOPT_URL) error", __func__);
+ g_critical("%s: curl_easy_setopt(CURLOPT_URL) error", __func__);
goto get_remote_metadata_cleanup;
}
// Set output file descriptor
if (curl_easy_setopt(handle, CURLOPT_WRITEDATA, f_repomd) != CURLE_OK) {
- g_critical(MODULE"%s: curl_easy_setopt(CURLOPT_WRITEDATA) error", __func__);
+ g_critical("%s: curl_easy_setopt(CURLOPT_WRITEDATA) error", __func__);
goto get_remote_metadata_cleanup;
}
// Fail on HTTP error (return code >= 400)
if (curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1) != CURLE_OK) {
- g_critical(MODULE"%s: curl_easy_setopt(CURLOPT_FAILONERROR) error", __func__);
+ g_critical("%s: curl_easy_setopt(CURLOPT_FAILONERROR) error", __func__);
goto get_remote_metadata_cleanup;
}
rcode = curl_easy_perform(handle);
if (rcode != 0) {
- g_critical(MODULE"%s: curl_easy_perform() error: %s", __func__, errorbuf);
+ g_critical("%s: curl_easy_perform() error: %s", __func__, errorbuf);
goto get_remote_metadata_cleanup;
}
r_location = parse_repomd(tmp_repomd, repopath, ignore_sqlite);
if (!r_location) {
- g_critical(MODULE"%s: repomd.xml parser failed on %s", __func__, tmp_repomd);
+ g_critical("%s: repomd.xml parser failed on %s", __func__, tmp_repomd);
goto get_remote_metadata_cleanup;
}
cr_download(handle, r_location->updateinfo_href, tmp_repodata, &error);
if (error) {
- g_critical(MODULE"%s: Error while downloadig files: %s", __func__, error);
+ g_critical("%s: Error while downloadig files: %s", __func__, error);
g_free(error);
goto get_remote_metadata_cleanup;
}
- g_debug(MODULE"%s: Remote metadata was successfully downloaded", __func__);
+ g_debug("%s: Remote metadata was successfully downloaded", __func__);
// Parse downloaded data
struct cr_MetadataLocation *ml;
if (!repopath || !g_file_test(repopath, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_DIR)) {
- g_debug(MODULE"%s: remove_old_metadata: Cannot remove %s", __func__, repopath);
+ g_debug("%s: remove_old_metadata: Cannot remove %s", __func__, repopath);
return -1;
}
full_repopath = g_strconcat(repopath, "/repodata/", NULL);
repodir = g_dir_open(full_repopath, 0, NULL);
if (!repodir) {
- g_debug(MODULE"%s: Path %s doesn't exists", __func__, repopath);
+ g_debug("%s: Path %s doesn't exists", __func__, repopath);
g_free(full_repopath);
return -1;
}
for (element=list; element; element=element->next) {
gchar *path = (char *) element->data;
- g_debug(MODULE"%s: Removing: %s (path obtained from repomd.xml)", __func__, path);
+ g_debug("%s: Removing: %s (path obtained from repomd.xml)", __func__, path);
if (g_remove(path) == -1) {
- // g_warning(MODULE"%s: remove_old_metadata: Cannot remove %s", __func__, path);
+ // g_warning("%s: remove_old_metadata: Cannot remove %s", __func__, path);
;
} else {
removed_files++;
!g_strcmp0(file, "repomd.xml"))
{
gchar *path = g_strconcat(full_repopath, file, NULL);
- g_debug(MODULE"%s: Removing: %s", __func__, path);
+ g_debug("%s: Removing: %s", __func__, path);
if (g_remove(path) == -1)
- g_warning(MODULE"%s: Cannot remove %s", __func__, path);
+ g_warning("%s: Cannot remove %s", __func__, path);
else
removed_files++;
g_free(path);
el = g_slist_nth(list, retain);
for (; el; el = g_slist_next(el)) {
OldFile *of = (OldFile *) el->data;
- g_debug(MODULE"%s: Removing: %s", __func__, of->path);
+ g_debug("%s: Removing: %s", __func__, of->path);
if (g_remove(of->path) == -1)
- g_warning(MODULE"%s: Cannot remove %s", __func__, of->path);
+ g_warning("%s: Cannot remove %s", __func__, of->path);
else
removed++;
}
GSList *oth_lst = NULL, *oth_db_lst = NULL;
if (!repopath || !g_file_test(repopath, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_DIR)) {
- g_debug(MODULE"%s: remove_old_metadata: Cannot remove %s", __func__, repopath);
+ g_debug("%s: remove_old_metadata: Cannot remove %s", __func__, repopath);
return -1;
}
full_repopath = g_strconcat(repopath, "/repodata/", NULL);
repodir = g_dir_open(full_repopath, 0, NULL);
if (!repodir) {
- g_debug(MODULE"%s: Path %s doesn't exists", __func__, repopath);
+ g_debug("%s: Path %s doesn't exists", __func__, repopath);
g_free(full_repopath);
return -1;
}
// Remove old metadata
repomd_path = g_strconcat(full_repopath, "repomd.xml", NULL);
- g_debug(MODULE"%s: Removing: %s", __func__, repomd_path);
+ g_debug("%s: Removing: %s", __func__, repomd_path);
g_remove(repomd_path);
g_free(repomd_path);
g_free(full_repopath);
#include "constants.h"
#include "misc.h"
-#undef MODULE
-#define MODULE "misc: "
-
-
#define BUFFER_SIZE 4096
GChecksumType gchecksumtype;
if (!filename) {
- g_debug(MODULE"%s: Filename param is NULL", __func__);
+ g_debug("%s: Filename param is NULL", __func__);
return NULL;
}
// Check if file exists and if it is a regular file (not a directory)
if (!g_file_test(filename, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
- g_debug(MODULE"%s: File %s doesn't exists", __func__, filename);
+ g_debug("%s: File %s doesn't exists", __func__, filename);
return NULL;
}
gchecksumtype = G_CHECKSUM_SHA256;
break;
default:
- g_debug(MODULE"%s: Unknown checksum type", __func__);
+ g_debug("%s: Unknown checksum type", __func__);
return NULL;
};
FILE *fp = fopen(filename, "rb");
if (!fp) {
- g_critical(MODULE"%s: Cannot open %s (%s)", __func__, filename,
+ g_critical("%s: Cannot open %s (%s)", __func__, filename,
strerror(errno));
return NULL;
}
g_checksum_free(checksum);
if (!checksum_str) {
- g_critical(MODULE"%s: Cannot get checksum %s (low memory?)", __func__,
+ g_critical("%s: Cannot get checksum %s (low memory?)", __func__,
filename);
}
FILE *fp = fopen(filename, "rb");
if (!fp) {
- g_debug(MODULE"%s: Cannot open file %s (%s)", __func__, filename,
+ g_debug("%s: Cannot open file %s (%s)", __func__, filename,
strerror(errno));
return results;
}
// Get header range
if (fseek(fp, 104, SEEK_SET) != 0) {
- g_debug(MODULE"%s: fseek fail on %s (%s)", __func__, filename,
+ g_debug("%s: fseek fail on %s (%s)", __func__, filename,
strerror(errno));
fclose(fp);
return results;
// Check sanity
if (hdrend < hdrstart) {
- g_debug(MODULE"%s: sanity check fail on %s (%d > %d))", __func__,
+ g_debug("%s: sanity check fail on %s (%d > %d))", __func__,
filename, hdrstart, hdrend);
return results;
}
name = "sha256";
break;
default:
- g_debug(MODULE"%s: Unknown checksum (%d)", __func__, type);
+ g_debug("%s: Unknown checksum (%d)", __func__, type);
break;
}
FILE *new;
if (!src || !in_dst) {
- g_debug(MODULE"%s: File name cannot be NULL", __func__);
+ g_debug("%s: File name cannot be NULL", __func__);
return CR_COPY_ERR;
}
}
if ((orig = fopen(src, "r")) == NULL) {
- g_debug(MODULE"%s: Cannot open source file %s (%s)", __func__, src,
+ g_debug("%s: Cannot open source file %s (%s)", __func__, src,
strerror(errno));
return CR_COPY_ERR;
}
if ((new = fopen(dst, "w")) == NULL) {
- g_debug(MODULE"%s: Cannot open destination file %s (%s)", __func__, dst,
+ g_debug("%s: Cannot open destination file %s (%s)", __func__, dst,
strerror(errno));
fclose(orig);
return CR_COPY_ERR;
while ((readed = fread(buf, 1, BUFFER_SIZE, orig)) > 0) {
if (fwrite(buf, 1, readed, new) != readed) {
- g_debug(MODULE"%s: Error while copy %s -> %s (%s)", __func__, src,
+ g_debug("%s: Error while copy %s -> %s (%s)", __func__, src,
dst, strerror(errno));
fclose(new);
fclose(orig);
}
if (readed != BUFFER_SIZE && ferror(orig)) {
- g_debug(MODULE"%s: Error while copy %s -> %s (%s)", __func__, src,
+ g_debug("%s: Error while copy %s -> %s (%s)", __func__, src,
dst, strerror(errno));
fclose(new);
fclose(orig);
CR_FILE *new;
if (!src) {
- g_debug(MODULE"%s: File name cannot be NULL", __func__);
+ g_debug("%s: File name cannot be NULL", __func__);
return CR_COPY_ERR;
}
if (compression == CR_CW_AUTO_DETECT_COMPRESSION ||
compression == CR_CW_UNKNOWN_COMPRESSION) {
- g_debug(MODULE"%s: Bad compression type", __func__);
+ g_debug("%s: Bad compression type", __func__);
return CR_COPY_ERR;
}
if (g_str_has_suffix(src, "/") ||
!g_file_test(src, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)))
{
- g_debug(MODULE"%s: Source (%s) must be directory!", __func__, src);
+ g_debug("%s: Source (%s) must be directory!", __func__, src);
return CR_COPY_ERR;
}
}
if ((orig = fopen(src, "r")) == NULL) {
- g_debug(MODULE"%s: Cannot open source file %s (%s)", __func__, src,
+ g_debug("%s: Cannot open source file %s (%s)", __func__, src,
strerror(errno));
return CR_COPY_ERR;
}
if ((new = cr_open(dst, CR_CW_MODE_WRITE, compression)) == NULL) {
- g_debug(MODULE"%s: Cannot open destination file %s", __func__, dst);
+ g_debug("%s: Cannot open destination file %s", __func__, dst);
fclose(orig);
return CR_COPY_ERR;
}
while ((readed = fread(buf, 1, BUFFER_SIZE, orig)) > 0) {
if (cr_write(new, buf, readed) != readed) {
- g_debug(MODULE"%s: Error while copy %s -> %s", __func__, src, dst);
+ g_debug("%s: Error while copy %s -> %s", __func__, src, dst);
cr_close(new);
fclose(orig);
return CR_COPY_ERR;
}
if (readed != BUFFER_SIZE && ferror(orig)) {
- g_debug(MODULE"%s: Error while copy %s -> %s (%s)", __func__, src,
+ g_debug("%s: Error while copy %s -> %s (%s)", __func__, src,
dst, strerror(errno));
cr_close(new);
fclose(orig);
file = fopen(dst, "w");
if (!file) {
- *error = g_strdup_printf(MODULE"%s: Cannot open %s", __func__, dst);
+ *error = g_strdup_printf("%s: Cannot open %s", __func__, dst);
remove(dst);
g_free(dst);
return;
// Set URL
if (curl_easy_setopt(handle, CURLOPT_URL, url) != CURLE_OK) {
- *error = g_strdup_printf(MODULE"%s: curl_easy_setopt(CURLOPT_URL) error",
+ *error = g_strdup_printf("%s: curl_easy_setopt(CURLOPT_URL) error",
__func__);
fclose(file);
remove(dst);
// Set output file descriptor
if (curl_easy_setopt(handle, CURLOPT_WRITEDATA, file) != CURLE_OK) {
- *error = g_strdup_printf(MODULE
+ *error = g_strdup_printf(
"%s: curl_easy_setopt(CURLOPT_WRITEDATA) error",
__func__);
fclose(file);
rcode = curl_easy_perform(handle);
if (rcode != 0) {
- *error = g_strdup_printf(MODULE"%s: curl_easy_perform() error: %s",
+ *error = g_strdup_printf("%s: curl_easy_perform() error: %s",
__func__, curl_easy_strerror(rcode));
fclose(file);
remove(dst);
}
- g_debug(MODULE"%s: Successfully downloaded: %s", __func__, dst);
+ g_debug("%s: Successfully downloaded: %s", __func__, dst);
fclose(file);
g_free(dst);
cr_download(handle, src, in_dst, &error);
curl_easy_cleanup(handle);
if (error) {
- g_debug(MODULE"%s: Error while downloading %s: %s", __func__, src,
+ g_debug("%s: Error while downloading %s: %s", __func__, src,
error);
return CR_COPY_ERR;
}
#include "xml_dump.h"
#include "misc.h"
-#undef MODULE
-#define MODULE "parsehdr: "
-
inline gchar *
safe_string_chunk_insert(GStringChunk *chunk, const char *str)
#include "misc.h"
#include "parsehdr.h"
-#undef MODULE
-#define MODULE "parsepkg: "
-
-
volatile short cr_initialized = 0;
rpmts ts = NULL;
rpmReadConfigFiles(NULL, NULL);
ts = rpmtsCreate();
if (!ts)
- g_critical(MODULE"%s: rpmtsCreate() failed", __func__);
+ g_critical("%s: rpmtsCreate() failed", __func__);
rpmVSFlags vsflags = 0;
vsflags |= _RPMVSF_NODIGESTS;
// Work around for this shoud be use empty keyring.
keyring = rpmKeyringNew();
if (rpmtsSetKeyring(ts, keyring) == -1)
- g_critical(MODULE"%s: rpmtsSetKeyring() failed", __func__);
+ g_critical("%s: rpmtsSetKeyring() failed", __func__);
rpmKeyringFree(keyring);
}
checksum_type_str = "sha256";
break;
default:
- g_warning(MODULE"%s: Unknown checksum type", __func__);
+ g_warning("%s: Unknown checksum type", __func__);
return result;
break;
};
FD_t fd = NULL;
fd = Fopen(filename, "r.ufdio");
if (!fd) {
- g_warning(MODULE"%s: Fopen of %s failed %s",
+ g_warning("%s: Fopen of %s failed %s",
__func__, filename, strerror(errno));
return result;
}
if (rc != RPMRC_OK) {
switch (rc) {
case RPMRC_NOKEY:
- g_debug(MODULE"%s: %s: Public key is unavailable.",
+ g_debug("%s: %s: Public key is unavailable.",
__func__, filename);
break;
case RPMRC_NOTTRUSTED:
- g_debug(MODULE"%s: %s: Signature is OK, but key is not trusted.",
+ g_debug("%s: %s: Signature is OK, but key is not trusted.",
__func__, filename);
break;
default:
- g_warning(MODULE"%s: rpmReadPackageFile() error (%s)",
+ g_warning("%s: rpmReadPackageFile() error (%s)",
__func__, strerror(errno));
return result;
}
if (!stat_buf) {
struct stat stat_buf_own;
if (stat(filename, &stat_buf_own) == -1) {
- g_warning(MODULE"%s: stat() error (%s)", __func__, strerror(errno));
+ g_warning("%s: stat() error (%s)", __func__, strerror(errno));
return result;
}
mtime = stat_buf_own.st_mtime;
checksum_type_str = "sha256";
break;
default:
- g_warning(MODULE"%s: Unknown checksum type", __func__);
+ g_warning("%s: Unknown checksum type", __func__);
return result;
break;
};
FD_t fd = NULL;
fd = Fopen(filename, "r.ufdio");
if (!fd) {
- g_warning(MODULE"%s: Fopen failed %s", __func__, strerror(errno));
+ g_warning("%s: Fopen failed %s", __func__, strerror(errno));
return result;
}
if (rc != RPMRC_OK) {
switch (rc) {
case RPMRC_NOKEY:
- g_debug(MODULE"%s: %s: Public key is unavailable.",
+ g_debug("%s: %s: Public key is unavailable.",
__func__, filename);
break;
case RPMRC_NOTTRUSTED:
- g_debug(MODULE"%s: %s: Signature is OK, but key is not trusted.",
+ g_debug("%s: %s: Signature is OK, but key is not trusted.",
__func__, filename);
break;
default:
- g_warning(MODULE"%s: rpmReadPackageFile() error (%s)",
+ g_warning("%s: rpmReadPackageFile() error (%s)",
__func__, strerror(errno));
return result;
}
if (!stat_buf) {
struct stat stat_buf_own;
if (stat(filename, &stat_buf_own) == -1) {
- g_warning(MODULE"%s: stat() error (%s)", __func__, strerror(errno));
+ g_warning("%s: stat() error (%s)", __func__, strerror(errno));
return result;
}
mtime = stat_buf_own.st_mtime;
#include "repomd.h"
#include "compression_wrapper.h"
-#undef MODULE
-#define MODULE "repomd: "
-
#define LOCATION_HREF_PREFIX "repodata/"
#define DEFAULT_DATABASE_VERSION 10
gchecksumtype = G_CHECKSUM_SHA256;
break;
default:
- g_critical(MODULE"%s: Unknown checksum type", __func__);
+ g_critical("%s: Unknown checksum type", __func__);
return NULL;
};
GChecksum *checksum = g_checksum_new(gchecksumtype);
if (!checksum) {
- g_critical(MODULE"%s: g_checksum_new() failed", __func__);
+ g_critical("%s: g_checksum_new() failed", __func__);
return NULL;
}
do {
readed = cr_read(cwfile, (void *) buffer, BUFFER_SIZE);
if (readed == CR_CW_ERR) {
- g_debug(MODULE"%s: Error while read compressed file: %s",
+ g_debug("%s: Error while read compressed file: %s",
__func__, filename);
break;
}
if (!g_file_test(path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR)) {
// File doesn't exists
- g_warning(MODULE"%s: File %s doesn't exists", __func__, path);
+ g_warning("%s: File %s doesn't exists", __func__, path);
return REPOMD_ERR;
}
g_free(open_stat);
} else {
// Unknown compression
- g_warning(MODULE"%s: File \"%s\" compressed by an unsupported type"
+ g_warning("%s: File \"%s\" compressed by an unsupported type"
" of compression", __func__, path);
md->checksum_open_type = g_string_chunk_insert(md->chunk, "UNKNOWN");
md->checksum_open = g_string_chunk_insert(md->chunk,
md->size = buf.st_size;
}
} else {
- g_warning(MODULE"%s: Stat on file \"%s\" failed", __func__, path);
+ g_warning("%s: Stat on file \"%s\" failed", __func__, path);
}
}
if (!g_file_test(path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR)) {
// File doesn't exists
- g_warning(MODULE"%s: File %s doesn't exists", __func__, path);
+ g_warning("%s: File %s doesn't exists", __func__, path);
return;
}
while ((readed = cr_read(cw_plain, buf, BUFFER_SIZE)) > 0) {
if (cr_write(cw_compressed, buf, (unsigned int) readed) == CR_CW_ERR) {
- g_debug(MODULE"%s: Error while groupfile compression", __func__);
+ g_debug("%s: Error while groupfile compression", __func__);
break;
}
}
cr_close(cw_plain);
if (readed == CR_CW_ERR) {
- g_debug(MODULE"%s: Error while groupfile compression", __func__);
+ g_debug("%s: Error while groupfile compression", __func__);
}
// Get stats
if (stat(path, &gf_stat)) {
- g_debug(MODULE"%s: Error while stat() on %s", __func__, path);
+ g_debug("%s: Error while stat() on %s", __func__, path);
} else {
gf_size = gf_stat.st_size;
gf_time = gf_stat.st_mtime;
}
if (stat(cpath, &cgf_stat)) {
- g_debug(MODULE"%s: Error while stat() on %s", __func__, path);
+ g_debug("%s: Error while stat() on %s", __func__, path);
} else {
cgf_size = cgf_stat.st_size;
cgf_time = cgf_stat.st_mtime;
// Rename file
if (g_file_test (new_location_real, G_FILE_TEST_EXISTS)) {
if (remove(new_location_real)) {
- g_critical(MODULE"%s: Cannot delete old %s",
+ g_critical("%s: Cannot delete old %s",
__func__,
new_location_real);
g_free(new_location_real);
}
}
if (rename(md->location_real, new_location_real)) {
- g_critical(MODULE"%s: Cannot rename %s to %s",
+ g_critical("%s: Cannot rename %s to %s",
__func__,
md->location_real,
new_location_real);
* USA.
*/
-/*
-TODO:
-- Fix possible license issue of this module!!!
- - Relicensins whole project to GPLv2?
- - Rewrite sqlite module?
-*/
-
#include <glib.h>
#include <string.h>
#include <stdlib.h>
#include "misc.h"
#include "sqlite.h"
-#undef MODULE
-#define MODULE "sqlite: "
-
#define ENCODED_PACKAGE_FILE_FILES 2048
#define ENCODED_PACKAGE_FILE_TYPES 60