File: simple_modifyrepo.py

package info (click to toggle)
createrepo-c 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,632 kB
  • sloc: ansic: 31,242; python: 4,868; xml: 2,669; sh: 363; makefile: 26; perl: 7
file content (32 lines) | stat: -rwxr-xr-x 827 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python3
"""
An example of inserting updateinfo.xml into repodata.
"""
import os
import shutil

import createrepo_c as cr

REPO_PATH = "repo/"

def modifyrepo(filename, repodata):
    repodata = os.path.join(repodata, 'repodata')
    uinfo_xml = os.path.join(repodata, os.path.basename(filename))
    shutil.copyfile(filename, uinfo_xml)

    uinfo_rec = cr.RepomdRecord('updateinfo', uinfo_xml)
    uinfo_rec.fill(cr.SHA256)
    uinfo_rec.rename_file()

    repomd_xml = os.path.join(repodata, 'repomd.xml')
    repomd = cr.Repomd(repomd_xml)
    repomd.set_record(uinfo_rec)
    with open(repomd_xml, 'w') as repomd_file:
        repomd_file.write(repomd.xml_dump())


if __name__ == '__main__':
    # Generate the updateinfo.xml
    exec(open("./updateinfo_gen_02.py").read())

    modifyrepo(OUT_FILE, REPO_PATH)