Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zzusdk opened this issue Jan 15, 2024 · 1 comment
Open

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

zzusdk opened this issue Jan 15, 2024 · 1 comment

Comments

@zzusdk
Copy link

zzusdk commented Jan 15, 2024

例如:
解压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
@mysterywolf
Copy link
Member

related: RT-Thread-packages/littlefs#16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants