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

miru: added passthru.updateScript #325352

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

matteo-pacini
Copy link
Contributor

@matteo-pacini matteo-pacini commented Jul 7, 2024

Description of changes

Added an update script for Miru.

To test it (in my branch):

nix-shell maintainers/scripts/update.nix --argstr package miru

Then build miru again - nix-build -A miru - and run it.

It should be the latest available version: 5.1.10 at the time of this port.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/4210

Comment on lines 16 to 17
MIRU_LATEST_VER=$(curl -s "https://api.github.com/repos/ThaUnknown/miru/releases/latest" | jq -r .tag_name | sed 's/v//')
MIRU_CURRENT_VER=$(grep -oP 'version = "\K[^"]+' "$PACKAGE_NIX")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
MIRU_LATEST_VER=$(curl -s "https://api.github.com/repos/ThaUnknown/miru/releases/latest" | jq -r .tag_name | sed 's/v//')
MIRU_CURRENT_VER=$(grep -oP 'version = "\K[^"]+' "$PACKAGE_NIX")
MIRU_LATEST_VER="$(curl -s "https://api.github.com/repos/ThaUnknown/miru/releases/latest" | jq -r .tag_name | sed 's/v//')"
MIRU_CURRENT_VER="$(grep -oP 'version = "\K[^"]+' "$PACKAGE_NIX")"

LINUX_NIX="$ROOT/linux.nix"
DARWIN_NIX="$ROOT/darwin.nix"

MIRU_LATEST_VER=$(curl -s "https://api.github.com/repos/ThaUnknown/miru/releases/latest" | jq -r .tag_name | sed 's/v//')
Copy link
Member

Choose a reason for hiding this comment

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

You should specify that you only want to remove the starting v (in case the versioning format ever changes we never know)

Suggested change
MIRU_LATEST_VER=$(curl -s "https://api.github.com/repos/ThaUnknown/miru/releases/latest" | jq -r .tag_name | sed 's/v//')
MIRU_LATEST_VER=$(curl -s "https://api.github.com/repos/ThaUnknown/miru/releases/latest" | jq -r .tag_name | sed 's/^v//')

We could use a more robust regex (s/^v([0-9]+\.[0-9]+\.[0-9]+)$/\1) to be sure that this does not break in case the versioning system changes. But keeping it simple should suffice and will avoid any potential error (and it's more readable), so I will leave it up to you to decide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Keeping the readable one for now, will revisit if things change upstream

LINUX_NIX="$ROOT/linux.nix"
DARWIN_NIX="$ROOT/darwin.nix"

MIRU_LATEST_VER=$(curl -s "https://api.github.com/repos/ThaUnknown/miru/releases/latest" | jq -r .tag_name | sed 's/v//')
Copy link
Member

Choose a reason for hiding this comment

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

Please check whether the request returned a valid result (e.g. if the repository's name changes the version tag will be null, raising a rather unclear error message from nix-prefetch-url, which could be prevented)

--- SHOWING ERROR LOG FOR miru-5.1.6 ----------------------

error: unable to download 'https://github.com/ThaUnknown/mirud/releases/download/vnull/linux-Miru-null.AppImage': HTTP error 404

       response body:

       Not Found
error: hash '' has wrong length for hash type 'sha256'


--- SHOWING ERROR LOG FOR miru-5.1.6 ----------------------
The update script for miru-5.1.6 failed with exit code 1

Copy link
Member

@d4ilyrun d4ilyrun left a comment

Choose a reason for hiding this comment

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

Oops, I'm sorry I unintentionally approved and github won't let me remove my approval 😓
Please address my remarks first.

@d4ilyrun
Copy link
Member

d4ilyrun commented Jul 8, 2024

  • Tested on x86_64-linux

@matteo-pacini
Copy link
Contributor Author

@d4ilyrun comments addressed, retested on aarch64-darwin on my end, all good 👍🏻

MIRU_CURRENT_VER="$(grep -oP 'version = "\K[^"]+' "$PACKAGE_NIX")"

if [[ "$MIRU_LATEST_VER" == "null" ]]; then
echo "error: could not fetch miru latest version from GitHub API"
Copy link
Member

Choose a reason for hiding this comment

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

The update.py script only displays the content of stderr when an error occurs.

Suggested change
echo "error: could not fetch miru latest version from GitHub API"
echo "error: could not fetch miru latest version from GitHub API" >&2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@d4ilyrun fixed


ROOT="$(dirname "$(readlink -f "$0")")"
if [[ ! "$(basename $ROOT)" == "miru" || ! -f "$ROOT/package.nix" ]]; then
echo "ERROR: Not in the miru folder"
Copy link
Member

@d4ilyrun d4ilyrun Jul 8, 2024

Choose a reason for hiding this comment

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

Oops sorry I missed this one, same as the previous error message

Suggested change
echo "ERROR: Not in the miru folder"
echo "error: Not in the miru folder" >&2

Copy link
Member

Choose a reason for hiding this comment

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

LGTM after this one !

Copy link
Member

Choose a reason for hiding this comment

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

@matteo-pacini You re-requested a review but did not fix this last issue, was this a mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@d4ilyrun yup, my bad! Forgot to push the changes 😇

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/4218

@eclairevoyant
Copy link
Member

Does nix-update not work? I thought it handled gh releases.

Copy link
Member

@d4ilyrun d4ilyrun left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@matteo-pacini
Copy link
Contributor Author

Does nix-update not work? I thought it handled gh releases.

@eclairevoyant Didn't know it could, hence the custom approach 🙏🏻

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/1828

LINUX_NIX="$ROOT/linux.nix"
DARWIN_NIX="$ROOT/darwin.nix"

MIRU_LATEST_VER="$(curl -s "https://api.github.com/repos/ThaUnknown/miru/releases/latest" | jq -r .tag_name | sed 's/^v//')"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
MIRU_LATEST_VER="$(curl -s "https://api.github.com/repos/ThaUnknown/miru/releases/latest" | jq -r .tag_name | sed 's/^v//')"
MIRU_LATEST_VER="$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/ThaUnknown/miru/releases/latest" | jq -r .tag_name | sed 's/^v//')"

exit 1
fi

if [ "$MIRU_LATEST_VER" = "$MIRU_CURRENT_VER" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if [ "$MIRU_LATEST_VER" = "$MIRU_CURRENT_VER" ]; then
if [[ "$MIRU_LATEST_VER" == "$MIRU_CURRENT_VER" ]]; then

please use new test consistently

@matteo-pacini
Copy link
Contributor Author

@SuperSandro2000 comments addressed, thanks

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/1838

@matteo-pacini
Copy link
Contributor Author

@SuperSandro2000 friendly ping so we can get this merged 🙏🏻 thanks!

Comment on lines +6 to +10
ROOT="$(dirname "$(readlink -f "$0")")"
if [[ ! "$(basename $ROOT)" == "miru" || ! -f "$ROOT/package.nix" ]]; then
echo "error: Not in the miru folder" >&2
exit 1
fi
Copy link
Member

Choose a reason for hiding this comment

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

nixpkgs-update and r-ryantm will usually call the update script from nixpkgs root folder. You can test this easily with nix-update -u miru

Copy link
Contributor Author

@matteo-pacini matteo-pacini Aug 1, 2024

Choose a reason for hiding this comment

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

@pbsds left another comment in #329752 - r-ryantm stopped calling the update script for some reason after that change?

Copy link
Member

Choose a reason for hiding this comment

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

please note the -u, which will call the passthru.updateScript

@matteo-pacini
Copy link
Contributor Author

@SuperSandro2000 friendly ping for merge, as this has been alive for 3 weeks now 🙏🏻

@tomberek
Copy link
Contributor

tomberek commented Aug 2, 2024

functions as expected... further updates to 5.2.7 pending

@tomberek tomberek merged commit 6d4f247 into NixOS:master Aug 2, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants