### Example: Dumping RPM Metadata with createrepo_c Source: https://rpm-software-management.github.io/createrepo_c/c/group__xml__dump.html This example demonstrates how to initialize the library, parse an RPM file, dump its metadata into XML format, and then clean up resources. Ensure proper error handling and memory management. ```c cr_Package *pkg; struct cr_XmlStruct xml; cr_xml_dump_init(); cr_package_parser_init(); pkg = cr_package_from_rpm_base("path/to/rpm.rpm", 5, CR_HDRR_NONE, NULL); xml = cr_xml_dump(pkg, NULL); cr_package_free(pkg); printf("Primary XML chunk:\n%s\n", xml.primary); printf("Filelists XML chunk:\n%s\n", xml.filelists); printf("Other XML chunk:\n%s\n", xml.other); free(xml.primary); free(xml.filelists); free(xml.other); cr_package_parser_cleanup(); cr_xml_dump_cleanup(); ``` -------------------------------- ### Logging Setup Source: https://rpm-software-management.github.io/createrepo_c/c/group__createrepo__shared.html Function to configure the logging behavior of the library. ```APIDOC ## CR_SETUP_LOGGING ### Description Setup logging for the application. ### Method N/A (Function) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Parallelized Compression Example Source: https://rpm-software-management.github.io/createrepo_c/c/group__threads.html Demonstrates how to use cr_CompressionTask and GThreadPool for parallel compression. Ensure to free the pool and tasks after use. ```c cr_CompressionTask *task_1, *task_2; GThreadPool *pool; // Prepare tasks task_1 = cr_compressiontask_new("foo", "foo.gz", CR_CW_GZ_COMPRESSION, 1, CR_CHECKSUM_SHA256, NULL); task_2 = cr_compressiontask_new("bar", "bar.gz", CR_CW_GZ_COMPRESSION, 1, CR_CHECKSUM_SHA512, NULL); // Create pool for tasks pool = g_thread_pool_new(cr_compressing_thread, NULL, 2, FALSE, NULL); // Push tasks to the pool g_thread_pool_push(pool, task_1, NULL); g_thread_pool_push(pool, task_2, NULL); // Wait until both treats finish and free the pool. g_thread_pool_free(pool, FALSE, TRUE); // Use results // Do whatever you want or need to do // Clean up cr_compressiontask_free(task_1, NULL); cr_compressiontask_free(task_2, NULL); ``` -------------------------------- ### Logging Setup Function Source: https://rpm-software-management.github.io/createrepo_c/c/createrepo__shared_8h_source.html Configures the logging behavior of the library. Set `quiet` to true to suppress output, or `verbose` to enable more detailed logging. This function does not return an error. ```c void cr_setup_logging(gboolean quiet, gboolean verbose); ``` -------------------------------- ### createrepo_c Module - X Functions and Classes Source: https://rpm-software-management.github.io/createrepo_c/python/genindex.html Functions, classes, and attributes starting with 'X' in the createrepo_c module. ```APIDOC ## xml_dump() ### Description Dumps the XML representation of a repomd or update info object. ### Method (Implicitly a method of createrepo_c.Repomd, createrepo_c.UpdateInfo) ### Endpoint N/A (Internal method) ## xml_dump_filelists() ### Description Dumps the filelists XML. ### Method (Implicitly a function in module createrepo_c) ### Endpoint N/A (Internal function) ## xml_dump_other() ### Description Dumps the other XML. ### Method (Implicitly a function in module createrepo_c) ### Endpoint N/A (Internal function) ## xml_dump_primary() ### Description Dumps the primary XML. ### Method (Implicitly a function in module createrepo_c) ### Endpoint N/A (Internal function) ## xml_from_rpm() ### Description Generates XML from an RPM file. ### Method (Implicitly a function in module createrepo_c) ### Endpoint N/A (Internal function) ## xml_parse_filelists() ### Description Parses the filelists XML. ### Method (Implicitly a function in module createrepo_c) ### Endpoint N/A (Internal function) ## xml_parse_other() ### Description Parses the other XML. ### Method (Implicitly a function in module createrepo_c) ### Endpoint N/A (Internal function) ## xml_parse_primary() ### Description Parses the primary XML. ### Method (Implicitly a function in module createrepo_c) ### Endpoint N/A (Internal function) ## xml_parse_repomd() ### Description Parses the repomd XML. ### Method (Implicitly a function in module createrepo_c) ### Endpoint N/A (Internal function) ## xml_parse_updateinfo() ### Description Parses the updateinfo XML. ### Method (Implicitly a function in module createrepo_c) ### Endpoint N/A (Internal function) ## XML_WARNING_BADATTRVAL ### Description Constant representing a warning for a bad attribute value in XML. ### Type Constant in module createrepo_c ## XML_WARNING_MISSINGATTR ### Description Constant representing a warning for a missing attribute in XML. ### Type Constant in module createrepo_c ## XML_WARNING_UNKNOWNTAG ### Description Constant representing a warning for an unknown tag in XML. ### Type Constant in module createrepo_c ## XML_WARNING_UNKNOWNVAL ### Description Constant representing a warning for an unknown value in XML. ### Type Constant in module createrepo_c ## XmlFile ### Description Represents an XML file. ### Type Class in createrepo_c ## XMLFILE_FILELISTS ### Description Constant representing the filelists XML file type. ### Type Constant in module createrepo_c ## XMLFILE_OTHER ### Description Constant representing the other XML file type. ### Type Constant in module createrepo_c ## XMLFILE_PRESTODELTA ### Description Constant representing the presto delta XML file type. ### Type Constant in module createrepo_c ## XMLFILE_PRIMARY ### Description Constant representing the primary XML file type. ### Type Constant in module createrepo_c ## XMLFILE_UPDATEINFO ### Description Constant representing the updateinfo XML file type. ### Type Constant in module createrepo_c ## XZ ### Description Constant representing the XZ compression format. ### Type Constant in module createrepo_c ## XZ_COMPRESSION ### Description Constant representing XZ compression. ### Type Constant in module createrepo_c ``` -------------------------------- ### Initialize Package Parser Source: https://rpm-software-management.github.io/createrepo_c/c/parsepkg_8h_source.html Call this function to initialize the package parser before using other parsing functions. No specific setup is required beyond including the necessary headers. ```c void cr_package_parser_init(); ``` -------------------------------- ### cr_XmlParserNewPkgCb Source: https://rpm-software-management.github.io/createrepo_c/c/group__xml__parser.html Callback triggered when a new package object parsing starts. ```APIDOC ## typedef int(* cr_XmlParserNewPkgCb) ### Description Callback for XML parser which is called when a new package object parsing is started. This function sets the package object to be populated by the parser. ### Parameters - **pkg** (cr_Package **) - Required - Package that will be populated. - **pkgId** (const char *) - Required - pkgId (hash) of the new package or package type. - **name** (const char *) - Required - Name of the new package. - **arch** (const char *) - Required - Arch of the new package. - **cbdata** (void *) - Required - User data. - **err** (GError **) - Required - GError pointer. ### Response - **Return** (int) - CR_CB_RET_OK (0) or CR_CB_RET_ERR (1) to stop parsing. ``` -------------------------------- ### createrepo_c Module - W Functions Source: https://rpm-software-management.github.io/createrepo_c/python/genindex.html Functions starting with 'W' in the createrepo_c module. ```APIDOC ## write() ### Description Writes the content of a CrFile object. ### Method (Implicitly a method of createrepo_c.CrFile) ### Endpoint N/A (Internal method) ``` -------------------------------- ### createrepo_c Module - U Functions and Classes Source: https://rpm-software-management.github.io/createrepo_c/python/genindex.html Functions, classes, and attributes starting with 'U' in the createrepo_c module. ```APIDOC ## UNKNOWN_CHECKSUM ### Description Constant representing an unknown checksum type. ### Type Constant in module createrepo_c ## UNKNOWN_COMPRESSION ### Description Constant representing an unknown compression type. ### Type Constant in module createrepo_c ## UpdateCollection ### Description Represents a collection of updates. ### Type Class in createrepo_c ## UpdateCollectionPackage ### Description Represents a package within an update collection. ### Type Class in createrepo_c ## updated_date ### Description Represents the update date of an update record. ### Type Attribute of createrepo_c.UpdateRecord ## UpdateInfo ### Description Represents update information. ### Type Class in createrepo_c ## UpdateInfoXmlFile ### Description Represents an XML file containing update information. ### Type Class in createrepo_c ## UpdateRecord ### Description Represents a single update record. ### Type Class in createrepo_c ## UpdateReference ### Description Represents a reference to an update. ### Type Class in createrepo_c ## updates ### Description Represents the updates contained within an UpdateInfo object. ### Type Attribute of createrepo_c.UpdateInfo ## url ### Description Represents the URL of a package. ### Type Attribute of createrepo_c.Package ``` -------------------------------- ### Get Package NEVRA String Source: https://rpm-software-management.github.io/createrepo_c/c/package_8h_source.html Returns a formatted string representing the Name-Epoch-Version-Release-Architecture (NEVRA) of a package. The caller is responsible for freeing the returned string. ```c gchar *cr_package_nevra(cr_Package *package); ``` -------------------------------- ### Get Metadata Hash Table Source: https://rpm-software-management.github.io/createrepo_c/c/group__load__metadata.html Retrieves the hash table containing all loaded packages from a metadata object. The key of the hash table is the package's relative path. ```c GHashTable hashtable; hashtable = cr_metadata_hashtable(oldmetadata); ``` -------------------------------- ### Get Compression Suffix Source: https://rpm-software-management.github.io/createrepo_c/c/compression__wrapper_8h_source.html Returns the file suffix corresponding to a given compression type. For example, returns ".gz" for GZIP compression. ```c const char *cr_compression_suffix(cr_CompressionType comtype); ``` -------------------------------- ### Build from source Source: https://rpm-software-management.github.io/createrepo_c Standard sequence of commands to compile the project from the checkout directory. ```bash mkdir build cd build/ cmake .. make ``` -------------------------------- ### Build RPM dependencies Source: https://rpm-software-management.github.io/createrepo_c Commands to prepare the RPM environment before building createrepo_c. ```bash cd /home/tmlcoch/git/rpm CPPFLAGS='-I/usr/include/nss3/ -I/usr/include/nspr4/' ./autogen.sh --rpmconfigure --with-vendor=redhat --with-external-db --with-lua --with-selinux --with-cap --with-acl --enable-python make clean && make ``` -------------------------------- ### createrepo_c Library - Introduction Source: https://rpm-software-management.github.io/createrepo_c/c/group__package.html Provides an overview of the createrepo_c library and its capabilities. ```APIDOC ## createrepo_c Library ### Introduction The createrepo_c library is a C library designed for efficient manipulation of repository metadata. It supports various operations including metadata creation, modification, and parsing. ``` -------------------------------- ### createrepo_c Module - S Attributes Source: https://rpm-software-management.github.io/createrepo_c/python/genindex.html Attributes starting with 'S' in the createrepo_c module. ```APIDOC ## severity ### Description Represents the severity of an update record. ### Type Attribute of createrepo_c.UpdateRecord ## SHA ### Description Constant representing SHA checksum type. ### Type Constant in module createrepo_c ## SHA1 ### Description Constant representing SHA1 checksum type. ### Type Constant in module createrepo_c ## SHA224 ### Description Constant representing SHA224 checksum type. ### Type Constant in module createrepo_c ## SHA256 ### Description Constant representing SHA256 checksum type. ### Type Constant in module createrepo_c ## SHA384 ### Description Constant representing SHA384 checksum type. ### Type Constant in module createrepo_c ## SHA512 ### Description Constant representing SHA512 checksum type. ### Type Constant in module createrepo_c ## shortname ### Description Represents the short name of an update collection. ### Type Attribute of createrepo_c.UpdateCollection ## size ### Description Represents the size of a content stat or repomd record. ### Type Attribute of createrepo_c.ContentStat, createrepo_c.RepomdRecord ## size_archive ### Description Represents the size of a package in its archive format. ### Type Attribute of createrepo_c.Package ## size_installed ### Description Represents the installed size of a package. ### Type Attribute of createrepo_c.Package ## size_open ### Description Represents the open size of a repomd record. ### Type Attribute of createrepo_c.RepomdRecord ## size_package ### Description Represents the size of a package. ### Type Attribute of createrepo_c.Package ## solution ### Description Represents the solution associated with an update record. ### Type Attribute of createrepo_c.UpdateRecord ## sort_records() ### Description Sorts the records within a repomd object. ### Method (Implicitly a method of createrepo_c.Repomd) ### Endpoint N/A (Internal method) ## Sqlite ### Description Represents an SQLite database. ### Type Class in createrepo_c ## src ### Description Represents the source of an update collection package. ### Type Attribute of createrepo_c.UpdateCollectionPackage ## status ### Description Represents the status of an update record. ### Type Attribute of createrepo_c.UpdateRecord ## suggests ### Description Represents package suggestions. ### Type Attribute of createrepo_c.Package ## sum ### Description Represents the checksum of an update collection package. ### Type Attribute of createrepo_c.UpdateCollectionPackage ## sum_type ### Description Represents the type of checksum for an update collection package. ### Type Attribute of createrepo_c.UpdateCollectionPackage ## summary ### Description Represents the summary of a package or an update record. ### Type Attribute of createrepo_c.Package, createrepo_c.UpdateRecord ## supplements ### Description Represents package supplements. ### Type Attribute of createrepo_c.Package ``` -------------------------------- ### Introduction to createrepo_c Source: https://rpm-software-management.github.io/createrepo_c/c/index.html This snippet shows the basic usage of the createrepo_c library by including the main header file. ```APIDOC ## Introduction to createrepo_c ### Description This section provides the basic usage information for the createrepo_c library. ### Method Include Header ### Endpoint N/A ### Parameters N/A ### Request Example ```c #include ``` ### Response N/A ``` -------------------------------- ### createrepo_c Module - S Functions Source: https://rpm-software-management.github.io/createrepo_c/python/genindex.html Functions and methods starting with 'S' in the createrepo_c module. ```APIDOC ## set_contenthash() ### Description Sets the content hash for a repomd object. ### Method (Implicitly a method of createrepo_c.Repomd) ### Endpoint N/A (Internal method) ## set_num_of_pkgs() ### Description Sets the number of packages for a FilelistsXmlFile object. ### Method (Implicitly a method of createrepo_c.FilelistsXmlFile) ### Endpoint N/A (Internal method) ## set_record() ### Description Sets a record for a repomd object. ### Method (Implicitly a method of createrepo_c.Repomd) ### Endpoint N/A (Internal method) ## set_repoid() ### Description Sets the repository ID for a repomd object. ### Method (Implicitly a method of createrepo_c.Repomd) ### Endpoint N/A (Internal method) ## set_revision() ### Description Sets the revision for a repomd object. ### Method (Implicitly a method of createrepo_c.Repomd) ### Endpoint N/A (Internal method) ``` -------------------------------- ### Generate repomd.xml with createrepo_c Source: https://rpm-software-management.github.io/createrepo_c/c/group__repomd.html Demonstrates the workflow for initializing a repomd object, adding records, calculating metadata parameters, and dumping the final XML content. ```c 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(); ``` -------------------------------- ### Get Filename from Path Source: https://rpm-software-management.github.io/createrepo_c/c/misc_8h_source.html Extracts the filename component from a given file path. ```c char *cr_get_filename(const char *filepath); ``` -------------------------------- ### createrepo_c Module - T Functions and Attributes Source: https://rpm-software-management.github.io/createrepo_c/python/genindex.html Functions and attributes starting with 'T' in the createrepo_c module. ```APIDOC ## time_build ### Description Represents the build time of a package. ### Type Attribute of createrepo_c.Package ## time_file ### Description Represents the file modification time of a package. ### Type Attribute of createrepo_c.Package ## timestamp ### Description Represents the timestamp of a repomd record. ### Type Attribute of createrepo_c.RepomdRecord ## title ### Description Represents the title of an update record or update reference. ### Type Attribute of createrepo_c.UpdateRecord, createrepo_c.UpdateReference ## type ### Description Represents the type of a repomd record, update record, or update reference. ### Type Attribute of createrepo_c.RepomdRecord, createrepo_c.UpdateRecord, createrepo_c.UpdateReference ``` -------------------------------- ### Create Package File Function Source: https://rpm-software-management.github.io/createrepo_c/c/package_8h_source.html Allocates and initializes a new `cr_PackageFile` structure. Remember to free the returned pointer after use. ```c cr_PackageFile *cr_package_file_new(void); ``` -------------------------------- ### GET /locate_metadata Source: https://rpm-software-management.github.io/createrepo_c/c/group__locate__metadata.html Parses the repomd.xml file at the specified path and returns a cr_MetadataLocation structure. ```APIDOC ## cr_locate_metadata ### Description Parses repomd.xml and returns a filled cr_MetadataLocation structure. Remote repodata (repopath with prefix "ftp://" or "http://") are downloaded into a temporary directory and removed when the cr_metadatalocation_free() is called. ### Parameters #### Path Parameters - **repopath** (const char *) - Required - Path to directory with repodata/ subdirectory. - **ignore_sqlite** (gboolean) - Required - If != 0, sqlite databases are ignored. - **err** (GError **) - Required - Pointer to GError for error reporting. ### Response - **Returns** (struct cr_MetadataLocation *) - A filled cr_MetadataLocation structure or NULL on failure. ``` -------------------------------- ### createrepo_c Module - V Functions and Attributes Source: https://rpm-software-management.github.io/createrepo_c/python/genindex.html Functions and attributes starting with 'V' in the createrepo_c module. ```APIDOC ## version ### Description Represents the version of a package, update collection package, or update record. ### Type Attribute of createrepo_c.Package, createrepo_c.UpdateCollectionPackage, createrepo_c.UpdateRecord ## VERSION ### Description Constant representing the major version of the createrepo_c module. ### Type Constant in module createrepo_c ## VERSION_MAJOR ### Description Constant representing the major version component. ### Type Constant in module createrepo_c ## VERSION_MINOR ### Description Constant representing the minor version component. ### Type Constant in module createrepo_c ## VERSION_PATCH ### Description Constant representing the patch version component. ### Type Constant in module createrepo_c ``` -------------------------------- ### Compare Version Strings Source: https://rpm-software-management.github.io/createrepo_c/c/misc_8h_source.html Compares two version strings lexicographically. ```c int cr_cmp_version_str(const char* str1, const char *str2); ``` -------------------------------- ### Run unit tests Source: https://rpm-software-management.github.io/createrepo_c Execute the full suite of C and Python unit tests. ```bash make tests && make test ``` -------------------------------- ### Get boolean from GKeyFile with default Source: https://rpm-software-management.github.io/createrepo_c/c/misc_8h_source.html Retrieves a boolean value from a GKeyFile, returning a default value if an error occurs. ```c static inline gboolean cr_key_file_get_boolean_default(GKeyFile *key_file, const gchar *group_name, const gchar *key, gboolean default_value, GError **error) { GError *tmp_err = NULL; gboolean ret = g_key_file_get_boolean(key_file, group_name, key, &tmp_err); if (tmp_err) { g_propagate_error(error, tmp_err); return default_value; } return ret; } ``` -------------------------------- ### Build with delta rpm support Source: https://rpm-software-management.github.io/createrepo_c Steps to clone and integrate the drpm library for delta rpm functionality. ```bash git clone ssh://git.fedorahosted.org/git/drpm.git cd drpm/ make ``` ```bash cmake -DDRPM_PATH="/home/tmlcoch/git/drpm" .. && make ``` -------------------------------- ### Build RPM package Source: https://rpm-software-management.github.io/createrepo_c Create an RPM package using the project's spec file. ```bash utils/make_rpm.sh ``` -------------------------------- ### Get Compression Type from Name Source: https://rpm-software-management.github.io/createrepo_c/c/compression__wrapper_8h_source.html Determines the compression type based on a given string name (e.g., 'gz', 'bz2'). ```c cr_CompressionType cr_compression_type(const char *name); ``` -------------------------------- ### Create New RepomdRecord Source: https://rpm-software-management.github.io/createrepo_c/c/repomd_8h_source.html Allocates and initializes a new cr_RepomdRecord. Requires the type and path of the record to be provided. ```c cr_RepomdRecord *cr_repomd_record_new(const char *type, const char *path); ``` -------------------------------- ### createrepo_c Library - XML File Handling Source: https://rpm-software-management.github.io/createrepo_c/c/group__xml__file.html Functions and macros for opening, writing to, and closing XML files used in repository metadata. ```APIDOC ## Macros for XML File Operations ### Description Macros to simplify opening XML files for different types (primary, filelists, etc.) with specified compression types. ### Macros - `cr_xmlfile_open_primary(FILENAME, COMTYPE, ERR)` - `cr_xmlfile_sopen_primary(FILENAME, COMTYPE, STAT, ERR)` - `cr_xmlfile_open_filelists(FILENAME, COMTYPE, ERR)` - `cr_xmlfile_sopen_filelists(FILENAME, COMTYPE, STAT, ERR)` - `cr_xmlfile_open_other(FILENAME, COMTYPE, ERR)` - `cr_xmlfile_sopen_other(FILENAME, COMTYPE, STAT, ERR)` - `cr_xmlfile_open_prestodelta(FILENAME, COMTYPE, ERR)` - `cr_xmlfile_sopen_prestodelta(FILENAME, COMTYPE, STAT, ERR)` - `cr_xmlfile_open_updateinfo(FILENAME, COMTYPE, ERR)` - `cr_xmlfile_sopen_updateinfo(FILENAME, COMTYPE, STAT, ERR)` - `cr_xmlfile_open(FILENAME, TYPE, COMTYPE, ERR)` ## Enumerations for XML File Types ### Description Defines the types of XML files that can be handled by the library. ### Enum - `cr_XmlFileType`: - `CR_XMLFILE_PRIMARY` - `CR_XMLFILE_FILELISTS` - `CR_XMLFILE_OTHER` - `CR_XMLFILE_PRESTODELTA` - `CR_XMLFILE_UPDATEINFO` - `CR_XMLFILE_SENTINEL` ## Functions for XML File Handling ### Description Provides functions to manage the lifecycle and content of XML repository metadata files. ### Functions - `cr_XmlFile * cr_xmlfile_sopen (const char *filename, cr_XmlFileType type, cr_CompressionType comtype, cr_ContentStat *stat, GError **err)` - Opens an XML file for writing with specified type, compression, and statistics. - `int cr_xmlfile_set_num_of_pkgs (cr_XmlFile *f, long num, GError **err)` - Sets the number of packages expected in the XML file. - `int cr_xmlfile_add_pkg (cr_XmlFile *f, cr_Package *pkg, GError **err)` - Adds a package entry to the XML file. - `int cr_xmlfile_add_chunk (cr_XmlFile *f, const char *chunk, GError **err)` - Adds a raw chunk of data to the XML file. - `int cr_xmlfile_close (cr_XmlFile *f, GError **err)` - Closes the XML file, flushing any buffered data. ``` -------------------------------- ### Get Checksum Name String Source: https://rpm-software-management.github.io/createrepo_c/c/checksum_8h_source.html Converts a cr_ChecksumType enumeration value to its string representation. Useful for logging or display purposes. ```c const char *cr_checksum_name_str(cr_ChecksumType type); ``` -------------------------------- ### Get Header Byte Range Source: https://rpm-software-management.github.io/createrepo_c/c/misc_8h_source.html Retrieves the byte range for a file header. This function may set a GError if an issue occurs. ```c struct cr_HeaderRangeStruct cr_get_header_byte_range(const char *filename, GError **err); ``` -------------------------------- ### Build with custom RPM path Source: https://rpm-software-management.github.io/createrepo_c Configure the build to use a specific local RPM source directory. ```bash cmake -DRPM_PATH="/home/tmlcoch/git/rpm" .. && make ``` -------------------------------- ### Get Record from Repomd Source: https://rpm-software-management.github.io/createrepo_c/c/repomd_8h_source.html Retrieves a specific cr_RepomdRecord from the cr_Repomd structure based on its type. Returns NULL if no record of that type is found. ```c cr_RepomdRecord *cr_repomd_get_record(cr_Repomd *repomd, const char *type); ``` -------------------------------- ### Open Primary SQLite Database Source: https://rpm-software-management.github.io/createrepo_c/c/group__sqlite.html Opens or creates a primary SQLite database for repository metadata. Ensure the package is loaded before adding it. ```c cr_Package *pkg; cr_SqliteDb *primary_db; // Load pkg (See parsepkg or parsehdr module) // Create primary sqlite database primary_db = cr_db_open_primary("/foo/bar/repodata/primary.sqlite", NULL); // Add all packages here cr_db_add_pkg(primary_db, pkg, NULL); // Add checksum of XML version of file (primary in this case) cr_db_dbinfo_update(primary_db, "foochecksum", NULL); // Cleanup cr_db_close(primary_db, NULL); ``` -------------------------------- ### Get Metadata Key Type Source: https://rpm-software-management.github.io/createrepo_c/c/group__load__metadata.html Returns the type of key used for indexing packages within the metadata's hash table. ```c cr_HashTableKey cr_metadata_key (cr_Metadata *md); ``` -------------------------------- ### Get Checksum Type from Name Source: https://rpm-software-management.github.io/createrepo_c/c/checksum_8h_source.html Determines the cr_ChecksumType enumeration value from its string name. Useful for parsing configuration or user input. ```c cr_ChecksumType cr_checksum_type(const char *name); ``` -------------------------------- ### createrepo_c Library API Overview Source: https://rpm-software-management.github.io/createrepo_c/c/group__contants.html This section provides an overview of the different API modules available in the createrepo_c library. ```APIDOC ## createrepo_c Library API Modules ### Description This documentation outlines the various modules and functionalities provided by the createrepo_c library for metadata manipulation. ### Modules - **Complete API of createrepo_c library**: Provides access to all functions and structures within the library. - **Library version information**: Functions to retrieve the current version of the createrepo_c library. - **API for checksum calculation**: Utilities for generating and verifying checksums of files. - **Wrapper for compressed file**: Functions to handle compressed files, potentially for storage or transfer. - **Global constants and enums**: Definitions of constants and enumerations used throughout the library. - **Constants**: Specific constant values used in various operations. - **Createrepo API**: Core functionalities for creating and managing repository metadata. - **Support for deltarpms**: Functionality related to handling delta RPM packages. - **Implementation of concurrent dumping used in createrepo_c**: Utilities for efficient, concurrent data dumping. - **Helpers for createrepo_c, modifyrepo_c, mergerepo_c**: Helper functions that assist in repository creation, modification, and merging operations. - **Load metadata API**: Functions to load repository metadata from various sources. - **Locate metadata API**: Utilities for finding and accessing repository metadata files. - **Miscellaneous useful functions and macros**: A collection of general-purpose functions and macros. - **Modifyrepo API**: Functionalities for modifying existing repository metadata. - **Package representation**: Structures and functions for representing software packages. - **Header parser API**: Tools for parsing package header information. - **Package parser API**: Functions to parse package files and extract relevant data. - **Repomd API**: Functionality for working with the repomd.xml file, which describes repository contents. - **SQLite metadata API**: Utilities for interacting with repository metadata stored in SQLite databases. - **Useful thread function to use in GThreadPool**: Thread-safe functions suitable for use with GThreadPool. - **Updateinfo API**: Functionality for managing update information for packages. - **XML dump API**: Functions to generate XML representations of repository data. - **XML file API**: Utilities for creating and manipulating XML files. - **XML parser API**: Functions to parse XML files containing repository metadata. ``` -------------------------------- ### Package Parser Initialization and Cleanup Source: https://rpm-software-management.github.io/createrepo_c/c/group__parsepkg.html Functions to manage the global state of the package parser. ```APIDOC ## void cr_package_parser_init() ### Description Initialize global structures for package parsing. This function calls rpmReadConfigFiles() and creates a global transaction set. It should be called only once and is not thread-safe. ## void cr_package_parser_cleanup() ### Description Free global structures for package parsing. ``` -------------------------------- ### createrepo_c Library - Package Creation Functions Source: https://rpm-software-management.github.io/createrepo_c/c/group__package.html Functions for creating and managing package structures. ```APIDOC ## Functions ### `cr_Dependency* cr_dependency_new (void)` Create new (empty) dependency structure. Returns: new empty `cr_Dependency` ### `cr_PackageFile* cr_package_file_new (void)` Create new (empty) package file structure. Returns: new empty `cr_PackageFile` ### `cr_ChangelogEntry* cr_changelog_entry_new (void)` Create new (empty) changelog structure. Returns: new empty `cr_ChangelogEntry` ### `cr_BinaryData* cr_binary_data_new (void)` Create new (empty) structure for binary data. Returns: new empty `cr_BinaryData` ### `cr_Package* cr_package_new (void)` Create new (empty) package structure. Returns: new empty `cr_Package` ### `cr_Package* cr_package_new_without_chunk (void)` Create new (empty) package structure without initialized string chunk. Returns: new empty `cr_Package` ``` -------------------------------- ### Create New Repomd Structure Source: https://rpm-software-management.github.io/createrepo_c/c/repomd_8h_source.html Allocates and initializes a new cr_Repomd structure. This is the entry point for creating new repository metadata. ```c cr_Repomd *cr_repomd_new(); ``` -------------------------------- ### Get Package NVRA String Source: https://rpm-software-management.github.io/createrepo_c/c/package_8h_source.html Returns a formatted string representing the Name-Version-Release-Architecture (NVRA) of a package. The returned string is dynamically allocated and must be freed by the caller. ```c gchar *cr_package_nvra(cr_Package *package); ``` -------------------------------- ### Open Primary SQLite Database Macro Source: https://rpm-software-management.github.io/createrepo_c/c/group__sqlite.html Macro to open or create a primary SQLite database. It sets up the primary tables and database info. ```c #define cr_db_open_primary ( PATH, \ ERR ) cr_db_open(PATH, CR_DB_PRIMARY, ERR) ``` -------------------------------- ### Open File with Compression (Function) Source: https://rpm-software-management.github.io/createrepo_c/c/compression__wrapper_8h_source.html Opens a file with specified compression settings. Supports read or write modes and optional content statistics. ```c CR_FILE *cr_sopen(const char *filename, cr_OpenMode mode, cr_CompressionType comtype, cr_ContentStat *stat, GError **err); ``` -------------------------------- ### Build with debugging symbols Source: https://rpm-software-management.github.io/createrepo_c Compile the project with debug information enabled. ```bash cmake -DCMAKE_BUILD_TYPE:STRING=DEBUG .. && make ``` -------------------------------- ### Get Metadata Hash Table (Direct Access) Source: https://rpm-software-management.github.io/createrepo_c/c/group__load__metadata.html Provides direct access to the hash table used for storing metadata packages. The key type is determined by the `cr_HashTableKey` setting. ```c GHashTable * cr_metadata_hashtable (cr_Metadata *md); ``` -------------------------------- ### Package Creation Source: https://rpm-software-management.github.io/createrepo_c/python/lib.html Functions for creating Package objects and XML data from RPM files. ```APIDOC ## Package Creation Functions ### Functions #### package_from_rpm(filename, checksum_type=5, location_href=None, location_base=None, changelog_limit=10) - **filename** (str) - Required - Path to the RPM file - **checksum_type** (int) - Optional - Checksum type (default: 5) - **location_href** (str) - Optional - Href for the package location - **location_base** (str) - Optional - Base URL for the package location - **changelog_limit** (int) - Optional - Limit for changelog entries (default: 10) Returns a `Package` object from the RPM package. #### xml_from_rpm(filename, checksum_type=5, location_href=None, location_base=None, changelog_limit=10) - **filename** (str) - Required - Path to the RPM file - **checksum_type** (int) - Optional - Checksum type (default: 5) - **location_href** (str) - Optional - Href for the package location - **location_base** (str) - Optional - Base URL for the package location - **changelog_limit** (int) - Optional - Limit for changelog entries (default: 10) Returns XML data for the RPM package. ``` -------------------------------- ### createrepo_c Library Overview Source: https://rpm-software-management.github.io/createrepo_c/c/group__main.html The library provides modular APIs for various repository management tasks including metadata loading, XML manipulation, and package parsing. ```APIDOC ## createrepo_c Library Modules ### Description The createrepo_c library is a C-based toolkit for manipulating RPM repository metadata. It is organized into several functional modules. ### Modules - **Checksum API**: Functions for checksum calculation. - **Compressed File Wrapper**: Utilities for handling compressed files. - **Createrepo API**: Core repository creation functionality. - **Deltarpm Support**: API for handling deltarpms. - **Metadata API**: Tools for loading, locating, and modifying repository metadata. - **Package API**: Representation and parsing of RPM packages. - **Repomd API**: Handling of repomd.xml files. - **SQLite API**: Management of SQLite-based metadata. - **Updateinfo API**: Handling of updateinfo metadata. - **XML API**: Comprehensive suite for XML dumping, file handling, and parsing. ``` -------------------------------- ### Build for Python 3 Source: https://rpm-software-management.github.io/createrepo_c Configure the build system to target Python 3 instead of the default Python 2. ```bash cmake -DPYTHON_DESIRED=3 . ``` -------------------------------- ### Createrepo_c Library Constants Source: https://rpm-software-management.github.io/createrepo_c/python/lib.html Overview of available constants for checksums, compression, and database types used within the library. ```APIDOC ## Library Constants ### Description Provides definitions for various library configurations including checksum algorithms, compression types, and database identifiers. ### Constants - **Checksums**: MD5 (1), SHA (2), SHA1 (3), SHA224 (4), SHA256 (5), SHA384 (6), SHA512 (7) - **Compression**: NO_COMPRESSION (2), GZ_COMPRESSION (3), BZ2_COMPRESSION (4), XZ_COMPRESSION (5) - **Database Types**: DB_PRIMARY (0), DB_FILELISTS (1), DB_OTHER (2) ``` -------------------------------- ### Initialize XML Dumping Source: https://rpm-software-management.github.io/createrepo_c/c/xml__dump_8h_source.html Initializes the XML dumping functionality. Call this before using other XML dump functions. ```c void cr_xml_dump_init(); ``` -------------------------------- ### Set Number of Packages Source: https://rpm-software-management.github.io/createrepo_c/c/xml__file_8h_source.html Sets the expected number of packages for an XML file. This can be used for pre-allocation or validation. ```c int cr_xmlfile_set_num_of_pkgs(cr_XmlFile *f, long num, GError **err); ``` -------------------------------- ### Create Changelog Entry Function Source: https://rpm-software-management.github.io/createrepo_c/c/package_8h_source.html Allocates and initializes a new `cr_ChangelogEntry` structure. The caller is responsible for freeing the returned pointer. ```c cr_ChangelogEntry *cr_changelog_entry_new(void); ``` -------------------------------- ### Open XML File (Generic) Source: https://rpm-software-management.github.io/createrepo_c/c/xml__file_8h_source.html Generic macro to open an XML file for writing. It calls `cr_xmlfile_sopen` with a NULL `stat` pointer. ```c #define cr_xmlfile_open(FILENAME, TYPE, COMTYPE, ERR) \ cr_xmlfile_sopen(FILENAME, TYPE, COMTYPE, NULL, ERR) ``` -------------------------------- ### cr_sopen Source: https://rpm-software-management.github.io/createrepo_c/c/compression__wrapper_8h_source.html Opens a file with specified compression settings. ```APIDOC ## cr_sopen ### Description Opens a file for reading or writing with a specific compression type. ### Method Function Call ### Parameters - **filename** (const char *) - Required - Path to the file - **mode** (cr_OpenMode) - Required - Opening mode - **comtype** (cr_CompressionType) - Required - Compression type to use - **stat** (cr_ContentStat *) - Optional - Pointer to content statistics - **err** (GError **) - Optional - Pointer to GError for error reporting ### Response - **CR_FILE*** - Returns a pointer to the opened file structure ``` -------------------------------- ### Create New cr_UpdateInfo Source: https://rpm-software-management.github.io/createrepo_c/c/updateinfo_8h_source.html Allocates and initializes a new cr_UpdateInfo structure. Use this to create a new update information container. ```c cr_UpdateInfo * cr_updateinfo_new(void); ``` -------------------------------- ### File and Path Utilities Source: https://rpm-software-management.github.io/createrepo_c/c/group__misc.html Functions for handling file paths, checking file identity, and directory removal. ```APIDOC ## cr_get_header_byte_range ### Description Return header byte range. ### Parameters #### Path Parameters - **filename** (const char *) - Required - filename - **err** (GError **) - Required - GError ** ### Response - **Returns** (cr_HeaderRangeStruct) - header range (start = end = 0 on error) ## cr_identical_files ### Description Checks if two paths point to the same file. ### Parameters - **fn1** (const gchar *) - Required - First path - **fn2** (const gchar *) - Required - Second path - **identical** (gboolean *) - Required - Are the files same or not - **err** (GError **) - Required - GError ** ### Response - **Returns** (gboolean) - FALSE if an error was encountered, TRUE otherwise ## cr_normalize_dir_path ### Description Normalize path (Path with exactly one trailing '/'). ### Parameters - **path** (const char *) - Required - path ### Response - **Returns** (char*) - mallocated string with normalized path or NULL ## cr_remove_dir ### Description Recursively remove directory. ### Parameters - **path** (const char *) - Required - filepath - **err** (GError **) - Required - GError ** ### Response - **Returns** (int) - cr_Error return code ``` -------------------------------- ### Logging and System Utilities Source: https://rpm-software-management.github.io/createrepo_c/c/group__misc.html Logging functions and system process status checks. ```APIDOC ## cr_log_fn ### Description Createrepo_c library standard logging function. ### Parameters - **log_domain** (const gchar *) - Required - logging domain - **log_level** (GLogLevelFlags) - Required - logging level - **message** (const gchar *) - Required - message - **user_data** (gpointer) - Required - user data ## cr_null_log_fn ### Description Logging function with no output. ### Parameters - **log_domain** (const gchar *) - Required - logging domain - **log_level** (GLogLevelFlags) - Required - logging level - **message** (const gchar *) - Required - message - **user_data** (gpointer) - Required - user data ## cr_spawn_check_exit_status ### Description Reimplementation of g_spawn_check_exit_status() for glib compatibility. ### Parameters - **exit_status** (gint) - Required - An exit code as returned from g_spawn_sync() - **error** (GError **) - Required - GError ** ### Response - **Returns** (gboolean) - TRUE if child exited successfully, FALSE otherwise ``` -------------------------------- ### createrepo_c Library Header Files Source: https://rpm-software-management.github.io/createrepo_c/c/dir_68267d1309a1af8e8297ef4c3efbcdba.html A list of the primary header files available in the createrepo_c library for metadata manipulation and repository management. ```APIDOC ## createrepo_c Library Headers ### Description The createrepo_c library provides a set of C headers for handling RPM repository metadata, including checksums, compression, package parsing, and XML manipulation. ### Available Files - **checksum.h**: Checksum calculation utilities. - **compression_wrapper.h**: Wrappers for repository compression tasks. - **createrepo_c.h**: Main library entry point. - **load_metadata.h**: Functions for loading repository metadata. - **package.h**: Structures and functions for RPM package handling. - **parsepkg.h**: Utilities for parsing RPM packages. - **repomd.h**: Handling of repomd.xml files. - **sqlite.h**: SQLite database interaction for metadata. - **xml_parser.h**: XML parsing utilities for repository metadata. ``` -------------------------------- ### cr_open Source: https://rpm-software-management.github.io/createrepo_c/c/group__compression__wrapper.html Opens or creates a file with a specified compression type. ```APIDOC ## cr_open ### Description Opens or creates the specified file using the provided compression type and mode. ### Parameters #### Arguments - **FILENAME** (const char *) - Required - The path to the file. - **MODE** (cr_OpenMode) - Required - The mode to open the file (Read/Write). - **COMTYPE** (cr_CompressionType) - Required - The type of compression to use. - **ERR** (GError **) - Required - Pointer to a GError structure for error reporting. ### Response - **Returns** (CR_FILE *) - A pointer to a CR_FILE structure or NULL on failure. ``` -------------------------------- ### Open New XML File with Stats Source: https://rpm-software-management.github.io/createrepo_c/c/group__xml__file.html Use this macro to open a new XML file with statistics. The opened file must not exist. This function cannot open an existing file. ```c #define cr_xmlfile_open | ( | | FILENAME, ---|---|---|--- | | | TYPE, | | | COMTYPE, | | | ERR | ) | | cr_xmlfile_sopen(FILENAME, TYPE, COMTYPE, NULL, ERR) ``` -------------------------------- ### createrepo_c Library - Enumerations Source: https://rpm-software-management.github.io/createrepo_c/c/group__package.html Documentation for enumerations used in the createrepo_c library. ```APIDOC ## Enumerations ### `enum cr_PackageLoadingFlags` Flags to control how package metadata is loaded. #### Enumerator Details - **CR_PACKAGE_FROM_HEADER**: Metadata parsed from header. - **CR_PACKAGE_FROM_XML**: Metadata parsed from XML. - **CR_PACKAGE_LOADED_PRI**: Primary metadata was loaded. - **CR_PACKAGE_LOADED_FIL**: Filelists metadata was loaded. - **CR_PACKAGE_LOADED_OTH**: Other metadata was loaded. - **CR_PACKAGE_SINGLE_CHUNK**: Package uses a single chunk. ``` -------------------------------- ### createrepo_c RepomdRecord Methods Source: https://rpm-software-management.github.io/createrepo_c/python/genindex.html Methods for the RepomdRecord class in createrepo_c. ```APIDOC ## RepomdRecord Methods ### Description Methods for interacting with individual records within a repomd file. ### Methods - **fill()** (createrepo_c.RepomdRecord method) - **rename_file()** (createrepo_c.RepomdRecord method) - **load_contentstat()** (createrepo_c.RepomdRecord method) ``` -------------------------------- ### Create Compression Task Source: https://rpm-software-management.github.io/createrepo_c/c/group__threads.html Prepares a new cr_CompressionTask for file compression. The destination filename can be NULL, in which case it's derived from the source. Checksum type can be CR_CHECKSUM_UNKNOWN if stats are not needed. ```c cr_CompressionTask* cr_compressiontask_new (const char *src, const char *dst, cr_CompressionType compression_type, cr_ChecksumType checksum_type, int delsrc, GError **err) ``` -------------------------------- ### Standard Logging Function Source: https://rpm-software-management.github.io/createrepo_c/c/misc_8h_source.html A standard logging function for the createrepo_c library. ```c void cr_log_fn(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data); ``` -------------------------------- ### Open Filelists SQLite Database Macro Source: https://rpm-software-management.github.io/createrepo_c/c/group__sqlite.html Macro to open or create a filelists SQLite database. It handles the creation of necessary tables and database parameters. ```c #define cr_db_open_filelists ( PATH, \ ERR ) cr_db_open(PATH, CR_DB_FILELISTS, ERR) ``` -------------------------------- ### Compare EVR strings Source: https://rpm-software-management.github.io/createrepo_c/c/misc_8h_source.html Compares two sets of epoch, version, and release strings. ```c #define cr_cmp_nevra(A, B) (cr_cmp_evr((A)->epoch, (A)->version, (A)->release,\ (B)->epoch, (B)->version, (B)->release)) ``` ```c int cr_cmp_evr(const char *e1, const char *v1, const char *r1, const char *e2, const char *v2, const char *r2); ``` -------------------------------- ### Run C unit tests Source: https://rpm-software-management.github.io/createrepo_c Execute only the C-based unit tests. ```bash build/tests/run_gtester.sh ```