summaryrefslogtreecommitdiff
path: root/src/backend/purgeEnvironment.py
blob: 0eba801552730a5fe66a63905581a404f678b45e (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python3

import animation
import os
import shutil
import sisyphus.getFilesystem

@animation.wait('purging branch configuration')
def branch():
    if os.path.isdir(sisyphus.getFilesystem.portageRepoDir):
        for files in os.listdir(sisyphus.getFilesystem.portageRepoDir):
            if os.path.isfile(os.path.join(sisyphus.getFilesystem.portageRepoDir, files)):
                os.remove(os.path.join(sisyphus.getFilesystem.portageRepoDir, files))
            else:
                shutil.rmtree(os.path.join(sisyphus.getFilesystem.portageRepoDir, files))
    else:
        os.makedirs(sisyphus.getFilesystem.portageRepoDir)

    if os.path.isdir(sisyphus.getFilesystem.redcoreRepoDir):
        for files in os.listdir(sisyphus.getFilesystem.redcoreRepoDir):
            if os.path.isfile(os.path.join(sisyphus.getFilesystem.redcoreRepoDir, files)):
                os.remove(os.path.join(sisyphus.getFilesystem.redcoreRepoDir, files))
            else:
                shutil.rmtree(os.path.join(sisyphus.getFilesystem.redcoreRepoDir, files))
    else:
        os.makedirs(sisyphus.getFilesystem.redcoreRepoDir)

    if os.path.isdir(sisyphus.getFilesystem.portageConfigDir):
        for files in os.listdir(sisyphus.getFilesystem.portageConfigDir):
            if os.path.isfile(os.path.join(sisyphus.getFilesystem.portageConfigDir, files)):
                os.remove(os.path.join(sisyphus.getFilesystem.portageConfigDir, files))
            else:
                shutil.rmtree(os.path.join(sisyphus.getFilesystem.portageConfigDir, files))
    else:
        os.makedirs(sisyphus.getFilesystem.portageConfigDir)

def cache():
    if os.path.isdir(sisyphus.getFilesystem.portageCacheDir):
        for files in os.listdir(sisyphus.getFilesystem.portageCacheDir):
            if os.path.isfile(os.path.join(sisyphus.getFilesystem.portageCacheDir, files)):
                os.remove(os.path.join(sisyphus.getFilesystem.portageCacheDir, files))
            else:
                shutil.rmtree(os.path.join(sisyphus.getFilesystem.portageCacheDir, files))

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