|
@@ -10,6 +10,7 @@ namespace Usm {
|
|
INVALID_FILE_TYPE,
|
|
INVALID_FILE_TYPE,
|
|
INVALID_REMOVE_TYPE,
|
|
INVALID_REMOVE_TYPE,
|
|
INVALID_INSTALL_TYPE,
|
|
INVALID_INSTALL_TYPE,
|
|
|
|
+ INVALID_PACKAGE
|
|
}
|
|
}
|
|
|
|
|
|
public class Manifest {
|
|
public class Manifest {
|
|
@@ -49,6 +50,42 @@ namespace Usm {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public Manifest.from_file(string path) throws Error {
|
|
|
|
+ var element = new InvercargillJson.JsonElement.from_file(path);
|
|
|
|
+ Manifest.get_mapper().map_into(this, element.as<Invercargill.Properties>());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Manifest.from_package(string path) throws Error {
|
|
|
|
+ var archive = new Archive.Read();
|
|
|
|
+ archive.support_format_tar();
|
|
|
|
+ archive.support_filter_xz();
|
|
|
|
+ var result = archive.open_filename(path, 10240);
|
|
|
|
+ if(result != Archive.Result.OK) {
|
|
|
|
+ throw new ManifestError.INVALID_PACKAGE("Could not read archive");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ unowned Archive.Entry entry;
|
|
|
|
+ while(archive.next_header(out entry) == Archive.Result.OK) {
|
|
|
|
+ var path_name = entry.pathname();
|
|
|
|
+ if(path_name != "./MANIFEST.usm") {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var manifest_blob = new BinaryData();
|
|
|
|
+ uint8[] buffer;
|
|
|
|
+ Posix.off_t offset;
|
|
|
|
+ while (archive.read_data_block (out buffer, out offset) == Archive.Result.OK) {
|
|
|
|
+ manifest_blob.append_byte_array(buffer[offset:]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var element = new InvercargillJson.JsonElement.from_string(manifest_blob.to_raw_string());
|
|
|
|
+ Manifest.get_mapper().map_into(this, element.as<Invercargill.Properties>());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ throw new ManifestError.INVALID_PACKAGE("MANIFEST.usm not found within archive");
|
|
|
|
+ }
|
|
|
|
+
|
|
private void build_provides_dict(Properties obj) throws Error {
|
|
private void build_provides_dict(Properties obj) throws Error {
|
|
provides = new Dictionary<ResourceRef, ManifestFile>();
|
|
provides = new Dictionary<ResourceRef, ManifestFile>();
|
|
var mapper = ManifestFile.get_mapper();
|
|
var mapper = ManifestFile.get_mapper();
|