瀏覽代碼

Make build path optional for install verb

Billy Barrow 10 月之前
父節點
當前提交
d0fbc06eaa
共有 2 個文件被更改,包括 30 次插入5 次删除
  1. 29 4
      src/cli/Cli.vala
  2. 1 1
      src/lib/Paths.vala

+ 29 - 4
src/cli/Cli.vala

@@ -13,7 +13,7 @@ public static int main(string[] args) {
 
     var verb = args[1];
 
-    if(verb != "remove" && verb != "acquire") {
+    if(verb != "remove" && verb != "acquire" && verb != "install") {
         if(args.length < 3) {
             usage();
             return 255;
@@ -40,6 +40,17 @@ public static int main(string[] args) {
     }
 
     if(verb == "install") {
+        if(build_path == null) {
+            var dir = File.new_build_filename("/tmp", Uuid.string_random());
+            try {
+                dir.make_directory();
+            }
+            catch(Error e) {
+                printerr(@"Could not create temporary build directory, try specifying one instead: $(e.message)\n");
+                return 255;
+            }
+            build_path = dir.get_path();
+        }
         return install();
     }
 
@@ -135,9 +146,23 @@ private int install() {
         var path = paths.get_suggested_path(resource.key);
         printerr(@"Installing $(resource.key) to $path...");
         try {
-            var src = File.new_build_filename(build_path, resource.value);
-            var dest = File.new_for_path(path);
-            src.copy(dest, FileCopyFlags.OVERWRITE);
+            if(resource.value.file_type == Usm.ManifestFileType.REGULAR) {
+                var src = File.new_build_filename(build_path, resource.value.path);
+                var dest = File.new_for_path(path);
+                src.copy(dest, FileCopyFlags.OVERWRITE);
+            }
+            else if(resource.value.file_type == Usm.ManifestFileType.DIRECTORY) {
+                var dest = File.new_for_path(path);
+                dest.make_directory();
+            }
+            else if(resource.value.file_type == Usm.ManifestFileType.SYMBOLIC_LINK) {
+                var dest = File.new_for_path(path);
+                dest.make_symbolic_link(resource.value.path);
+            }
+            else {
+                printerr(@" File type not implemented\n");
+                return 250;
+            }
         }
         catch(Error e) {
             printerr(@" $(e.message)\n");

+ 1 - 1
src/lib/Paths.vala

@@ -72,7 +72,7 @@ namespace Usm {
                 case Usm.ResourceType.VALA_API:
                     return Path.build_filename(destination, prefix, "share", "vala", "vapi", resource.resource);
                 case Usm.ResourceType.GOBJECT_IR:
-                    return Path.build_filename(destination, prefix, "share", "gir", resource.resource);
+                    return Path.build_filename(destination, prefix, "share", "gir-1.0", resource.resource);
                 case Usm.ResourceType.TYPELIB:
                     return Path.build_filename(destination, prefix, lib, "girepository-1.0", resource.resource);
                 default: