Exemplo n.º 1
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", "")
Exemplo n.º 2
0
if sys.argv[1:] == []:
    colors.show("saye", "fail", "no inputs.")
    sys.exit(0)

filename = sys.argv[1]

if not permissions.check(
        files.output(filename) + '.sa', "x", files.readall("/proc/info/su")):
    colors.show("saye", "perm", "")
    sys.exit(0)

if not files.isfile(filename + '.sa'):
    colors.show("saye", "fail", filename + ": script file not found.")
    sys.exit(0)

cmdall = control.read_list(filename + '.sa')

k = 0

for cmd in cmdall:
    k = k + 1
    ## Create cmdln with variables ##
    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:
Exemplo n.º 3
0
    files.write("/proc/info/ip", ip)
    files.write("/proc/info/os", osname)
    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 ##
Exemplo n.º 4
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", "")
Exemplo n.º 5
0
#  Pyabr (c) 2020 Pasand team. GNU General Public License v3.0
#
#  Offical website:         http://itpasand.com
#  Telegram or Gap channel: @pyabr
#  Telegram or Gap group:   @pyabr_community
#  Git source:              github.com/pasandteam/pyabr
#
#######################################################################################

## import modules ##
import sys
from libnam import permissions, files,control ,colors

## entry ##

## Check root ##
if not permissions.check_root (files.readall("/proc/info/su")):
    colors.show ("upv","perm","")
    sys.exit(0)

sel = files.readall ('/proc/info/sel') ## Get selector

## List all controls ##

listc = control.read_list (sel)

for i in listc:
    if not i.__contains__(':'): pass
    else:
        spliter = i.split (': ')
        files.write ('/proc/info/'+spliter[0],spliter[1])