forked from mirrors/nixpkgs
Merge branch 'replace-dependency' of https://github.com/roconnor/nixpkgs
When replace-dependency is given a drv that doesn't actually depend on oldDependency, then just return back the original drv but also issue a warning.
This commit is contained in:
commit
a75de3ce56
|
@ -17,11 +17,12 @@
|
||||||
# };
|
# };
|
||||||
# This will rebuild glibc with your security patch, then copy over firefox
|
# This will rebuild glibc with your security patch, then copy over firefox
|
||||||
# (and all of its dependencies) without rebuilding further.
|
# (and all of its dependencies) without rebuilding further.
|
||||||
{ drv, oldDependency, newDependency }:
|
{ drv, oldDependency, newDependency, verbose ? true }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
warn = if verbose then builtins.trace else (x:y:y);
|
||||||
references = import (runCommand "references.nix" { exportReferencesGraph = [ "graph" drv ]; } ''
|
references = import (runCommand "references.nix" { exportReferencesGraph = [ "graph" drv ]; } ''
|
||||||
(echo {
|
(echo {
|
||||||
while read path
|
while read path
|
||||||
|
@ -47,7 +48,7 @@ let
|
||||||
|
|
||||||
oldStorepath = builtins.storePath (discard (toString oldDependency));
|
oldStorepath = builtins.storePath (discard (toString oldDependency));
|
||||||
|
|
||||||
referencesOf = drv: getAttr (discard (toString drv)) references;
|
referencesOf = drv: references.${discard (toString drv)};
|
||||||
|
|
||||||
dependsOnOldMemo = listToAttrs (map
|
dependsOnOldMemo = listToAttrs (map
|
||||||
(drv: { name = discard (toString drv);
|
(drv: { name = discard (toString drv);
|
||||||
|
@ -55,7 +56,7 @@ let
|
||||||
any dependsOnOld (referencesOf drv);
|
any dependsOnOld (referencesOf drv);
|
||||||
}) (builtins.attrNames references));
|
}) (builtins.attrNames references));
|
||||||
|
|
||||||
dependsOnOld = drv: getAttr (discard (toString drv)) dependsOnOldMemo;
|
dependsOnOld = drv: dependsOnOldMemo.${discard (toString drv)};
|
||||||
|
|
||||||
drvName = drv:
|
drvName = drv:
|
||||||
discard (substring 33 (stringLength (builtins.baseNameOf drv)) (builtins.baseNameOf drv));
|
discard (substring 33 (stringLength (builtins.baseNameOf drv)) (builtins.baseNameOf drv));
|
||||||
|
@ -77,5 +78,6 @@ let
|
||||||
})
|
})
|
||||||
(filter dependsOnOld (builtins.attrNames references))) // rewrittenDeps;
|
(filter dependsOnOld (builtins.attrNames references))) // rewrittenDeps;
|
||||||
|
|
||||||
|
drvHash = discard (toString drv);
|
||||||
in assert (stringLength (drvName (toString oldDependency)) == stringLength (drvName (toString newDependency)));
|
in assert (stringLength (drvName (toString oldDependency)) == stringLength (drvName (toString newDependency)));
|
||||||
getAttr (discard (toString drv)) rewriteMemo
|
rewriteMemo.${drvHash} or (warn "replace-dependency.nix: Derivation ${drvHash} does not depend on ${discard (toString oldDependency)}" drv)
|
||||||
|
|
Loading…
Reference in a new issue