Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instruction to be used in .zon #5

Merged
merged 1 commit into from
Sep 25, 2023
Merged

Conversation

iacore
Copy link
Contributor

@iacore iacore commented Sep 15, 2023

Don't merge this yet! You need to publish your own archive files, and change this patch to mention the files you created.

See ziglang/zig#17064 keybase/client#10800 (comment)

Edit: I misunderstood this.

@greenfork
Copy link
Owner

So do I need to have a script like this one that I run to upload tarballs to GitHub?

.version = "0.0.1",
.dependencies = .{
.jzignet = .{
.url = "https://github.com/greenfork/jzignet/archive/<commit>.tar.gz",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The keybase issue says that GitHub can arbitrarily change archived source tarballs. We should probably use tags here and manually upload the archives?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not it is not a problem. andrewk said that the Zig hash won't change, since it's based on extracted content.

Also, btrfs on Linux has a bug that made the hash different, which is fixed just now (Linux 6.5.3).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't merge this yet! You need to publish your own archive files, and change this patch to mention the files you created.

What did you mean by this then? GitHub already has archives for each release

Copy link
Contributor Author

@iacore iacore Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood how zig's hash works. Apparently, you can use the Github tarball.
caveat: The Github tarball doesn't include git submodules.

}
```

Next, run `zig build`. There should be an error telling you to include `.hash = ......` in `build.zig.zon`. Paste the line from the terminal.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this instruction for me or for the end user? I have a feeling that that I need to do this manually and provide a hash inside the readme for the tarball I have created

Copy link
Contributor Author

@iacore iacore Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can put this code snippet on each release page, with the correct hash.

And then you can make readme shorter.

@greenfork greenfork merged commit 28c272e into greenfork:master Sep 25, 2023
@greenfork
Copy link
Owner

I will merge this and get working instructions on the readme

@greenfork
Copy link
Owner

Here is a patch for your repository that uses zon:

commit 047a494cf09d73b840a75350c660f1dea93e9dca
Author: Dmitry Matveyev <public@greenfork.me>
Date:   Tue Sep 26 00:48:57 2023 +0600

    Use zon module instead of a git submodule

diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 762339d..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "lib/jzignet"]
-	path = lib/jzignet
-	url = https://github.com/greenfork/jzignet/
diff --git a/build.zig b/build.zig
index be5bf00..4554160 100644
--- a/build.zig
+++ b/build.zig
@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) void {
     // set a preferred release mode, allowing the user to decide how to optimize.
     const optimize = b.standardOptimizeOption(.{});
 
-    const lib_jzignet = b.anonymousDependency("lib/jzignet", @import("lib/jzignet/build.zig"), .{});
+    const lib_jzignet = b.dependency("jzignet", .{ .target = target, .optimize = optimize });
 
     const exe = b.addExecutable(.{
         .name = "janet-zig-catalog",
diff --git a/build.zig.zon b/build.zig.zon
new file mode 100644
index 0000000..74af452
--- /dev/null
+++ b/build.zig.zon
@@ -0,0 +1,10 @@
+.{
+    .name = "janet-zig-test",
+    .version = "0.0.1",
+    .dependencies = .{
+        .jzignet = .{
+            .url = "https://git.sr.ht/~greenfork/jzignet/archive/0.7.0.tar.gz",
+            .hash = "1220e5739ec063602a628d5b03265f7b55933158574e97dbac0696a73586d9416162",
+        },
+    },
+}
diff --git a/lib/jzignet b/lib/jzignet
deleted file mode 160000
index 35d7f61..0000000
--- a/lib/jzignet
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 35d7f61d34450f332f10bc8d5a698cfe3c937ace

@iacore
Copy link
Contributor Author

iacore commented Sep 25, 2023

Thanks! I've applied the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants