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

common-updater: use nix-prefetch-url to get new hash #31627

Closed
wants to merge 3 commits into from

Conversation

Mic92
Copy link
Member

@Mic92 Mic92 commented Nov 13, 2017

Motivation for this change

that way the downloaded archive is not discarded.

@dezgeg

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

that way the downloaded archive is not discarded.
nix-build --no-out-link -A "$attr.src" 2>"$attr.fetchlog" >/dev/null || true
# FIXME: use nix-build --hash here once https://github.com/NixOS/nix/issues/1172 is fixed
newHash=$(tail -n2 "$attr.fetchlog" | grep "output path .* has .* hash .* when .* was expected" | head -n1 | tr -dc '\040-\177' | awk '{ print $(NF-4) }')
newHash=$(nix-prefetch-url -A "$attr.src" 2>"$attr.fetchlog")
Copy link
Member Author

Choose a reason for hiding this comment

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

Also replaced hashes contained enclosing ' characters before.

@dezgeg
Copy link
Contributor

dezgeg commented Nov 13, 2017

Have you tried this for something using fetchForGitHub or fetchgit?

@dezgeg
Copy link
Contributor

dezgeg commented Nov 13, 2017

(BTW if you want to look at my existing auto-updater stuff it's at https://github.com/dezgeg/nixpkgs/blob/updater-next/pkgs/common-updater/scripts/list-upstream-versions, eye bleach needed at least currently ;)

@Mic92
Copy link
Member Author

Mic92 commented Nov 13, 2017

@dezgeg yes since some time all pre-fetch scripts has been replaced by nix-prefetch-url.

@@ -34,6 +34,20 @@ if [ -z "$drvName" -o -z "$oldVersion" ]; then
die "Couldn't evaluate name and version from '$attr.name'!"
fi

if [ -z "$newVersion" ]; then
# works for fetchFromGitHub & fetchgit
url=$(nix-instantiate --eval --strict --expr "with import <nixpkgs> {}; if $attr ? src.meta.homepage then $attr.src.meta.homepage else $attr.src.url")
Copy link
Member Author

@Mic92 Mic92 Nov 13, 2017

Choose a reason for hiding this comment

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

seems like I have reinvented the wheel, since I saw your comment too late.

@dezgeg
Copy link
Contributor

dezgeg commented Nov 13, 2017

Try this:

./pkgs/common-updater/scripts/update-source-version dtc 1.4.5

@Mic92
Copy link
Member Author

Mic92 commented Nov 14, 2017

the old version prints sha256 = "'10y5pbkcj5gkijcgnlvrh6q2prpnvsgihb9asz3zfp66mcjwzsy3'"; which is also incorrect. so this is no regression.

@dezgeg
Copy link
Contributor

dezgeg commented Nov 15, 2017

Ah, which Nix version is that? It works on 1.11.15 which gives sha256 = "10y5pbkcj5gkijcgnlvrh6q2prpnvsgihb9asz3zfp66mcjwzsy3";

@Mic92
Copy link
Member Author

Mic92 commented Nov 15, 2017

I will rather rewrite this in some more robust than shell.

@Mic92 Mic92 closed this Nov 15, 2017
@dezgeg
Copy link
Contributor

dezgeg commented Nov 15, 2017

Yeah, I don't mind rewriting that script, as long as the functionality is equivalent or better ;) and that we don't end up in a situation where every single script in nixpkgs is written in a different language. Probably Python is the next most popular one after Bash and Perl.

But, IMHO this 'figure out latest version from GitHub/Apache directory listings/divine knowledge' belongs in another script. In my grand vision (which is not yet written down anywhere unfortunately) there would be a system similar to the phases in stdenv where individual packages could override only some parts of the update process.

@makefu
Copy link
Contributor

makefu commented Nov 28, 2017

@dezgeg i am having the same issue with single-quotes in the checksum with nix-unstable 1.12.
However simply adding an older version of nix to the path does not solve the issue.
It seems like the nix-daemon responds differently from before, e.g. :

nix-daemon 1.11:

output path ‘/nix/store/6vrsawvsmah5jd2gsl15y9229lqyc3rk-source‘ has r:sha256 hash ‘031ndvinsypagpkdszxjq0hj91ijq9zx4dzk53sz7il7s3zn65c7‘ when ‘000...000‘ was expected

nix-daemon unstable 1.12:

output path '/nix/store/6vrsawvsmah5jd2gsl15y9229lqyc3rk-source' has r:sha256 hash '031ndvinsypagpkdszxjq0hj91ijq9zx4dzk53sz7il7s3zn65c7' when '000...000' was expected

@Mic92 Mic92 deleted the common-updater branch September 6, 2018 08:46
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

4 participants