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

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

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

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

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