Add 'nix store repair' command
This commit is contained in:
parent
3da9a9241c
commit
61216d32e1
6 changed files with 66 additions and 5 deletions
|
@ -198,9 +198,7 @@ public:
|
||||||
|
|
||||||
void vacuumDB();
|
void vacuumDB();
|
||||||
|
|
||||||
/* Repair the contents of the given path by redownloading it using
|
void repairPath(const StorePath & path) override;
|
||||||
a substituter (if available). */
|
|
||||||
void repairPath(const StorePath & path);
|
|
||||||
|
|
||||||
void addSignatures(const StorePath & storePath, const StringSet & sigs) override;
|
void addSignatures(const StorePath & storePath, const StringSet & sigs) override;
|
||||||
|
|
||||||
|
|
|
@ -604,6 +604,11 @@ public:
|
||||||
virtual ref<FSAccessor> getFSAccessor()
|
virtual ref<FSAccessor> getFSAccessor()
|
||||||
{ unsupported("getFSAccessor"); }
|
{ unsupported("getFSAccessor"); }
|
||||||
|
|
||||||
|
/* Repair the contents of the given path by redownloading it using
|
||||||
|
a substituter (if available). */
|
||||||
|
virtual void repairPath(const StorePath & path)
|
||||||
|
{ unsupported("repairPath"); }
|
||||||
|
|
||||||
/* Add signatures to the specified store path. The signatures are
|
/* Add signatures to the specified store path. The signatures are
|
||||||
not verified. */
|
not verified. */
|
||||||
virtual void addSignatures(const StorePath & storePath, const StringSet & sigs)
|
virtual void addSignatures(const StorePath & storePath, const StringSet & sigs)
|
||||||
|
|
|
@ -757,7 +757,7 @@ static void opRepairPath(Strings opFlags, Strings opArgs)
|
||||||
throw UsageError("no flags expected");
|
throw UsageError("no flags expected");
|
||||||
|
|
||||||
for (auto & i : opArgs)
|
for (auto & i : opArgs)
|
||||||
ensureLocalStore()->repairPath(store->followLinksToStorePath(i));
|
store->repairPath(store->followLinksToStorePath(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Optimise the disk space usage of the Nix store by hard-linking
|
/* Optimise the disk space usage of the Nix store by hard-linking
|
||||||
|
|
|
@ -32,7 +32,6 @@ struct CmdStoreDelete : StorePathsCommand
|
||||||
|
|
||||||
void run(ref<Store> store, std::vector<StorePath> storePaths) override
|
void run(ref<Store> store, std::vector<StorePath> storePaths) override
|
||||||
{
|
{
|
||||||
|
|
||||||
for (auto & path : storePaths)
|
for (auto & path : storePaths)
|
||||||
options.pathsToDelete.insert(path);
|
options.pathsToDelete.insert(path);
|
||||||
|
|
||||||
|
|
27
src/nix/store-repair.cc
Normal file
27
src/nix/store-repair.cc
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#include "command.hh"
|
||||||
|
#include "store-api.hh"
|
||||||
|
|
||||||
|
using namespace nix;
|
||||||
|
|
||||||
|
struct CmdStoreRepair : StorePathsCommand
|
||||||
|
{
|
||||||
|
std::string description() override
|
||||||
|
{
|
||||||
|
return "repair store paths";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string doc() override
|
||||||
|
{
|
||||||
|
return
|
||||||
|
#include "store-repair.md"
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void run(ref<Store> store, std::vector<StorePath> storePaths) override
|
||||||
|
{
|
||||||
|
for (auto & path : storePaths)
|
||||||
|
store->repairPath(path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static auto rStoreRepair = registerCommand2<CmdStoreRepair>({"store", "repair"});
|
32
src/nix/store-repair.md
Normal file
32
src/nix/store-repair.md
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
R""(
|
||||||
|
|
||||||
|
# Examples
|
||||||
|
|
||||||
|
* Repair a store path, after determining that it is corrupt:
|
||||||
|
|
||||||
|
```console
|
||||||
|
# nix store verify /nix/store/yb5q57zxv6hgqql42d5r8b5k5mcq6kay-hello-2.10
|
||||||
|
path '/nix/store/yb5q57zxv6hgqql42d5r8b5k5mcq6kay-hello-2.10' was
|
||||||
|
modified! expected hash
|
||||||
|
'sha256:1hd5vnh6xjk388gdk841vflicy8qv7qzj2hb7xlyh8lpb43j921l', got
|
||||||
|
'sha256:1a25lf78x5wi6pfkrxalf0n13kdaca0bqmjqnp7wfjza2qz5ssgl'
|
||||||
|
|
||||||
|
# nix store repair /nix/store/yb5q57zxv6hgqql42d5r8b5k5mcq6kay-hello-2.10
|
||||||
|
```
|
||||||
|
|
||||||
|
# Description
|
||||||
|
|
||||||
|
This command attempts to "repair" the store paths specified by
|
||||||
|
*installables* by redownloading them using the available
|
||||||
|
substituters. If no substitutes are available, then repair is not
|
||||||
|
possible.
|
||||||
|
|
||||||
|
> **Warning**
|
||||||
|
>
|
||||||
|
> During repair, there is a very small time window during which the old
|
||||||
|
> path (if it exists) is moved out of the way and replaced with the new
|
||||||
|
> path. If repair is interrupted in between, then the system may be left
|
||||||
|
> in a broken state (e.g., if the path contains a critical system
|
||||||
|
> component like the GNU C Library).
|
||||||
|
|
||||||
|
)""
|
Loading…
Reference in a new issue