From faf6ddc3e2f66a1ee55ddef29275ea4c1a7291bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=96R=C3=96SK=C5=90I=20Andr=C3=A1s?= Date: Thu, 10 Mar 2022 23:19:38 +0100 Subject: [PATCH 1/3] Add pijul support --- src/common.zig | 10 ++++++++++ src/util/dep_type.zig | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/common.zig b/src/common.zig index f572d40..408742a 100644 --- a/src/common.zig +++ b/src/common.zig @@ -205,6 +205,16 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! try std.fs.deleteFileAbsolute(file_path); return p; }, + .pijul => { + if (!try u.does_folder_exist(p)) { + try d.type.pull(options.alloc, d.path, p); + } else { + if (options.update) { + try d.type.update(options.alloc, p, d.path); + } + } + return p; + }, } } diff --git a/src/util/dep_type.zig b/src/util/dep_type.zig index 865b826..9def3c3 100644 --- a/src/util/dep_type.zig +++ b/src/util/dep_type.zig @@ -14,6 +14,23 @@ pub const DepType = enum { git, // https://git-scm.com/ hg, // https://www.mercurial-scm.org/ http, // https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol + pijul, // https://pijul.org/ + // svn, // https://subversion.apache.org/ + // fossil, // https://fossil-scm.org/ + // cvs, // https://nongnu.org/cvs/ + // darcs, // http://darcs.net/ + // // + // bazaar, // https://bazaar.canonical.com/en/ + // // + // ftp, // https://en.wikipedia.org/wiki/File_Transfer_Protocol + // ssh, // https://www.ssh.com/ssh/ + // onion, // https://www.torproject.org/ + // i2p, // https://geti2p.net/en/ + // torrent, // https://en.wikipedia.org/wiki/BitTorrent + // magnet, // https://en.wikipedia.org/wiki/BitTorrent + // dat, // https://www.datprotocol.com/ + // ipfs, // https://www.ipfs.com/ + // hypercore, // https://hypercore-protocol.org/ // zig fmt: on pub fn pull(self: DepType, alloc: std.mem.Allocator, rpath: string, dpath: string) !void { @@ -38,6 +55,9 @@ pub const DepType = enum { u.assert((try u.run_cmd(alloc, dpath, &.{ "tar", "-xf", f, "-C", "." })) == 0, "un-tar {s} failed", .{f}); } }, + .pijul => { + u.assert((try u.run_cmd(alloc, null, &.{ "pijul", "clone", rpath, dpath })) == 0, "pijul clone {s} {s} failed", .{ rpath, dpath }); + }, } } @@ -58,6 +78,9 @@ pub const DepType = enum { .http => { // }, + .pijul => { + u.assert((try u.run_cmd(alloc, dpath, &.{ "pijul", "pull" })) == 0, "pijul pull failed", .{}); + }, } } @@ -71,6 +94,7 @@ pub const DepType = enum { .git => try std.fmt.allocPrint(alloc, "commit-{s}", .{(try u.git_rev_HEAD(alloc, mdir))}), .hg => "", .http => "", + .pijul => "", }; } @@ -82,6 +106,7 @@ pub const DepType = enum { .git => false, .hg => false, .http => false, + .pijul => false, }; } From affde0ef54ff72de82c85f2667560d1160151d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=96R=C3=96SK=C5=90I=20Andr=C3=A1s?= Date: Sun, 13 Mar 2022 23:28:38 +0100 Subject: [PATCH 2/3] pijul depends: add channel support --- src/common.zig | 29 +++++++++++++++++++++++++++++ src/util/dep_type.zig | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/src/common.zig b/src/common.zig index 408742a..06247c2 100644 --- a/src/common.zig +++ b/src/common.zig @@ -206,6 +206,35 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! return p; }, .pijul => { + if (d.version.len > 0) { + const vers = u.parse_split(zigmod.DepType.Version.Pijul, "-").do(d.version) catch |e| switch (e) { + error.IterEmpty => unreachable, + error.NoMemberFound => { + const vtype = d.version[0..std.mem.indexOf(u8, d.version, "-").?]; + u.fail("pijul: version type '{s}' is invalid.", .{vtype}); + }, + }; + // this version is already pulled + if (try u.does_folder_exist(pv)) { + if (vers.id == .channel) { + if (options.update) { + // This does not work with pijul, have to use explicit channel name + // try d.type.update(options.alloc, pv, d.path); + if ((try u.run_cmd(options.alloc, pv, &.{ "pijul", "pull", "--all", "--from-channel", vers.string })) > 0) { + u.fail("pijul pull --from-channel {s}: did not succeed", .{vers.string}); + } + } + } + return pv; + } + // version has not pulled yet + if ((try u.run_cmd(options.alloc, null, &.{ "pijul", "clone", "--channel", vers.string, d.path, pv })) > 0) { + u.fail("pijul clone --channel: {s}: {s} {s} does not exist", .{ d.path, @tagName(vers.id), vers.string }); + } + return pv; + } + + // no version string if (!try u.does_folder_exist(p)) { try d.type.pull(options.alloc, d.path, p); } else { diff --git a/src/util/dep_type.zig b/src/util/dep_type.zig index 9def3c3..e5c7dbd 100644 --- a/src/util/dep_type.zig +++ b/src/util/dep_type.zig @@ -117,6 +117,7 @@ pub const DepType = enum { git: Git, hg: void, http: void, + pijul: Pijul, pub const Git = enum { branch, @@ -131,5 +132,8 @@ pub const DepType = enum { }; } }; + pub const Pijul = enum { + channel, + }; }; }; From fec062ec91d8d6e58064b1e659144cea405f5e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=96R=C3=96SK=C5=90I=20Andr=C3=A1s?= Date: Mon, 14 Mar 2022 21:40:13 +0100 Subject: [PATCH 3/3] docs: add pijul support --- docs/zig.mod.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/zig.mod.md b/docs/zig.mod.md index dcf6c1c..a710dcc 100644 --- a/docs/zig.mod.md +++ b/docs/zig.mod.md @@ -81,6 +81,7 @@ The available `type`s are: - `git` - `hg` - `http` +- `pijul` For the full details on `Dep` types, you can check out the source where the enum is defined: https://github.com/nektro/zigmod/blob/master/src/util/dep_type.zig. @@ -107,6 +108,8 @@ Version types available to each Dep type: - `blake3` - `sha256` - `sha512` +- `pijul` + - `channel` #### Dep `only_os` - Type: `comma-split string[]`