示例#1
0
 def _add_patches_to_packages(self, package_manifest, patches):
     if patches is not None and len(patches) >= 1:
         log.info('Adding patches to package list')
         for p in patches:
             # We'll skip if patch meta data is incomplete
             if hasattr(p, 'ready') is False:
                 continue
             if hasattr(p, 'ready') and p.ready is False:
                 continue
             for pm in package_manifest:
                 #
                 if p.dst_filename == pm.filename:
                     pm.patch_info['patch_name'] = \
                         os.path.basename(p.patch_name)
                     # Don't try to get hash on a ghost file
                     if not os.path.exists(p.patch_name):
                         p_name = ''
                         p_size = 0
                     else:
                         p_name = gph(p.patch_name)
                         p_size = in_bytes(p.patch_name)
                     pm.patch_info['patch_hash'] = p_name
                     pm.patch_info['patch_size'] = p_size
                     # No need to keep searching
                     # We have the info we need for this patch
                     break
                 else:
                     log.debug('No patch match found')
     else:
         if self.patch_support is True:
             log.warning('No patches found')
     return package_manifest
示例#2
0
 def _add_patches_to_packages(self, package_manifest, patches):
     if patches is not None and len(patches) >= 1:
         log.debug('Adding patches to package list')
         for p in patches:
             # We'll skip if patch meta data is incomplete
             if hasattr(p, 'ready') is False:
                 continue
             if hasattr(p, 'ready') and p.ready is False:
                 continue
             for pm in package_manifest:
                 #
                 if p.dst_filename == pm.filename:
                     pm.patch_info['patch_name'] = \
                         os.path.basename(p.patch_name)
                     # Don't try to get hash on a ghost file
                     if not os.path.exists(p.patch_name):
                         p_name = ''
                         p_size = 0
                     else:
                         p_name = gph(p.patch_name)
                         p_size = in_bytes(p.patch_name)
                     pm.patch_info['patch_hash'] = p_name
                     pm.patch_info['patch_size'] = p_size
                     # No need to keep searching
                     # We have the info we need for this patch
                     break
                 else:
                     log.debug('No patch match found')
     else:
         if self.patch_support is True:
             log.debug('No patches found')
     return package_manifest
示例#3
0
    def _get_package_list(self, report_errors):
        # Adds compatible packages to internal package manifest
        # for further processing
        # Process all packages in new folder and gets
        # url, hash and some outer info.
        log.info("Generating package list")
        # Clears manifest if sign updates runs more the once without
        # app being restarted
        package_manifest = []
        patch_manifest = []
        bad_packages = []
        with ChDir(self.new_dir):
            # Getting a list of all files in the new dir
            packages = os.listdir(os.getcwd())
            for p in packages:
                # On package initialization we do the following
                # 1. Check for a supported archive
                # 2. get required info: version, platform, hash
                # If any check fails new_pkg.info['status'] will be False
                # You can query new_pkg.info['reason'] for the reason
                new_pkg = Package(p)
                if new_pkg.info["status"] is False:
                    # Package failed at something
                    # new_pkg.info['reason'] will tell why
                    bad_packages.append(new_pkg)
                    continue

                # Add package hash
                new_pkg.file_hash = gph(new_pkg.filename)
                new_pkg.file_size = in_bytes(new_pkg.filename)

                PackageHandler._update_file_list(self.version_data, new_pkg)

                package_manifest.append(new_pkg)
                PackageHandler._add_package_to_config(new_pkg, self.config)

                if self.patch_support:
                    data = {
                        "filename": p,
                        "files_dir": self.files_dir,
                        "new_dir": self.new_dir,
                        "json_data": self.version_data,
                        "pkg_info": new_pkg,
                        "config": self.config,
                    }
                    _patch = Patch(**data)

                    if _patch.ok:
                        patch_manifest.append(_patch)

        if report_errors is True:  # pragma: no cover
            log.warning("Bad package & reason for being naughty:")
            for b in bad_packages:
                log.warning(b.name, b.info["reason"])

        return package_manifest, patch_manifest
示例#4
0
    def _add_patches_to_packages(package_manifest, patches, patch_support):
        if patches is not None and len(patches) >= 1:
            log.debug("Adding patches to package list")
            for p in patches:
                if not p.ok or not os.path.exists(p.patch_name):
                    continue

                log.debug("We have a good patch: %s", p)
                for pm in package_manifest:
                    if p.dst_filename == pm.filename:
                        pm.patch = p
                        pm.patch.hash = gph(pm.patch.patch_name)
                        pm.patch.size = in_bytes(pm.patch.patch_name)
                        break
                    else:
                        log.debug("No patch match found")
        else:
            if patch_support is True:
                log.debug("No patches found: %s", patches)
示例#5
0
    def _get_package_list(self, report_errors):
        # Adds compatible packages to internal package manifest
        # for futher processing
        # Process all packages in new folder and gets
        # url, hash and some outer info.
        log.info('Getting package list')
        # Clears manifest if sign updates runs more the once without
        # app being restarted
        package_manifest = []
        patch_manifest = []
        bad_packages = []
        with ChDir(self.new_dir):
            # Getting a list of all files in the new dir
            packages = os.listdir(os.getcwd())
            for p in packages:
                # On package initialization we do the following
                # 1. Check for a supported archive
                # 2. get required info: version, platform, hash
                # If any check fails package.info['status'] will be False
                # You can query package.info['reason'] for the reason
                package = Package(p)
                if package.info['status'] is False:
                    # Package failed at something
                    # package.info['reason'] will tell why
                    bad_packages.append(package)
                    continue

                # Add package hash
                package.file_hash = gph(package.filename)
                package.file_size = in_bytes(package.filename)
                self.json_data = self._update_file_list(
                    self.json_data, package)

                package_manifest.append(package)
                self.config = self._add_package_to_config(package, self.config)

                if self.patch_support:
                    # If channel is not stable skip patch creation
                    if package.channel != 'stable':
                        log.debug(
                            'Package %s not on stable channel: '
                            'Skipping', p)
                        continue
                    # Will check if source file for patch exists
                    # if so will return the path and number of patch
                    # to create. If missing source file None returned
                    path = self._check_make_patch(
                        self.json_data,
                        package.name,
                        package.platform,
                    )
                    if path is not None:
                        log.info('Found source file to create patch')
                        patch_name = package.name + '-' + package.platform
                        src_path = path[0]
                        patch_number = path[1]
                        patch_info = dict(src=src_path,
                                          dst=os.path.abspath(p),
                                          patch_name=os.path.join(
                                              self.new_dir, patch_name),
                                          patch_num=patch_number,
                                          package=package.filename)
                        # ready for patching
                        patch_manifest.append(patch_info)
                    else:
                        log.warning('No source file to patch from')

        # ToDo: Expose this & remove "pragma: no cover" once done
        if report_errors is True:  # pragma: no cover
            log.warning('Bad package & reason for being naughty:')
            for b in bad_packages:
                log.warning(b.name, b.info['reason'])
        # End ToDo

        return package_manifest, patch_manifest
示例#6
0
    def _get_package_list(self, report_errors):
        # Adds compatible packages to internal package manifest
        # for futher processing
        # Process all packages in new folder and gets
        # url, hash and some outer info.
        log.info('Generating package list')
        # Clears manifest if sign updates runs more the once without
        # app being restarted
        package_manifest = []
        patch_manifest = []
        bad_packages = []
        with ChDir(self.new_dir):
            # Getting a list of all files in the new dir
            packages = os.listdir(os.getcwd())
            for p in packages:
                # On package initialization we do the following
                # 1. Check for a supported archive
                # 2. get required info: version, platform, hash
                # If any check fails package.info['status'] will be False
                # You can query package.info['reason'] for the reason
                package = Package(p)
                if package.info['status'] is False:
                    # Package failed at something
                    # package.info['reason'] will tell why
                    bad_packages.append(package)
                    continue

                # Add package hash
                package.file_hash = gph(package.filename)
                package.file_size = in_bytes(package.filename)
                self.version_data = PackageHandler._update_file_list(self.version_data,
                                                                  package)

                package_manifest.append(package)
                self.config = PackageHandler._add_package_to_config(package,
                                                                    self.config)

                if self.patch_support:
                    # If channel is not stable skip patch creation
                    if package.channel != 'stable':
                        log.debug('Package %s not on stable channel: '
                                  'Skipping', p)
                        continue
                    # Will check if source file for patch exists
                    # if so will return the path and number of patch
                    # to create. If missing source file None returned
                    path = self._check_make_patch(self.version_data,
                                                  package.name,
                                                  package.platform,
                                                  )
                    if path is not None:
                        log.debug('Found source file to create patch')
                        patch_name = package.name + '-' + package.platform
                        src_path = path[0]
                        patch_number = path[1]
                        patch_info = dict(src=src_path,
                                          dst=os.path.abspath(p),
                                          patch_name=os.path.join(self.new_dir,
                                                                  patch_name),
                                          patch_num=patch_number,
                                          package=package.filename)
                        # ready for patching
                        patch_manifest.append(patch_info)
                    else:
                        log.warning('No source file to patch from')

        if report_errors is True:  # pragma: no cover
            log.warning('Bad package & reason for being naughty:')
            for b in bad_packages:
                log.warning(b.name, b.info['reason'])

        return package_manifest, patch_manifest