diff options
Diffstat (limited to 'src/libstore/derivations.cc')
-rw-r--r-- | src/libstore/derivations.cc | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index 5590b99b36fa..d934bda38225 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -9,7 +9,7 @@ namespace nix { -void DerivationOutput::parseHashInfo(bool & recursive, HashType & hashType, Hash & hash) const +void DerivationOutput::parseHashInfo(bool & recursive, Hash & hash) const { recursive = false; string algo = hashAlgo; @@ -19,7 +19,7 @@ void DerivationOutput::parseHashInfo(bool & recursive, HashType & hashType, Hash algo = string(algo, 2); } - hashType = parseHashType(algo); + HashType hashType = parseHashType(algo); if (hashType == htUnknown) throw Error(format("unknown hash algorithm ‘%1%’") % algo); @@ -61,6 +61,7 @@ bool BasicDerivation::canBuildLocally() const #if __linux__ || (platform == "i686-linux" && settings.thisSystem == "x86_64-linux") || (platform == "armv6l-linux" && settings.thisSystem == "armv7l-linux") + || (platform == "armv5tel-linux" && (settings.thisSystem == "armv7l-linux" || settings.thisSystem == "armv6l-linux")) #elif __FreeBSD__ || (platform == "i686-linux" && settings.thisSystem == "x86_64-freebsd") || (platform == "i686-linux" && settings.thisSystem == "i686-freebsd") @@ -87,6 +88,38 @@ Path writeDerivation(ref<Store> store, } +MakeError(FormatError, Error) + + +/* Read string `s' from stream `str'. */ +static void expect(std::istream & str, const string & s) +{ + char s2[s.size()]; + str.read(s2, s.size()); + if (string(s2, s.size()) != s) + throw FormatError(format("expected string ‘%1%’") % s); +} + + +/* Read a C-style string from stream `str'. */ +static string parseString(std::istream & str) +{ + string res; + expect(str, "\""); + int c; + while ((c = str.get()) != '"') + if (c == '\\') { + c = str.get(); + if (c == 'n') res += '\n'; + else if (c == 'r') res += '\r'; + else if (c == 't') res += '\t'; + else res += c; + } + else res += c; + return res; +} + + static Path parsePath(std::istream & str) { string s = parseString(str); @@ -96,6 +129,20 @@ static Path parsePath(std::istream & str) } +static bool endOfList(std::istream & str) +{ + if (str.peek() == ',') { + str.get(); + return false; + } + if (str.peek() == ']') { + str.get(); + return true; + } + return false; +} + + static StringSet parseStrings(std::istream & str, bool arePaths) { StringSet res; @@ -390,4 +437,11 @@ Sink & operator << (Sink & out, const BasicDerivation & drv) } +std::string hashPlaceholder(const std::string & outputName) +{ + // FIXME: memoize? + return "/" + printHash32(hashString(htSHA256, "nix-output:" + outputName)); +} + + } |