tarantool / mkrepo

Maintain DEB and RPM repositories on S3
69 stars 24 forks source link

Add apt-rpm (altlinux-specific) repositories support #93

Open enp opened 2 months ago

enp commented 2 months ago

Hi,

Are you have a plans for apt-rpm (altlinux-specific) repositories support?

See https://www.altlinux.org/Ownrepo for reference how to create apt-rpm repositories in altlinux environment

Technically, apt-rpm index is just one file pkglist which is really simple to read via rpm-python binding:

import rpm

with open('pkglist.classic') as f:
    hdrs = rpm.readHeaderListFromFD(f.fileno())
    for hdr in hdrs:
        for tag in hdr.keys():
            print(f'{tag} => {hdr[tag]}')
    del hdrs

I suppose function writeHeaderListToFD should write similar data to index file back - I see mention of this function in https://fossies.org/linux/misc/old/rpm-5.2.1.tar.gz/rpm-5.2.1/CHANGES but no implementation in /usr/lib64/python3/site-packages/rpm/__init__.py

So, see C implementation of reading/writing pkglist file:

Is it possible to implement something like above in mkrepo with own rpm implementation?

enp commented 1 week ago

Example of how to create apt-rpm index via rpm-python binding:

with open('repo/RPMS.classic/one-0.1-793.x86_64.rpm') as f:
    hdrRpm = rpm.ts().hdrFromFdno(f.fileno())
    hdrNew = rpm.hdr()
    for tag in [100,1000,1001,1002,1004,1005,1006,1009,1016,1022,1044,1047,1048,1049,1050,1112,1113]:
        hdrNew[tag] = hdrRpm[tag]
    hdrNew[1000000] = 'one-0.1-793.x86_64.rpm'
    hdrNew[1000001] = 6413637
    hdrNew[1000010] = 'RPMS.classic'
    with open('repo/base/pkglist.classic', 'w+') as f:
        hdrNew.write(f.fileno())