* Quick hack to let nix-install-package set the package name properly

(e.g., "java-front-0.9pre15899" instead of "java-front";
  particularly important when doing upgrades later on).
This commit is contained in:
Eelco Dolstra 2006-09-25 14:00:59 +00:00
parent d43565c3e8
commit 3632019b73
2 changed files with 12 additions and 2 deletions

View File

@ -129,7 +129,7 @@ system("@bindir@/nix-pull", $manifestURL) == 0
print "\nInstalling package...\n"; print "\nInstalling package...\n";
system("@bindir@/nix-env", "--install", $outPath, @extraNixEnvArgs) == 0 system("@bindir@/nix-env", "--install", $outPath, "--force-name", $drvName, @extraNixEnvArgs) == 0
or barf "nix-env failed: $?"; or barf "nix-env failed: $?";

View File

@ -59,6 +59,7 @@ struct Globals
bool dryRun; bool dryRun;
bool preserveInstalled; bool preserveInstalled;
bool keepDerivations; bool keepDerivations;
string forceName;
}; };
@ -448,8 +449,15 @@ static void installDerivations(Globals & globals,
queryInstSources(globals.state, globals.instSource, args, newElems, true); queryInstSources(globals.state, globals.instSource, args, newElems, true);
StringSet newNames; StringSet newNames;
for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i) for (DrvInfos::iterator i = newElems.begin(); i != newElems.end(); ++i) {
/* `forceName' is a hack to get package names right in some
one-click installs, namely those where the name used in the
path is not the one we want (e.g., `java-front' versus
`java-front-0.9pre15899'). */
if (globals.forceName != "")
i->name = globals.forceName;
newNames.insert(DrvName(i->name).name); newNames.insert(DrvName(i->name).name);
}
/* Add in the already installed derivations, unless they have the /* Add in the already installed derivations, unless they have the
same name as a to-be-installed element. */ same name as a to-be-installed element. */
@ -1139,6 +1147,8 @@ void run(Strings args)
Expr value = parseExprFromString(globals.state, *i, absPath(".")); Expr value = parseExprFromString(globals.state, *i, absPath("."));
globals.instSource.autoArgs.set(toATerm(name), value); globals.instSource.autoArgs.set(toATerm(name), value);
} }
else if (arg == "--force-name") // undocumented flag for nix-install-package
globals.forceName = needArg(i, args, arg);
else if (arg == "--uninstall" || arg == "-e") else if (arg == "--uninstall" || arg == "-e")
op = opUninstall; op = opUninstall;
else if (arg == "--upgrade" || arg == "-u") else if (arg == "--upgrade" || arg == "-u")