createrepo_c library  0.9.1
C library for metadata manipulation
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 ()
 
cr_Repomdcr_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_RepomdRecordcr_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;
// Set some repomd stuff
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, ...)
// Rename source file - insert checksum into the filename
// Append the record into the repomd
// Get repomd.xml content
xml = cr_xml_dump_repomd(md, NULL);
// Cleanup

Function Documentation

void cr_repomd_add_content_tag ( cr_Repomd repomd,
const char *  tag 
)

Add content tag.

Parameters
repomdcr_Repomd object
tagcontent tag
void cr_repomd_add_distro_tag ( cr_Repomd repomd,
const char *  cpeid,
const char *  tag 
)

Add distro tag.

Parameters
repomdcr_Repomd object
cpeidcpeid string (could be NULL)
tagdistro tag string
void cr_repomd_add_repo_tag ( cr_Repomd repomd,
const char *  tag 
)

Add repo tag.

Parameters
repomdcr_Repomd object
tagrepo tag
cr_Repomd* cr_repomd_copy ( cr_Repomd repomd)

Create copy of cr_Repomd

Parameters
repomdcr_Repomd object
Returns
Copy of the input cr_Repomd object
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
repomdcr_Repomd object
recRecord to be removed
void cr_repomd_free ( cr_Repomd repomd)

Frees cr_Repomd object and all its cr_RepomdRecord objects

Parameters
repomdcr_Repomd object
cr_RepomdRecord* cr_repomd_get_record ( cr_Repomd repomd,
const char *  type 
)

Get repomd record from the repomd object.

Parameters
repomdcr_Repomd object
typeType of the record ("primary", "primary_db", ..)
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
recordcr_RepomdRecord initialized to an existing uncompressed file
compressed_recordempty cr_RepomdRecord object that will by filled
checksum_typetype of checksums
compressiontype of compression
errGError **
Returns
cr_Error code
cr_RepomdRecord* cr_repomd_record_copy ( const cr_RepomdRecord orig)

Copy cr_RepomdRecord object.

Parameters
origcr_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
recordcr_RepomdRecord object
checksum_typetype of checksum to use
errGError **
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
recordcr_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
recordcr_RepomdRecord
statscr_ContentStat
cr_RepomdRecord* cr_repomd_record_new ( const char *  type,
const char *  path 
)

Creates (alloc) new cr_RepomdRecord object

Parameters
typeType of record ("primary", "filelists", ..)
pathpath to the compressed file
int cr_repomd_record_rename_file ( cr_RepomdRecord record,
GError **  err 
)

Add a hash as prefix to the filename.

Parameters
recordcr_RepomdRecord of file to be renamed
errGError **
Returns
cr_Error code
void cr_repomd_remove_record ( cr_Repomd repomd,
const char *  type 
)

Remove first record of the specified type

Parameters
repomdcr_Repomd object
typeType of the record ("primary", "primary_db", ..)
void cr_repomd_set_contenthash ( cr_Repomd repomd,
const char *  hash,
const char *  type 
)

Set a contenthash

Parameters
repomdcr_Repomd object
hashcontent hash
typeType of hash function
void cr_repomd_set_record ( cr_Repomd repomd,
cr_RepomdRecord record 
)

Set cr_Repomd record into cr_Repomd object.

Parameters
repomdcr_Repomd object
recordcr_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
repomdcr_Repomd object
repoidRepoId
typeType 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
repomdcr_Repomd object
revisionrevision 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
repomdcr_Repomd object