createrepo_c library 1.2.1 C library for metadata manipulation

Data Structures | Functions
Repomd API.

Module for generating repomd.xml. More...

## Data Structures
struct | cr_RepomdRecord
struct | cr_DistroTag
struct | cr_Repomd

## Functions
cr_RepomdRecord * | cr_repomd_record_new (const char *type, const char *path)
void | cr_repomd_record_free (cr_RepomdRecord *record)
cr_RepomdRecord * | cr_repomd_record_copy (const cr_RepomdRecord *orig)
int | cr_repomd_record_fill (cr_RepomdRecord *record, cr_ChecksumType checksum_type, GError **err)
int | cr_repomd_record_compress_and_fill (cr_RepomdRecord *record, cr_RepomdRecord *compressed_record, cr_ChecksumType checksum_type, cr_CompressionType compression, const char *zck_dict_dir, GError **err)
int | cr_repomd_record_rename_file (cr_RepomdRecord *record, GError **err)
void | cr_repomd_record_set_timestamp (cr_RepomdRecord *record, gint64 timestamp)
void | cr_repomd_record_load_contentstat (cr_RepomdRecord *record, cr_ContentStat *stats)
void | cr_repomd_record_load_zck_contentstat (cr_RepomdRecord *record, cr_ContentStat *stats)
cr_Repomd * | cr_repomd_new ()
cr_Repomd * | cr_repomd_copy (cr_Repomd *repomd)
void | cr_repomd_set_record (cr_Repomd *repomd, cr_RepomdRecord *record)
void | cr_repomd_set_revision (cr_Repomd *repomd, const char *revision)
void | cr_repomd_set_repoid (cr_Repomd *repomd, const char *repoid, const char *type)
void | cr_repomd_set_contenthash (cr_Repomd *repomd, const char *hash, const char *type)
void | cr_repomd_add_distro_tag (cr_Repomd *repomd, const char *cpeid, const char *tag)
void | cr_repomd_add_repo_tag (cr_Repomd *repomd, const char *tag)
void | cr_repomd_add_content_tag (cr_Repomd *repomd, const char *tag)
cr_RepomdRecord * | cr_repomd_get_record (cr_Repomd *repomd, const char *type)
void | cr_repomd_detach_record (cr_Repomd *repomd, cr_RepomdRecord *rec)
void | cr_repomd_remove_record (cr_Repomd *repomd, const char *type)
void | cr_repomd_sort_records (cr_Repomd *repomd)
void | cr_repomd_free (cr_Repomd *repomd)

## Detailed Description

Module for generating repomd.xml.

Example:

char *xml;
cr_Repomd *md = cr_repomd_new();
cr_RepomdRecord *rec;
cr_xml_dump_init();
// Set some repomd stuff
cr_repomd_set_revision(md, "007");
cr_repomd_add_repo_tag(md, "repotag");
cr_repomd_add_content_tag(md, "contenttag");
cr_repomd_add_distro_tag(md, "foocpeid", "data");
// Create record for new metadata file
rec = cr_repomd_record_new("primary", "/foo/bar/repodata/primary.xml.xz");
// Calculate all needed parameters (uncompresed size, checksum, ...)
cr_repomd_record_fill(rec, CR_CHECKSUM_SHA256);
// Rename source file - insert checksum into the filename
cr_repomd_record_rename_file(rec)
// Append the record into the repomd
cr_repomd_set_record(md, rec);
// Get repomd.xml content
xml = cr_xml_dump_repomd(md, NULL);
// Cleanup
cr_repomd_free(md);
cr_xml_dump_cleanup();

## Function Documentation

## ◆ cr_repomd_add_content_tag()

void cr_repomd_add_content_tag | ( | cr_Repomd * | repomd,
|  | const char * | tag
| ) |  |

Add content tag.

Parameters

  repomd | cr_Repomd object
  tag | content tag

## ◆ cr_repomd_add_distro_tag()

void cr_repomd_add_distro_tag | ( | cr_Repomd * | repomd,
|  | const char * | cpeid,
|  | const char * | tag
| ) |  |

Add distro tag.

Parameters

  repomd | cr_Repomd object
  cpeid | cpeid string (could be NULL)
  tag | distro tag string

## ◆ cr_repomd_add_repo_tag()

void cr_repomd_add_repo_tag | ( | cr_Repomd * | repomd,
|  | const char * | tag
| ) |  |

Add repo tag.

Parameters

  repomd | cr_Repomd object
  tag | repo tag

## ◆ cr_repomd_copy()

cr_Repomd* cr_repomd_copy | ( | cr_Repomd * | repomd | ) |

Create copy of cr_Repomd

Parameters

  repomd | cr_Repomd object

Returns
  Copy of the input cr_Repomd object

## ◆ cr_repomd_detach_record()

void cr_repomd_detach_record | ( | cr_Repomd * | repomd,
|  | cr_RepomdRecord * | rec
| ) |  |

Detach this record from the repomd records list. Note: Responsibility of freeing record memory no longer belongs to cr_Repomd object.

Parameters

  repomd | cr_Repomd object
  rec | Record to be removed

## ◆ cr_repomd_free()

void cr_repomd_free | ( | cr_Repomd * | repomd | ) |

Frees cr_Repomd object and all its cr_RepomdRecord objects

Parameters

  repomd | cr_Repomd object

## ◆ cr_repomd_get_record()

cr_RepomdRecord* cr_repomd_get_record | ( | cr_Repomd * | repomd,
|  | const char * | type
| ) |  |

Get repomd record from the repomd object.

Parameters

  repomd | cr_Repomd object
  type | Type of the record ("primary", "primary_db", ..)

Returns
  Pointer to a record of desired type or NULL

## ◆ cr_repomd_new()

cr_Repomd* cr_repomd_new | ( |  | ) |

Create new empty cr_Repomd object wich represents content of repomd.xml.

## ◆ cr_repomd_record_compress_and_fill()

int cr_repomd_record_compress_and_fill | ( | cr_RepomdRecord * | record,
|  | cr_RepomdRecord * | compressed_record,
|  | cr_ChecksumType | checksum_type,
|  | cr_CompressionType | compression,
|  | const char * | zck_dict_dir,
|  | GError ** | err
| ) |  |

Almost analogous to cr_repomd_record_fill but suitable for groupfile. Record must be set with the path to existing non compressed groupfile. Compressed file will be created and compressed_record updated.

Parameters

  record | cr_RepomdRecord initialized to an existing uncompressed file
  compressed_record | empty cr_RepomdRecord object that will by filled
  checksum_type | type of checksums
  compression | type of compression
  zck_dict_dir | Location of zchunk dictionaries (NULL if unused)
  err | GError **

Returns
  cr_Error code

## ◆ cr_repomd_record_copy()

cr_RepomdRecord* cr_repomd_record_copy | ( | const cr_RepomdRecord * | orig | ) |

Copy cr_RepomdRecord object.

Parameters

  orig | cr_RepomdRecord object

Returns
  copy of cr_RepomdRecord object

## ◆ cr_repomd_record_fill()

int cr_repomd_record_fill | ( | cr_RepomdRecord * | record,
|  | cr_ChecksumType | checksum_type,
|  | GError ** | err
| ) |  |

Fill unfilled items in the cr_RepomdRecord (calculate checksums, get file size before/after compression, etc.). Note: If checksum_open, checksum_open_type and size_open are filed then their calculation will be skiped. This items could be filled directly on our own or use function for load them from a cr_ContentStat. If no open stats are supplied, then this function has to decompress the file for the open checksum calculation.

Parameters

  record | cr_RepomdRecord object
  checksum_type | type of checksum to use
  err | GError **

Returns
  cr_Error code

## ◆ cr_repomd_record_free()

void cr_repomd_record_free | ( | cr_RepomdRecord * | record | ) |

Destroy cr_RepomdRecord object. NOTE: Do NOT use this function on objects attached to cr_Repomd (by cr_repomd_set_record).

Parameters

  record | cr_RepomdRecord object

## ◆ cr_repomd_record_load_contentstat()

void cr_repomd_record_load_contentstat | ( | cr_RepomdRecord * | record,
|  | cr_ContentStat * | stats
| ) |  |

Load the open stats (checksum_open, checksum_open_type and size_open) from the cr_ContentStat object.

Parameters

  record | cr_RepomdRecord
  stats | cr_ContentStat

## ◆ cr_repomd_record_load_zck_contentstat()

void cr_repomd_record_load_zck_contentstat | ( | cr_RepomdRecord * | record,
|  | cr_ContentStat * | stats
| ) |  |

Load the zchunk stats (zck_header_checksum, zck_header_checksum_type and zck_header_size) from the cr_ContentStat object.

Parameters

  record | cr_RepomdRecord
  stats | cr_ContentStat

## ◆ cr_repomd_record_new()

cr_RepomdRecord* cr_repomd_record_new | ( | const char * | type,
|  | const char * | path
| ) |  |

Creates (alloc) new cr_RepomdRecord object

Parameters

  type | Type of record ("primary", "filelists", ..)
  path | path to the compressed file

## ◆ cr_repomd_record_rename_file()

int cr_repomd_record_rename_file | ( | cr_RepomdRecord * | record,
|  | GError ** | err
| ) |  |

Add a hash as prefix to the filename.

Parameters

  record | cr_RepomdRecord of file to be renamed
  err | GError **

Returns
  cr_Error code

## ◆ cr_repomd_record_set_timestamp()

void cr_repomd_record_set_timestamp | ( | cr_RepomdRecord * | record,
|  | gint64 | timestamp
| ) |  |

Set timestamp of the file. Needed to reproduce bit-by-bit identical metadata.

Parameters

  record | cr_RepomdRecord of file to be renamed
  timestamp | timestamp in number of seconds since 1970-01-01

## ◆ cr_repomd_remove_record()

void cr_repomd_remove_record | ( | cr_Repomd * | repomd,
|  | const char * | type
| ) |  |

Remove first record of the specified type

Parameters

  repomd | cr_Repomd object
  type | Type of the record ("primary", "primary_db", ..)

## ◆ cr_repomd_set_contenthash()

void cr_repomd_set_contenthash | ( | cr_Repomd * | repomd,
|  | const char * | hash,
|  | const char * | type
| ) |  |

Set a contenthash

Parameters

  repomd | cr_Repomd object
  hash | content hash
  type | Type of hash function

## ◆ cr_repomd_set_record()

void cr_repomd_set_record | ( | cr_Repomd * | repomd,
|  | cr_RepomdRecord * | record
| ) |  |

Set cr_Repomd record into cr_Repomd object.

Parameters

  repomd | cr_Repomd object
  record | cr_RepomdRecord object

## ◆ cr_repomd_set_repoid()

void cr_repomd_set_repoid | ( | cr_Repomd * | repomd,
|  | const char * | repoid,
|  | const char * | type
| ) |  |

Set a repoid - OBSOLETE, use cr_repomd_set_contenthash instead

Parameters

  repomd | cr_Repomd object
  repoid | RepoId
  type | Type of hash function used to calculate repoid

## ◆ cr_repomd_set_revision()

void cr_repomd_set_revision | ( | cr_Repomd * | repomd,
|  | const char * | revision
| ) |  |

Set custom revision string of repomd.

Parameters

  repomd | cr_Repomd object
  revision | revision string

## ◆ cr_repomd_sort_records()

void cr_repomd_sort_records | ( | cr_Repomd * | repomd | ) |

Records are stored in order they were added to the repomd. Because sometimes deterministic output is desirable this function exists.

Parameters

  repomd | cr_Repomd object

cr_repomd_add_content_tag
void cr_repomd_add_content_tag(cr_Repomd *repomd, const char *tag)
cr_RepomdRecord
Definition: repomd.h:74
cr_repomd_record_new
cr_RepomdRecord * cr_repomd_record_new(const char *type, const char *path)
cr_Repomd
Definition: repomd.h:103
cr_xml_dump_init
void cr_xml_dump_init()
cr_repomd_add_repo_tag
void cr_repomd_add_repo_tag(cr_Repomd *repomd, const char *tag)
cr_repomd_free
void cr_repomd_free(cr_Repomd *repomd)
cr_repomd_set_revision
void cr_repomd_set_revision(cr_Repomd *repomd, const char *revision)
CR_CHECKSUM_SHA256
@ CR_CHECKSUM_SHA256
Definition: checksum.h:51
cr_repomd_record_fill
int cr_repomd_record_fill(cr_RepomdRecord *record, cr_ChecksumType checksum_type, GError **err)
cr_xml_dump_repomd
char * cr_xml_dump_repomd(cr_Repomd *repomd, GError **err)
cr_repomd_record_rename_file
int cr_repomd_record_rename_file(cr_RepomdRecord *record, GError **err)
cr_repomd_add_distro_tag
void cr_repomd_add_distro_tag(cr_Repomd *repomd, const char *cpeid, const char *tag)
cr_repomd_new
cr_Repomd * cr_repomd_new()
cr_repomd_set_record
void cr_repomd_set_record(cr_Repomd *repomd, cr_RepomdRecord *record)
cr_xml_dump_cleanup
void cr_xml_dump_cleanup()