| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- #!/usr/bin/env python3
- """
- Debug script to trace dependency detection for GCC.
- This script will help identify where the incorrect dependencies are coming from.
- """
- import logging
- import json
- from pathlib import Path
- # Set up detailed logging
- logging.basicConfig(
- level=logging.DEBUG,
- format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
- )
- # Import autusm components
- from src.autusm.usm_integration import USMIntegration
- from src.autusm.analyzer import SourceAnalyzer
- from src.autusm.metadata import MetadataExtractor
- from src.autusm.manifest import ManifestGenerator
- from src.autusm.models import PackageInfo, BuildSystem, BuildSystemType
- def debug_dependency_detection():
- """Debug the dependency detection process."""
-
- print("=== DEBUGGING DEPENDENCY DETECTION FOR GCC ===\n")
-
- # Path to the extracted GCC source
- gcc_source_dir = Path("test_output1")
-
- if not gcc_source_dir.exists():
- print(f"ERROR: GCC source directory not found at {gcc_source_dir}")
- return
-
- print(f"Analyzing GCC source at: {gcc_source_dir}\n")
-
- # 1. Check USM autoprovides
- print("1. CHECKING USM AUTOPROVIDES...")
- usm_integration = USMIntegration()
- if usm_integration.is_available():
- print("USM is available, getting autoprovides...")
- autoprovides = usm_integration.get_autoprovides(gcc_source_dir)
- print(f"USM autoprovides returned: {json.dumps(autoprovides, indent=2)}")
- else:
- print("USM is not available on this system")
-
- print("\n" + "="*60 + "\n")
-
- # 2. Check metadata extraction
- print("2. CHECKING METADATA EXTRACTION...")
- metadata_extractor = MetadataExtractor()
- package_info = metadata_extractor.extract(gcc_source_dir)
-
- print(f"Extracted package name: {package_info.name}")
- print(f"Extracted version: {package_info.version}")
- print(f"Extracted runtime dependencies: {package_info.runtime_dependencies}")
- print(f"Extracted build dependencies: {package_info.build_dependencies}")
-
- print("\n" + "="*60 + "\n")
-
- # 3. Check source code analysis
- print("3. CHECKING SOURCE CODE ANALYSIS...")
- analyzer = SourceAnalyzer()
-
- # Analyze dependencies in source code
- try:
- source_dependencies = analyzer.analyze_dependencies(gcc_source_dir)
- print(f"Source code dependencies: {json.dumps(source_dependencies, indent=2)}")
- except Exception as e:
- print(f"Error analyzing source dependencies: {e}")
-
- print("\n" + "="*60 + "\n")
-
- # 4. Check manifest generation
- print("4. CHECKING MANIFEST GENERATION...")
- manifest_generator = ManifestGenerator()
-
- # Create a basic build system for GCC
- build_system = BuildSystem(
- type=BuildSystemType.AUTOTOOLS,
- config_files=[],
- build_files=[],
- detected_commands=[],
- custom_args={}
- )
-
- # Generate manifest (add a summary if missing)
- if not package_info.summary:
- package_info.summary = "GNU Compiler Collection"
- manifest = manifest_generator.generate(package_info, build_system)
-
- print(f"Generated manifest dependencies:")
- print(f" Runtime: {manifest.depends.runtime}")
- print(f" Build: {manifest.depends.build}")
- print(f" Manage: {manifest.depends.manage}")
-
- # Check the _convert_to_resource_refs method specifically
- print("\n5. TESTING _convert_to_resource_refs METHOD...")
-
- # Test with various inputs
- test_deps = ["libc", "generic_format_parser", "gcc", "make"]
- for dep in test_deps:
- converted = manifest_generator._convert_to_resource_refs([dep])
- print(f" '{dep}' -> {converted}")
-
- print("\n" + "="*60 + "\n")
-
- # 6. Check current manifest file
- print("6. CHECKING CURRENT MANIFEST.USM FILE...")
- manifest_file = gcc_source_dir / "MANIFEST.usm"
- if manifest_file.exists():
- with open(manifest_file, 'r') as f:
- current_manifest = json.load(f)
-
- print("Current manifest dependencies:")
- if "depends" in current_manifest and "runtime" in current_manifest["depends"]:
- print(f" Runtime: {current_manifest['depends']['runtime']}")
- else:
- print(" No runtime dependencies found in current manifest")
- else:
- print("No MANIFEST.usm file found")
- if __name__ == "__main__":
- debug_dependency_detection()
|