Skip to content

Commit a532a40

Browse files
authored
Merge pull request #37 from SummerGGift/master
【修改】:BUG 修复以及代码更新
2 parents d26dcd4 + 440f5d5 commit a532a40

File tree

3 files changed

+41
-22
lines changed

3 files changed

+41
-22
lines changed

archive.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
import pkgsdb
3030

3131

32-
def unpack(archive_fn, path, pkg):
32+
def unpack(archive_fn, path, pkg, pkgs_name_in_json):
3333

3434
flag = True
3535

36+
#print(pkg)
37+
3638
if ".tar.bz2" in archive_fn:
3739
arch = tarfile.open(archive_fn, "r:bz2")
3840
for tarinfo in arch:
@@ -66,7 +68,7 @@ def unpack(archive_fn, path, pkg):
6668
# Gets the folder name and change_dirname only once
6769
if flag:
6870
dir_name = os.path.split(right_path)[0]
69-
change_dirname = dir_name + '-' + pkg['ver']
71+
change_dirname = pkgs_name_in_json + '-' + pkg['ver']
7072
flag = False
7173

7274
right_name_to_db = right_path.replace(
@@ -76,9 +78,12 @@ def unpack(archive_fn, path, pkg):
7678
arch.close()
7779

7880
#Change the folder name
81+
82+
change_dirname = pkgs_name_in_json + '-' + pkg['ver']
7983
#print(os.path.join(path, dir_name))
80-
#rint(os.path.join(path, change_dirname))
81-
84+
#print(os.path.join(path, change_dirname))
85+
#print(pkgs_name_in_json)
86+
8287
if os.path.isdir(os.path.join(path, change_dirname)):
8388
cmd = 'rd /s /q ' + os.path.join(path, change_dirname)
8489
os.system(cmd)

cmds/cmd_package.py

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ def install_pkg(env_root, bsp_root, pkg):
196196
#print "url:",package_url
197197
#print "url_from_json: ",url_from_json
198198
#print("==================================================>")
199-
199+
200+
get_package_url = None
201+
get_ver_sha = None
202+
200203
if os.path.isfile(env_config_file) and find_macro_in_condfig(env_config_file, 'SYS_PKGS_DOWNLOAD_ACCELERATE'):
201204
get_package_url, get_ver_sha = get_url_from_mirror_server(
202205
pkgs_name_in_json, pkg['ver'])
@@ -264,7 +267,7 @@ def install_pkg(env_root, bsp_root, pkg):
264267

265268
# unpack package
266269
if not os.path.exists(pkg_dir):
267-
package.unpack(pkg_fullpath, bsp_pkgs_path, pkg)
270+
package.unpack(pkg_fullpath, bsp_pkgs_path, pkg, pkgs_name_in_json)
268271
ret = True
269272

270273
return ret
@@ -440,22 +443,9 @@ def update_latest_packages(read_back_pkgs_json, bsp_packages_path):
440443
(pkgs_name_in_json))
441444

442445

443-
def package_update():
444-
"""Update env's packages.
446+
def pre_package_update():
445447

446-
Compare the old and new software package list and update the package.
447-
Remove unwanted packages and download the newly selected package.
448-
Check if the files in the deleted packages have been changed, and if so,
449-
remind the user saved the modified file.
450-
"""
451-
452448
bsp_root = Import('bsp_root')
453-
env_root = Import('env_root')
454-
455-
flag = True
456-
457-
#print bsp_root
458-
#print env_root
459449

460450
if not os.path.exists('.config'):
461451
print (
@@ -509,6 +499,30 @@ def package_update():
509499
with open(pkgs_fn, 'r') as f:
510500
oldpkgs = json.load(f)
511501

502+
return [oldpkgs, newpkgs, pkgs_fn, bsp_packages_path, dbsqlite_pathname]
503+
504+
505+
def package_update():
506+
"""Update env's packages.
507+
508+
Compare the old and new software package list and update the package.
509+
Remove unwanted packages and download the newly selected package.
510+
Check if the files in the deleted packages have been changed, and if so,
511+
remind the user saved the modified file.
512+
"""
513+
514+
bsp_root = Import('bsp_root')
515+
env_root = Import('env_root')
516+
517+
flag = True
518+
519+
sys_value = pre_package_update()
520+
oldpkgs = sys_value[0]
521+
newpkgs = sys_value[1]
522+
pkgs_fn = sys_value[2]
523+
bsp_packages_path = sys_value[3]
524+
dbsqlite_pathname = sys_value[4]
525+
512526
#print "newpkgs:",newpkgs
513527
#print "oldpkgs:",oldpkgs
514528

package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ def download(self, ver, path, url_from_srv):
220220
return False
221221
return ret
222222

223-
def unpack(self, fullpkg_path, path, pkg):
223+
def unpack(self, fullpkg_path, path, pkg, pkgs_name_in_json):
224224
try:
225-
archive.unpack(fullpkg_path, path, pkg)
225+
archive.unpack(fullpkg_path, path, pkg, pkgs_name_in_json)
226226
except Exception, e:
227227
print('e.message:%s\t' % e.message)
228228
print('unpack %s failed' % os.path.basename(fullpkg_path))

0 commit comments

Comments
 (0)