* The environment variable NIX_ROOT can now be set to execute Nix in a
chroot() environment. * A operation `--validpath' to register path validity. Useful for bootstrapping in a pure Nix environment. * Safety checks: ensure that files involved in store operations are in the store.
This commit is contained in:
		
							parent
							
								
									6f5a5ea5ea
								
							
						
					
					
						commit
						76c0e85929
					
				
					 4 changed files with 70 additions and 12 deletions
				
			
		|  | @ -9,8 +9,10 @@ Operations: | |||
|   --add / -A: copy a path to the Nix store | ||||
|   --query / -q: query information | ||||
| 
 | ||||
|   --successor: register a successor expression | ||||
|   --substitute: register a substitute expression | ||||
|   --successor: register a successor expression (dangerous!) | ||||
|   --substitute: register a substitute expression (dangerous!) | ||||
|   --validpath: register path validity (dangerous!) | ||||
|   --isvalid: check path validity | ||||
| 
 | ||||
|   --dump: dump a path as a Nix archive | ||||
|   --restore: restore a path from a Nix archive | ||||
|  |  | |||
|  | @ -185,6 +185,30 @@ static void opSubstitute(Strings opFlags, Strings opArgs) | |||
| } | ||||
| 
 | ||||
| 
 | ||||
| static void opValidPath(Strings opFlags, Strings opArgs) | ||||
| { | ||||
|     if (!opFlags.empty()) throw UsageError("unknown flag"); | ||||
|      | ||||
|     Transaction txn; | ||||
|     createStoreTransaction(txn); | ||||
|     for (Strings::iterator i = opArgs.begin(); | ||||
|          i != opArgs.end(); ++i) | ||||
|         registerValidPath(txn, *i); | ||||
|     txn.commit(); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| static void opIsValid(Strings opFlags, Strings opArgs) | ||||
| { | ||||
|     if (!opFlags.empty()) throw UsageError("unknown flag"); | ||||
| 
 | ||||
|     for (Strings::iterator i = opArgs.begin(); | ||||
|          i != opArgs.end(); ++i) | ||||
|         if (!isValidPath(*i)) | ||||
|             throw Error(format("path `%1%' is not valid") % *i); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /* A sink that writes dump output to stdout. */ | ||||
| struct StdoutSink : DumpSink | ||||
| { | ||||
|  | @ -273,6 +297,10 @@ void run(Strings args) | |||
|             op = opSuccessor; | ||||
|         else if (arg == "--substitute") | ||||
|             op = opSubstitute; | ||||
|         else if (arg == "--validpath") | ||||
|             op = opValidPath; | ||||
|         else if (arg == "--isvalid") | ||||
|             op = opIsValid; | ||||
|         else if (arg == "--dump") | ||||
|             op = opDump; | ||||
|         else if (arg == "--restore") | ||||
|  | @ -292,7 +320,8 @@ void run(Strings args) | |||
| 
 | ||||
|     if (!op) throw UsageError("no operation specified"); | ||||
| 
 | ||||
|     openDB(); | ||||
|     if (op != opDump && op != opRestore) /* !!! hack */ | ||||
|         openDB(); | ||||
| 
 | ||||
|     op(opFlags, opArgs); | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue