浏览代码

feat: stream podman save directly into xz (no intermediate tar); fix GIR/typelib version in manifest; all four SPM shims declared as bin: provides

clanker 1 周之前
父节点
当前提交
4e517f0197
共有 3 个文件被更改,包括 36 次插入9 次删除
  1. 6 3
      MANIFEST.usm
  2. 23 3
      src/cli/Deploy.vala
  3. 7 3
      src/lib/meson.build

+ 6 - 3
MANIFEST.usm

@@ -9,10 +9,13 @@
     "lib:libusm-0.1.so": "as-expected",
     "inc:usm-0.1.h": "as-expected",
     "vapi:usm-0.1.vapi": "as-expected",
-    "typelib:usm-1.0.typelib": "as-expected",
-    "gir:usm-1.0.gir": "as-expected",
+    "gir:usm-0.1.gir": "as-expected",
+    "typelib:usm-0.1.typelib": "as-expected",
     "pc:usm-0.1.pc": "as-expected",
-    "libexec:usm-spm-dnf": "as-expected",
+    "bin:usm-spm-dnf": "as-expected",
+    "bin:usm-spm-apt": "as-expected",
+    "bin:usm-spm-apk": "as-expected",
+    "bin:usm-spm-emerge": "as-expected",
     "res:slopdocs/structure.usm.manifest.md": "source:slopdocs/structure.usm.manifest.md",
     "res:slopdocs/utility.usm.manifest.validate.md": "source:slopdocs/utility.usm.manifest.validate.md",
     "res:slopdocs/structure.usm.manifest.packaging.md": "source:slopdocs/structure.usm.manifest.packaging.md",

+ 23 - 3
src/cli/Deploy.vala

@@ -432,10 +432,30 @@ public int manifest_deploy(string[] args) {
     var artifact_base = @"$(manifest.name)-$version_string.image.tar";
     printerr(@"Saving image to \"$artifact_base.xz\"...\n");
     try {
-        var save_proc = new Subprocess.newv(new string[] { "podman", "save", "-o", artifact_base, tag }, SubprocessFlags.INHERIT_FDS);
+        // Stream podman save stdout directly into xz stdin (no intermediate
+        // .tar on disk); xz -T0 uses every available CPU core/thread
+        var xz_launcher = new SubprocessLauncher(SubprocessFlags.STDIN_PIPE);
+        xz_launcher.set_stdout_file_path(@"$artifact_base.xz");
+        var xz_proc = xz_launcher.spawnv(new string[] { "xz", "-T0" });
+
+        var save_launcher = new SubprocessLauncher(SubprocessFlags.STDOUT_PIPE);
+        var save_proc = save_launcher.spawnv(new string[] { "podman", "save", tag });
+
+        var source = save_proc.get_stdout_pipe();
+        var sink = xz_proc.get_stdin_pipe();
+        var buffer = new uint8[65536];
+        while (true) {
+            var read = source.read(buffer);
+            if (read <= 0) {
+                break;
+            }
+            sink.write(buffer[0:read]);
+        }
+        sink.close();
+        source.close();
+
         save_proc.wait_check();
-        var compress_proc = new Subprocess.newv(new string[] { "xz", "-T0", artifact_base }, SubprocessFlags.INHERIT_FDS);
-        compress_proc.wait_check();
+        xz_proc.wait_check();
     }
     catch(Error e) {
         printerr(@"Saving the image failed: $(e.message)\n");

+ 7 - 3
src/lib/meson.build

@@ -55,9 +55,13 @@ pkg.generate(usm,
     version : library_version,
     name : 'usm-@0@'.format(library_version))
     
-g_ir_compiler = find_program('g-ir-compiler')
-custom_target('usm typelib', command: [g_ir_compiler, '--shared-library=libusm-@0@.so'.format(library_version), '--output', '@OUTPUT@', meson.current_build_dir() / 'usm-@0@.gir'.format(library_version)],
+# g-ir-compiler is unavailable on some platforms (e.g. musl/alpine);
+# generate the typelib only when the tool is present
+g_ir_compiler = find_program('g-ir-compiler', required: false)
+if g_ir_compiler.found()
+    custom_target('usm typelib', command: [g_ir_compiler, '--shared-library=libusm-@0@.so'.format(library_version), '--output', '@OUTPUT@', meson.current_build_dir() / 'usm-@0@.gir'.format(library_version)],
               output: 'usm-@0@.typelib'.format(library_version),
               depends: usm,
               install: true,
-              install_dir: get_option('libdir') / 'girepository-1.0')
+              install_dir: get_option('libdir') / 'girepository-1.0')
+endif