install

installer
Log | Files | Refs | README | LICENSE | git clone https://git.ne02ptzero.me/git/install

commit 713d4d8b694bb7ad3c6bb0bf73a26836401a83dd
parent 3d52be71673244a1f3b540583b7ca11ebec13466
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Tue, 25 Oct 2016 15:32:25 +0200

Add(Partitions): Now handling partitions

Diffstat:
Mexample_output.json | 1-
Mscreen.py | 3+--
Mscreens/config/config.py | 50+++++++++++++++++++++++++++++++++++++++++++++++---
Mscreens/main/main.py | 6+++---
Ascreens/partitions/__init__.py | 0
Ascreens/partitions/partitions.py | 144+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 195 insertions(+), 9 deletions(-)

diff --git a/example_output.json b/example_output.json @@ -5,7 +5,6 @@ "users": [ { "name": "louis", - "group": "louis", "password": "password" } ] diff --git a/screen.py b/screen.py @@ -209,11 +209,10 @@ class Screen: if (quit != self.curr_screen.config["id"]): win.erase() self.change_screen(quit) + c_input = 0 if self.curr_screen.config["type"] == "input": conf = self.curr_screen.config["input"][c_input] input.s_input(win, conf["title"], conf["default"], conf["function"], conf["type"]) - else: - c_input = 0 self.curr_screen.refresh(win) win.border() self.stdscr.refresh() diff --git a/screens/config/config.py b/screens/config/config.py @@ -56,7 +56,29 @@ class Config: "default": "", "type": "password", "function": self.root_p2 - } + }, + { + "name": "user", + "title": "SET YOUR USERNAME", + "default": "user", + "type": "text", + "function": self.username + }, + { + "name": "userp1", + "title": "USER PASSWORD", + "default": "", + "type": "password", + "function": self.user_p1 + }, + { + "name": "root2", + "title": "CONFIRM USER PASSWORD", + "default": "", + "type": "password", + "function": self.user_p2 + }, + ] } @@ -78,15 +100,37 @@ class Config: return 0 self.root_p = string return 1 - + def root_p2(self, string): if string != self.root_p: self.main.error("Passwords did not match !"); return -1 - self.quit = 0 self.main.config("system.root_p", string) return 1 + def username(self, string): + if len(string) == 0: + self.main.error("Username cannot be empty."); + return 0 + self.main.config("system.username", string) + return 1 + + def user_p1(self, string): + if len(string) == 0: + self.main.error("Password cannot be empty."); + return 0 + self.root_p = string + return 1 + + def user_p2(self, string): + if string != self.root_p: + self.main.error("Passwords did not match !"); + return -1 + self.quit = 2 + self.main.config("system.user_p", string) + return 1 + + def reset(self): self.quit = 1 diff --git a/screens/main/main.py b/screens/main/main.py @@ -25,7 +25,7 @@ import curses class Main: key = 0 - menu_s = ["INSTALL", "INSTALL 64BITS", "OPTIONS", "QUIT"] + menu_s = ["INSTALL", "BOOT", "LAUNCH SHELL", "OPTIONS", "QUIT"] menu_choice = 0 quit = 0 main = 0 @@ -73,7 +73,7 @@ class Main: def refresh(self, win): size = win.getmaxyx() if (size[0] > 10): - self.menu((size[0] / 2) - (len(self.menu_s) / 2) - 1, win, 1); + self.menu((size[0] / 2) - (len(self.menu_s) / 2) - 2, win, 1); else: - self.menu((size[0] / 2) - (len(self.menu_s) / 2) - 1, win, 0); + self.menu((size[0] / 2) - (len(self.menu_s) / 2) - 2, win, 0); return self.quit diff --git a/screens/partitions/__init__.py b/screens/partitions/__init__.py diff --git a/screens/partitions/partitions.py b/screens/partitions/partitions.py @@ -0,0 +1,144 @@ +################################### LICENSE #################################### +# Copyright 2016 Louis Solofrizzo # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +## +# partitions.py +# Created: 25/10/2016 +# By: Louis Solofrizzo <louis@morphux.org> +## + +import curses +import os.path +import stat + +class Partitions: + + key = 0 + quit = 2 + main = 0 + + def init(self, main): + self.main = main + self.config = { + "id": 2, + "title": "Partitions", + "type": "input", + "input": [ + { + "name": "disk", + "title": "ENTER DISK NAME", + "default": "/dev/sda", + "type": "text", + "function": self.disk + }, + { + "name": "grub", + "title": "ENTER GRUB PARTITION", + "default": "1", + "type": "text", + "function": self.grub + }, + { + "name": "root", + "title": "ENTER ROOT PARTITION", + "default": "2", + "type": "text", + "function": self.root + }, + { + "name": "swap", + "title": "ENTER SWAP PARTITION", + "default": "3", + "type": "text", + "function": self.swap + }, + { + "name": "boot", + "title": "ENTER BOOT PARTITION", + "default": "4", + "type": "text", + "function": self.boot + }, + { + "name": "home", + "title": "ENTER HOME PARTITION", + "default": "5", + "type": "text", + "function": self.home + }, + ] + } + return self.config + + def exist(self, string): + try: + return stat.S_ISBLK(os.stat(string).st_mode) + except: + return False + + def disk(self, string): + if self.exist(string): + self.main.config("partitions.disk", string) + self.config["input"][1]["default"] = string + self.config["input"][1]["default"] + self.config["input"][2]["default"] = string + self.config["input"][2]["default"] + self.config["input"][3]["default"] = string + self.config["input"][3]["default"] + self.config["input"][4]["default"] = string + self.config["input"][4]["default"] + self.config["input"][5]["default"] = string + self.config["input"][5]["default"] + return 1 + self.main.error("Disk " + string + " cannot be found") + return 0 + + def grub(self, string): + if self.exist(string): + self.main.config("partitions.grub", string) + return 1 + self.main.error("Partition " + string + " cannot be found") + return 0 + + def root(self, string): + if self.exist(string): + self.main.config("partitions.root", string) + return 1 + self.main.error("Partition " + string + " cannot be found") + return 0 + + def swap(self, string): + if self.exist(string): + self.main.config("partitions.swap", string) + return 1 + self.main.error("Partition " + string + " cannot be found") + return 0 + + def boot(self, string): + if self.exist(string): + self.main.config("partitions.boot", string) + return 1 + self.main.error("Partition " + string + " cannot be found") + return 0 + + def home(self, string): + if self.exist(string): + self.main.config("partitions.home", string) + return 1 + self.quit = 0 + self.main.error("Partition " + string + " cannot be found") + return 0 + + def reset(self): + self.quit = 2 + + def refresh(self, win): + return self.quit