aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo/simplerpm.py
blob: 94b0fb0f53791a561839a373bacfe2cdc039093c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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