install

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

commit 6a0eb4f6e9bc4d6875d7036a77d43a84295f361c
parent 6576ff5e052d34d264665fecde6e605585d8005d
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Thu,  1 Dec 2016 15:32:13 +0100

Fix(Checksums): Better way to check package integrity

Diffstat:
Mpkgs/binutils_p1/binutils_p1.py | 1-
Mscreens/install/install.py | 27++++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/pkgs/binutils_p1/binutils_p1.py b/pkgs/binutils_p1/binutils_p1.py @@ -37,7 +37,6 @@ class Binutils_P1: "version": "2.27", # Version of the package "size": 519, # Size of the installed package (MB) "archive": "binutils-2.27.tar.bz2", # Archive name - "cheksum": "2869c9bf3e60ee97c74ac2a6bf4e9d68", # Checksum of the archive "SBU": 1, # SBU (Compilation time) "tmp_install": True, # Is this package part of the temporary install "next": False, # Next package to install diff --git a/screens/install/install.py b/screens/install/install.py @@ -38,6 +38,9 @@ class Install: pkgs = {} # Packages instances mnt_point = "/mnt/morphux" # Install mount point arch_dir = "/opt/packages/" # Archive directory + sums_url = "https://install.morphux.org/packages/CHECKSUMS" # checksums url + sum_file = "CHECKSUMS" + checksums = {} # Object of packages sums m_gauge = {} # Object used for easy progress install ## @@ -324,6 +327,7 @@ class Install: to_check = len(pkg_list) # Number of package to check checked = 1 # Numbers of package checked + self.get_checksums() # Start the gauge self.dlg.gauge_start("Checking integrity of "+ str(to_check) +" packages ...", width=50) @@ -340,7 +344,7 @@ class Install: arch_sum = arch_sum.split(" ")[0] # Checking the sum - if arch_sum != pkg[1]["cheksum"]: + if arch_sum != self.checksums[pkg[1]["archive"]]: # The sum is wrong, we warn the user, and we abort self.dlg.msgbox("The integrity of package "+ pkg[1]["name"]+ " is wrong ! Aborting ...") @@ -353,6 +357,27 @@ class Install: # Stop the gauge self.dlg.gauge_stop() + # This function parse the checksums file, and if the is not here, + # get it from the install.morphux.org server + def get_checksums(self): + # Test if the file is already there + try: + fd = open(self.sum_file, 'r') + + except IOError: + # If not, we retrieve it from the server + urlretrieve(self.sums_url, self.sum_file) + fd = open(self.sum_file, 'r') + + # Getting the file content + content = fd.readlines() + + # Iterating over each line + for line in content: + line = line.strip("\n").split(" ") + self.checksums[line[1]] = line[0] + + # 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]