The Createrepo_c Library

Createrepo_c includes several classes.

createrepo_c.VERSION_MAJOR = 0

Major version

createrepo_c.VERSION_MINOR = 9

Minor version

createrepo_c.VERSION_PATCH = 1

Patch version

createrepo_c.VERSION = u'0.9.1'

Version string

createrepo_c.UNKNOWN_CHECKSUM = 0

Checksum unknown

createrepo_c.CHECKSUM_UNKNOWN = 0

Checksum unknown

createrepo_c.MD5 = 1

MD5 checksum

createrepo_c.SHA = 2

SHA1 checksum alias

createrepo_c.SHA1 = 3

SHA1 checksum

createrepo_c.SHA224 = 4

SHA224 checksum

createrepo_c.SHA256 = 5

SHA256 checksum

createrepo_c.SHA384 = 6

SHA384 checksum

createrepo_c.SHA512 = 7

SHA512 checksum

createrepo_c.MODE_READ = 0

Read open mode

createrepo_c.MODE_WRITE = 1

Write open mode

createrepo_c.AUTO_DETECT_COMPRESSION = 0

Use compression autodetection

createrepo_c.UNKNOWN_COMPRESSION = 1

Unknown compression

createrepo_c.NO_COMPRESSION = 2

No compression

createrepo_c.GZ_COMPRESSION = 3

Gzip compression

createrepo_c.BZ2_COMPRESSION = 4

Bzip2 compression

createrepo_c.XZ_COMPRESSION = 5

XZ compression

createrepo_c.GZ = 3

Gzip compression alias

createrepo_c.BZ2 = 4

Bzip2 compression alias

createrepo_c.XZ = 5

XZ compression alias

createrepo_c.HT_KEY_DEFAULT = 0

Default key (hash)

createrepo_c.HT_KEY_HASH = 0

Package hash as a key

createrepo_c.HT_KEY_NAME = 1

Package name as a key

createrepo_c.HT_KEY_FILENAME = 2

Package filename as a key

createrepo_c.HT_DUPACT_KEEPFIRST = 0

If an key is duplicated, keep only the first occurrence

createrepo_c.HT_DUPACT_REMOVEALL = 1

If an key is duplicated, discard all occurrences

createrepo_c.DB_PRIMARY = 0

Primary database

createrepo_c.DB_FILELISTS = 1

Filelists database

createrepo_c.DB_OTHER = 2

Other database

createrepo_c.XMLFILE_PRIMARY = 0

Primary xml file

createrepo_c.XMLFILE_FILELISTS = 1

Filelists xml file

createrepo_c.XMLFILE_OTHER = 2

Other xml file

createrepo_c.XMLFILE_PRESTODELTA = 3

Prestodelta xml file

createrepo_c.XMLFILE_UPDATEINFO = 4

Updateinfo xml file

createrepo_c.XML_WARNING_UNKNOWNTAG = 0

XML warning - Unknown tag

createrepo_c.XML_WARNING_MISSINGATTR = 1

XML warning - Missing attribute

createrepo_c.XML_WARNING_UNKNOWNVAL = 2

XML warning - Unknown value

createrepo_c.XML_WARNING_BADATTRVAL = 3

XML warning - Bad attribute value

createrepo_c.PCOR_ENTRY_NAME = 0

PCOR entry tuple index - name

createrepo_c.PCOR_ENTRY_FLAGS = 1

PCOR entry tuple index - flags

createrepo_c.PCOR_ENTRY_EPOCH = 2

PCOR entry tuple index - epoch

createrepo_c.PCOR_ENTRY_VERSION = 3

PCOR entry tuple index - version

createrepo_c.PCOR_ENTRY_RELEASE = 4

PCOR entry tuple index - release

createrepo_c.PCOR_ENTRY_PRE = 5

PCOR entry tuple index - pre

createrepo_c.FILE_ENTRY_TYPE = 0

File entry tuple index - file type

createrepo_c.FILE_ENTRY_PATH = 1

File entry tuple index - path

createrepo_c.FILE_ENTRY_NAME = 2

File entry tuple index - file name

createrepo_c.CHANGELOG_ENTRY_AUTHOR = 0

Changelog entry tuple index - Author

createrepo_c.CHANGELOG_ENTRY_DATE = 1

Changelog entry tuple index - Date

createrepo_c.CHANGELOG_ENTRY_CHANGELOG = 2

Changelog entry tuple index - Changelog

exception createrepo_c.CreaterepoCError

Createrepo_c library exception

args
message
class createrepo_c.ContentStat

ContentStat object representing statistical information about content

__init__(checksum_type)
Parameters:checksum_type – Type of checksum that should be used
checksum

Calculated checksum

checksum_type

Type of used checksum

size

Number of uncompressed bytes written

class createrepo_c.CrFile(filename, mode=0, comtype=2, stat=None)
__init__(filename, mode=0, comtype=2, stat=None)
Parameters:
  • filename – Filename
  • mode – MODE_READ or MODE_WRITE
  • comtype – Compression type (GZ, BZ, XZ or NO_COMPRESSION)
  • stat – ContentStat object or None
close() → None

Close the file

write() → None

Write a data to the file

class createrepo_c.Metadata
__init__(key=HT_KEY_DEFAULT, use_single_chunk=False, pkglist=[])
Parameters:
  • key – Which value shoud be used as a key. One of HT_KEY_* constants.
  • use_single_chunk – Specify if all package strings should be stored in metadata object instead of package iself. This save some space if you need to have a all packages loaded into a memory.
  • pkglist – Package list that specify which packages shloud be loaded. Use its base filename (e.g. “GConf2-3.2.6-6.fc19.i686.rpm”).
dupaction()
dupaction(dupaction)
Parameters:dupation – What to do when we encounter already existing key. use constants prefixed with HT_DUPACT_. I.e. HT_DUPACT_KEEPFIRST, HT_DUPACT_REMOVEALL.
get(key) → Package

Get Package which has a key key

has_key(key) → bool

Test if metadata contains the key

key

Type of used key

keys() → list

List of all keys

len() → long

Number of packages

load_xml(metadata_location_object) → None

Load XML specified by MetadataLocation Object

locate_and_load_xml(path) → NoneLoad XML specified by path
remove(key) → bool

Remove package which has a key key from the metadata

class createrepo_c.MetadataLocation

Class representing location of metadata

__init__(path, ignore_db)
Parameters:
  • path – String with url/path to the repository
  • ignore_db – Boolean. If False then in case of remote repository databases will not be downloaded)
class createrepo_c.Package

Package object

__init__()

Default constructor

arch

Architecture for which the package was built

changelogs

Changelogs that package contains

checksum_type

Type of checksum

conflicts

Capabilities the package conflicts with

copy() → Package

Copy of the package object

description

In-depth description of the packaged software

enhances

Capabilities the package enhances

epoch

Epoch

files

Files that package contains

location_base

Base location of this package

location_href

Relative location of package to the repodata

name

Name of the package

nevra() → str

Package NEVRA string (Name-Epoch-Version-Release-Architecture)

nvra() → str

Package NVRA string (Name-Version-Release-Architecture)

obsoletes

Capabilities the package obsoletes

pkgId

Checksum of the package file

provides

Capabilities the package provides

recommends

Capabilities the package recommends

release

Release number of the package

requires

Capabilities the package requires

rpm_buildhost

Hostname of the system that built the package

rpm_group

RPM group (See: http://fedoraproject.org/wiki/RPMGroups)

rpm_header_end

Last byte of the header

rpm_header_start

First byte of the header

rpm_license

License term applicable to the package software (GPLv2, etc.)

rpm_packager

Person or persons responsible for creating the package

rpm_sourcerpm

Name of the source package from which this binary package was built

rpm_vendor

Name of the organization producing the package

size_archive

Size, in bytes, of the archive portion of the original package file

size_installed

Total size, in bytes, of every file installed by this package

size_package

Size, in bytes, of the package

suggests

Capabilities the package suggests

summary

Short description of the packaged software

supplements

Capabilities the package supplements

time_build

Time when package was builded

time_file

mtime of the package file

url

URL with more information about packaged software

version

Version of the packaged software

class createrepo_c.Repomd(path=None)
__init__(path=None)
Parameters:path – Path to existing repomd.xml or None
add_content_tag(tag) → None

Add content tag

add_distro_tag(tag[, cpeid=None]) → None

Add distro tag

add_repo_tag(tag) → None

Add repo tag

content_tags

List of content tags

contenthash

Contenthash value

contenthash_type

contenthash type value

distro_tags

List of distro tags

records

List of RepomdRecords

repo_tags

List of repo tags

repoid

Repoid value

repoid_type

Repoid type value

revision

Revision value

set_contenthash(contenthash, contenthash_type) → None

Set contenthash value and contenthash_type

set_record(repomdrecord) → None

Add RepomdRecord

set_repoid(repoid, repoid_type) → None

Set repoid value and repoid_type

set_revision(revision) → None

Set revision string

sort_records() → str

Sort repomd records to the createrepo_c prefered order

xml_dump() → str

Generate xml representation of the repomd

class createrepo_c.RepomdRecord(type=None, path=None)
__init__(type=None, path=None)
Parameters:
  • type – String with type of the file (e.g. other, other_db etc.)
  • path – Path to the file
compress_and_fill(hashtype, compresstype)
checksum

Checksum of the file

checksum_open

Checksum of the archive content

checksum_open_type

Type of the archive content checksum

checksum_type

Type of the file checksum

copy() → RepomdRecord

Return copy of the RepomdRecord object

db_ver

Database version (used only for sqlite databases like primary.sqlite etc.)

fill() → None

Fill unfilled items in the RepomdRecord (sizes and checksums)

load_contentstat(contentstat) → None

Load some content statistics from the ContentStat object. The statistics loaded from ContentStat doesn’t have to be calculated during a fill() method call and thus speed up the method.

location_base

Base location of the file

location_href

Relative location of the file in a repository

location_real

Currentlocation of the file in the system

rename_file() → None

Add (prepend) file checksum to the filename

size

Size of the file

size_open

Size of the archive content

timestamp

Mtime of the file

type

Record type

class createrepo_c.Sqlite

Sqlite object

__init__(path, db_type)
Parameters:
  • path – Path to the database
  • db_type – One from DB_PRIMARY, DB_FILELISTS, DB_OTHER constans
add_pkg(Package) → None

Add Package to the database

close() → None

Close the sqlite database

dbinfo_update(checksum) → None

Set checksum of the xml file representing same data

class createrepo_c.PrimarySqlite(path)
__init__(path)
Parameters:path – path to the primary.sqlite database
add_pkg(Package) → None

Add Package to the database

close() → None

Close the sqlite database

dbinfo_update(checksum) → None

Set checksum of the xml file representing same data

class createrepo_c.FilelistsSqlite(path)
__init__(path)
Parameters:path – Path to the filelists.sqlite database
add_pkg(Package) → None

Add Package to the database

close() → None

Close the sqlite database

dbinfo_update(checksum) → None

Set checksum of the xml file representing same data

class createrepo_c.OtherSqlite(path)
__init__(path)
Parameters:path – Path to the other.sqlite database
add_pkg(Package) → None

Add Package to the database

close() → None

Close the sqlite database

dbinfo_update(checksum) → None

Set checksum of the xml file representing same data

class createrepo_c.UpdateCollection
__init__()
append(updatecollectionpackage) → None

Add UpdateCollectionPackage

copy() → UpdateCollection

Return copy of the UpdateCollection object

name

Name of the collection

packages

List of packages

shortname

Short name

class createrepo_c.UpdateCollectionPackage
__init__()
arch

Architecture

copy() → UpdateCollectionPackage

Return copy of the UpdateCollectionPackage object

epoch

Epoch

filename

Filename

name

Name

reboot_suggested

Size of the file

release

Release

src

Source filename

sum

Checksum

sum_type

Type of checksum

version

Version

class createrepo_c.UpdateInfo(path=None)
__init__(path=None)
Parameters:path – Path to existing updateinfo.xml or None
append(updaterecord) → None

Append UpdateRecord

updates

List of UpdateRecords

xml_dump() → str

Generate xml representation of the updateinfo

class createrepo_c.UpdateRecord
__init__()
append_collection(collection) → None

Append UpdateCollection

append_reference(reference) → None

Append UpdateReference

collections

List of UpdateCollections

copy() → UpdateRecord

Return copy of the UpdateRecord object

description

Description

fromstr

Who issued this update

id

Update id

issued_date

Date when the update was issued

pushcount

Pushcount

references

List of UpdateReferences

release

Update release

rights

Copyrights

severity

Severity

solution

Solution

status

Status of the update

summary

Short summary

title

Update title

type

Update type

updated_date

Date when the update was updated

version

Version of update

class createrepo_c.UpdateReference
__init__()
copy() → UpdateReference

Return copy of the UpdateReference object

href

Reference URL

id

ID

title

Title

type

Type

class createrepo_c.XmlFile

XmlFile object represents a single XML file (primary, filelists or other).

__init__(path, type, compression_type, contentstat)
Parameters:
  • path – Path to the xml file
  • type – Type of the XML file. One from XMLFILE_PRIMARY, XMLFILE_FILELISTS, XMLFILE_OTHER constants
  • compression_type – Compression type specified by constant
  • contentstat – ContentStat object to gather content statistics or None
add_chunk(chunk) → None

Add a string chunk to the xml

add_pkg(Package) → None

Add Package to the xml

close() → None

Close the XML file

set_num_of_pkgs(number_of_packages) → None

Set number of all packages

class createrepo_c.PrimaryXmlFile(path, compressiontype=3, contentstat=None)
__init__(path, compressiontype=3, contentstat=None)
Parameters:
  • path – Path to the primary xml file
  • compressiontype – Compression type
  • contentstat – ContentStat object
add_chunk(chunk) → None

Add a string chunk to the xml

add_pkg(Package) → None

Add Package to the xml

close() → None

Close the XML file

set_num_of_pkgs(number_of_packages) → None

Set number of all packages

class createrepo_c.FilelistsXmlFile(path, compressiontype=3, contentstat=None)
__init__(path, compressiontype=3, contentstat=None)
Parameters:
  • path – Path to the filelists xml file
  • compressiontype – Compression type
  • contentstat – ContentStat object
add_chunk(chunk) → None

Add a string chunk to the xml

add_pkg(Package) → None

Add Package to the xml

close() → None

Close the XML file

set_num_of_pkgs(number_of_packages) → None

Set number of all packages

class createrepo_c.OtherXmlFile(path, compressiontype=3, contentstat=None)
__init__(path, compressiontype=3, contentstat=None)
Parameters:
  • path – Path to the other xml file
  • compressiontype – Compression type
  • contentstat – ContentStat object
add_chunk(chunk) → None

Add a string chunk to the xml

add_pkg(Package) → None

Add Package to the xml

close() → None

Close the XML file

set_num_of_pkgs(number_of_packages) → None

Set number of all packages

class createrepo_c.UpdateInfoXmlFile(path, compressiontype=3, contentstat=None)
__init__(path, compressiontype=3, contentstat=None)
Parameters:
  • path – Path to the updateinfo xml file
  • compressiontype – Compression type
  • contentstat – ContentStat object
add_chunk(chunk) → None

Add a string chunk to the xml

add_pkg(Package) → None

Add Package to the xml

close() → None

Close the XML file

set_num_of_pkgs(number_of_packages) → None

Set number of all packages

createrepo_c.package_from_rpm(filename, checksum_type=5, location_href=None, location_base=None, changelog_limit=10)

Package object from the rpm package

createrepo_c.xml_from_rpm(filename, checksum_type=5, location_href=None, location_base=None, changelog_limit=10)

XML for the rpm package

createrepo_c.xml_parse_primary(path, newpkgcb=None, pkgcb=None, warningcb=None, do_files=1)

Parse primary.xml

createrepo_c.xml_parse_filelists(path, newpkgcb=None, pkgcb=None, warningcb=None)

Parse filelists.xml

createrepo_c.xml_parse_other(path, newpkgcb=None, pkgcb=None, warningcb=None)

Parse other.xml

createrepo_c.xml_parse_updateinfo(path, updateinfoobj, warningcb=None)

Parse updateinfo.xml

createrepo_c.xml_parse_repomd(path, repomdobj, warningcb=None)

Parse repomd.xml

createrepo_c.compress_file(src, dst, comtype, stat=None)
createrepo_c.decompress_file(src, dst, comtype, stat=None)
createrepo_c.xml_dump_primary(pkg) → str

Generate primary xml chunk from the package

createrepo_c.xml_dump_filelists(pkg) → str

Generate filelists xml chunk from the package

createrepo_c.xml_dump_other(pkg) → str

Generate other xml chunk from the package

createrepo_c.xml_dump(pkg) -> (str, str, str)

Generate primary, filelists and other xml chunks from the package

createrepo_c.checksum_name_str(checksum_type) → str

Checksum name from checksum type constant

createrepo_c.checksum_type(checksum_name) → long

Checksum type from checksum name

createrepo_c.compress_file_with_stat(source, destination, compression_type, contentstat_object) → None

Compress file. destination and contentstat_object could be None

createrepo_c.compression_suffix(compression_type) → str or None

Compression suffix for the compression type

createrepo_c.detect_compression(path) → long

Detect compression type used on the file

Previous topic

createrepo_c

This Page