Skip to content

Commit 440f5d5

Browse files
committed
【修改】:解决从 github 下载的软件包解压后有版本号导致的文件夹名错误,进而无法删除的问题
1 parent 783d48f commit 440f5d5

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
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: 5 additions & 2 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

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)