Просмотр исходного кода

feat(manifest): add symbolic link support in manifest scanning

Add support for detecting and processing symbolic links during manifest
generation. The changes include:

- Use NOFOLLOW_SYMLINKS flag when enumerating directory contents to properly
  handle symlinks without following their targets
- Add new branch in autoprovides_scan_tree to process FileType.SYMBOLIC_LINK
- Create appropriate ResourceRef and ManifestFile entries for symlinks with
  correct file type and destination information
- Extend library type detection to include object files (.o) as libraries

This enables the manifest system to accurately represent symbolic links
in the package metadata, improving resource tracking and dependency
resolution.
clanker 1 месяц назад
Родитель
Сommit
31ecb08f23
1 измененных файлов с 22 добавлено и 4 удалено
  1. 22 4
      src/cli/Manifest.vala

+ 22 - 4
src/cli/Manifest.vala

@@ -529,7 +529,7 @@ public static Invercargill.DataStructures.Dictionary<Usm.ResourceRef, Usm.Manife
     var folder = File.new_for_path(path);
 
     // Getting a list of all files and folders inside the directory
-    var enumerator = folder.enumerate_children("*", FileQueryInfoFlags.NONE);
+    var enumerator = folder.enumerate_children("*", FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
 
     var provides = new Invercargill.DataStructures.Dictionary<Usm.ResourceRef, Usm.ManifestFile>();
 
@@ -542,7 +542,6 @@ public static Invercargill.DataStructures.Dictionary<Usm.ResourceRef, Usm.Manife
 
         // Checking if the current item is a file or a folder
         if (info.get_file_type() == FileType.REGULAR) {
-            // Removing the file
             var file = folder.get_child(info.get_name());
             var true_path = file.get_path().substring(install_root.length);
             var type = guess_resource_type(true_path);
@@ -558,8 +557,27 @@ public static Invercargill.DataStructures.Dictionary<Usm.ResourceRef, Usm.Manife
             var manifest_file = new Usm.ManifestFile.from_string("as-expected");
             provides[resource_ref] = manifest_file;
         }
+        else if (info.get_file_type() == FileType.SYMBOLIC_LINK) {
+            var file = folder.get_child(info.get_name());
+            var true_path = file.get_path().substring(install_root.length);
+            var type = guess_resource_type(true_path);
+            
+            var relative_path = get_relative_path_for_type(true_path, type.to_string());
+            // Remove leading slash from relative_path if present
+            if (relative_path.has_prefix("/")) {
+                relative_path = relative_path.substring(1);
+            }
+            
+            // Create ResourceRef and ManifestFile
+            var resource_ref = new Usm.ResourceRef.with_type(type, relative_path);
+            var manifest_file = new Usm.ManifestFile() {
+                path_base = Usm.ManifestFilePathBase.AS_EXPECTED,
+                file_type = Usm.ManifestFileType.SYMBOLIC_LINK,
+                destination = info.get_symlink_target()
+            };
+            provides[resource_ref] = manifest_file;
+        }
         else if (info.get_file_type() == FileType.DIRECTORY) {
-            // Removing the folder recursively
             var subfolder = folder.get_child(info.get_name());
             var sub_provides = autoprovides_scan_tree(install_root, subfolder.get_path());
             // Add all entries from subdirectory
@@ -648,7 +666,7 @@ private static Usm.ResourceType guess_resource_type(string path) {
             
             // Library and Library resource have the same path. Try to have actual libraries get 'lib:' type, and all others 'libres:'
             var basename = Path.get_basename(path);
-            var is_library = basename.has_suffix(".so") || basename.has_suffix(".a") || basename.contains(".so.");
+            var is_library = basename.has_suffix(".so") || basename.contains(".so.") || basename.has_suffix(".a") || basename.has_suffix(".o");
             if(!is_library && (type == Usm.ResourceType.LIBRARY || type == Usm.ResourceType.CANONICAL_LIBRARY)) {
                 continue;
             }