* Uninstallation.
This commit is contained in:
parent
2e9042bd1e
commit
06208d1d86
|
@ -93,12 +93,18 @@ static string processBinding(EvalState & state, Expr e, StoreExpr & ne)
|
||||||
Expr a = queryAttr(e, "type");
|
Expr a = queryAttr(e, "type");
|
||||||
if (a && evalString(state, a) == "derivation") {
|
if (a && evalString(state, a) == "derivation") {
|
||||||
a = queryAttr(e, "drvPath");
|
a = queryAttr(e, "drvPath");
|
||||||
if (a) {
|
if (!a) throw badTerm("derivation name missing", e);
|
||||||
Path drvPath = evalPath(state, a);
|
Path drvPath = evalPath(state, a);
|
||||||
|
|
||||||
|
a = queryAttr(e, "drvHash");
|
||||||
|
if (!a) throw badTerm("derivation hash missing", e);
|
||||||
|
Hash drvHash = parseHash(evalString(state, a));
|
||||||
|
|
||||||
|
state.drvHashes[drvPath] = drvHash;
|
||||||
|
|
||||||
return addInput(state, drvPath, ne);
|
return addInput(state, drvPath, ne);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (atMatch(m, e) >> "Path" >> s) {
|
if (atMatch(m, e) >> "Path" >> s) {
|
||||||
Path drvPath = copyAtom(state, s);
|
Path drvPath = copyAtom(state, s);
|
||||||
|
@ -199,13 +205,13 @@ Expr primDerivation(EvalState & state, Expr args)
|
||||||
? hashString((string) outHash + outPath)
|
? hashString((string) outHash + outPath)
|
||||||
: hashDerivation(state, ne);
|
: hashDerivation(state, ne);
|
||||||
Path drvPath = writeTerm(unparseStoreExpr(ne), "-d-" + drvName);
|
Path drvPath = writeTerm(unparseStoreExpr(ne), "-d-" + drvName);
|
||||||
state.drvHashes[drvPath] = drvHash;
|
|
||||||
|
|
||||||
printMsg(lvlChatty, format("instantiated `%1%' -> `%2%'")
|
printMsg(lvlChatty, format("instantiated `%1%' -> `%2%'")
|
||||||
% drvName % drvPath);
|
% drvName % drvPath);
|
||||||
|
|
||||||
attrs.set("outPath", ATmake("Path(<str>)", outPath.c_str()));
|
attrs.set("outPath", ATmake("Path(<str>)", outPath.c_str()));
|
||||||
attrs.set("drvPath", ATmake("Path(<str>)", drvPath.c_str()));
|
attrs.set("drvPath", ATmake("Path(<str>)", drvPath.c_str()));
|
||||||
|
attrs.set("drvHash", ATmake("Str(<str>)", ((string) drvHash).c_str()));
|
||||||
attrs.set("type", ATmake("Str(\"derivation\")"));
|
attrs.set("type", ATmake("Str(\"derivation\")"));
|
||||||
|
|
||||||
return makeAttrs(attrs);
|
return makeAttrs(attrs);
|
||||||
|
|
|
@ -14,6 +14,7 @@ struct DrvInfo
|
||||||
string name;
|
string name;
|
||||||
Path drvPath;
|
Path drvPath;
|
||||||
Path outPath;
|
Path outPath;
|
||||||
|
Hash drvHash;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef map<Path, DrvInfo> DrvInfos;
|
typedef map<Path, DrvInfo> DrvInfos;
|
||||||
|
@ -36,6 +37,10 @@ bool parseDerivation(EvalState & state, Expr e, DrvInfo & drv)
|
||||||
if (!a) throw badTerm("derivation path missing", e);
|
if (!a) throw badTerm("derivation path missing", e);
|
||||||
drv.drvPath = evalPath(state, a);
|
drv.drvPath = evalPath(state, a);
|
||||||
|
|
||||||
|
a = queryAttr(e, "drvHash");
|
||||||
|
if (!a) throw badTerm("derivation hash missing", e);
|
||||||
|
drv.drvHash = parseHash(evalString(state, a));
|
||||||
|
|
||||||
a = queryAttr(e, "outPath");
|
a = queryAttr(e, "outPath");
|
||||||
if (!a) throw badTerm("output path missing", e);
|
if (!a) throw badTerm("output path missing", e);
|
||||||
drv.outPath = evalPath(state, a);
|
drv.outPath = evalPath(state, a);
|
||||||
|
@ -169,10 +174,12 @@ void createUserEnv(EvalState & state, const DrvInfos & drvs)
|
||||||
"Bind(\"type\", Str(\"derivation\")), "
|
"Bind(\"type\", Str(\"derivation\")), "
|
||||||
"Bind(\"name\", Str(<str>)), "
|
"Bind(\"name\", Str(<str>)), "
|
||||||
"Bind(\"drvPath\", Path(<str>)), "
|
"Bind(\"drvPath\", Path(<str>)), "
|
||||||
|
"Bind(\"drvHash\", Str(<str>)), "
|
||||||
"Bind(\"outPath\", Path(<str>))"
|
"Bind(\"outPath\", Path(<str>))"
|
||||||
"])",
|
"])",
|
||||||
i->second.name.c_str(),
|
i->second.name.c_str(),
|
||||||
i->second.drvPath.c_str(),
|
i->second.drvPath.c_str(),
|
||||||
|
((string) i->second.drvHash).c_str(),
|
||||||
i->second.outPath.c_str());
|
i->second.outPath.c_str());
|
||||||
inputs = ATinsert(inputs, t);
|
inputs = ATinsert(inputs, t);
|
||||||
}
|
}
|
||||||
|
@ -280,12 +287,10 @@ void uninstallDerivations(EvalState & state, Strings drvNames)
|
||||||
if (j == nameMap.end())
|
if (j == nameMap.end())
|
||||||
throw Error(format("unknown derivation `%1%'") % *i);
|
throw Error(format("unknown derivation `%1%'") % *i);
|
||||||
else
|
else
|
||||||
installedDrvs.erase(j->first);
|
installedDrvs.erase(j->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
createUserEnv(state, installedDrvs);
|
createUserEnv(state, installedDrvs);
|
||||||
#if 0
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue