mirror of
https://abf.rosa.ru/djam/repo-analyzer.git
synced 2025-02-23 18:12:54 +00:00
Adjust links resolution for implicitly provided directories
This commit is contained in:
parent
4c305cd105
commit
21a5ec6090
2 changed files with 26 additions and 2 deletions
|
@ -325,6 +325,7 @@ def process_package_worker(num, queue_in, generator, gen_lock, db_struct, repodi
|
||||||
(pkg_file_paths, pkg_file_names, pkg_file_sizes, pkg_file_modes) = \
|
(pkg_file_paths, pkg_file_names, pkg_file_sizes, pkg_file_modes) = \
|
||||||
(hdr['RPMTAG_FILEPATHS'], hdr['RPMTAG_BASENAMES'], hdr['RPMTAG_FILESIZES'], hdr['RPMTAG_FILEMODES'])
|
(hdr['RPMTAG_FILEPATHS'], hdr['RPMTAG_BASENAMES'], hdr['RPMTAG_FILESIZES'], hdr['RPMTAG_FILEMODES'])
|
||||||
files_list = data['package_files']
|
files_list = data['package_files']
|
||||||
|
files_dirs = {}
|
||||||
obj_so_files_idx = []
|
obj_so_files_idx = []
|
||||||
for i in xrange(0, len(pkg_file_paths)):
|
for i in xrange(0, len(pkg_file_paths)):
|
||||||
file_name = pkg_file_names[i]
|
file_name = pkg_file_names[i]
|
||||||
|
@ -340,7 +341,11 @@ def process_package_worker(num, queue_in, generator, gen_lock, db_struct, repodi
|
||||||
None #mark FILE_REC_LINK_IDX = 7
|
None #mark FILE_REC_LINK_IDX = 7
|
||||||
])
|
])
|
||||||
if pkg_file_modes[i] & RPMFILEMODE_DIRECTORY != 0:
|
if pkg_file_modes[i] & RPMFILEMODE_DIRECTORY != 0:
|
||||||
|
files_dirs[file_path] = False
|
||||||
continue
|
continue
|
||||||
|
dir_name = os.path.dirname(file_path)
|
||||||
|
if dir_name not in files_dirs:
|
||||||
|
files_dirs[dir_name] = True
|
||||||
if os.path.splitext(file_name)[1] in \
|
if os.path.splitext(file_name)[1] in \
|
||||||
['.debug', '.xz', '.conf', '.py', '.c', '.h', '.hpp', '.png',
|
['.debug', '.xz', '.conf', '.py', '.c', '.h', '.hpp', '.png',
|
||||||
'.cc', '.cpp', '.sh', '.java', '.pl', '.patch', '.desktop']:
|
'.cc', '.cpp', '.sh', '.java', '.pl', '.patch', '.desktop']:
|
||||||
|
@ -352,6 +357,20 @@ def process_package_worker(num, queue_in, generator, gen_lock, db_struct, repodi
|
||||||
(pkg_file_modes[i] & RPMFILEMODE_EXECUTE) != 0:
|
(pkg_file_modes[i] & RPMFILEMODE_EXECUTE) != 0:
|
||||||
obj_so_files_idx.append(len(files_list) - 1)
|
obj_so_files_idx.append(len(files_list) - 1)
|
||||||
|
|
||||||
|
for fdir in sorted(files_dirs.keys()):
|
||||||
|
if files_dirs[fdir]:
|
||||||
|
# Add parent directories as implicit files # TODO: recursive processing?
|
||||||
|
pkg_file_id = generate_new_id(generator, gen_lock)
|
||||||
|
files_list.append([pkg_file_id, #FILE_REC_ID_IDX = 0
|
||||||
|
pkg_id,
|
||||||
|
os.path.basename(fdir),
|
||||||
|
fdir, #FILE_REC_PATH_IDX = 3
|
||||||
|
0,
|
||||||
|
-1, # special mode
|
||||||
|
None, #link_to_path FILE_REC_LINK_IDX = 6
|
||||||
|
None #mark FILE_REC_LINK_IDX = 7
|
||||||
|
])
|
||||||
|
|
||||||
if obj_so_files_idx:
|
if obj_so_files_idx:
|
||||||
pkg_temp_dir = os.path.join(temp_dir, os.path.basename(pkg))
|
pkg_temp_dir = os.path.join(temp_dir, os.path.basename(pkg))
|
||||||
os.makedirs(pkg_temp_dir)
|
os.makedirs(pkg_temp_dir)
|
||||||
|
|
|
@ -155,9 +155,14 @@ SELECT id FROM package_files WHERE path = ? AND package_id = ?
|
||||||
if tofile:
|
if tofile:
|
||||||
target_obj_id = tofile[0]
|
target_obj_id = tofile[0]
|
||||||
if not target_obj_id:
|
if not target_obj_id:
|
||||||
|
# Just two level of dependency recursion - TODO: Full depth recursion?
|
||||||
tofile = dbc.execute("""
|
tofile = dbc.execute("""
|
||||||
SELECT id FROM package_files WHERE path = ? AND package_id IN (SELECT dep_package_id FROM requires WHERE package_id = ?)
|
SELECT id FROM package_files WHERE path = ? AND package_id IN (
|
||||||
""", [target_path, pkg_id]).fetchone()
|
SELECT dep_package_id FROM requires WHERE package_id = ?
|
||||||
|
UNION
|
||||||
|
SELECT dep_package_id FROM requires WHERE package_id IN (SELECT dep_package_id FROM requires WHERE package_id = ?)
|
||||||
|
)
|
||||||
|
""", [target_path, pkg_id, pkg_id]).fetchone()
|
||||||
if tofile:
|
if tofile:
|
||||||
target_obj_id = tofile[0]
|
target_obj_id = tofile[0]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue