Example #1
0
def shutdown():
    colors.show('', 'ok', 'Shutdowning the clouding system ...')
    if files.isdir("/desk/guest"):
        files.removedirs("/desk/guest")
    if files.isdir("/tmp"):
        files.removedirs("/tmp")
        files.mkdir("/tmp")
    if files.isfile("/proc/selected"): files.remove("/proc/selected")
    process.endall()
Example #2
0
def reboot():
    colors.show('', 'ok', 'Rebooting the clouding system ...')
    if files.isfile("/proc/selected"): files.remove("/proc/selected")
    colors.show("kernel", "reboot", "")
    if files.isdir("/desk/guest"):
        files.removedirs("/desk/guest")
    if files.isdir("/tmp"):
        files.removedirs("/tmp")
        files.mkdir("/tmp")
    process.endall()
    sub.call(['./' + files.readall("/proc/info/boot")])
Example #3
0
def shut():
    colors.show('', 'ok', 'Closing the switched process ...')
    if files.isfile("/proc/selected"): files.remove("/proc/selected")
    process.end(int(files.readall("/proc/info/sp")))

    if files.readall("/proc/info/su") == "0":
        if files.isdir("/desk/guest"):
            files.removedirs("/desk/guest")
        if files.isdir("/tmp"):
            files.removedirs("/tmp")
            files.mkdir("/tmp")
        if files.isfile("/proc/selected"): files.remove("/proc/selected")
        process.endall()
Example #4
0
def cut(src, dest):
    su = files.readall("/proc/info/su")
    if permissions.check(files.output(src), "r", su) and permissions.check(
            files.output(src), "w", su):
        if isfile(src):
            if permissions.check(files.output(dest), "w", su):
                if files.isdir(dest):
                    colors.show("libabr.file.cut", "fail",
                                dest + ": dest is a directory.")
                else:
                    perm = permissions.get_permissions(files.output(src))
                    control.write_record(files.output(dest), perm,
                                         "/etc/permtab")
                    files.cut(src, dest)
            else:
                colors.show("libabr.file.cut", "perm", "")
        elif isdir(src):
            if permissions.check(files.output(dest), "w", su):
                if files.isfile(dest):
                    colors.show("libabr.file.cut", "fail",
                                dest + ": dest is a file.")
                else:
                    perm = permissions.get_permissions(files.output(src))
                    control.write_record(files.output(dest), perm,
                                         "/etc/permtab")
                    files.cutdir(src, dest)
            else:
                colors.show("libabr.file.cut", "perm", "")
        else:
            colors.show("libabr.file.cut", "fail", src + ": source not found.")
    else:
        colors.show("libabr.file.cut", "perm", "")
Example #5
0
def isdir(name):
    su = files.readall("/proc/info/su")
    if permissions.check(files.output(name), "r", su):
        return files.isdir(name)
    else:
        colors.show("libabr.file.isdir", "perm", "")
        return None
Example #6
0
def udel(input_username, user):
    ## Check not exists user account ##
    if input_username == user:
        colors.show("udel", "fail",
                    input_username + ": cannot remove switched user.")
    else:
        if permissions.check_root(user):
            if not files.isfile("/etc/users/" + input_username):
                colors.show("udel", "fail",
                            input_username + ": user not found.")
            else:
                if input_username == "root":
                    colors.show("udel", "fail",
                                input_username + ": is a permanet user.")
                else:
                    hashname = hashlib.sha3_256(str(input_username).encode(
                    )).hexdigest()  ## Create hashname
                    username = control.read_record(
                        "username", "/etc/users/" + input_username)

                    if not hashname == username:
                        colors.show("udel", "fail",
                                    input_username + ": user not found.")
                    else:
                        files.remove("/etc/users/" + input_username)
                        if files.isdir('/desk/' + input_username):
                            files.removedirs("/desk/" + input_username)
                        colors.show(
                            '', 'ok',
                            "Remove '" + input_username + "' user account.")
        else:
            colors.show("udel", "perm", "")
Example #7
0
def zip (src,dest):
    su = files.readall("/proc/info/su") ## Get user data base
    if permissions.check (files.output(src),"r",su): ## Check this user permissions
        if permissions.check (files.output(dest+".zip"),"r",su): ## Check read only permission
            if files.isdir (src): ## Check source dir exists
                if files.isdir (dest+".zip"): ## Check dest dir exists
                    colors.show("libabr.archive.zip", "fail", dest+".zip" + ": dest is a directory.")
                else:
                    shutil.make_archive(files.input(dest),"zip",files.input(src)) ## Create archive
            elif files.isfile (src):
                colors.show("libabr.archive.zip", "fail",src+ ": source is a file.") ## Show error for permissions
            else:
                colors.show("libabr.archive.zip", "fail",src+ ": source not found.")
        else:
            colors.show("libabr.archive.zip", "perm", "")
    else:
        colors.show ("libabr.archive.zip","perm","")
Example #8
0
def gzip(src, dest):
    su = files.readall("/proc/info/su")
    if permissions.check(files.output(src), "r", su):
        if permissions.check(files.output(dest + ".gz"), "r", su):
            if files.isdir(src):
                if files.isdir(dest + ".gz"):
                    colors.show("libabr.archive.xzip", "fail", dest + ".gz" + ": dest is a directory.")
                else:
                    shutil.make_archive(files.input(dest), "gz", files.input(src))
            elif files.isfile(src):
                colors.show("libabr.archive.gzip", "fail", src + ": source is a file.")
            else:
                colors.show("libabr.archive.gzip", "fail", src + ": source not found.")
        else:
            colors.show("libabr.archive.gzip", "perm", "")
    else:
        colors.show("libabr.archive.gzip", "perm", "")
Example #9
0
def build(name):
    if permissions.check_root(files.readall("/proc/info/su")):
        if not files.isfile(name + "/control/manifest"):
            colors.show("libpa.build", "fail", "cannot create archive package")
            clean()
            sys.exit(0)

        if not files.isdir(name + "/data"): files.mkdir(name + "/data")
        if not files.isdir(name + "/code"): files.mkdir(name + "/code")

        ## Remove cache archives ##
        if files.isdir('/app/cache/archives/code'):
            files.removedirs('/app/cache/archives/code')
        if files.isdir('/app/cache/archives/control'):
            files.removedirs('/app/cache/archives/control')
        if files.isdir('/app/cache/archives/data'):
            files.removedirs('/app/cache/archives/data')

        ## Copy dir ##
        files.copydir(name + '/data', '/app/cache/archives/data')
        files.copydir(name + '/code', '/app/cache/archives/code')
        files.copydir(name + '/control', '/app/cache/archives/control')

        ## Compile codes ##
        if files.isfile("/app/cache/archives/control/compile"):
            listcodes = control.read_list(
                "/app/cache/archives/control/compile")
            for i in listcodes:
                i = i.split(":")
                files.compile("/app/cache/archives/code/" + i[0],
                              "/app/cache/archives/data/" + i[1])

        ## Pack archives ##
        shutil.make_archive(files.input("/app/cache/archives/build/data"),
                            "xztar", files.input('/app/cache/archives/data'))
        shutil.make_archive(files.input("/app/cache/archives/build/control"),
                            "xztar",
                            files.input('/app/cache/archives/control'))
        shutil.make_archive(files.input(name), "zip",
                            files.input("/app/cache/archives/build"))

        files.cut(name + ".zip", name + ".pa")
        ## Unlock the cache ##
    else:
        colors.show("libpa.build", "perm", "")
Example #10
0
def mv(src, dest):
    if files.isdir(src):
        if files.isfile(dest):
            colors.show("mv", "fail", dest + ": dest is a file.")
        else:
            if permissions.check(
                    files.output(src), "r",
                    files.readall("/proc/info/su")) and permissions.check(
                        files.output(src), "w",
                        files.readall("/proc/info/su")):
                if permissions.check(files.output(dest), "w",
                                     files.readall("/proc/info/su")):
                    perm = permissions.get_permissions(files.output(src))
                    control.write_record(files.output(dest), perm,
                                         "/etc/permtab")
                    files.copydir(src, dest)
                    files.removedirs(src)
                else:
                    colors.show("mv", "perm", "")
            else:
                colors.show("mv", "perm", "")
    elif files.isfile(src):
        if files.isdir(dest):
            colors.show("mv", "fail", dest + ": dest is a directory.")
        else:
            if permissions.check(
                    files.output(src), "r",
                    files.readall("/proc/info/su")) and permissions.check(
                        files.output(src), "w",
                        files.readall("/proc/info/su")):
                if permissions.check(files.output(dest), "w",
                                     files.readall("/proc/info/su")):
                    perm = permissions.get_permissions(files.output(src))
                    control.write_record(files.output(dest), perm,
                                         "/etc/permtab")
                    files.copy(src, dest)
                    files.remove(src)
                else:
                    colors.show("mv", "perm", "")
            else:
                colors.show("mv", "perm", "")
    else:
        colors.show("mv", "fail", src + ": source not found.")
Example #11
0
def clean():
    if permissions.check_root(files.readall("/proc/info/su")):
        if files.isdir("/app/cache"):
            files.removedirs("/app/cache")
            files.mkdir("/app/cache")
            files.mkdir("/app/cache/gets")
            files.mkdir("/app/cache/archives")
            files.mkdir("/app/cache/archives/code")
            files.mkdir("/app/cache/archives/control")
            files.mkdir("/app/cache/archives/data")
            files.mkdir("/app/cache/archives/build")
    else:
        colors.show("libpa.clean", "perm", "")
Example #12
0
def ls(path, options):
    if options == "":
        if files.isdir(path):
            if permissions.check(files.output(path), "r",
                                 files.readall("/proc/info/su")):
                list = files.list(path)
                list.sort()
                for i in list:
                    if files.isdir(path + "/" + i):
                        print(colors.get_path() + i + "/" +
                              colors.get_colors())
                    else:
                        print(i)
            else:
                colors.show("ls", "perm", "")
        else:
            colors.show("ls", "fail", path + ": directory not found.")
    elif options == "-p":
        if files.isdir(path):
            if permissions.check(files.output(path), "r",
                                 files.readall("/proc/info/su")):
                list = files.list(path)
                list.sort()
                for i in list:
                    if files.isdir(path + "/" + i):
                        perm = permissions.get_permissions(path + "/" + i)
                        print(perm + "\t" + colors.get_path() + i + "/" +
                              colors.get_colors())
                    else:
                        perm = permissions.get_permissions(path + "/" + i)
                        print(perm + "\t" + i)
            else:
                colors.show("ls", "perm", "")
        else:
            colors.show("ls", "fail", path + ": directory not found.")
    elif options == "-n":
        if files.isdir(path):
            if permissions.check(files.output(path), "r",
                                 files.readall("/proc/info/su")):
                list = files.list(path)
                list.sort()
                for i in list:
                    if files.isdir(path + "/" + i):
                        perm = permissions.get_permissions(path + "/" + i)
                        perm = str(permissions.show_number(perm))
                        print(perm + "\t" + colors.get_path() + i + "/" +
                              colors.get_colors())
                    else:
                        perm = permissions.get_permissions(path + "/" + i)
                        perm = str(permissions.show_number(perm))
                        print(perm + "\t" + i)
            else:
                colors.show("ls", "perm", "")
        else:
            colors.show("ls", "fail", path + ": directory not found.")
Example #13
0
def compile(src, dest):
    su = files.readall("/proc/info/su")
    if permissions.check(files.output(src), "r", su):
        if isfile(src):
            if permissions.check(files.output(dest), "w", su):
                if files.isdir(dest):
                    colors.show("libabr.file.compile", "fail",
                                dest + ": dest is a directory.")
                else:
                    files.compile(src, dest)
            else:
                colors.show("libabr.file.compile", "perm", "")
        elif isdir(src):
            colors.show("libabr.file.compile", "fail",
                        src + ": source is a directory.")
        else:
            colors.show("libabr.file.compile", "fail",
                        src + ": source not found.")
    else:
        colors.show("libabr.file.compile", "perm", "")
Example #14
0
def rm(names):
    for i in names:
        if files.isdir(i):
            if permissions.check(files.output(i), "w",
                                 files.readall("/proc/info/su")):
                files.removedirs(i)
                colors.show('', 'ok', "Remove '" + i + "' directory.")
            else:
                colors.show("rm", "perm", "")
                sys.exit(0)
        elif files.isfile(i):
            if permissions.check(files.output(i), "w",
                                 files.readall("/proc/info/su")):
                files.remove(i)
                colors.show('', 'ok', "Remove '" + i + "' file.")
            else:
                colors.show("rm", "perm", "")
                sys.exit(0)
        else:
            colors.show("rm", "fail", i + ": file or directory not found.")
            sys.exit(0)
Example #15
0
def cd(path):
    if permissions.check(files.output(path), "r",
                         files.readall("/proc/info/su")):
        if path == '..':
            pwd = files.readall('/proc/info/pwd')
            pwd = pwd.split('/')
            lens = len(pwd) - 1
            pwd.pop(lens)

            strv = ''

            for i in pwd:
                strv += "/" + i

            pwd = files.output_shell(strv)
            files.write("/proc/info/pwd", pwd)
        elif files.isdir(path):
            files.write("/proc/info/pwd", files.output_shell(path))
        else:
            colors.show("cd", "fail", path + ": directory not found.")
    else:
        colors.show("cd", "perm", "")
Example #16
0
def get_permissions(name):
    perms = control.read_record(name, "/etc/permtab")  ## get permissions
    if not perms == None:
        return perms
    else:
        ## Father permtab ##
        if files.isdir(name):
            dirfile = "d"
        else:
            dirfile = "-"

        ## The most important part of father permtab ##
        names = name.split("/")

        while not exists(name):
            l = len(names) - 1
            names.pop(l)
            name = ""
            for i in names:
                name = name + "/" + i
            name = name.replace("//", "/")

        perm = control.read_record(name, "/etc/permtab")  ## get permissions
        perm = perm.split("/")
        owner = perm[1]
        perms = perm[0]
        user_r = perms[1]
        user_w = perms[2]
        user_x = perms[3]
        others_r = perms[4]
        others_w = perms[5]
        others_x = perms[6]
        guest_r = perms[7]
        guest_w = perms[8]
        guest_x = perms[9]
        return dirfile + user_r + user_w + user_x + others_r + others_w + others_x + guest_r + guest_w + guest_x + "/" + owner
Example #17
0
def create(name, user, others, guest, owner):
    if files.isfile(name) or files.isdir(name):
        ## Learned by Guru99 2020 ##
        ## Set user permissions section
        if user == 0:
            user = "******"
        elif user == 1:
            user = "******"
        elif user == 2:
            user = "******"
        elif user == 3:
            user = "******"
        elif user == 4:
            user = "******"
        elif user == 5:
            user = "******"
        elif user == 6:
            user = "******"
        elif user == 7:
            user = "******"
        else:
            user = "******"

        ## Set other users permissions section
        if others == 0:
            others = "---"
        elif others == 1:
            others = "--x"
        elif others == 2:
            others = "-w-"
        elif others == 3:
            others = "-wx"
        elif others == 4:
            others = "r--"
        elif others == 5:
            others = "r-x"
        elif others == 6:
            others = "rw-"
        elif others == 7:
            others = "rwx"
        else:
            others = "rwx"

        ## Set guest user permissions section
        if guest == 0:
            guest = "---"
        elif guest == 1:
            guest = "--x"
        elif guest == 2:
            guest = "-w-"
        elif guest == 3:
            guest = "-wx"
        elif guest == 4:
            guest = "r--"
        elif guest == 5:
            guest = "r-x"
        elif guest == 6:
            guest = "rw-"
        elif guest == 7:
            guest = "rwx"
        else:
            guest = "rwx"

        if files.isdir(name):
            control.write_record(
                name, "d" + user + others + guest + "/" + owner,
                "/etc/permtab")  # Write permissions for this directory
        else:
            control.write_record(
                name, "-" + user + others + guest + "/" + owner,
                "/etc/permtab")  # Write permissions for this file
Example #18
0
def cat(name, option):

    ## Read files ##
    if option == '' or option == '-r':
        if files.isfile(name):
            if permissions.check(files.output(name), "r",
                                 files.readall("/proc/info/su")):
                file = open(files.input(name), "rb")
                check_bin = str(file.read())
                file.close()
                if check_bin.__contains__("\\x00"):
                    print(check_bin)
                else:
                    print(files.readall(name))
            else:
                colors.show("cat", "perm", "")
        elif files.isdir(name):
            colors.show("cat", "fail", name + ": is a directory.")
        else:
            colors.show("cat", "fail", name + ": file not found.")

    ## Create files ##
    elif option == '-c':
        if files.isdir(name):
            colors.show("cat", "fail", name + ": is a directory.")
        else:
            if permissions.check(files.output(name), "w",
                                 files.readall("/proc/info/su")):
                files.create(name)
            else:
                colors.show("cat", "perm", "")

    ## Write into files ##
    elif option == '-w':
        if files.isdir(name):
            colors.show("cat", "fail", name + ": is a directory.")
        else:
            if permissions.check(files.output(name), "w",
                                 files.readall("/proc/info/su")):

                ## Set EOF
                if cmdln[3:] == []:
                    EOF = 'EOF'
                else:
                    EOF = cmdln[3]

                # WRITE COMMAND LINE

                texts = ''

                while True:
                    cmd = input('> ')
                    if cmd == EOF: break
                    else:
                        if texts == '':
                            texts = cmd
                        else:
                            texts = texts + '\n' + cmd

                ## WRITE INTO FILE
                files.write(cmdln[2], texts)
            else:
                colors.show("cat", "perm", "")

    ## Write into files ##
    elif option == '-a':
        if files.isdir(name):
            colors.show("cat", "fail", name + ": is a directory.")
        else:
            if permissions.check(files.output(name), "w",
                                 files.readall("/proc/info/su")):

                ## Set EOF
                if cmdln[3] == []:
                    EOF = 'EOF'
                else:
                    EOF = cmdln[3]

                # WRITE COMMAND LINE

                texts = ''

                while True:
                    cmd = input('> ')
                    if cmd == EOF:
                        break
                    else:
                        if texts == '':
                            texts = cmd
                        else:
                            texts = texts + '\n' + cmd

                ## WRITE INTO FILE
                files.append(cmdln[2], texts)
            else:
                colors.show("cat", "perm", "")
Example #19
0
    files.write("/proc/info/arch", arch)
    files.write("/proc/info/os_su", os_user)
    files.write("/proc/info/inter", interface)
    files.write("/proc/info/tz", tz)
    files.write("/proc/info/sweek", sweek)
    files.write("/proc/info/boot", kernel_file)
    files.write("/proc/info/cpu", cpu)
    files.write("/proc/info/cpuc", cpuc)
    files.write("/proc/info/ram", ram)

## @core/dirs ##

colors.show("dirs", "ok-start", "")
fhs = control.read_list("/etc/fhs")
for i in fhs:
    if not files.isdir(i) and not files.isfile(i):
        files.mkdir(i)

## @core/welcome ##

if argv[0] == "kernel":
    colors.show("welcome", "ok-start", "")
    print()
    print("Welcome to " + distro_name + " " + distro_version + " (" +
          distro_code + ") clouding system.")
    print()

## @core/issue ##

if (argv[0] == "kernel") and files.isfile("/etc/issue"):
    colors.show("issue", "ok-start", "")
Example #20
0
def shell():
    print()

    if user == "root":
        files.write("/proc/info/pwd", "/root")
    else:
        files.write("/proc/info/pwd", "/desk/" + user)

    select = files.readall("/proc/info/sel")  # Change selected database

    while True:
        if not files.isfile("/proc/selected"):
            files.write("/proc/info/sel",
                        "/proc/" + str(switch))  ## Write this controller
        ## Check the switched process ##
        process.check(switch)  # Check the switched process

        files.write("/proc/info/sp", str(switch))  # Write switched process

        if files.isfile("/tmp/su.tmp"): files.remove("/tmp/su.tmp")

        ## User configure check ##
        files.write("/proc/info/su", user)  # Write user name in info processor
        if not user == "guest":
            hashname = hashlib.sha3_256(str(user).encode()).hexdigest()
            username = control.read_record("username", "/etc/users/" + user)
            hashcode = hashlib.sha3_512(str(code).encode()).hexdigest()
            password = control.read_record("code", "/etc/users/" + user)

            if not (hostname == username) and not (password == hashcode):
                colors.show("shell", "fail-start", "")
                colors.show("kernel", "stop", "")
                sys.exit(0)
        ## PWD path setting up at all ##
        if not user == "root":
            if not files.isdir("/desk/" + user):
                files.mkdir("/desk/" + user)  # Create home folder

        ## Prompt data base ##

        show_username = control.read_record("show_username", "/etc/prompt")
        show_hostname = control.read_record("show_hostname", "/etc/prompt")
        show_path = control.read_record("show_path", "/etc/prompt")
        root_symbol = control.read_record("root", "/etc/prompt")
        user_symbol = control.read_record("user", "/etc/prompt")

        ## Setting up prompt data base 2 ##

        color_uh = ""
        color_path = ""
        prompt_symbol = ""

        if user == "root":
            prompt_symbol = root_symbol
            color_uh = colors.get_colors()
            color_path = colors.get_colors()
        else:
            prompt_symbol = user_symbol
            color_uh = colors.get_ok()
            color_path = colors.get_path()

        ## Setting up space of prompt ##

        if show_username == "Yes":
            space_username = user
        else:
            space_username = ""

        if show_hostname == "Yes":
            space_hostname = hostname
        else:
            space_hostname = ""

        if show_path == "Yes":
            space_path = files.readall("/proc/info/pwd")
        else:
            space_path = ""

        if show_hostname == "Yes" and show_username == "Yes":
            space1 = "@"
        else:
            space1 = ""

        if (show_hostname == "Yes"
                or show_username == "Yes") and show_path == "Yes":
            space2 = ":"
        else:
            space2 = ""

        ## Shell prompt ##

        cmd = input(color_uh + space_username + space1 + space_hostname +
                    colors.get_colors() + space2 + color_path + space_path +
                    colors.get_colors() + prompt_symbol + " ")

        cmdln = cmd.split(" ")

        strcmdln = ""

        for i in cmdln:
            if str(i).startswith("$"):
                select = files.readall("/proc/info/sel")
                var = control.read_record(str(i).replace("$", ""), select)
                if var == None:
                    strcmdln = strcmdln + " " + i
                else:
                    strcmdln = strcmdln + " " + var
            else:
                strcmdln = strcmdln + " " + i

        ## Command line ##
        cmdln = strcmdln.split(" ")
        cmdln.remove('')

        ## All commands run in here ##

        ## New command ##
        if cmdln[0] == "new":
            files.create("/tmp/su.tmp")
            control.write_record("username", user, "/tmp/su.tmp")
            control.write_record("code", code, "/tmp/su.tmp")

        ## Other commands ##
        if (cmdln == [] or cmdln[0] == "" or cmdln[0] == " "
                or cmd.startswith("#") or cmd.startswith("//")
                or (cmd.startswith("/*") and cmd.endswith("*/"))
                or (cmd.startswith("\'\'\'") and cmd.endswith("\'\'\'"))
                or cmd.startswith(";")):
            continue
        else:
            ## Run commands ##
            # os.system('./'+kernel_file+" exec "+cmd)# Credit learned with https://pymotw.com/2/subprocess/

            ## Prompt ##
            prompt = ['./' + kernel_file, 'exec', cmdln[0]]

            ## Arguments ##
            for i in cmdln[1:]:
                prompt.append(i)

            ## Call the kernel ##
            sub.call(prompt)
Example #21
0
def remove(name):
    if permissions.check_root(files.readall("/proc/info/su")):

        location = "/app/packages/" + name.lower() + ".manifest"

        if not files.isfile(location):
            colors.show("libpa.remove", "fail", name + ": package not found")
            clean()
            sys.exit(0)

        ## Database control ##

        list = "/app/packages/" + name.lower() + ".list"
        preinstall = "/app/packages/" + name.lower() + ".preinstall"
        postinstall = "/app/packages/" + name.lower() + ".postinstall"
        preremove = "/app/packages/" + name.lower() + ".preremove"
        postremove = "/app/packages/" + name.lower() + ".postremove"
        compile = "/app/packages/" + name.lower() + ".compile"
        depends = "/app/packages/" + name.lower() + ".depends"

        ## Create preremove and postremove copies ##

        if files.isfile(preremove):
            files.copy(preremove, "/app/cache/archives/control/preremove.py")
        if files.isfile(postremove):
            files.copy(postremove, "/app/cache/archives/control/postremove.py")

        ## Run pre remove script ##

        if files.isfile("/app/cache/archives/control/preremove.py"):
            files.compile("/app/cache/archives/control/preremove.py",
                          '/usr/bin/preremove.pyc')
            core.system("preremove")
            files.remove('/usr/bin/preremove.pyc')

        ## Remove depends ##

        if files.isfile(depends):
            depends = control.read_list(depends)
            for i in depends:
                remove(i)

        ####################

        unpack = control.read_record("unpack", location)

        ## Unpacked removal ##
        filelist = control.read_list(list)

        for i in filelist:
            if files.isdir(unpack + "/" + i):
                files.removedirs(unpack + "/" + i)
            elif files.isfile(unpack + "/" + i):
                files.remove(unpack + "/" + i)

        ## Database removal ##

        if files.isfile(location): files.remove(location)
        if files.isfile(compile): files.remove(compile)
        if files.isfile(list): files.remove(list)
        if files.isfile(preinstall): files.remove(preinstall)
        if files.isfile(postinstall): files.remove(postinstall)
        if files.isfile(preremove): files.remove(preremove)
        if files.isfile(postremove): files.remove(postremove)
        if files.isfile(depends): files.remove(depends)

        ## Remove source code ##
        if files.isdir('/usr/src/' + name):
            files.removedirs('/usr/src/' + name)

        ## Run postremove script ##

        if files.isfile("/app/cache/archives/control/postremove.py"):
            files.compile('/app/cache/archives/control/postremove.py',
                          '/usr/bin/postremove.pyc')
            core.system("postremove")
            files.remove('/usr/bin/postremove.pyc')

    else:
        colors.show("libpa.remove", "perm", "")