|
@@ -10,7 +10,9 @@ namespace Usm {
|
|
|
INVALID_FILE_TYPE,
|
|
|
INVALID_REMOVE_TYPE,
|
|
|
INVALID_INSTALL_TYPE,
|
|
|
- INVALID_PACKAGE
|
|
|
+ INVALID_PACKAGE,
|
|
|
+ INVALID_PATH_BASE,
|
|
|
+ INVALID_FILE_PATH,
|
|
|
}
|
|
|
|
|
|
public class Manifest {
|
|
@@ -139,11 +141,20 @@ namespace Usm {
|
|
|
return proc;
|
|
|
}
|
|
|
|
|
|
- public Subprocess? run_install(string build_path, InstallType type, SubprocessFlags flags) throws Error {
|
|
|
+ public Subprocess? run_install(string build_path, string install_path, InstallType type, SubprocessFlags flags) throws Error {
|
|
|
if(executables.install == null) {
|
|
|
return null;
|
|
|
}
|
|
|
var path = Path.build_filename(Environment.get_current_dir(), executables.install);
|
|
|
+ var proc = new Subprocess.newv(new string[] { path, build_path, install_path, type.to_string() }, flags);
|
|
|
+ return proc;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Subprocess? run_post_install(string build_path, InstallType type, SubprocessFlags flags) throws Error {
|
|
|
+ if(executables.install == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ var path = Path.build_filename(Environment.get_current_dir(), executables.post_install);
|
|
|
var proc = new Subprocess.newv(new string[] { path, build_path, type.to_string() }, flags);
|
|
|
return proc;
|
|
|
}
|
|
@@ -158,7 +169,7 @@ namespace Usm {
|
|
|
}
|
|
|
|
|
|
public delegate void ResourceProgressCallback(ResourceRef resource, int current_resource, int total_resources, float resource_frac);
|
|
|
- public void install_resources(string build_path, Paths paths, ResourceProgressCallback callback) throws Error {
|
|
|
+ public void install_resources(string source_path, string build_path, string? install_path, Paths paths, ResourceProgressCallback callback, bool dry_run = false) throws Error {
|
|
|
// Install each resource speficied by the manifest
|
|
|
var resource_count = provides.count();
|
|
|
var resources_installed = 0;
|
|
@@ -172,23 +183,57 @@ namespace Usm {
|
|
|
if(resource.key.resource_type == ResourceType.TAG) {
|
|
|
// Ensure parent directories are created first
|
|
|
var parent_dir = File.new_for_path(Path.get_basename(path));
|
|
|
- if(!parent_dir.query_exists()) {
|
|
|
+ if(!parent_dir.query_exists() && !dry_run) {
|
|
|
parent_dir.make_directory_with_parents();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(resource.value.file_type == Usm.ManifestFileType.REGULAR) {
|
|
|
+ var base_path = "";
|
|
|
+ switch (resource.value.path_base) {
|
|
|
+ case ManifestFilePathBase.BUILD:
|
|
|
+ base_path = build_path;
|
|
|
+ break;
|
|
|
+ case ManifestFilePathBase.SOURCE:
|
|
|
+ base_path = source_path;
|
|
|
+ break;
|
|
|
+ case ManifestFilePathBase.INSTALL:
|
|
|
+ if(install_path == null) {
|
|
|
+ throw new ManifestError.INVALID_FILE_PATH("Install path was not provided");
|
|
|
+ }
|
|
|
+ base_path = install_path;
|
|
|
+ break;
|
|
|
+ case ManifestFilePathBase.AS_EXPECTED:
|
|
|
+ if(install_path == null) {
|
|
|
+ throw new ManifestError.INVALID_FILE_PATH("Install path was not provided");
|
|
|
+ }
|
|
|
+ base_path = Path.build_filename(install_path, paths.get_suggested_path(resource.key));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ assert_not_reached();
|
|
|
+ }
|
|
|
var src = File.new_build_filename(build_path, resource.value.path);
|
|
|
var dest = File.new_for_path(path);
|
|
|
- src.copy(dest, FileCopyFlags.OVERWRITE, null, (c, t) => callback(resource.key, resources_installed, resource_count, (float)c / (float)t));
|
|
|
+
|
|
|
+ if(!src.query_exists()) {
|
|
|
+ throw new ManifestError.INVALID_FILE_PATH(@"Expected to find file listed in manifest at \"$(src.get_path())\", but no such file was found.");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!dry_run) {
|
|
|
+ src.copy(dest, FileCopyFlags.OVERWRITE, null, (c, t) => callback(resource.key, resources_installed, resource_count, (float)c / (float)t));
|
|
|
+ }
|
|
|
}
|
|
|
else if(resource.value.file_type == Usm.ManifestFileType.DIRECTORY) {
|
|
|
var dest = File.new_for_path(path);
|
|
|
- dest.make_directory();
|
|
|
+ if(!dry_run) {
|
|
|
+ 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);
|
|
|
+ if(!dry_run){
|
|
|
+ dest.make_symbolic_link(resource.value.path);
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
throw new TransactionError.INSTALL_ERROR(@"Could not understand resource key \"$(resource.key)\"");
|