aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo/simplerpm.py
blob: 3d50176d0528abe5eab079b51ac882be5fd10f5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/python3
from MgaRepo.util import execcmd

class SRPM:
    def __init__(self, filename):
        self.filename = filename
        self._getinfo()

    def _getinfo(self):
        args = ["rpm", "-qp", "--qf", "%{name} %{epoch} %{release} %{version}",
                self.filename]
        status, output = execcmd(args)
        self.name, self.epoch, self.release, self.version = output.split()
        if self.epoch == "(none)":
            self.epoch = None

    def unpack(self, topdir):
        args ["rpm", "-i", "--nodeps", "--define", "_sourcedir", topdir+"/SOURCES",
        "--define", "_specdir", topdir + "/SPECS", "--define", "_patchdir",
        topdir+"/SOURCES", self.filename]
        execcmd(args)

# vim:et:ts=4:sw=4