|
|
@@ -541,8 +541,9 @@ public static Invercargill.DataStructures.Vector<string> autoprovides_scan_tree(
|
|
|
// Removing the file
|
|
|
var file = folder.get_child(info.get_name());
|
|
|
var true_path = file.get_path().substring(install_root.length);
|
|
|
- var type = get_local_resource_type(true_path);
|
|
|
- var relative_path = get_relative_path_for_type(true_path, type);
|
|
|
+ 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);
|
|
|
@@ -560,7 +561,7 @@ public static Invercargill.DataStructures.Vector<string> autoprovides_scan_tree(
|
|
|
return provides;
|
|
|
}
|
|
|
|
|
|
-private static string get_local_resource_type(string path) {
|
|
|
+private static Usm.ResourceType guess_resource_type(string path) {
|
|
|
// Remove leading slash if present
|
|
|
string clean_path = path.has_prefix("/") ? path.substring(1) : path;
|
|
|
|
|
|
@@ -568,16 +569,17 @@ private static string get_local_resource_type(string path) {
|
|
|
var default_paths = new Usm.Paths.usm_environ();
|
|
|
|
|
|
// Find all matching resource types and calculate directory traversals
|
|
|
- var matching_types = new Invercargill.DataStructures.Vector<string>();
|
|
|
+ var matching_types = new Invercargill.DataStructures.Vector<Usm.ResourceType>();
|
|
|
var traversal_counts = new Invercargill.DataStructures.Vector<int>();
|
|
|
|
|
|
// Define all resource types to check
|
|
|
- Usm.ResourceType[] types_to_check = {
|
|
|
+ var types_to_check = new Invercargill.Composition<Usm.ResourceType>();
|
|
|
+ types_to_check.append(Invercargill.Iterate.these<Usm.ResourceType>(
|
|
|
Usm.ResourceType.BINARY,
|
|
|
Usm.ResourceType.SUPER_BINARY,
|
|
|
Usm.ResourceType.LIBRARY,
|
|
|
- Usm.ResourceType.LIBRARY_EXECUTABLE,
|
|
|
Usm.ResourceType.LIBRARY_RESOURCE,
|
|
|
+ Usm.ResourceType.LIBRARY_EXECUTABLE,
|
|
|
Usm.ResourceType.INCLUDE,
|
|
|
Usm.ResourceType.APPLICATION,
|
|
|
Usm.ResourceType.INFO_PAGE,
|
|
|
@@ -591,7 +593,15 @@ private static string get_local_resource_type(string path) {
|
|
|
Usm.ResourceType.TYPELIB,
|
|
|
Usm.ResourceType.CONFIGURATION,
|
|
|
Usm.ResourceType.OPTIONAL
|
|
|
- };
|
|
|
+ ));
|
|
|
+
|
|
|
+ // If the canonlib directory is different to the regular library path, add the canonical checks
|
|
|
+ if(paths.canonlib != paths.lib) {
|
|
|
+ types_to_check.append(Invercargill.Iterate.these<Usm.ResourceType>(
|
|
|
+ Usm.ResourceType.CANONICAL_LIBRARY,
|
|
|
+ Usm.ResourceType.CANONICAL_LIBRARY_RESOURCE
|
|
|
+ ));
|
|
|
+ }
|
|
|
|
|
|
foreach (var type in types_to_check) {
|
|
|
var suggested_path = default_paths.get_suggested_base_path_for_type(type);
|
|
|
@@ -612,26 +622,26 @@ private static string get_local_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.");
|
|
|
- if(type == Usm.ResourceType.LIBRARY && !is_library) {
|
|
|
+ if(!is_library && (type == Usm.ResourceType.LIBRARY || type == Usm.ResourceType.CANONICAL_LIBRARY)) {
|
|
|
continue;
|
|
|
}
|
|
|
- if(type == Usm.ResourceType.LIBRARY_RESOURCE && is_library) {
|
|
|
+ if(is_library && (type == Usm.ResourceType.LIBRARY_RESOURCE || type == Usm.ResourceType.CANONICAL_LIBRARY_RESOURCE)) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- matching_types.add(type.to_string());
|
|
|
+ matching_types.add(type);
|
|
|
traversal_counts.add(traversal_count);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// If no matches found, default to "rootpath"
|
|
|
if (matching_types.peek_count() == 0) {
|
|
|
- return "rootpath";
|
|
|
+ return Usm.ResourceType.ROOT_PATH;
|
|
|
}
|
|
|
|
|
|
// Find the type with the fewest directory traversals
|
|
|
int min_traversals = traversal_counts[0];
|
|
|
- string best_type = matching_types[0];
|
|
|
+ Usm.ResourceType best_type = matching_types[0];
|
|
|
|
|
|
for (int i = 1; i < traversal_counts.peek_count(); i++) {
|
|
|
if (traversal_counts[i] < min_traversals) {
|