Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@
import pkgsdb
import platform
import shutil
import logging


def unpack(archive_fn, path, pkg, package_name):
pkg_ver = pkg['ver']
def unpack(archive_fn, path, package_info, package_name):
pkg_ver = package_info['ver']
flag = True

package_temp_path = os.path.join(path, "package_temp")
os.makedirs(package_temp_path)

logging.info("archive_fn", archive_fn)
logging.info("path", path)

if platform.system() == "Windows":
is_windows = True
else:
Expand All @@ -52,6 +59,7 @@ def unpack(archive_fn, path, pkg, package_name):
else:
right_path = a
a = os.path.join(os.path.split(right_path)[0], os.path.split(right_path)[1])

pkgsdb.save_to_database(a, archive_fn)
arch.close()

Expand All @@ -72,8 +80,8 @@ def unpack(archive_fn, path, pkg, package_name):
if ".zip" in archive_fn:
arch = zipfile.ZipFile(archive_fn, "r")
for item in arch.namelist():
arch.extract(item, path)
if not os.path.isdir(os.path.join(path, item)):
arch.extract(item, package_temp_path)
if not os.path.isdir(os.path.join(package_temp_path, item)):
if is_windows:
right_path = item.replace('/', '\\')
else:
Expand All @@ -86,6 +94,7 @@ def unpack(archive_fn, path, pkg, package_name):
flag = False

right_name_to_db = right_path.replace(dir_name, change_dirname, 1)
right_path = os.path.join("package_temp", right_path)
pkgsdb.save_to_database(right_name_to_db, archive_fn, right_path)
arch.close()

Expand All @@ -99,7 +108,14 @@ def unpack(archive_fn, path, pkg, package_name):
else:
shutil.rmtree(os.path.join(path, change_dirname))

os.rename(os.path.join(path, dir_name), os.path.join(path, change_dirname))
rename_path = os.path.join(package_temp_path, change_dirname)
os.rename(os.path.join(package_temp_path, dir_name), rename_path)

# copy to bsp packages path.
shutil.move(rename_path, os.path.join(path, change_dirname))

# remove temp dir
shutil.rmtree(package_temp_path)


def package_integrity_test(path):
Expand Down
2 changes: 1 addition & 1 deletion cmds/cmd_menuconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
def is_pkg_special_config(config_str):
"""judge if it's CONFIG_PKG_XX_PATH or CONFIG_PKG_XX_VER"""

if type(config_str) == type('a'):
if isinstance(config_str, str):
if config_str.startswith("PKG_") and (config_str.endswith('_PATH') or config_str.endswith('_VER')):
return True
return False
Expand Down
4 changes: 2 additions & 2 deletions cmds/cmd_package/cmd_package_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import os
import platform
import kconfig
from package import Package
from package import PackageOperation
from vars import Import


Expand Down Expand Up @@ -55,7 +55,7 @@ def list_packages():
packages = kconfig.parse(config_file)

for pkg in packages:
package = Package()
package = PackageOperation()
pkg_path = pkg['path']
if pkg_path[0] == '/' or pkg_path[0] == '\\':
pkg_path = pkg_path[1:]
Expand Down
Loading