def actions(self): if self.Env.objectName() == 'Login': username = self.leInput.text() ## Get username if self.Env.guest == 'Yes' and username == 'guest': self.Env.setCentralWidget( Desktop([self.Backend, self], username, '*')) elif not files.isfile('/etc/users/' + username): self.leInput.clear() self.leInput.setEnabled(False) message = res.get('@string/user_not_found') if not message == None: message = message.replace("{0}", username) self.leInput.setPlaceholderText(message) QTimer.singleShot(2500, self.clean) else: ## Check user ## hashname = hashlib.sha3_256( username.encode()).hexdigest() ## Get hashname name = control.read_record('username', '/etc/users/' + username) if not hashname == name: self.leInput.clear() self.leInput.setEnabled(False) message = res.get('@string/user_not_found') if not message == None: message = message.replace("{0}", username) self.leInput.setPlaceholderText(message) QTimer.singleShot(2500, self.clean) else: ## Setting up switched user ## self.Env.setCentralWidget( Enter([self.Backend, self], username)) ## Switch user elif self.Env.objectName() == 'Enter': username = self.Env.username password = self.leInput.text() ## Check password ## hashcode = hashlib.sha3_512( password.encode()).hexdigest() ## Create hashcode for password code = control.read_record('code', '/etc/users/' + username) if not code == hashcode: self.leInput.clear() self.leInput.setEnabled(False) message = res.get('@string/wrong_password') self.leInput.setPlaceholderText(message) QTimer.singleShot(2500, self.clean) else: self.Env.setCentralWidget( Desktop([self.Backend, self], username, password))
def get_ok(): if not files.isfile("/proc/id/desktop"): style = control.read_record("ok_style", "/etc/color") fgcolor = control.read_record("ok_fgcolor", "/etc/color") bgcolor = control.read_record("ok_bgcolor", "/etc/color") strv = "\033[" + str(style) + ";" + str(fgcolor) + ";" + str(bgcolor) + "m" return strv else: return ""
def get_hide(): if not files.isfile("/proc/id/desktop"): style = control.read_record("style", "/etc/color") bgcolor = control.read_record("bgcolor", "/etc/color") fgcolor = int(control.read_record("bgcolor", "/etc/color")) + 10 strv = "\033[" + str(style) + ";" + str(fgcolor) + ";" + str(bgcolor) + "m" return strv else: return ""
def uinfo(input_username): enable_cli = control.read_record("enable_cli", "/etc/guest") if not (input_username == "guest" and enable_cli == "Yes"): if files.isfile("/etc/users/" + input_username): ## Get information from user database ## first_name = control.read_record("first_name", "/etc/users/" + input_username) last_name = control.read_record("last_name", "/etc/users/" + input_username) company = control.read_record("company", "/etc/users/" + input_username) birthday = control.read_record("birthday", "/etc/users/" + input_username) gender = control.read_record("gender", "/etc/users/" + input_username) blood_type = control.read_record("blood_type", "/etc/users/" + input_username) phone = control.read_record("phone", "/etc/users/" + input_username) website = control.read_record("website", "/etc/users/" + input_username) email = control.read_record("email", "/etc/users/" + input_username) ## Show it on screen ## bold = colors.color(1, colors.get_bgcolor(), colors.get_fgcolor()) if not (first_name == None or first_name == ""): print("\t First name: " + bold + first_name + colors.get_colors()) if not (last_name == None or last_name == ""): print("\t Last name: " + bold + last_name + colors.get_colors()) if not (company == None or company == ""): print("\t Company: " + bold + company + colors.get_colors()) if not (birthday == None or birthday == ""): print("\t Birthday: " + bold + birthday + colors.get_colors()) if not (gender == None or gender == ""): print("\t Gender: " + bold + gender + colors.get_colors()) if not (blood_type == None or blood_type == ""): print("\t BloodType: " + bold + blood_type + colors.get_colors()) if not (phone == None or phone == ""): print("\t Phone number: " + bold + phone + colors.get_colors()) if not (website == None or website == ""): print("\t Website: " + bold + website + colors.get_colors()) if not (email == None or email == ""): print("\tEmail address: " + bold + email + colors.get_colors()) else: colors.show("uinfo", "fail", input_username + ": user not found.")
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", "")
def get_style (): if not files.isfile("/proc/id/desktop"): style = control.read_record("style", "/etc/color") return style else: return ""
def get_bgcolor (): if not files.isfile("/proc/id/desktop"): bgcolor = control.read_record("bgcolor", "/etc/color") return bgcolor else: return ""
def check_root(user): if user == "root": if files.isfile("/etc/users/" + user): hashname = hashlib.sha3_256(str(user).encode()).hexdigest() username = control.read_record("username", "/etc/users/" + user) if (hashname == username): return True else: return False else: return False
def __init__(self, ports): super(TaskBar, self).__init__() ## Ports ## self.Backend = ports[0] self.Env = ports[1] ## Set username ## self.username = self.Env.username ## Get DATAS ################### ## Set bgcolor ## bgcolor = getdata('taskbar.bgcolor') if not self.Env.username == 'guest': value = control.read_record('taskbar.bgcolor', '/etc/users/' + self.username) if not value == None: bgcolor = value if bgcolor == None: bgcolor = variables.taskbar_bgcolor ## Set fgcolor ## fgcolor = getdata('taskbar.fgcolor') if not self.Env.username == 'guest': value = control.read_record('taskbar.fgcolor', '/etc/users/' + self.username) if not value == None: fgcolor = value if fgcolor == None: fgcolor = 'black' ################################ # styles # self.setStyleSheet('background-color: ' + bgcolor + ";color: " + fgcolor + ";") ## Add taskbar ## self.Env.addToolBar(self)
def su(input_username, user): if files.isfile("/proc/selected"): files.remove("/proc/selected") if user == input_username: colors.show("su", "warning", user + " has already switched.") elif input_username == "guest": enable_cli = control.read_record("enable_cli", "/etc/guest") if enable_cli == "Yes": colors.show('', 'ok', "Switching '" + input_username + "' user account.") os.system("./" + files.readall("/proc/info/boot") + " user guest") else: colors.show(input_username, "fail", "user not found.") elif files.isfile("/etc/users/" + input_username): hashname = hashlib.sha3_256(str(input_username).encode()).hexdigest() username = control.read_record("username", "/etc/users/" + input_username) if hashname == username: input_password = getpass.getpass('Enter ' + input_username + '\'s password: '******'', 'ok', "Switching '" + input_username + "' user account ...") os.system("./" + files.readall("/proc/info/boot") + " user " + input_username + " " + input_password) else: colors.show("su", "fail", input_username + ": wrong password.") else: colors.show("su", "fail", input_username + " user not found.") else: colors.show("su", "fail", input_username + " user not found.")
def check_owner(filename, user): owner = get_owner(filename) if user == "guest": enable_cli = control.read_record("enable_cli", "/etc/guest") if enable_cli == "Yes": if owner == user: return True else: return False else: return False elif user == "root": if files.isfile("/etc/users/" + user): hashname = hashlib.sha3_256(str(user).encode()).hexdigest() username = control.read_record("username", "/etc/users/" + user) if (hashname == username): return True else: return False else: return False else: if files.isfile("/etc/users/" + user): hashname = hashlib.sha3_256(str(user).encode()).hexdigest() username = control.read_record("username", "/etc/users/" + user) if (hashname == username): if owner == user: return True elif owner == "guest": return True else: return False else: return False else: return False
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
def getdata(name): return control.read_record(name, '/etc/gui')
def __init__(self, ports, username): super(Enter, self).__init__() ## username ## self.username = username.lower() ## Ports ## self.Backend = ports[0] self.Env = ports[1] ## Set port name ## self.setObjectName('Enter') ## Get informations ## cs = files.readall('/proc/info/cs') ver = files.readall('/proc/info/ver') cd = files.readall('/proc/info/cd') self.setWindowTitle(cs + ' ' + ver + ' (' + cd + ")") ## Get app logo ## applogo = getdata('logo') if not applogo == None: self.setWindowIcon(QIcon(res.get(applogo))) bgcolor = getdata('enter.bgcolor') background = getdata('enter.background') fgcolor = getdata('enter.fgcolor') if not self.username == 'guest': value = control.read_record('enter.bgcolor', '/etc/users/' + self.username) if not value == None: bgcolor = value if not self.username == 'guest': value = control.read_record('enter.background', '/etc/users/' + self.username) if not value == None: background = value if not self.username == 'guest': value = control.read_record('enter.fgcolor', '/etc/users/' + self.username) if not value == None: fgcolor = value ## Widget for bgcolor or background ## self.backgroundButton = QPushButton() self.backgroundButton.setGeometry(0, 0, variables.width, variables.height) self.layout().addWidget(self.backgroundButton) ## Set bgcolor and background ## if background == None and bgcolor == None and not fgcolor == None: variables.enter_fgcolor = fgcolor ## Set colors ## self.setStyleSheet('color: {0};'.replace('{0}', variables.enter_fgcolor)) self.backgroundButton.setStyleSheet( 'border:none;background-color: {0};'.replace( '{0}', variables.enter_bgcolor)) elif background == None and not fgcolor == None: ## Set colors ## variables.enter_bgcolor = bgcolor variables.enter_fgcolor = fgcolor self.setStyleSheet('color: {0};'.replace('{0}', variables.enter_fgcolor)) self.backgroundButton.setStyleSheet( 'border:none;background-color: {0};'.replace( '{0}', variables.enter_bgcolor)) elif not background == None and not fgcolor == None: ## Set bgcolor ## variables.enter_background = res.get(background) self.setStyleSheet('color: {0};'.replace('{0}', variables.enter_fgcolor)) self.backgroundButton.setStyleSheet( 'border:none;background-image: url({0});'.replace( '{0}', variables.enter_background)) else: self.setStyleSheet('background-color:{1};color: {0};'.replace( '{0}', variables.enter_fgcolor).replace('{1}', variables.enter_bgcolor)) ## Set size ## width = getdata('width') height = getdata('height') autosize = getdata('autosize') if not width == None and not autosize == 'Yes': variables.width = int(width) if not height == None: variables.height = int(height) self.resize(variables.width, variables.height) ## Set sides ## ## Set sides ## sides = getdata('sides') if sides == 'Yes': variables.sides = True else: variables.sides = False if variables.sides == False: self.setWindowFlag(Qt.FramelessWindowHint) ## Login widget ## self.loginw = LoginWidget([self.Backend, self]) self.layout().addWidget(self.loginw) ## Show ## ## Get data ## fullscreen = getdata('fullscreen') if fullscreen == 'Yes': variables.fullscreen = True else: variables.fullscreen = False if variables.fullscreen == True: self.showFullScreen() else: self.show()
## @core/hostname ## if files.isfile("/etc/hostname"): files.copy("/etc/hostname", "/proc/info/host") hostname = files.readall("/etc/hostname") colors.show("hostname", "ok-start", "") else: colors.show("hostname", "fail-start", "") colors.show("kernel", "stop", "") sys.exit(0) ## @core/distro ## if files.isfile("/etc/distro"): distro_name = control.read_record("name", "/etc/distro") distro_code = control.read_record("code", "/etc/distro") distro_version = control.read_record("version", "/etc/distro") distro_build = control.read_record("build", "/etc/distro") files.write("/proc/info/cs", distro_name) files.write("/proc/info/cd", distro_code) files.write("/proc/info/ver", distro_version) files.write("/proc/info/bl", distro_build) colors.show("distro", "ok-start", "") else: colors.show("distro", "fail-start", "") colors.show("kernel", "stop", "") sys.exit(0) ## @core/kernel-info ##
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)
style_none = 0 style_bold = 1 style_underline = 2 style_negative1 = 3 style_negative2 = 5 bg_black = 40 bg_red = 41 bg_green = 42 bg_yellow = 43 bg_blue = 44 bg_purple = 45 bg_cyan = 46 bg_white = 47 kernel = control.read_record("kernel","/etc/procmsg") gui = control.read_record("gui","/etc/procmsg") gui_login = control.read_record("gui-login","/etc/procmsg") gui_user = control.read_record("gui-user","/etc/procmsg") login = control.read_record("login","/etc/procmsg") user = control.read_record("user","/etc/procmsg") exec = control.read_record("exec","/etc/procmsg") client = control.read_record("client","/etc/procmsg") def show (process_name,process_type,process_message): if process_type=="fail": print (get_fail()+process_name+": error: "+process_message+get_colors()) elif process_type=="ok": ok = control.read_record('ok','/etc/procmsg') if ok=='Yes': print(get_ok() + process_message + get_colors())
# In the name of God, the Compassionate, the Merciful # 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 # ####################################################################################### from libnam import process, files, permissions, colors, control, modules import os, importlib, getpass, sys from libabr import core lang = control.read_record('locale','/etc/gui') ## Graphical application library ## ## Start ID Process ## def start (id): ## Check exists ## if files.isfile ('/proc/id/'+id): pass colors.show (id,'ok-start','') ## Create id ## files.create ("/proc/id/"+id)
def get(filename): model = control.read_record("model", "/etc/gui") # read model if not filename == None: filename = filename.split("/") # @widget:barge share = filename[0] name = filename[1] ## Real Resource ## if share.startswith("@widget"): if files.isfile("/usr/share/" + share.replace("@widget", "widgets") + "/" + name + ".ui"): return files.input("/usr/share/" + share.replace("@widget", "widgets") + "/" + name + ".ui") else: return None elif share.startswith("@font"): if files.isfile("/usr/share/fonts/" + name + ".ttf"): return "/usr/share/fonts/" + name + ".ttf" else: return None elif share.startswith("@background"): if files.isfile("/usr/share/backgrounds/" + name + ".svg"): return files.input("/usr/share/backgrounds/" + name + ".svg") elif files.isfile("/usr/share/backgrounds/" + name + ".png"): return files.input("/usr/share/backgrounds/" + name + ".png") elif files.isfile("/usr/share/backgrounds/" + name + ".jpg"): return files.input("/usr/share/backgrounds/" + name + ".jpg") elif files.isfile("/usr/share/backgrounds/" + name + ".jpeg"): return files.input("/usr/share/backgrounds/" + name + ".jpeg") elif files.isfile("/usr/share/backgrounds/" + name + ".gif"): return files.input("/usr/share/backgrounds/" + name + ".gif") else: return None elif share.startswith("@image"): if files.isfile("/usr/share/images/" + name + ".svg"): return files.input("/usr/share/images/" + name + ".svg") elif files.isfile("/usr/share/images/" + name + ".png"): return files.input("/usr/share/images/" + name + ".png") elif files.isfile("/usr/share/images/" + name + ".jpg"): return files.input("/usr/share/images/" + name + ".jpg") elif files.isfile("/usr/share/images/" + name + ".jpeg"): return files.input("/usr/share/images/" + name + ".jpeg") elif files.isfile("/usr/share/images/" + name + ".gif"): return files.input("/usr/share/images/" + name + ".gif") else: return None elif share.startswith("@app"): if files.isfile("/usr/share/" + share.replace("@app", "applications") + "/" + name + ".desk"): return files.input("/usr/share/" + share.replace("@app", "applications") + "/" + name + ".desk") else: return None elif share.startswith("@icon"): if files.isfile("/usr/share/" + share.replace("@icon", "icons") + "/" + name + ".svg"): return files.input("/usr/share/" + share.replace("@icon", "icons") + "/" + name + ".svg") elif files.isfile("/usr/share/" + share.replace("@icon", "icons") + "/" + name + ".png"): return files.input("/usr/share/" + share.replace("@icon", "icons") + "/" + name + ".png") elif files.isfile("/usr/share/" + share.replace("@icon", "icons") + "/" + name + ".gif"): return files.input("/usr/share/" + share.replace("@icon", "icons") + "/" + name + ".gif") else: return None elif share.startswith("@string"): locale = control.read_record("locale", "/etc/gui") id = files.readall("/proc/info/id") ## Set default lang ## if locale == None: locale = "en" ## Get value from string ## result = control.read_record( id.replace(".desk", "") + "." + name, "/usr/share/locales/" + locale + ".locale") ## Find default ## if result == None: result = control.read_record( id.replace(".desk", "") + "." + name, "/usr/share/locales/" + 'en' + ".locale") return result ## None Resource ## else: return None else: return None
def exists(name): perms = control.read_record(name, "/etc/permtab") ## get permissions if perms == None: return False else: return True
####################################################################################### # In the name of God, the Compassionate, the Merciful # 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 sys, os, hashlib, subprocess as sub from libnam import files, control, permissions, colors, process boot = files.readall("/proc/info/boot") def new(user, code): colors.show('', 'ok', 'Switching a new process ...') if files.isfile("/proc/selected"): files.remove("/proc/selected") if user == "guest": sub.call(['./' + boot, 'user', 'guest']) else: sub.call(['./' + boot, 'user', user, code]) new(control.read_record("username", "/tmp/su.tmp"), control.read_record("code", "/tmp/su.tmp")) if files.isfile("/tmp/su.tmp"): files.remove("/tmp/su.tmp")
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", "")
def __init__(self, ports): super(LoginWidget, self).__init__() ## ports ## self.Backend = ports[0] self.Env = ports[1] ###### loginw_bgcolor = getdata('loginw.bgcolor') loginw_fgcolor = getdata('loginw.fgcolor') loginw_width = getdata('loginw.width') loginw_height = getdata('loginw.height') loginw_round = getdata('loginw.round') loginw_round_size = getdata('loginw.round-size') loginw_location = getdata('loginw.location') loginw_shadow = getdata('loginw.shadow') loginw_userlogo = getdata('loginw.userlogo') loginw_userlogo_shadow = getdata('loginw.userlogo.shadow') loginw_userlogo_color = getdata('loginw.userlogo.color') loginw_input_bgcolor = getdata('loginw.input.bgcolor') loginw_input_fgcolor = getdata('loginw.input.fgcolor') loginw_input_shadow = getdata('loginw.input.shadow') loginw_input_round = getdata('loginw.input.round') loginw_input_width = getdata('loginw.input.width') loginw_input_round_size = getdata('loginw.input.round-size') loginw_userlogo_round = getdata('loginw.userlogo.round') loginw_userlogo_round_size = getdata('loginw.userlogo.round-size') loginw_input_fontsize = getdata('loginw.input.fontsize') loginw_login_bgcolor = getdata('loginw.login.bgcolor') loginw_login_fgcolor = getdata('loginw.login.fgcolor') loginw_login_fontsize = getdata('loginw.login.fontsize') loginw_login_round = getdata('loginw.login.round') loginw_login_round_size = getdata('loginw.login.round-size') loginw_login_hide = getdata('loginw.login.hide') loginw_login_pressed_fgcolor = getdata('loginw.login.pressed-fgcolor') loginw_login_pressed_bgcolor = getdata('loginw.login.pressed-bgcolor') loginw_login_width = getdata('loginw.login.width') loginw_login_shadow = getdata('loginw.login.shadow') loginw_enter_bgcolor = getdata('loginw.enter.bgcolor') loginw_enter_fgcolor = getdata('loginw.enter.fgcolor') loginw_enter_fontsize = getdata('loginw.enter.fontsize') loginw_enter_round = getdata('loginw.enter.round') loginw_enter_round_size = getdata('loginw.enter.round-size') loginw_enter_hide = getdata('loginw.enter.hide') loginw_enter_pressed_fgcolor = getdata('loginw.enter.pressed-fgcolor') loginw_enter_pressed_bgcolor = getdata('loginw.enter.pressed-bgcolor') loginw_enter_width = getdata('loginw.enter.width') loginw_enter_shadow = getdata('loginw.enter.shadow') loginw_input_height = getdata('loginw.input.height') loginw_login_height = getdata('loginw.login.height') loginw_enter_height = getdata('loginw.enter.height') ## Check data ## if loginw_bgcolor == None: loginw_bgcolor = variables.loginw_bgcolor if loginw_input_height == None: loginw_input_height = variables.loginw_input_height else: loginw_input_height = int(loginw_input_height) if loginw_login_height == None: loginw_login_height = variables.loginw_login_height else: loginw_login_height = int(loginw_login_height) if loginw_enter_height == None: loginw_enter_height = variables.loginw_enter_height else: loginw_enter_height = int(loginw_enter_height) if loginw_login_width == None: loginw_login_width = variables.loginw_login_width else: loginw_login_width = int(loginw_login_width) if loginw_input_width == None: loginw_input_width = variables.loginw_input_width else: loginw_input_width = int(loginw_input_width) if loginw_enter_width == None: loginw_enter_width = variables.loginw_enter_width else: loginw_enter_width = int(loginw_enter_width) if loginw_fgcolor == None: loginw_fgcolor = variables.loginw_fgcolor if loginw_login_bgcolor == None: loginw_login_bgcolor = variables.loginw_login_bgcolor if loginw_login_fgcolor == None: loginw_login_fgcolor = variables.loginw_login_fgcolor if loginw_login_pressed_bgcolor == None: loginw_login_pressed_bgcolor = variables.loginw_login_pressed_bgcolor if loginw_login_pressed_fgcolor == None: loginw_login_pressed_fgcolor = variables.loginw_login_pressed_fgcolor if loginw_enter_bgcolor == None: loginw_enter_bgcolor = variables.loginw_enter_bgcolor if loginw_enter_fgcolor == None: loginw_enter_fgcolor = variables.loginw_enter_fgcolor if loginw_enter_pressed_bgcolor == None: loginw_enter_pressed_bgcolor = variables.loginw_enter_pressed_bgcolor if loginw_enter_pressed_fgcolor == None: loginw_enter_pressed_fgcolor = variables.loginw_enter_pressed_fgcolor if loginw_width == None: loginw_width = self.width() if loginw_height == None: loginw_height = self.height() if loginw_round_size == None: loginw_round_size = str(variables.loginw_round_size) + '% ' + str( variables.loginw_round_size) + '%' else: loginw_round_size = loginw_round_size.replace(' ', '% ') + '%' if loginw_userlogo_round_size == None: loginw_userlogo_round_size = str( variables.loginw_userlogo_round_size) + '% ' + str( variables.loginw_userlogo_round_size) + '%' else: loginw_userlogo_round_size = loginw_userlogo_round_size.replace( ' ', '% ') + '%' if loginw_input_round_size == None: loginw_input_round_size = str( variables.loginw_input_round_size) + '% ' + str( variables.loginw_input_round_size) + '%' else: loginw_input_round_size = loginw_input_round_size.replace( ' ', '% ') + '%' if loginw_login_round_size == None: loginw_login_round_size = str( variables.loginw_login_round_size) + '% ' + str( variables.loginw_login_round_size) + '%' else: loginw_login_round_size = loginw_login_round_size.replace( ' ', '% ') + '%' if loginw_enter_round_size == None: loginw_enter_round_size = str( variables.loginw_enter_round_size) + '% ' + str( variables.loginw_enter_round_size) + '%' else: loginw_enter_round_size = loginw_enter_round_size.replace( ' ', '% ') + '%' if loginw_round == 'Yes': loginw_round = loginw_round_size else: loginw_round = '0% 0%' if loginw_userlogo_round == 'Yes': loginw_userlogo_round = loginw_userlogo_round_size else: loginw_userlogo_round = '0% 0%' if loginw_input_round == 'Yes': loginw_input_round = loginw_input_round_size else: loginw_input_round = '0% 0%' if loginw_login_round == 'Yes': loginw_login_round = loginw_login_round_size else: loginw_login_round = '0% 0%' if loginw_enter_round == 'Yes': loginw_enter_round = loginw_enter_round_size else: loginw_enter_round = '0% 0%' if loginw_location == None: loginw_location = variables.loginw_location if loginw_input_fontsize == None: loginw_input_fontsize = variables.loginw_input_fontsize else: loginw_input_fontsize = int(loginw_input_fontsize) if loginw_login_fontsize == None: loginw_login_fontsize = variables.loginw_login_fontsize else: loginw_login_fontsize = int(loginw_login_fontsize) if loginw_login_hide == None: loginw_login_hide = variables.loginw_login_hide if loginw_enter_fontsize == None: loginw_enter_fontsize = variables.loginw_enter_fontsize else: loginw_enter_fontsize = int(loginw_enter_fontsize) if loginw_enter_hide == None: loginw_enter_hide = variables.loginw_enter_hide self.setMaximumSize(int(loginw_width), int(loginw_height)) ## Set size of loginw ## Locations ## if loginw_location == 'center': self.setGeometry( int(self.Env.width() / 2) - int(self.width() / 2), int(self.Env.height() / 2) - int(self.height() / 2), self.width(), self.height()) ## Geometric elif loginw_location == 'top': self.setGeometry( int(self.Env.width() / 2) - int(self.width() / 2), int(self.height() / 20), self.width(), self.height()) ## Geometric elif loginw_location == 'left': self.setGeometry( int(self.width() / 20), int(self.Env.height() / 2) - int(self.height() / 2), self.width(), self.height()) ## Geometric elif loginw_location == 'right': self.setGeometry( self.Env.width() - int(self.width() / 20) - self.width(), int(self.Env.height() / 2) - int(self.height() / 2), self.width(), self.height()) ## Geometric elif loginw_location == 'bottom': self.setGeometry( int(self.Env.width() / 2) - int(self.width() / 2), self.Env.height() - int(self.height() / 20) - self.height(), self.width(), self.height()) ## Geometric if loginw_shadow == None: loginw_shadow = variables.loginw_shadow if loginw_userlogo_shadow == None: loginw_userlogo_shadow = variables.loginw_userlogo_shadow if loginw_input_shadow == None: loginw_input_shadow = variables.loginw_input_shadow if loginw_login_shadow == None: loginw_login_shadow = variables.loginw_login_shadow if loginw_enter_shadow == None: loginw_enter_shadow = variables.loginw_enter_shadow if loginw_shadow == 'Yes': ## Shadow ## # Copy right shadow box: medium.com/@rekols/qt-button-box-shadow-property-c47c7bf58721 ## shadow = QGraphicsDropShadowEffect() shadow.setColor(QColor(10, 2, 34, 255 * 0.8)) shadow.setOffset(0) shadow.setBlurRadius(10) self.setGraphicsEffect(shadow) ## BackgroudcolorButton ## self.btnColorButton = QPushButton() self.btnColorButton.setGeometry(0, 0, self.width(), self.height()) self.layout().addWidget(self.btnColorButton) ## ## Set colors ## self.setStyleSheet('color:{0};border-radius:{1};'.replace( '{0}', loginw_fgcolor).replace( '{1}', loginw_round)) ## Set color white as default self.btnColorButton.setStyleSheet('background-color:{0};'.replace( '{0}', loginw_bgcolor)) ## Userlogo ## self.userlogo = QToolButton() ## Set size & location ## self.userlogo.setMaximumSize(250, 250) self.userlogo.setGeometry( int(self.width() / 2) - int(self.userlogo.width() / 2), int(self.height() / 4) - int(self.userlogo.height() / 4), self.userlogo.width(), self.userlogo.height()) if loginw_userlogo_color == None: loginw_userlogo_color = variables.userlogo_color if not loginw_userlogo == None: if self.Env.objectName() == 'Enter': logo = control.read_record('loginw.userlogo', '/etc/users/' + self.Env.username) if not logo == None: loginw_userlogo = logo self.userlogo.setStyleSheet( 'background-color: {0};border-radius: {1};background-image: url({2});' .replace('{0}', loginw_userlogo_color).replace( '{1}', loginw_userlogo_round).replace('{2}', res.get(loginw_userlogo))) ## Shadow for userlogo ## ## Shadow ## if loginw_userlogo_shadow == 'Yes': # Copy right shadow box: medium.com/@rekols/qt-button-box-shadow-property-c47c7bf58721 ## shadow = QGraphicsDropShadowEffect() shadow.setColor(QColor(10, 2, 34, 255 * 0.8)) shadow.setOffset(0) shadow.setBlurRadius(10) self.userlogo.setGraphicsEffect(shadow) ## Default userlogo ## self.layout().addWidget(self.userlogo) ## leInput username ## self.leInput = QLineEdit() ## Size & Location of leInput ## self.leInput.setMaximumSize(loginw_input_width, loginw_input_height) self.leInput.setGeometry( int(self.width() / 2) - int(self.leInput.width() / 2), self.height() - int(self.height() / 4) - self.leInput.height(), self.leInput.width(), self.leInput.height()) ## Shadow of leInput ## ## Shadow ## if loginw_input_shadow == 'Yes': # Copy right shadow box: medium.com/@rekols/qt-button-box-shadow-property-c47c7bf58721 ## shadow = QGraphicsDropShadowEffect() shadow.setColor(QColor(10, 2, 34, 255 * 0.8)) shadow.setOffset(0) shadow.setBlurRadius(10) self.leInput.setGraphicsEffect(shadow) ## Colors of leInput ## if loginw_input_bgcolor == None: loginw_input_bgcolor = variables.input_bgcolor if loginw_input_fgcolor == None: loginw_input_fgcolor = variables.input_fgcolor ## Setting up all colors ## self.leInput.setStyleSheet('background-color: ' + loginw_input_bgcolor + ';color: ' + loginw_input_fgcolor + ";border-width: 3%;border-radius: " + loginw_input_round) ## Place holder in input ## if self.Env.objectName() == 'Login': self.leInput.setPlaceholderText( res.get('@string/username_placeholder') ) # See https://stackoverflow.com/questions/24274318/placeholder-text-not-showing-pyside-pyqt else: self.leInput.setEchoMode(QLineEdit.Password) self.leInput.setPlaceholderText( res.get('@string/password_placeholder').replace( "{0}", self.Env.username)) ## Setting up font settings ## f = QFont() f.setPointSize(loginw_input_fontsize) self.leInput.setFont(f) ## Connect to action ## self.leInput.returnPressed.connect(self.actions) ## Add leInput Widget ## self.layout().addWidget(self.leInput) ## Enter button ## if self.Env.objectName() == 'Login': self.btnLogin = QPushButton() ## Shadow ## if loginw_login_shadow == 'Yes': ## Shadow ## # Copy right shadow box: medium.com/@rekols/qt-button-box-shadow-property-c47c7bf58721 ## shadow = QGraphicsDropShadowEffect() shadow.setColor(QColor(10, 2, 34, 255 * 0.8)) shadow.setOffset(0) shadow.setBlurRadius(10) self.btnLogin.setGraphicsEffect(shadow) self.btnLogin.clicked.connect(self.actions) print(loginw_login_round) self.btnLogin.setStyleSheet(''' QPushButton { background-color: ''' + loginw_login_bgcolor + """; color: """ + loginw_login_fgcolor + """; border-radius: """ + loginw_login_round + ''' } QPushButton:pressed { background-color:''' + loginw_login_pressed_bgcolor + '''; color:''' + loginw_login_pressed_fgcolor + '''; border-radius: ''' + loginw_login_round + '''; } ''') f = QFont() f.setPointSize(loginw_login_fontsize) self.btnLogin.setFont(f) if loginw_login_hide == 'Yes': self.btnLogin.hide() self.btnLogin.setText(res.get('@string/next_text')) self.btnLogin.setMaximumSize(loginw_login_width, loginw_login_height) self.btnLogin.setGeometry( int(self.width() / 2) - int(self.btnLogin.width() / 2), self.height() - int(self.height() / 4) - int(self.btnLogin.height() / 4) + int(self.btnLogin.height() / 2), self.btnLogin.width(), self.btnLogin.height()) self.layout().addWidget(self.btnLogin) else: self.btnEnter = QPushButton() ## Shadow ## if loginw_enter_shadow == 'Yes': ## Shadow ## # Copy right shadow box: medium.com/@rekols/qt-button-box-shadow-property-c47c7bf58721 ## shadow = QGraphicsDropShadowEffect() shadow.setColor(QColor(10, 2, 34, 255 * 0.8)) shadow.setOffset(0) shadow.setBlurRadius(10) self.btnEnter.setGraphicsEffect(shadow) self.btnEnter.clicked.connect(self.actions) self.btnEnter.setStyleSheet(''' QPushButton { background-color: ''' + loginw_enter_bgcolor + """; color: """ + loginw_enter_fgcolor + """; border-radius: """ + loginw_enter_round + ''' } QPushButton:pressed { background-color:''' + loginw_enter_pressed_bgcolor + '''; color:''' + loginw_enter_pressed_fgcolor + '''; border-radius: ''' + loginw_enter_round + '''; } ''') f = QFont() f.setPointSize(loginw_enter_fontsize) self.btnEnter.setFont(f) if loginw_enter_hide == 'Yes': self.btnEnter.hide() self.btnEnter.setText(res.get('@string/enter_text')) self.btnEnter.setMaximumSize(loginw_enter_width, loginw_enter_height) self.btnEnter.setGeometry( int(self.width() / 2) - int(self.btnEnter.width() / 2), self.height() - int(self.height() / 4) - int(self.btnEnter.height() / 4) + int(self.btnEnter.height() / 2), self.btnEnter.width(), self.btnEnter.height()) self.layout().addWidget(self.btnEnter)
def check(name, request, user): perm = get_permissions(name) perm = perm.split("/") perms = perm[0] owner = perm[1] dirfile = perms[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] if user == "root": ## Check exists user ## if files.isfile("/etc/users/" + user): hashname = hashlib.sha3_256(str("root").encode()).hexdigest() username = control.read_record("username", "/etc/users/root") if (hashname == username): return True else: return False else: return False elif user == "guest": enable_cli = control.read_record("enable_cli", "/etc/guest") if enable_cli == "Yes": if owner == user: if request == "r": r = user_r if r == "r": return True else: return False elif request == "w": w = user_w if w == "w": return True else: return False elif request == "x": x = user_x if x == "x": return True else: return False else: return False else: if request == "r": r = guest_r if r == "r": return True else: return False elif request == "w": w = guest_w if w == "w": return True else: return False elif request == "x": x = guest_x if x == "x": return True else: return False else: return False else: return False else: ## Check exists user ## if files.isfile("/etc/users/" + user): hashname = hashlib.sha3_256(str(user).encode()).hexdigest() username = control.read_record("username", "/etc/users/" + user) if (hashname == username): if owner == user: if request == "r": r = user_r if r == "r": return True else: return False elif request == "w": w = user_w if w == "w": return True else: return False elif request == "x": x = user_x if x == "x": return True else: return False else: return False else: if request == "r": r = others_r if r == "r": return True else: return False elif request == "w": w = others_w if w == "w": return True else: return False elif request == "x": x = others_x if x == "x": return True else: return False else: return False else: return False else: return False
def show (process_name,process_type,process_message): if process_type=="fail": print (get_fail()+process_name+": error: "+process_message+get_colors()) elif process_type=="ok": ok = control.read_record('ok','/etc/procmsg') if ok=='Yes': print(get_ok() + process_message + get_colors()) elif process_type=="perm": print(get_fail()+process_name+": error: " + "Permission denied." + get_colors()) elif process_type=="upgrade": repo = control.read_record('upgrade-mirror','/etc/repo') print(get_ok() + "Upgrade: "+get_colors()+" to lates version from ("+repo+") ...") elif process_type=="warning": print (get_warning()+process_name+": warning: "+process_message+get_colors()) elif process_type=="ok-start": if ( (argv=='kernel' and kernel=="Yes") or (argv == 'gui' and gui == "Yes") or (argv == 'gui-login' and gui_login == "Yes") or (argv == 'gui-user' and gui_user == "Yes") or (argv == 'login' and login == "Yes") or (argv == 'user' and user == "Yes") or (argv == 'exec' and exec == "Yes") ): print ("[ "+get_ok()+" OK "+get_colors()+" ] Start "+process_name+" process.") elif process_type=="ok-end": if ( (argv == 'kernel' and kernel == "Yes") or (argv == 'gui' and gui == "Yes") or (argv == 'gui-login' and gui_login == "Yes") or (argv == 'gui-user' and gui_user == "Yes") or (argv == 'login' and login == "Yes") or (argv == 'user' and user == "Yes") or (argv == 'exec' and exec == "Yes") ): print ("[ "+get_ok()+" OK "+get_colors()+" ] End "+process_name+" process.") elif process_type=="ok-switch": if ( (argv == 'kernel' and kernel == "Yes") or (argv == 'gui' and gui == "Yes") or (argv == 'gui-login' and gui_login == "Yes") or (argv == 'gui-user' and gui_user == "Yes") or (argv == 'login' and login == "Yes") or (argv == 'user' and user == "Yes") or (argv == 'exec' and exec == "Yes") ): print ("[ "+get_ok()+" OK "+get_colors()+" ] Switch "+process_name+" process.") elif process_type=="ok-endswitch": if ( (argv == 'kernel' and kernel == "Yes") or (argv == 'gui' and gui == "Yes") or (argv == 'gui-login' and gui_login == "Yes") or (argv == 'gui-user' and gui_user == "Yes") or (argv == 'login' and login == "Yes") or (argv == 'user' and user == "Yes") or (argv == 'exec' and exec == "Yes") ): print ("[ "+get_ok()+" OK "+get_colors()+" ] End "+process_name+" switched process.") elif process_type=="ok-id": if ( (argv == 'kernel' and kernel == "Yes") or (argv == 'gui' and gui == "Yes") or (argv == 'gui-login' and gui_login == "Yes") or (argv == 'gui-user' and gui_user == "Yes") or (argv == 'login' and login == "Yes") or (argv == 'user' and user == "Yes") or (argv == 'exec' and exec == "Yes") ): print ("[ "+get_ok()+" OK "+get_colors()+" ] Switch ID "+process_name+" process.") elif process_type=="ok-endid": if ( (argv == 'kernel' and kernel == "Yes") or (argv == 'gui' and gui == "Yes") or (argv == 'gui-login' and gui_login == "Yes") or (argv == 'gui-user' and gui_user == "Yes") or (argv == 'login' and login == "Yes") or (argv == 'user' and user == "Yes") or (argv == 'exec' and exec == "Yes") ): print ("[ "+get_ok()+" OK "+get_colors()+" ] End "+process_name+" ID process.") elif process_type=="fail-start": print ("[ "+get_fail()+"FAIL "+get_colors()+"] Fail to start "+process_name+" process.") elif process_type=="fail-switch": print ("[ "+get_fail()+"FAIL "+get_colors()+"] Fail to switch "+process_name+" process.") elif process_type=="stop": print ("[ "+get_fail()+"STOP"+get_colors()+" ] Stop the "+process_name) elif process_type=="ok-show": print("[ " + get_ok() + " OK " + get_colors() + " ] "+process_message) elif process_type=="fail-show": print ("[ "+get_fail()+"FAIL"+get_colors()+" ] "+process_message) elif process_type=="poweron": if ( (argv == 'kernel' and kernel == "Yes") or (argv == 'gui' and gui == "Yes") or (argv == 'gui-login' and gui_login == "Yes") or (argv == 'gui-user' and gui_user == "Yes") or (argv == 'login' and login == "Yes") or (argv == 'user' and user == "Yes") or (argv == 'exec' and exec == "Yes") ): print ("[ "+get_ok()+" OK "+get_colors()+" ] Power on the "+process_name) elif process_type=="poweroff": if ( (argv == 'kernel' and kernel == "Yes") or (argv == 'gui' and gui == "Yes") or (argv == 'gui-login' and gui_login == "Yes") or (argv == 'gui-user' and gui_user == "Yes") or (argv == 'login' and login == "Yes") or (argv == 'user' and user == "Yes") or (argv == 'exec' and exec == "Yes") ): print ("[ "+get_ok()+" OK "+get_colors()+" ] Power off the "+process_name) elif process_type=="reboot": print ("[ "+get_ok()+" OK "+get_colors()+" ] Restart the "+process_name)
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: strcmdln = strcmdln + " " + i else: strcmdln = strcmdln + " " + var else: strcmdln = strcmdln + " " + i cmdln = strcmdln.split(" ") cmdln.remove('') cmd = "" for j in cmdln: cmd = cmd + " " + j if (cmdln == [] or cmdln[0] == "" or cmdln[0] == " " or cmd.startswith("#")
files.write("/proc/info/su", 'root') prompt = ['./' + files.readall('/proc/info/boot'), 'exec'] for i in sys.argv[1:]: prompt.append(i) subprocess.call(prompt) files.write("/proc/info/su", thisuser) elif sys.argv[1] == '-a': ## Check root ## if not permissions.check_root(files.readall("/proc/info/su")): colors.show("sudo", "perm", "") sys.exit(0) ## Check user exists or no ## if files.isfile('/etc/users/' + sys.argv[2]): hashname = hashlib.sha3_256(sys.argv[2].encode()).hexdigest() username = control.read_record('username', '/etc/users/' + sys.argv[2]) if hashname == username: files.append('/etc/sudoers', sys.argv[2] + "\n") colors.show('', 'ok', 'Add \'' + sys.argv[2] + '\' user account in sudoers.') else: colors.show('sudo', 'fail', sys.argv[2] + ": user not found.") else: colors.show('sudo', 'fail', sys.argv[2] + ": user not found.") else: colors.show('sudo', 'fail', sys.argv[1] + ": option not found.")
def unpack(name): if permissions.check_root(files.readall("/proc/info/su")): ## unpack package ## shutil.unpack_archive(files.input(name), files.input("/app/cache/archives/build"), "zip") shutil.unpack_archive( files.input("/app/cache/archives/build/data.tar.xz"), files.input("/app/cache/archives/data"), "xztar") shutil.unpack_archive( files.input("/app/cache/archives/build/control.tar.xz"), files.input("/app/cache/archives/control"), "xztar") ## Get database of this package ## name = control.read_record( "name", "/app/cache/archives/control/manifest").lower() unpack = control.read_record("unpack", "/app/cache/archives/control/manifest") depends = control.read_record("depends", "/app/cache/archives/control/manifest") if not (depends == None): depends.split(",") ## Search for tree dependency ## if not depends == None: for i in depends: if not files.isfile("/app/packages/" + i + ".manifest"): core.system('paye -i ' + name) ## Write dependency ## if not depends == None: for i in depends: files.create("/app/packages/" + i + ".depends") files.write("/app/packages/" + i + ".depends", name + "\n") ## Run preinstall script ## if files.isfile('/app/cache/archives/control/preinstall.py'): files.compile('/app/cache/archives/control/preinstall.py', '/usr/bin/preinstall.pyc') core.system('preinstall') # Run it files.remove('/usr/bin/preinstall.pyc') ## Copy preinstall script ## files.copy('/app/cache/archives/control/preinstall.py', '/app/packages/' + name + ".preinstall") ## Setting up ## if files.isfile("/app/cache/archives/control/list"): files.copy("/app/cache/archives/control/list", "/app/packages/" + name + ".list") if files.isfile("/app/cache/archives/control/manifest"): files.copy("/app/cache/archives/control/manifest", "/app/packages/" + name + ".manifest") ## Unpack data again ## shutil.unpack_archive( files.input("/app/cache/archives/build/data.tar.xz"), files.input(unpack), "xztar") ## After install ## ## Run postinstall script ## if files.isfile('/app/cache/archives/control/postinstall.py'): files.compile('/app/cache/archives/control/postinstall.py', '/usr/bin/postinstall.pyc') core.system('postinstall') # Run it files.remove('/usr/bin/postinstall.pyc') ## Copy preinstall script ## files.copy('/app/cache/archives/control/postinstall.py', '/app/packages/' + name + ".postinstall") ## Copy other scripts ## if files.isfile('/app/cache/archives/control/preremove.py'): files.copy('/app/cache/archives/control/preremove.py', '/app/packages/' + name + ".preremove") if files.isfile('/app/cache/archives/control/postremove.py'): files.copy('/app/cache/archives/control/postremove.py', '/app/packages/' + name + ".postremove") ## Unlock the cache ## else: colors.show("libpa.unpack", "perm", "")