Exemplo n.º 1
0
 def hasUser(self, username):
     if self.filename is None:
         return False
     if not os.path.exists(self.filename):
         return False
     ret = FmUtil.cmdCall("pdbedit", "-d", "0", "-b", "tdbsam:%s" % (self.filename), "-L")
     return re.search("^%s:[0-9]+:$" % (username), ret, re.M) is not None
Exemplo n.º 2
0
 def _disableSwapService(self, path, serviceName):
     if self.param.runMode == "normal":
         FmUtil.cmdCall("systemctl", "stop", serviceName)
     elif self.param.runMode == "setup":
         FmUtil.cmdCall("swapoff", path)
     else:
         assert False
     FmUtil.cmdCall("systemctl", "disable", serviceName)
Exemplo n.º 3
0
 def _enableSwapService(self, path, serviceName):
     FmUtil.cmdCall("systemctl", "enable", serviceName)
     if self.param.runMode == "normal":
         FmUtil.cmdCall("systemctl", "start", serviceName)
     elif self.param.runMode == "setup":
         FmUtil.cmdCall("swapon", path)
     else:
         assert False
Exemplo n.º 4
0
    def getAuxOsInfo(self):
        if not FmConst.supportOsProber:
            return []

        ret = []
        for line in FmUtil.cmdCall("os-prober").split("\n"):
            itemList = line.split(":")
            if len(itemList) != 4:
                continue
            if itemList[3] == "linux":
                continue

            if itemList[1].endswith(
                    "(loader)"):  # for Microsoft Windows quirks
                m = re.fullmatch("(.*?)([0-9]+)", itemList[0])
                osDesc = itemList[1].replace("(loader)", "").strip()
                osPart = "%s%d" % (m.group(1), int(m.group(2)) + 1)
                chain = 4
                ret.append(bbki.HostAuxOs(osDesc, osPart, chain))
                continue
            if True:
                ret.append(bbki.HostAuxOs(itemList[1], itemList[0], 1))
                continue
        return ret
sys.path.append('/usr/lib64/fpemud-os-sysman')
from fm_util import FmUtil
from fm_param import FmConst
from helper_pkg_merger import PkgMerger

bPretend = (sys.argv[1] != "0")
assert not bPretend

i = 1
while True:
    # remove unused packages
    pkgChanged = False
    print("        - Cycle %d: removing unused packages..." % (i))
    if not bPretend:
        list1 = FmUtil.getFileList(FmConst.portageDbDir, 2, "d")
        FmUtil.cmdCall("emerge", "--depclean")
        list2 = FmUtil.getFileList(FmConst.portageDbDir, 2, "d")
        pkgChanged |= (list1 != list2)
    else:
        FmUtil.cmdExec("emerge", "--depclean", "--pretend")
    print("")

    # clean python
    if os.path.exists("/usr/share/eselect/modules/python.eselect"):
        print("        - Cycle %d: cleaning python..." % (i))
        if not bPretend:
            FmUtil.cmdCall("eselect", "python", "cleanup")
        else:
            FmUtil.cmdCall("eselect", "python", "list")
        print("")
Exemplo n.º 6
0
    def removeUser(self, username):
        """do nothing if the user doesn't exist"""

        if not self.hasUser(username):
            return
        FmUtil.cmdCall("pdbedit", "-d", "0", "-b", "tdbsam:%s" % (self.filename), "-x", username)