install

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

commit fa3d2e1744cedac60a04d0ec0e8fb25689d9e819
parent 6a0eb4f6e9bc4d6875d7036a77d43a84295f361c
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Thu,  1 Dec 2016 16:01:07 +0100

Fix(Installation): Now handling installation error

Diffstat:
Mpkgs/binutils_p1/binutils_p1.py | 13+++++--------
Mscreens/install/install.py | 40+++++++++++++++++++++++++++++-----------
2 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/pkgs/binutils_p1/binutils_p1.py b/pkgs/binutils_p1/binutils_p1.py @@ -49,12 +49,12 @@ class Binutils_P1: return self.config def before(self): - self.e(["mkdir", "-v", "build"]) + res = self.e(["mkdir", "-v", "build"]) os.chdir("build") - return 0 + return res def configure(self): - self.e(["../configure", + return self.e(["../configure", "--prefix=/tools", "--with-sysroot="+ self.root_dir, "--with-lib-path=/tools/lib", @@ -62,15 +62,12 @@ class Binutils_P1: "--disable-nls", "--disable-werror" ]) - return 0 def make(self): - self.e(["make"]) - return 0 + return self.e(["make"]) def install(self): if self.conf_lst["arch"] == "x86_64": self.e(["mkdir", "-v", "/tools/lib"]) self.e(["ln", "-sv", "lib", "/tools/lib64"]) - self.e(["make", "install"]) - return 0 + return self.e(["make", "install"]) diff --git a/screens/install/install.py b/screens/install/install.py @@ -69,13 +69,13 @@ class Install: json.dump(self.conf_lst, fd) # Get target architecture - self.conf_lst["arch"] = self.exec(["uname", "-m"]).decode().split("\n")[0] - self.conf_lst["target"] = self.exec(["uname", "-m"]).decode().split("\n")[0] + "-morphux-linux-gnu" + self.conf_lst["arch"] = self.exec(["uname", "-m"])[0].decode().split("\n")[0] + self.conf_lst["target"] = self.exec(["uname", "-m"])[0].decode().split("\n")[0] + "-morphux-linux-gnu" # Load packages files self.load_pkgs() - self.phase_1_install() - sys.exit(1) + #self.phase_1_install() + #sys.exit(1) # If a pre-existing install is present, format it if os.path.isdir(self.mnt_point): @@ -221,7 +221,7 @@ class Install: out = p.communicate(input=input)[0] else: out = p.communicate()[0] - return out + return out, p.returncode # Function that mount the partitions for install # self.mnt_point is used for the mount point. @@ -340,7 +340,7 @@ class Install: pkg_content = fd.read() # Get the sum of the archive - arch_sum = self.exec(["md5sum"], input=bytes(pkg_content)).decode() + arch_sum = self.exec(["md5sum"], input=bytes(pkg_content))[0].decode() arch_sum = arch_sum.split(" ")[0] # Checking the sum @@ -402,7 +402,9 @@ class Install: # Before instructions if "before" not in pkg[1]: - pkg[0].before() + res = pkg[0].before() + if res[1] != 0: + self.inst_error(res) self.global_progress_bar(pre_comp="Done") else: self.global_progress_bar(pre_comp="Skipped") @@ -410,7 +412,9 @@ class Install: self.global_progress_bar(conf="In Progress") # ./configure instructions if "configure" not in pkg[1]: - pkg[0].configure() + res = pkg[0].configure() + if res[1] != 0: + self.inst_error(res) self.global_progress_bar(conf="Done") else: self.global_progress_bar(conf="Skipped") @@ -418,7 +422,9 @@ class Install: self.global_progress_bar(comp="In Progress") # make instructions if "make" not in pkg[1]: - pkg[0].make() + res = pkg[0].make() + if res[1] != 0: + self.inst_error(res) self.global_progress_bar(comp="Done") else: self.global_progress_bar(comp="Skipped") @@ -426,7 +432,9 @@ class Install: self.global_progress_bar(inst="In Progress") # make install instructions if "install" not in pkg[1]: - pkg[0].install() + res = pkg[0].install() + if res[1] != 0: + self.inst_error(res) self.global_progress_bar(inst="Done") else: self.global_progress_bar(inst="Skipped") @@ -434,7 +442,9 @@ class Install: self.global_progress_bar(post_comp="In Progress") # after instructions if "after" not in pkg[1]: - pkg[0].after() + res = pkg[0].after() + if res[1] != 0: + self.inst_error(res) self.global_progress_bar(post_comp="Done") else: self.global_progress_bar(post_comp="Skipped") @@ -508,3 +518,11 @@ class Install: ("Installation", self.m_gauge["inst"]), ("Post-Compilation", self.m_gauge["post_comp"]), ], title=self.inst_title) + + # Function that handle installation error + # exec_return arg is a tuple of (string_out, return_code) + def inst_error(self, exec_return): + code = self.dlg.yesno("An error happened during the installation :(\nDo you want to see the log file ?") + if code == "ok": + self.dlg.scrollbox(exec_return[0].decode()) + sys.exit(1)