mirror of
https://github.com/Mic92/nix-update.git
synced 2024-09-17 13:27:27 +03:00
Merge pull request #115 from figsoda/update-script
add flag to run passthru.updateScript if possible
This commit is contained in:
commit
9838795b16
@ -17,6 +17,7 @@ designed to work with nixpkgs but also other package sets.
|
||||
- build and run the resulting package (see `--build`,
|
||||
`--run` or `--shell`
|
||||
- commit updated files (see `--commit` flag)
|
||||
- run update scripts (`passthru.updateScript`, see `--use-update-script` flag)
|
||||
- run package tests (see `--test` flag)
|
||||
|
||||
## Installation
|
||||
|
@ -31,6 +31,12 @@ def parse_args(args: list[str]) -> Options:
|
||||
parser.add_argument(
|
||||
"--commit", action="store_true", help="Commit the updated package"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-u",
|
||||
"--use-update-script",
|
||||
action="store_true",
|
||||
help="Use passthru.updateScript instead if possible",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--write-commit-message",
|
||||
metavar="FILE",
|
||||
@ -65,6 +71,7 @@ def parse_args(args: list[str]) -> Options:
|
||||
import_path=a.file,
|
||||
build=a.build,
|
||||
commit=a.commit,
|
||||
use_update_script=a.use_update_script,
|
||||
write_commit_message=a.write_commit_message,
|
||||
run=a.run,
|
||||
shell=a.shell,
|
||||
|
@ -34,6 +34,7 @@ class Package:
|
||||
cargo_deps: Optional[str]
|
||||
npm_deps: Optional[str]
|
||||
tests: List[str]
|
||||
has_update_script: bool
|
||||
|
||||
raw_version_position: InitVar[Optional[Dict[str, Any]]]
|
||||
|
||||
@ -81,6 +82,7 @@ def eval_expression(import_path: str, attr: str) -> str:
|
||||
cargo_deps = (pkg.cargoDeps or null).outputHash or null;
|
||||
npm_deps = (pkg.npmDeps or null).outputHash or null;
|
||||
tests = builtins.attrNames (pkg.passthru.tests or {{}});
|
||||
has_update_script = pkg.passthru.updateScript or null != null;
|
||||
src_homepage = pkg.src.meta.homepage or null;
|
||||
changelog = pkg.meta.changelog or null;
|
||||
}})"""
|
||||
|
@ -13,6 +13,7 @@ class Options:
|
||||
import_path: str = "./."
|
||||
override_filename: Optional[str] = None
|
||||
commit: bool = False
|
||||
use_update_script: bool = False
|
||||
write_commit_message: Optional[str] = None
|
||||
shell: bool = False
|
||||
run: bool = False
|
||||
|
@ -1,6 +1,7 @@
|
||||
import fileinput
|
||||
import subprocess
|
||||
import tempfile
|
||||
from os import path
|
||||
from typing import Dict, Optional
|
||||
|
||||
from .errors import UpdateError
|
||||
@ -172,6 +173,23 @@ def update_version(
|
||||
def update(opts: Options) -> Package:
|
||||
package = eval_attr(opts)
|
||||
|
||||
if package.has_update_script and opts.use_update_script:
|
||||
run(
|
||||
[
|
||||
"nix-shell",
|
||||
path.join(opts.import_path, "maintainers/scripts/update.nix"),
|
||||
"--argstr",
|
||||
"package",
|
||||
opts.attribute,
|
||||
],
|
||||
stdout=None,
|
||||
)
|
||||
|
||||
new_package = eval_attr(opts)
|
||||
package.new_version = Version(new_package.old_version, rev=new_package.rev)
|
||||
|
||||
return package
|
||||
|
||||
update_hash = True
|
||||
|
||||
if opts.version_preference != VersionPreference.SKIP:
|
||||
|
Loading…
Reference in New Issue
Block a user