Skip to content

使用pkgs --update 下载解压zip文件是解析会出现错误 #215

Open
@zzusdk

Description

@zzusdk

例如:
解压v2.5.0_for_rtthread.zip 时找到的第一个文件是littlefs-refs-tags-v2.5.0_for_rtthread.github\workflows\下面的文件

def handle_zip_package 中
package_folder_name = os.path.split(right_path)[0]
package_folder_name 就成了littlefs-refs-tags-v2.5.0_for_rtthread.github\workflows
所以最终解压的内容经过cp就只有.github\workflows\ 下的文件

是否改成这样,找第一个item, 因为第一个itme永远是压缩包本身的文件夹
def handle_zip_package(archive_filename, bsp_package_path, package_name, package_info):
package_version = package_info['ver']
package_temp_path = os.path.join(bsp_package_path, "package_temp")

try:
    if remove_folder(package_temp_path):
        os.makedirs(package_temp_path)
except Exception as e:
    logging.warning('Error message : {0}'.format(e))

logging.info("BSP packages path {0}".format(bsp_package_path))
logging.info("BSP package temp path: {0}".format(package_temp_path))
logging.info("archive filename : {0}".format(archive_filename))

try:
    flag = True
    package_folder_name = ""
    package_name_with_version = ""
    arch = zipfile.ZipFile(archive_filename, "r")
    for item in arch.namelist():
        arch.extract(item, package_temp_path)
        if is_windows():
            right_path = item.replace('/', '\\')
        else:
            right_path = item
        # Gets the folder name and changed folder name only once
        if flag:
            package_folder_name = os.path.split(right_path)[0]
            package_name_with_version = package_name + '-' + package_version
            flag = False
        if not os.path.isdir(os.path.join(package_temp_path, item)):
            right_name_to_db = right_path.replace(package_folder_name, package_name_with_version, 1)
            right_path = os.path.join("package_temp", right_path)
            pkgsdb.save_to_database(right_name_to_db, archive_filename, right_path)
    arch.close()

    if not move_package_to_bsp_packages(package_folder_name, package_name, package_temp_path, package_version,
                                        bsp_package_path):
        return False
except Exception as e:
    logging.warning('unpack error message : {0}'.format(e))
    logging.warning('unpack {0} failed'.format(os.path.basename(archive_filename)))
    # remove temp folder and archive file
    remove_folder(package_temp_path)
    os.remove(archive_filename)
    return False

return True

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions