Jelajahi Sumber

feat(manifest): add debug mode to autoprovides command

Add --debug flag to disable progress reporting and inherit file descriptors
for build and install subprocesses. This enables full subprocess output
visibility for troubleshooting build failures and install script issues
without progress interference.
clanker 1 bulan lalu
induk
melakukan
bccc45b99d
2 mengubah file dengan 59 tambahan dan 8 penghapusan
  1. 38 3
      slopdocs/utility.usm.manifest.autoprovides.md
  2. 21 5
      src/cli/Manifest.vala

+ 38 - 3
slopdocs/utility.usm.manifest.autoprovides.md

@@ -6,7 +6,7 @@ The `usm manifest autoprovides` command automatically generates the `provides` s
 ## Usage
 
 ```bash
-usm manifest autoprovides [--replace] [build-path]
+usm manifest autoprovides [--replace] [--debug] [build-path]
 ```
 
 ### Arguments
@@ -14,20 +14,23 @@ usm manifest autoprovides [--replace] [build-path]
 
 ### Options
 - `--replace`: Update MANIFEST.usm file with generated provides section
+- `--debug`: Disable build progress reporting and inherit file descriptors for subprocesses
 
 ## Process
 
 ### 1. Build Execution
 The command first builds the package using the specified build script:
-- Runs `usm manifest build` with silent output
-- Captures build progress for display
+- Runs `usm manifest build` with silent output (unless --debug is used)
+- Captures build progress for display (disabled with --debug)
 - Uses temporary build directory if not specified
+- With --debug: inherits file descriptors and disables progress callbacks
 
 ### 2. Installation Simulation
 Build output is installed to temporary directory:
 - Creates temporary install directory
 - Runs package's install script if present
 - Uses standard USM installation process
+- With --debug: inherits file descriptors for install subprocess
 
 ### 3. Filesystem Scanning
 The temporary install directory is scanned recursively:
@@ -95,6 +98,24 @@ Combine options:
 usm manifest autoprovides --replace /tmp/myapp-build
 ```
 
+### Debug Mode
+Enable debug mode for troubleshooting:
+```bash
+usm manifest autoprovides --debug
+```
+
+### Debug Mode with Replace
+Combine debug and replace options:
+```bash
+usm manifest autoprovides --debug --replace
+```
+
+### All Options Combined
+Use all available options:
+```bash
+usm manifest autoprovides --debug --replace /tmp/myapp-build
+```
+
 ## Output Format
 
 ### Console Output
@@ -209,6 +230,20 @@ If file update fails:
 
 ## Advanced Usage
 
+### Debug Mode Benefits
+The `--debug` flag provides enhanced debugging capabilities:
+- **Full subprocess output**: Inherit file descriptors to see all build/install output
+- **No progress interference**: Disables progress reporting that can obscure error messages
+- **Direct error visibility**: Build and install errors appear immediately without progress overlay
+- **Process monitoring**: Enables direct observation of subprocess behavior
+
+### When to Use Debug Mode
+- Troubleshooting build failures
+- Investigating install script issues
+- Analyzing subprocess output for debugging
+- When progress reporting interferes with error visibility
+- For detailed build/install process examination
+
 ### Custom Resource Mapping
 For non-standard layouts, manually edit generated provides:
 ```json

+ 21 - 5
src/cli/Manifest.vala

@@ -1,6 +1,7 @@
 Usm.Manifest manifest = null;
 string? build_path = null;
 bool replace_provides = false;
+bool debug_mode = false;
 
 
 public static int manifest_main(string[] args) {
@@ -13,11 +14,13 @@ public static int manifest_main(string[] args) {
 
     var verb = args[1];
     
-    // Check for --replace flag for autoprovides
+    // Check for --replace and --debug flags for autoprovides
     if(verb == "autoprovides") {
         for(int i = 2; i < args.length; i++) {
             if(args[i] == "--replace") {
                 replace_provides = true;
+            } else if(args[i] == "--debug") {
+                debug_mode = true;
             } else if(build_path == null) {
                 build_path = args[i];
             }
@@ -107,7 +110,7 @@ public static int manifest_main(string[] args) {
 }
 
 private void manifest_usage() {
-    printerr("USAGE:\n\tusm manifest build <build path>\n\tusm manifest install <build path>\n\tusm manifest remove\nusm manifest acquire\nusm manifest autoprovides [--replace] [build path]\nusm manifest test [build path]\n");
+    printerr("USAGE:\n\tusm manifest build <build path>\n\tusm manifest install <build path>\n\tusm manifest remove\nusm manifest acquire\nusm manifest autoprovides [--replace] [--debug] [build path]\nusm manifest test [build path]\n");
 }
 
 
@@ -426,9 +429,21 @@ private int autoprovides() {
     }
 
     try {
-        var proc = manifest.run_build(build_path, paths, SubprocessFlags.STDOUT_SILENCE, frac => printerr(@"Building '$(manifest.name)': $((int)(frac*100))%\r"));
+        Usm.ProgressDelegate? progress_callback = null;
+        SubprocessFlags build_flags = SubprocessFlags.STDOUT_SILENCE;
+        
+        if (!debug_mode) {
+            progress_callback = frac => printerr(@"Building '$(manifest.name)': $((int)(frac*100))%\r");
+        } else {
+            build_flags = SubprocessFlags.INHERIT_FDS;
+        }
+        
+        var proc = manifest.run_build(build_path, paths, build_flags, progress_callback);
         proc.wait_check();
-        printerr("\n");
+        
+        if (!debug_mode) {
+            printerr("\n");
+        }
     }
     catch(Error e) {
         printerr(@"\nError running build exec: $(e.message)\n");
@@ -445,7 +460,8 @@ private int autoprovides() {
     }
 
     try {
-        manifest.run_install(build_path, install_dir.get_path(), paths, Usm.InstallType.FRESH, SubprocessFlags.STDOUT_SILENCE).wait_check();
+        SubprocessFlags install_flags = debug_mode ? SubprocessFlags.INHERIT_FDS : SubprocessFlags.STDOUT_SILENCE;
+        manifest.run_install(build_path, install_dir.get_path(), paths, Usm.InstallType.FRESH, install_flags).wait_check();
     }
     catch(Error e) {
         printerr(@"Error running install exec: $(e.message)\n");