Repomd API.

Data Structures

struct  cr_RepomdRecord
struct  cr_DistroTag
struct  cr_Repomd

Functions

cr_RepomdRecordcr_repomd_record_new (const char *type, const char *path)
void cr_repomd_record_free (cr_RepomdRecord *record)
cr_RepomdRecordcr_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, GError **err)
int cr_repomd_record_rename_file (cr_RepomdRecord *record, GError **err)
void cr_repomd_record_load_contentstat (cr_RepomdRecord *record, cr_ContentStat *stats)
cr_Repomdcr_repomd_new ()
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_RepomdRecordcr_repomd_get_record (cr_Repomd *repomd, const char *type)
void cr_repomd_detach_record (cr_Repomd *repomd, cr_RepomdRecord *rec)
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

void cr_repomd_add_content_tag ( cr_Repomd repomd,
const char *  tag 
)

Add content tag.

Parameters:
repomd cr_Repomd object
tag content 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
void cr_repomd_add_repo_tag ( cr_Repomd repomd,
const char *  tag 
)

Add repo tag.

Parameters:
repomd cr_Repomd object
tag repo tag
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
void cr_repomd_free ( cr_Repomd repomd  ) 

Frees cr_Repomd object and all its cr_RepomdRecord objects

Parameters:
repomd cr_Repomd object
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
Returns:
Pointer to a record of desired type or NULL
cr_Repomd* cr_repomd_new (  ) 

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

int cr_repomd_record_compress_and_fill ( cr_RepomdRecord record,
cr_RepomdRecord compressed_record,
cr_ChecksumType  checksum_type,
cr_CompressionType  compression,
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
err GError **
Returns:
cr_Error code
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
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
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
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_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
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
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
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
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
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
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

Generated on 22 Oct 2014 for createrepo_c library by  doxygen 1.6.1