summaryrefslogtreecommitdiff
path: root/src/backend/metadata.py
blob: 99384a0300fc7c0288e3724c65c80e74d63f9c16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/python3

import animation
import os
import shutil
import subprocess
import sisyphus.filesystem

def regenMetadata():
    if os.path.isdir(sisyphus.filesystem.portageMetadataDir):
        for files in os.listdir(sisyphus.filesystem.portageMetadataDir):
            if os.path.isfile(os.path.join(sisyphus.filesystem.portageMetadataDir, files)):
                os.remove(os.path.join(sisyphus.filesystem.portageMetadataDir, files))
            else:
                shutil.rmtree(os.path.join(sisyphus.filesystem.portageMetadataDir, files))

    portageExecStage1 = subprocess.Popen(['emerge', '--quiet', '--regen'], stdout=subprocess.PIPE)
    portageExecStage1.wait()
    portageExecStage2 = subprocess.Popen(['emerge', '--quiet', '--metadata'], stdout=subprocess.PIPE)
    portageExecStage2.wait()

def regenSilent():
    regenMetadata()

@animation.wait("regenerating package metadata")
def regenAnimated():
    regenMetadata()