Commit Graph

41 Commits

Author SHA1 Message Date
Jan Tojnar
e628b43a9c common-updater-scripts: fix silent error on 404
When TOFU was unable to download the file, there would be no hash
in the fetch log, causing the grep to fail. Since the script
is set to errexit, it would terminate the processing without
any output. Let’s instead print the fetch log.
2022-09-27 02:19:25 +02:00
Jan Tojnar
31c2154465 common-updater-scripts: Use custom fake temporary hash
Some update scripts (e.g. sublime4) already use all-zeroes hashes
for resetting a version when updating multiple sources.
When `update-source-version "${attrPath}" 0 "${lib.fakeSha256}"`
was executed, u-s-v would not be able to detect that the hash
changed and would fail with the following message:

    Failed to replace temporary source hash of '…' to the final source hash!

The update script worked when we tested it because change detection itself
was broken until recently: https://github.com/NixOS/nixpkgs/pull/190554
2022-09-16 18:36:01 +02:00
Jan Tojnar
ee1795cc87 common-updater-scripts: Only look for URL when replacing it
This would do a pointless slow `nix-instantiate` call for a feature
that is rarely used – initially, it was added for Firefox updates
186de9ca9e
but now not even that uses it.

Additionally, this would break stuff like `cargoDeps`,
which lack the url attributes.
2022-09-09 22:31:28 +02:00
Jan Tojnar
17bc96df08 common-updater-scripts: Fix replacement failure detections
Previously, we only made `sed` back up the version replacement.
This meant that `cmp` would already recognize the files
as changed before replacing hash and the other values,
and the error would not be printed.

Let’s always make the `sed` create a backup so that we can
detect success of each situation. This will no longer
allow us to revert to the original version on failure
but the updated file should be tracked in git anyway.
2022-09-09 22:31:28 +02:00
OPNA2608
0276d2fcbb common-updater-scripts/update-source-version: Add flag required for nix-command 2022-07-07 23:01:35 +02:00
Jan Tojnar
d9ff6d90aa common-updater-scripts: Silence outPath check
It is expected to fail in repos not using flakes-compat (like Nixpkgs).
2021-12-31 07:06:27 +01:00
Jan Tojnar
d9dea8d2a9 common-updater-scripts: allow using different src attribute
Useful for packages with multiple sources.
2021-12-31 06:54:42 +01:00
Samuel Gräfenstein
17d18904e2
common-updater-scripts/update-source-version: Fix on Nix 2.4 2021-10-03 20:24:12 +02:00
Jan Tojnar
3771de8ae0
common-updater-scripts: Support attribute lookup in flake
In flakes, packages are not exposed directly but instead they are declared
inside “packages” or “legacyPackages” output under their host platform.
flake-compat reflects this.

Let’s look for an attribute also in these outputs if the direct lookup fails.
2021-04-24 04:52:48 +02:00
Jan Tojnar
38e20a3242
common-updater-scripts: Replace flake source by local path
When update-source-version is run in a repo with flake-compat,
it would find the files in Nix store.

Let’s replace them with the local path of the repository.
2021-04-24 03:42:01 +02:00
Jan Tojnar
3c781e6d19
common-updater-scripts: handle default.nix without arguments
So that the script can be used outside of nixpkgs.
For example, the default.nix recommended by flake-compat does not take arguments.
2021-04-24 03:41:33 +02:00
Jan Tojnar
d788c091b6
common-updater-scripts: remove lib dependency
So that the script can be used outside of nixpkgs.
2021-04-24 02:50:53 +02:00
Matej Urbas
ca9e2a3c3b pkgs.common-updater-scripts: update-source-version name singular 2021-01-09 10:08:52 +00:00
Francesco Gazzetta
4d8e0f9b77 common-updater-scripts: add --rev to update-source-version
Adds a --rev=<revision> parameter to the script that makes it possible
to explicitly specify a new revision.
Useful to update unstable packages, where the version and revision may
be independent.
2020-11-21 11:26:46 +01:00
Jan Tojnar
d351cea9f3
common-updater-scripts: add --print-changes flag
Printing the changed file and new version can be used to commit the changes to git.
2020-09-19 17:02:54 +02:00
Jan Tojnar
09a4a051e8
common-updater-scripts: Fix replacing SRI hashes
SRI hashes (base64 encoded) can contain + sign which is a special character
in extended regular expressions so it needs to be escaped.
2020-02-20 07:18:36 +01:00
Jan Tojnar
2e9eb449eb
common-updater-scripts: Handle errors in src hashing
Previously, when downloading src failed for other reason than hash mismatch,
the error ended up in newHash. This made evaluation fail since the error message
is not valid hash. Now the failure will make newHash empty.

It is also much cleaner than previously since \K is very cool thing
and we no longer grep for legacy messages.
2020-02-20 06:58:15 +01:00
Jan Tojnar
e4a0953ac7
common-updater-scripts: move destructive changes further in the script
We can check some things before the modifications take place.
2020-02-04 06:25:38 +01:00
Jan Tojnar
65543d1031
common-updater-scripts: clean up
Fix issues reported by shellcheck and few other style issues.

Though we need to ignore $systemArg complaints because Nix does not support passing --system as a single argument.
2020-02-04 06:25:37 +01:00
Jan Tojnar
5a1bc70ec0
common-updater-scripts: Support SRI-style hash
Some fetcher functions support SRI-style `hash` attribute in addition to legacy type-specific attributes. When `hash` is used `outputHashAlgo` is null so let’s complain when SRI-style hash value was not detected.

Such attributes match the form ${type}${separator}${hash}: True SRI uses dash as a separator and only supports base64, whereas Nix’s SRI-style format uses a colon and supports all the same encodings like regular hashes (16/32/64).

To keep this program reasonably simple, we will upgrade Nix’s SRI-like format to pure SRI instead of preserving it.
2020-02-04 06:25:37 +01:00
Jan Tojnar
ea9da648ef
common-updater-scripts: mention --ignore-same-hash in usage 2020-02-04 06:25:36 +01:00
talyz
809768bb91 common-updater-scripts: Fix breakage
Fixes a bug introduced by 9b090ccbca
where the script fails to run if $attr.${versionKey} exists.
2019-11-26 14:18:33 +01:00
John Ericson
9b090ccbca treewide: Get rid of most parseDrvName without breaking compat
That is because this commit should be merged to both master and
release-19.09.
2019-11-24 17:22:28 +00:00
Jan Tojnar
5751988b55
common-updater-scripts: simplify fetchgit fix
No need to try evaluate the URL twice as introduced in the original fix
cce486838b
2019-06-02 09:31:51 +02:00
Jan Tojnar
1b507bea4d
common-updater-scripts: keep the unescaped oldVersion
Previously, we escaped the old version in place for use in sed commands,
and then had to use that in error messages. We can do better.
2019-06-02 09:31:20 +02:00
Tim Steinbach
c2c4cc683f
common-updater: Fix syntax
Missing space before closing ] in if statement caused syntax errors
2019-05-06 08:49:11 -04:00
Jan Tojnar
a8293a0848
common-updater-scripts: fix fallback version detection
parseDrvName returns a set containing version attribute, not our customizable key.
2019-05-03 04:34:45 +02:00
Tim Steinbach
cce486838b
update-source-version: Fixes, add --ignore-same-hash
--ignore-same-hash allows ignoring if the same has is used.
This gives the ability to run update-source-version multiple times to
change multiple keys.

Fix version-key, which was not being used to determine the oldVersion
variable.

If $attr.src.drvAttrs.urls is not found, look for
$attr.src.drvAttrs.url since it is being used like that in fetchgit
2019-04-06 19:47:08 -04:00
Jan Tojnar
0105058698
common-updater-scripts: Add file and system flags
You can now optionally invoke update-source-versions with:

* --system flag changing the host platform, to be passed dirrectly to Nix commands.
  This is useful for binary packages which have different sources for each platform.
* --file flag allowing to change the file to be modified. This is useful for packages
  that offer multiple variants, listed in a different file than the derivation itself;
  e.g. packages.nix of Sublime Text 3.
* --version-key, which is now a keyword flag instead of a positional argument.
2019-03-02 23:03:04 +01:00
Will Dietz
8611d2e632 common-update-scripts: fixup for current/latest nix hash output
Courtesy of @jtojnar, thanks!

See https://github.com/NixOS/nixpkgs/issues/54962#issuecomment-459429698
2019-02-11 17:54:35 -06:00
taku0
4bb9af228e common-updater, firefox: fix updater for firefox 2018-11-16 23:04:54 +09:00
taku0
186de9ca9e common-updater: support updating source URL 2018-03-16 23:17:07 +09:00
Tuomas Tynkkynen
9c852aa3de update-source-version: Fix regex metacharacter
In sed variety of regexes, '\|' must be used in place of '|'.
2018-02-17 22:34:12 +02:00
Jan Tojnar
7934a0e5c5 common-update-scripts: fix compatibility with Nix unstable 2018-02-17 11:38:15 +02:00
Tuomas Tynkkynen
5ffbed75be update-source-version: Name part of name can contain dashes 2017-12-26 20:02:01 +02:00
Tuomas Tynkkynen
022b0c9abc update-source-version: Don't require whitespace around equals sign 2017-12-26 20:02:01 +02:00
Tuomas Tynkkynen
ce421a7283 update-source-version: More robust scanning for the output hash 2017-12-26 20:02:01 +02:00
Tuomas Tynkkynen
47acd09fdb update-source-version: Less strict regex for name = ... lines 2017-12-26 20:02:01 +02:00
Tuomas Tynkkynen
0101944621 update-source-version: Check for sources not dependent on ${version} 2017-12-26 20:02:01 +02:00
Tuomas Tynkkynen
e3b0c03507 update-source-version: Escape plus sign if it occurs in version 2017-12-26 20:02:00 +02:00
Tuomas Tynkkynen
b53c53b1b4 maintainers: Add script to patch version/sha256 in .nix files
Adds a script to help automatically upgrading packages: this one can
patch name/version attributes like:
    version = "50.1.0";
    name = "bc-1.06";
... to the given version, and updates the sha256 hash to match.

Usage is:

update-source-version <attr> <new-version> [<new-source-hash>]

where:
    - attr is the attribute path of the package
    - new-version is the version string to be patched in
    - new-source-hash is the optional sha256/etc. hash of the source.
      If not given, the script will automatically calculate it.

This is added to a subdirectory where other useful scripts can be added
in the future, like figuring out the newest version from a git repo or
GitHub releases etc.
2017-02-19 16:51:17 +02:00