mirror of
https://github.com/NixOS/nix
synced 2025-07-05 16:31:47 +02:00
* Prebuilt package sharing. We allow transparent binary deployment by
sharing package directories (i.e., the result of building a Nix descriptor). `nix-pull-prebuilts' obtains a list of all known prebuilts by consulting the paths and URLs specified in $prefix/etc/nix/prebuilts.conf. The mappings ($pkghash, $prebuilthash) and ($prebuilthash, $location) are registered with Nix so that it can use the prebuilt with hash $prebuilthash when installing a package with hash $pkghash by downloading and unpacking $location. `nix-push-prebuilts' creates prebuilts for all packages for which no prebuilt is known to exist. It can then optionally upload these to the network through rsync. `nix-[pull|push]-prebuilts' just provide a policy. Nix provides the mechanism through the `nix [export|regprebuilt|regurl]' commands.
This commit is contained in:
parent
0ef4b6d0f8
commit
7dd91d3779
9 changed files with 230 additions and 79 deletions
36
src/util.hh
36
src/util.hh
|
@ -85,17 +85,22 @@ string printHash(unsigned char * buf)
|
|||
|
||||
|
||||
/* Verify that a reference is valid (that is, is a MD5 hash code). */
|
||||
void checkHash(const string & s)
|
||||
bool isHash(const string & s)
|
||||
{
|
||||
string err = "invalid reference: " + s;
|
||||
if (s.length() != 32)
|
||||
throw BadRefError(err);
|
||||
if (s.length() != 32) return false;
|
||||
for (int i = 0; i < 32; i++) {
|
||||
char c = s[i];
|
||||
if (!((c >= '0' && c <= '9') ||
|
||||
(c >= 'a' && c <= 'f')))
|
||||
throw BadRefError(err);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void checkHash(const string & s)
|
||||
{
|
||||
if (!isHash(s)) throw BadRefError("invalid reference: " + s);
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,4 +118,25 @@ string hashFile(string filename)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* Return the directory part of the given path, i.e., everything
|
||||
before the final `/'. */
|
||||
string dirOf(string s)
|
||||
{
|
||||
unsigned int pos = s.rfind('/');
|
||||
if (pos == string::npos) throw Error("invalid file name");
|
||||
return string(s, 0, pos);
|
||||
}
|
||||
|
||||
|
||||
/* Return the base name of the given path, i.e., everything following
|
||||
the final `/'. */
|
||||
string baseNameOf(string s)
|
||||
{
|
||||
unsigned int pos = s.rfind('/');
|
||||
if (pos == string::npos) throw Error("invalid file name");
|
||||
return string(s, pos + 1);
|
||||
}
|
||||
|
||||
|
||||
#endif /* !__UTIL_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue