Explorar o código

Fix most build errors

Billy Barrow hai 3 días
pai
achega
4b282b9d05

+ 3 - 3
src/cli/Cli.vala

@@ -11,8 +11,8 @@ public static int main(string[] args) {
 
     var command = args[1];
     if(command == "manifest") {
-        var m_args = new Invercargill.Vector<string>();
-        m_args.add_all(Invercargill.Convert.ate(args));
+        var m_args = new Invercargill.DataStructures.Vector<string>();
+        m_args.add_all(Invercargill.Wrap.array(args));
         m_args.remove_at(1);
         return manifest_main(m_args.to_array());
     }
@@ -104,5 +104,5 @@ public Invercargill.BinaryData calculate_file_checksum(string path) throws Error
     size_t size = checksum_bytes.length;
     checksum.get_digest(checksum_bytes, ref size);
 
-    return new Invercargill.BinaryData.from_byte_array(checksum_bytes);
+    return Invercargill.Wrap.byte_array(checksum_bytes);
 }

+ 1 - 0
src/cli/Install.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.DataStructures;
 
 private int install_main(string[] args) {
 

+ 2 - 2
src/cli/Manifest.vala

@@ -412,14 +412,14 @@ private int autoprovides() {
     }
 }
 
-public static Invercargill.Vector<string> autoprovides_scan_tree(string install_root, string path) throws Error {
+public static Invercargill.DataStructures.Vector<string> autoprovides_scan_tree(string install_root, string path) throws Error {
     // Creating a new Directory object for the given folder path
     var folder = File.new_for_path(path);
 
     // Getting a list of all files and folders inside the directory
     var enumerator = folder.enumerate_children("*", FileQueryInfoFlags.NONE);
 
-    var provides = new Invercargill.Vector<string>();
+    var provides = new Invercargill.DataStructures.Vector<string>();
 
     // Looping through each file/folder and removing them
     while (true) {

+ 7 - 6
src/cli/Repository.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.DataStructures;
 
 private int repository_main(string[] args) {
 
@@ -43,7 +44,7 @@ private int repository_new(string name) {
         FileUtils.set_data("private-key", private_key);
     
         var repository = new Usm.Repository();
-        repository.key = new BinaryData.from_byte_array(public_key);
+        repository.key = Wrap.byte_array(public_key);
         repository.name = name;
         repository.url = @"file:///$(Environment.get_current_dir())/public";
         repository.summary = "My new repository";
@@ -71,7 +72,7 @@ private int repository_build_list() {
     var checksum = new Checksum(ChecksumType.SHA512);
     var mapper = Usm.RepositoryListingEntry.get_mapper();
 
-    foreach(var file in directory("public")) {
+    foreach(var file in Iterate.directory("public")) {
         var path = Path.build_filename("public", file);
         if(!path.has_suffix(".usmc")) {
             continue;
@@ -98,12 +99,12 @@ private int repository_build_list() {
     var signed = Sodium.Asymmetric.Signing.sign(buffer, private_key);
 
     var signature = new Usm.RepositoryListingSignature() {
-        key = new BinaryData.from_byte_array(public_key),
-        signature = new BinaryData.from_byte_array(signed)
+        key = Wrap.byte_array(public_key),
+        signature = Wrap.byte_array(signed)
     };
-    var signature_entry = new PropertiesDictionary();
+    var signature_entry = new PropertyDictionary();
     signature_entry.set("type", new NativeElement<string>("signatures"));
-    signature_entry.set("signatures", new NativeElement<Enumerable<Element>>(single(Usm.RepositoryListingSignature.get_mapper().map_from(signature)).to_elements()));
+    signature_entry.set("signatures", new NativeElement<Enumerable<Element>>(Iterate.single(Usm.RepositoryListingSignature.get_mapper().map_from(signature)).to_elements()));
 
     var serialised = new InvercargillJson.JsonElement.from_properties(signature_entry).stringify(false);
     output_stream.put_string(serialised);

+ 1 - 0
src/lib/Configuration.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.Mapping;
 
 namespace Usm {
 

+ 2 - 0
src/lib/Dependencies.vala

@@ -1,4 +1,6 @@
 using Invercargill;
+using Invercargill.Mapping;
+
 namespace Usm {
 
     public class Dependencies {

+ 2 - 0
src/lib/Exectuables.vala

@@ -1,4 +1,6 @@
 using Invercargill;
+using Invercargill.Mapping;
+
 namespace Usm {
 
     public class Executables {

+ 2 - 0
src/lib/File.vala

@@ -1,4 +1,6 @@
 using Invercargill;
+using Invercargill.Mapping;
+using Invercargill.DataStructures;
 
 namespace Usm {
 

+ 2 - 0
src/lib/Git.vala

@@ -1,4 +1,6 @@
 using Invercargill;
+using Invercargill.Mapping;
+
 namespace Usm {
 
     public class Git {

+ 2 - 0
src/lib/Licence.vala

@@ -1,4 +1,6 @@
 using Invercargill;
+using Invercargill.Mapping;
+
 namespace Usm {
 
     public enum LicenceCategory {

+ 5 - 3
src/lib/Manifest.vala

@@ -1,4 +1,6 @@
 using Invercargill;
+using Invercargill.Mapping;
+using Invercargill.DataStructures;
 
 namespace Usm {
 
@@ -88,7 +90,7 @@ namespace Usm {
                     continue;
                 }
 
-                var manifest_blob = new BinaryData();
+                var manifest_blob = new ByteComposition();
 				uint8[] buffer;
 				Posix.off_t offset;
 				while (archive.read_data_block (out buffer, out offset) == Archive.Result.OK) {
@@ -117,7 +119,7 @@ namespace Usm {
         }
 
         private Properties map_from_provides_dict() {
-            var dict = new PropertiesDictionary();
+            var dict = new PropertyDictionary();
             var mapper = ManifestFile.get_mapper();
             foreach (var pair in provides) {
                 try {
@@ -188,7 +190,7 @@ namespace Usm {
             return proc;
         }
 
-        public delegate void ResourceProgressCallback(ResourceRef resource, int current_resource, int total_resources, float resource_frac);
+        public delegate void ResourceProgressCallback(ResourceRef resource, uint current_resource, uint total_resources, float resource_frac);
         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();

+ 2 - 1
src/lib/Repository/Repository.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.Mapping;
 
 namespace Usm {
 
@@ -17,7 +18,7 @@ namespace Usm {
                 cfg.map<string>("url", o => o.url, (o, v) => o.url = v)
                     .undefined_when(o => o.url == null)
                     .when_undefined(o => o.url = null);
-                cfg.map<string>("key", o => o.key.to_base64(), (o, v) => o.key = new BinaryData.from_base64(v));
+                cfg.map<string>("key", o => o.key.to_base64(), (o, v) => o.key = Wrap.base64_string(v));
                 cfg.map<int>("cache_expiration", o => o.cache_expiration, (o, v) => o.cache_expiration = v);
                 cfg.set_constructor(() => new Repository());
             });

+ 4 - 2
src/lib/Repository/RepositoryClient.vala

@@ -1,4 +1,4 @@
-using Invercargill.Convert;
+using Invercargill;
 
 namespace Usm {
 
@@ -31,7 +31,9 @@ namespace Usm {
             size_t size = checksum_bytes.length;
             checksum.get_digest(checksum_bytes, ref size);
 
-            return package.sha512sum.equals(ate(checksum_bytes));
+            package.sha512sum.where(m => m % 2 == 0).to_base64();
+
+            return package.sha512sum.equals(Wrap.array(checksum_bytes));
         }
 
         protected void call_to(RepositoryClientProgressCallback? callback, string filename, int64 current, int64 total) {

+ 7 - 5
src/lib/Repository/RepositoryListing.vala

@@ -1,4 +1,6 @@
 using Invercargill;
+using Invercargill.Mapping;
+using Invercargill.DataStructures;
 using InvercargillJson;
 
 namespace Usm {
@@ -35,7 +37,7 @@ namespace Usm {
                     var buffer = new uint8[ChecksumType.SHA512.get_length()];
                     size_t buffer_length = buffer.length;
                     checksum.get_digest(buffer, ref buffer_length);
-                    this.checksum = new BinaryData.from_byte_array(buffer);
+                    this.checksum = Wrap.byte_array(buffer);
                     return;
                 }
 
@@ -61,7 +63,7 @@ namespace Usm {
                 return false;
             }
 
-            return checksum.equals(Convert.ate(signed));
+            return checksum.equals(Wrap.array(signed));
         }
     }
 
@@ -75,7 +77,7 @@ namespace Usm {
             return PropertyMapper.build_for<RepositoryListingEntry>(cfg => {
                 cfg.map<string>("path", o => o.path, (o, v) => o.path = v);
                 cfg.map_properties_with<Manifest>("manifest", o => o.manifest, (o, v) => o.manifest = v, Manifest.get_mapper());
-                cfg.map<string>("sha512", o => o.sha512sum.to_base64(), (o, v) => o.sha512sum = new BinaryData.from_base64(v));
+                cfg.map<string>("sha512", o => o.sha512sum.to_base64(), (o, v) => o.sha512sum = Wrap.base64_string(v));
                 cfg.set_constructor(() => new RepositoryListingEntry());
             });
         }       
@@ -88,8 +90,8 @@ namespace Usm {
 
         public static PropertyMapper<RepositoryListingSignature> get_mapper() {
             return PropertyMapper.build_for<RepositoryListingSignature>(cfg => {
-                cfg.map<string>("key", o => o.key.to_base64(), (o, v) => o.key = new BinaryData.from_base64(v));
-                cfg.map<string>("signature", o => o.signature.to_base64(), (o, v) => o.signature = new BinaryData.from_base64(v));
+                cfg.map<string>("key", o => o.key.to_base64(), (o, v) => o.key = Wrap.base64_string(v));
+                cfg.map<string>("signature", o => o.signature.to_base64(), (o, v) => o.signature = Wrap.base64_string(v));
                 cfg.set_constructor(() => new RepositoryListingSignature());
             });
         }       

+ 1 - 0
src/lib/Resolver.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.DataStructures;
 
 namespace Usm {
 

+ 5 - 5
src/lib/ResourceRef.vala

@@ -1,5 +1,5 @@
 using Invercargill;
-using Invercargill.Convert;
+
 namespace Usm {
 
     public enum ResourceType {
@@ -119,7 +119,7 @@ namespace Usm {
         }
 
         public static Enumerable<ResourceType> get_types() {
-            return ate(new ResourceType[] {
+            return Iterate.these(
                 ROOT_PATH,
                 PATH,
                 OPTIONAL,
@@ -140,7 +140,7 @@ namespace Usm {
                 GOBJECT_IR,
                 TYPELIB,
                 TAG
-            });
+            );
         }
     }
 
@@ -345,10 +345,10 @@ namespace Usm {
         }
 
         private bool check_pc() {
-            var paths = ate(new string[] { "/usr/lib/pkgconfig", "/usr/lib64/pkgconfig", "/usr/share/pkgconfig" });
+            var paths = Iterate.these("/usr/lib/pkgconfig", "/usr/lib64/pkgconfig", "/usr/share/pkgconfig");
             var env = Environment.get_variable("PKG_CONFIG_PATH");
             if(env != null) {
-                paths = paths.concat(ate(env.split(":")));
+                paths = paths.concat(Wrap.array(env.split(":")));
             }
 
             foreach (var path in paths) {

+ 1 - 0
src/lib/State/OriginInformation.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.Mapping;
 
 namespace Usm {
 

+ 4 - 4
src/lib/State/State.vala

@@ -24,17 +24,17 @@ namespace Usm {
         }
 
         public Enumerable<CachedPackage> get_cached_packages() throws Error {
-            return directory(Path.build_filename(state_path, "packages"))
+            return Iterate.directory(Path.build_filename(state_path, "packages"))
                 .select<CachedPackage>(d => new CachedPackage(Path.build_filename(state_path, "packages", d)));
         }
 
         public Enumerable<CachedPackage> get_installed_packages() throws Error {
-            return directory(Path.build_filename(state_path, "installed"))
+            return Iterate.directory(Path.build_filename(state_path, "installed"))
                 .select<CachedPackage>(d => new CachedPackage(Path.build_filename(state_path, "installed", d)));
         }
 
         public Enumerable<Repository> get_repositories() throws Error {
-            return directory(Path.build_filename(config_path, "repos.d"))
+            return Iterate.directory(Path.build_filename(config_path, "repos.d"))
                 .attempt_select<Repository>(d => new Repository.from_file(Path.build_filename(config_path, "repos.d", d)))
                 .to_series();
         }
@@ -45,7 +45,7 @@ namespace Usm {
                 return null;
             }
 
-            var latest = directory(list_path)
+            var latest = Iterate.directory(list_path)
                 .where(f => f.has_suffix(".usml"))
                 .contextualised_select<DateTime>(f => new DateTime.from_iso8601(f.replace(".usml", ""), null))
                 .sort((a, b) => b.result.compare(a.result))

+ 7 - 7
src/lib/Tag/Tag.vala

@@ -1,5 +1,5 @@
 using Invercargill;
-using Invercargill.Convert;
+using Invercargill.Mapping;
 
 namespace Usm {
 
@@ -19,8 +19,8 @@ namespace Usm {
             if(name.down() != name) {
                 throw new TagError.INVALID_NAME("Tags may only contain lowercase characters");
             }
-            if(ate(INVALID_SEQUENCES).any(seq => name.contains(seq))) {
-                var sequences = ate(INVALID_SEQUENCES).to_string(s => @"\"$s\"", ", ");
+            if(Wrap.array(INVALID_SEQUENCES).any(seq => name.contains(seq))) {
+                var sequences = Wrap.array(INVALID_SEQUENCES).to_string(s => @"\"$s\"", ", ");
                 throw new TagError.INVALID_NAME(@"Tags may not contain any of the following characters or sequences: $sequences");
             }
             this.name = name;
@@ -46,7 +46,7 @@ namespace Usm {
         }
         
         public Tag? get_parent() {
-            var parts = ate(name.split("."));
+            var parts = Wrap.array(name.split("."));
             if(parts.count() < 2) {
                 return null;
             }
@@ -57,18 +57,18 @@ namespace Usm {
             var paths = new Paths.usm_environ();
             var path = paths.get_tag_dir_path(name);
             if(!File.new_for_path(path).query_exists()) {
-                return Invercargill.empty<Tag>();
+                return Iterate.nothing<Tag>();
             }
 
             try {
-                return directory(path)
+                return Iterate.directory(path)
                     .where(f => f.has_suffix(".tag"))
                     .select<Tag>(f => read(f.substring(0, f.length - 4)))
                     .where(t => t != null);
             }
             catch (Error e) {
                 critical(@"Could not read children of tag $name: failed to read directory $(path): $(e.message)");
-                return Invercargill.empty<Tag>();
+                return Iterate.nothing<Tag>();
             }
         }
 

+ 12 - 11
src/lib/Transaction.vala

@@ -1,4 +1,5 @@
 using Invercargill;
+using Invercargill.DataStructures;
 
 namespace Usm {
 
@@ -9,10 +10,10 @@ namespace Usm {
         public Set<CachedPackage> to_install { get; set; }
         public Set<CachedPackage> to_remove { get; set; }
 
-        public signal void progress_updated(TransactionTask task_type, string subject, int current_task, int total_tasks, float task_progress);
+        public signal void progress_updated(TransactionTask task_type, string subject, uint current_task, uint total_tasks, float task_progress);
 
-        private int task_count = 0;
-        private int current_task = 0;
+        private uint task_count = 0;
+        private uint current_task = 0;
         private string current_subject = "transaction";
         private Vector<Vector<CachedPackage>> install_lots;
         private Vector<CachedPackage> remove_order;
@@ -44,7 +45,7 @@ namespace Usm {
         }
 
         private string previous_key = "";
-        public void print_progress(TransactionTask task_type, string subject, int current_task, int total_tasks, float task_progress) {
+        public void print_progress(TransactionTask task_type, string subject, uint current_task, uint total_tasks, float task_progress) {
             var verb = task_type.get_verb();
             verb = verb[0].toupper().to_string() + verb.substring(1);
             var percent = (int)(task_progress * 100.0f);
@@ -56,7 +57,7 @@ namespace Usm {
             printerr(@"$prefix[$(current_task+1)/$total_tasks] $verb $subject ($percent%)\n");
         }
 
-        public void print_progress_simple(TransactionTask task_type, string subject, int current_task, int total_tasks, float task_progress) {
+        public void print_progress_simple(TransactionTask task_type, string subject, uint current_task, uint total_tasks, float task_progress) {
             var verb = task_type.get_verb();
             verb = verb[0].toupper().to_string() + verb.substring(1);
             var percent = (int)(task_progress * 100.0f);
@@ -65,8 +66,8 @@ namespace Usm {
 
         public void strategise() throws TransactionError {
             task_count = (to_install.count() * 4) + (to_remove.count() * 3) + 1;
-            var strategise_worst_case_task_count = (to_remove.count() * to_remove.count()) + (to_install.count() * to_install.count());
-            var strategise_current_task = 0;
+            uint strategise_worst_case_task_count = (to_remove.count() * to_remove.count()) + (to_install.count() * to_install.count());
+            uint strategise_current_task = 0;
 
             report_progress(TransactionTask.STRATEGISING, 0.0f);
             
@@ -78,12 +79,12 @@ namespace Usm {
             while(true) {
                 strategise_current_task = round * to_install.count();
                 var lot = new Vector<CachedPackage>();
-                var remaining = to_install.difference(touched);
+                var remaining = to_install.exclude(touched);
                 if(remaining.count() == 0) {
                     break;
                 }
 
-                foreach (var package in to_install.difference(touched)) {
+                foreach (var package in to_install.exclude(touched)) {
                     report_progress(TransactionTask.STRATEGISING, (float)strategise_current_task / (float)strategise_worst_case_task_count);
                     try {
                         var manifest = package.get_manifest();
@@ -91,7 +92,7 @@ namespace Usm {
                         if(installtime_dependencies.all(d => d.is_satisfied() || available_resources.any(r => d.satisfied_by(r)))) {
                             lot.add(package);
                             touched.add(package);
-                            available_resources.add_all(manifest.provides.select<ResourceRef>(p => p.key));
+                            available_resources.union_with(manifest.provides.select<ResourceRef>(p => p.key));
                         }
                         strategise_current_task++;
                     }
@@ -101,7 +102,7 @@ namespace Usm {
                 }
 
                 if(lot.count() == 0) {
-                    var packages = to_install.difference(touched).to_string(p => p.package_name, ", ");
+                    var packages = to_install.exclude(touched).to_string(p => p.package_name, ", ");
                     throw new TransactionError.INVALID_TRANSACTION(@"Could not build a transaction strategy, packages $(packages) have unmet or cyclical dependencies");
                 }
 

+ 2 - 0
src/lib/TransactionSummary.vala

@@ -1,4 +1,6 @@
 using Invercargill;
+using Invercargill.DataStructures;
+using Invercargill.Mapping;
 using InvercargillJson;
 
 namespace Usm {

+ 1 - 1
src/lib/meson.build

@@ -31,7 +31,7 @@ dependencies = [
     dependency('gio-2.0'),
     dependency('gee-0.8'),
     dependency('json-glib-1.0'),
-    dependency('invercargill'),
+    dependency('invercargill-1'),
     dependency('invercargill-json'),
     dependency('libarchive'),
     meson.get_compiler('vala').find_library('libsodium', dirs: vapi_dir),