Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ Every command Herdr runs for the plugin goes through `bin/run.sh`, which runs `t
source file is newer than it. Then open the board ([get started](docs/get-started.md)).

**Updating** is `git pull`, then `cargo build --release` again; an open board and the keeper load the new program by
themselves. Build right after each pull: while the build is older than its source, `bin/run.sh` falls back to
upstream's v1.2.27 program, downloaded, which has none of the changes above. `herdr-projects update` is no use here:
it downloads upstream's releases, not this copy (this repo publishes none, and upstream's newest are Shepherdr's), and
a program built from source refuses it anyway.
themselves. Build right after each pull: while the build is older than its source, `bin/run.sh` says so on every
command and runs the older build. It never downloads upstream's program: the only releases it looks at are this
repo's, and there are none yet. For the same reason `herdr-projects update` finds nothing here, and a program built
from source refuses it anyway.

`herdr plugin install eliasstravik/herdr-projects` installs upstream, now Shepherdr. A `herdr plugin install` of this
repo would get upstream's prebuilt 1.2.27 program in its build step instead of building this copy: use a checkout as
above. [Installing](docs/install.md) has the details.
repo builds this copy from source in its build step, so it needs Rust there too. [Installing](docs/install.md) has
the details.

---

Expand Down Expand Up @@ -169,7 +169,7 @@ An agent that asks you something, wants a permission or a sign-in says so to the
git pull && cargo build --release # in your checkout of this repo
```

An open board and the keeper see the new program and load it by themselves, once nothing is half typed and no agent is held up. This copy publishes no releases, so `herdr-projects update` is no use here ([install and update this copy](#install-and-update-this-copy)). [Installing](docs/install.md) has the details.
An open board and the keeper see the new program and load it by themselves, once nothing is half typed and no agent is held up. This copy publishes no releases, so `herdr-projects update` finds nothing here ([install and update this copy](#install-and-update-this-copy)). [Installing](docs/install.md) has the details.

## Get your questions answered

Expand Down
9 changes: 6 additions & 3 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# download is tried again ten minutes later, not on every command.
# When there is none it says on stderr what to do and exits 1: it never waits long, so it never holds herdr up.
# `run.sh --fetch` only gets the program (the plugin's build step), building it from source when it cannot download.
# The releases are this repo's own (jbutton/herdr-projects-legacy), never upstream's: upstream is Shepherdr now, and its
# 1.2.27 program has none of this copy's changes. This copy has no release yet, so today the download finds nothing and
# step 4, or the build, is what runs.
# HERDR_PROJECTS_RELEASES names another place for the releases (a fork, a mirror, a folder as file:///…).
here=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
root=$(dirname -- "$here")
Expand All @@ -28,7 +31,7 @@ case "$(uname -s)" in Linux) os=linux ;; Darwin) os=macos ;; *) os="" ;; esac
case "$(uname -m)" in x86_64 | amd64) arch=x86_64 ;; aarch64 | arm64) arch=aarch64 ;; *) arch="" ;; esac
name="herdr-projects-$os-$arch"
prog="$here/$name"
base="${HERDR_PROJECTS_RELEASES:-https://github.com/eliasstravik/herdr-projects/releases}"; base="${base%/}"
base="${HERDR_PROJECTS_RELEASES:-https://github.com/jbutton/herdr-projects-legacy/releases}"; base="${base%/}"

# at_least A B: A is B or newer, part by part as numbers (0.10.0 is newer than 0.9.1).
at_least() {
Expand All @@ -45,7 +48,7 @@ at_least() {
have() { [ -x "$prog" ] && v=$(cat "$prog.version" 2>/dev/null) && [ -n "$v" ] && at_least "$v" "$want"; }
[ -n "$os" ] && [ -n "$arch" ] && have && run "$prog" "$@"

gh_repo="https://github.com/eliasstravik/herdr-projects/releases/download/"
gh_repo="https://github.com/jbutton/herdr-projects-legacy/releases/download/"
fetch() {
if command -v curl >/dev/null 2>&1; then curl -fsSL --connect-timeout 10 --max-time 300 -o "$2" "$1" 2>/dev/null && return 0
elif command -v wget >/dev/null 2>&1; then wget -q --tries=1 -T 30 -O "$2" "$1" && return 0
Expand All @@ -54,7 +57,7 @@ fetch() {
case "$1" in "$gh_repo"*/*) ;; *) return 1 ;; esac
command -v gh >/dev/null 2>&1 || return 1
rest=${1#"$gh_repo"}
gh release download "${rest%%/*}" -R eliasstravik/herdr-projects -p "${rest#*/}" -O "$2" --clobber </dev/null >/dev/null 2>&1
gh release download "${rest%%/*}" -R jbutton/herdr-projects-legacy -p "${rest#*/}" -O "$2" --clobber </dev/null >/dev/null 2>&1
}
sha256() { { sha256sum "$1" || shasum -a 256 "$1" || openssl dgst -sha256 -r "$1"; } 2>/dev/null | cut -d ' ' -f 1; }
build_hint="or build it here: cd '$root' && cargo build --release (Rust: https://rustup.rs)"
Expand Down
4 changes: 3 additions & 1 deletion crates/flow/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use crate::err::Res;
use crate::store::files::{bin, write_atomic, VERSION};
use std::path::{Path, PathBuf};

pub const REPO: &str = "eliasstravik/herdr-projects";
/// This copy's own repo: its releases are the only ones downloaded, never upstream's (upstream is Shepherdr now, and
/// its 1.2.27 program has none of this copy's changes).
pub const REPO: &str = "jbutton/herdr-projects-legacy";

/// The release files' name for a platform, from `uname -s`/`uname -m` or Rust's own names. None: no release is made.
pub fn platform_of(os: &str, arch: &str) -> Option<(&'static str, &'static str)> {
Expand Down
23 changes: 13 additions & 10 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ every command Herdr runs for it goes through `bin/run.sh`, which runs that build
`sh bin/run.sh install` writes the launcher agents and hooks use
([the command on your PATH](#the-command-on-your-path)).

`herdr plugin install` would instead clone the repo into Herdr's own plugins folder and run the plugin's build step
there, which downloads upstream's prebuilt program of this version (`v1.2.27`, without this copy's changes) rather than
building it. `herdr plugin install eliasstravik/herdr-projects` installs upstream itself, which is now Shepherdr.
`herdr plugin install jbutton/herdr-projects-legacy` would instead clone the repo into Herdr's own plugins folder and
run the plugin's build step there, which builds this copy from source (there is no release of it to download).
`herdr plugin install eliasstravik/herdr-projects` installs upstream itself, which is now Shepherdr.

## The first run

Expand Down Expand Up @@ -123,10 +123,11 @@ git pull && cargo build --release # in the checkout
```

- An open board and the keeper see the file change and load it by themselves ([the board's size](board-size.md)).
- Build right after each pull: while the build is older than its source, `bin/run.sh` runs upstream's downloaded
program of this version instead ([below](#details-which-program-runs)), which has none of this copy's changes.
- `herdr-projects update` is no use here: it downloads upstream's releases, never this copy (which publishes none,
while upstream's newest are Shepherdr's), and a program built from source refuses it.
- Build right after each pull: while the build is older than its source, `bin/run.sh` runs the older build and says
so on every command ([below](#details-which-program-runs)).
- `herdr-projects update` finds nothing here: it downloads this repo's releases, and there are none yet. A program
built from source refuses it anyway. Upstream's releases are never downloaded: its newest are Shepherdr's, and its
1.2.27 program has none of this copy's changes.

**The keeper updates itself.** Once the new file has stopped changing (a build still being linked is waited for), with
no board open and no agent running, the keeper starts its successor on the new file, and goes only once the successor
Expand Down Expand Up @@ -167,9 +168,9 @@ Every command Herdr runs for the plugin goes through `bin/run.sh`, which runs th

1. a program built in this checkout (`target/release/herdr-projects`) that no source file is newer than;
2. the downloaded one in `bin/`, when it is this checkout's version (`Cargo.toml`) or newer;
3. that file, downloaded now from upstream's GitHub release of this checkout's version (this copy publishes none, so
that is upstream's `v1.2.27`, without this copy's changes): its checksum checked, put in place in one step, one
download at a time;
3. that file, downloaded now from this repo's GitHub release of this checkout's version (this copy has none yet, so
today this step finds nothing; never upstream's): its checksum checked, put in place in one step, one download at
a time;
4. failing all that, an older build or an older download, with a line saying so. A download that failed is tried again
ten minutes later, not on every command (each of Herdr's hooks would wait for it).

Expand All @@ -179,3 +180,5 @@ With none, it says what to do and stops at once, so Herdr is never held up.
download it.
- `HERDR_PROJECTS_RELEASES` names another place for the releases (a fork, a mirror, a folder as `file:///…`).
- The release files are built for every version tag by `.github/workflows/release.yml`; this copy makes no tags.
- A `bin/run.sh` from before this change downloaded upstream's 1.2.27 program into `bin/`. Where one is still there,
step 2 runs it while the build is stale: remove it once (`rm bin/herdr-projects-*`).
2 changes: 1 addition & 1 deletion tests/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn herdr_must_run_the_plugin_enabled_from_a_folder_that_is_there() {
std::fs::write(s.root.join("herdr-plugin.toml"), "id = \"herdr-projects\"\n").unwrap();
let h = |v: Option<&str>, list: Vec<serde_json::Value>| plugin::Herdr { version: v.map(String::from), plugins: Ok(list) };
assert!(bad(&plugin::check(&h(None, vec![])))[0].starts_with("herdr does not run here"));
assert!(bad(&plugin::check(&h(Some("0.9.3"), vec![])))[0].ends_with("→ Run: herdr plugin install eliasstravik/herdr-projects"));
assert!(bad(&plugin::check(&h(Some("0.9.3"), vec![])))[0].ends_with("→ Run: herdr plugin install jbutton/herdr-projects-legacy"));
assert!(bad(&plugin::check(&h(Some("0.9.3"), vec![ours(false, &s.root, true)])))[0].ends_with("but turned off → Run: herdr plugin enable herdr-projects"));
assert!(bad(&plugin::check(&h(Some("0.9.3"), vec![ours(true, &w.base.join("gone"), true)])))[0].contains("which is gone"));
assert!(bad(&plugin::check(&h(Some("0.9.1"), vec![ours(true, &s.root, true)])))[0].starts_with("herdr 0.9.1 is older than 0.9.3"));
Expand Down
8 changes: 4 additions & 4 deletions tests/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ fn platform_names_urls_and_versions() {
assert_eq!(platform_of("FreeBSD", "x86_64"), None);
assert_eq!(platform_of("Linux", "riscv64"), None);
assert_eq!(asset_name(("macos", "aarch64")), "herdr-projects-macos-aarch64");
let base = "https://github.com/eliasstravik/herdr-projects/releases";
let base = "https://github.com/jbutton/herdr-projects-legacy/releases";
assert_eq!(asset_url(base, Some("0.3.1"), "herdr-projects-linux-x86_64"), format!("{base}/download/v0.3.1/herdr-projects-linux-x86_64"));
assert_eq!(asset_url(base, Some("v0.3.1"), "a"), format!("{base}/download/v0.3.1/a"), "a version typed with its v");
assert_eq!(asset_url(base, None, "a"), format!("{base}/latest/download/a"));
// The repo is private: gh, logged in, fetches what curl is refused.
let to = Path::new("/t/f");
let gh = |u: &str| gh_args(u, to).map(|v| v.join(" "));
assert_eq!(gh(&format!("{base}/download/v0.3.1/a.sha256")).as_deref(), Some("release download v0.3.1 -R eliasstravik/herdr-projects -p a.sha256 -O /t/f --clobber"));
assert_eq!(gh(&format!("{base}/latest/download/a")).as_deref(), Some("release download -R eliasstravik/herdr-projects -p a -O /t/f --clobber"));
assert_eq!(gh(&format!("{base}/download/v0.3.1/a.sha256")).as_deref(), Some("release download v0.3.1 -R jbutton/herdr-projects-legacy -p a.sha256 -O /t/f --clobber"));
assert_eq!(gh(&format!("{base}/latest/download/a")).as_deref(), Some("release download -R jbutton/herdr-projects-legacy -p a -O /t/f --clobber"));
assert_eq!(gh("file:///mirror/download/v0.3.1/a"), None, "a mirror is fetched as it is");
for (a, b, yes) in [("0.3.0", "0.2.0", true), ("0.10.0", "0.9.1", true), ("0.3.0", "0.3.0", false), ("0.2.9", "0.3.0", false), ("1.0", "0.9.9", true), ("0.3.0.1", "0.3.0", true), ("v0.3.1", "0.3.0", true), ("0.3.0", "0.3", false)] {
assert_eq!(newer(a, b), yes, "{a} newer than {b}");
Expand All @@ -60,7 +60,7 @@ fn platform_names_urls_and_versions() {
#[test]
fn releases_are_github_unless_named() {
let (_b, _one) = scratch();
assert_eq!(releases(), "https://github.com/eliasstravik/herdr-projects/releases");
assert_eq!(releases(), "https://github.com/jbutton/herdr-projects-legacy/releases");
set("HERDR_PROJECTS_RELEASES", "file:///mirror/releases/");
assert_eq!(releases(), "file:///mirror/releases");
}
Expand Down
Loading