install

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

commit 89523ec732a064eee49b7166b3bc3f42e859fd21
parent 0b1101498fa9446a423b847adf9eb2a383073b24
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Wed, 30 Nov 2016 18:37:14 +0100

Add(Package installation): First draft of multiples package installation:

TODO: Estimated time
Add all the LFS p1 packages
Handle patches download / verification

Diffstat:
Mpkgs/binutils_p1/binutils_p1.py | 36++++++++++++++++++++++++++++++++++--
Mscreens/install/install.py | 146++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 176 insertions(+), 6 deletions(-)

diff --git a/pkgs/binutils_p1/binutils_p1.py b/pkgs/binutils_p1/binutils_p1.py @@ -20,14 +20,18 @@ # By: Louis Solofrizzo <louis@morphux.org> ## +import os + class Binutils_P1: conf_lst = {} e = False + root_dir = "" - def init(self, c_lst, ex): + def init(self, c_lst, ex, root_dir): self.conf_lst = c_lst self.e = ex + self.root_dir = root_dir self.config = { "name": "binutils", # Name of the package "version": "2.27", # Version of the package @@ -36,10 +40,38 @@ class Binutils_P1: "cheksum": "2869c9bf3e60ee97c74ac2a6bf4e9d68", # Checksum of the archive "SBU": 1, # SBU (Compilation time) "tmp_install": True, # Is this package part of the temporary install - "next": "test2", # Next package to install + "next": False, # Next package to install + "after": False, "urls": [ # Url to download the package. The first one must be morphux servers "https://install.morphux.org/packages/binutils-2.27.tar.bz2", "http://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.bz2", ] } return self.config + + def before(self): + self.e(["mkdir", "-v", "build"]) + os.chdir("build") + return 0 + + def configure(self): + self.e(["../configure", + "--prefix=/tools", + "--with-sysroot="+ self.root_dir, + "--with-lib-path=/tools/lib", + "--target="+ self.conf_lst["target"], + "--disable-nls", + "--disable-werror" + ]) + return 0 + + def make(self): + self.e(["make"]) + return 0 + + 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 diff --git a/screens/install/install.py b/screens/install/install.py @@ -37,7 +37,8 @@ class Install: modules = {} # Module object pkgs = {} # Packages instances mnt_point = "/mnt/morphux" # Install mount point - arch_dir = "/opt/packages/" + arch_dir = "/opt/packages/" # Archive directory + m_gauge = {} # Object used for easy progress install ## # Functions @@ -64,10 +65,14 @@ class Install: with open("morphux_install.conf", "w") as fd: 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" + # 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): @@ -119,7 +124,7 @@ class Install: print("Reading info on "+ name +" ...", end="") klass = klass() # Calling the init function of each package - config = klass.init(self.conf_lst, self.exec) + config = klass.init(self.conf_lst, self.exec, self.mnt_point) # Saving the configuration of the object self.pkgs[config["name"]] = [klass, config] print("\tDone !") @@ -265,6 +270,8 @@ class Install: pkg_phase_1[name] = pkg self.pkg_download(pkg_phase_1) + self.inst_title = "Phase 1: Temporary" + self.install(pkg_phase_1, "binutils") # This function take an object of packages, check if the sources are there. # If they aren't, the function download them. @@ -345,3 +352,134 @@ class Install: # Stop the gauge self.dlg.gauge_stop() + + # This function launch the install of packages in lst, by compilation + # lst is an object of all the packages with the name in key and a list + # in value. The list is format like: [config_object, class_object] + # first is a string argument used to begin the install by a package. + # Then, the next package is defined in config["next"] + def install(self, lst, first): + pkg = [p for k, p in lst.items() if p[1]["name"] == first][0] + to_install = len(lst) # Len of package to install + installed = 1 + + while pkg != False: + # Init the global progress bar + self.global_progress_bar(text="Installing "+ pkg[1]["name"] +"-"+ pkg[1]["version"], + percent=int((to_install * 100) / installed), + decomp="In Progress", conf="N/A", comp="N/A", + inst="N/A", post_comp="N/A", pre_comp="N/A") + + # Decompress the archive + self.untar(pkg[1]) + + self.global_progress_bar(decomp="Done", pre_comp="In Progress") + + # Before instructions + if "before" not in pkg[1]: + pkg[0].before() + self.global_progress_bar(pre_comp="Done") + else: + self.global_progress_bar(pre_comp="Skipped") + + self.global_progress_bar(conf="In Progress") + # ./configure instructions + if "configure" not in pkg[1]: + pkg[0].configure() + self.global_progress_bar(conf="Done") + else: + self.global_progress_bar(conf="Skipped") + + self.global_progress_bar(comp="In Progress") + # make instructions + if "make" not in pkg[1]: + pkg[0].make() + self.global_progress_bar(comp="Done") + else: + self.global_progress_bar(comp="Skipped") + + self.global_progress_bar(inst="In Progress") + # make install instructions + if "install" not in pkg[1]: + pkg[0].install() + self.global_progress_bar(inst="Done") + else: + self.global_progress_bar(inst="Skipped") + + self.global_progress_bar(post_comp="In Progress") + # after instructions + if "after" not in pkg[1]: + pkg[0].after() + self.global_progress_bar(post_comp="Done") + else: + self.global_progress_bar(post_comp="Skipped") + + self.global_progress_bar(reset=True) + if pkg[1]["next"] in lst: + pkg = lst[pkg[1]["next"]] + else: + pkg = False + installed += 1 + return 0 + + # This function take a package configuration, and untar an archive in + # self.arch_dir directory, then chdir inside. + def untar(self, conf): + # Chdir in the archives directory + os.chdir(self.arch_dir) + + # Un-taring the archive + self.exec(["tar", "xf", conf["archive"]]) + + # Chdir into the decompressed directory (Must be in the format name-version) + os.chdir(conf["name"] + "-" + conf["version"]) + + # Function that display the global progress bar for an install + def global_progress_bar(self, text="", percent=-1, decomp="", + pre_comp="", conf="", comp="", inst="", post_comp="", reset=False): + + # Setting the text + if text != "": + self.m_gauge["text"] = text + + # Setting the percents + if percent != -1: + self.m_gauge["percent"] = percent + + # Setting the decompression status + if decomp != "": + self.m_gauge["decomp"] = decomp + + # Setting the pre compilation status + if pre_comp != "": + self.m_gauge["pre_comp"] = pre_comp + + # Setting the configuration status + if conf != "": + self.m_gauge["conf"] = conf + + # Setting the compilation status + if comp != "": + self.m_gauge["comp"] = comp + + # Setting the installation status + if inst != "": + self.m_gauge["inst"] = inst + + # Setting the post compilation status + if post_comp != "": + self.m_gauge["post_comp"] = post_comp + + if reset != False: + self.m_gauge = {} + return 0 + + self.dlg.mixedgauge(self.m_gauge["text"], percent=self.m_gauge["percent"], + elements = [ + ("Decompressing", self.m_gauge["decomp"]), + ("Pre-Compilation", self.m_gauge["pre_comp"]), + ("Configuration", self.m_gauge["conf"]), + ("Compilation", self.m_gauge["comp"]), + ("Installation", self.m_gauge["inst"]), + ("Post-Compilation", self.m_gauge["post_comp"]), + ], title=self.inst_title)