Fix narinfo optional References; working install
This commit is contained in:
1 parent
b3d95bb012
commit
82c08d45b1
2 files changed
+29
-5
No files matched your search
@@ -24,7 +24,7 @@ fn parse_i64(key : String, v : String) -> Int64 raise @store.NixError {
|
||||
|
||||
///|
|
||||
/// Parse the text of a narinfo file. Required keys: StorePath, URL,
|
||||
/// NarHash, NarSize, References. `Compression` defaults to "bzip2" when
|
||||
/// NarHash, NarSize. `References` is optional (omitted when empty). `Compression` defaults to "bzip2" when
|
||||
/// absent (per the Nix spec); unsupported values fail at decompression time.
|
||||
/// Duplicate keys (except `Sig`, which may repeat) and malformed lines are
|
||||
/// errors.
|
||||
@@ -36,11 +36,14 @@ pub fn NarInfo::parse(text : String) -> NarInfo raise @store.NixError {
|
||||
if line.length() == 0 {
|
||||
continue
|
||||
}
|
||||
guard line.find(": ") is Some(i) else {
|
||||
// "Key: value", or "Key:" alone when the value is empty (e.g. no references)
|
||||
let (key, value) = if line.find(": ") is Some(i) {
|
||||
(line[0:i].to_owned(), line[i + 2:].to_owned())
|
||||
} else if line.has_suffix(":") {
|
||||
(line[0:line.length() - 1].to_owned(), "")
|
||||
} else {
|
||||
raise Parse("narinfo: malformed line (no ': '): \{line}")
|
||||
}
|
||||
let key = line[0:i].to_owned()
|
||||
let value = line[i + 2:].to_owned()
|
||||
if key == "Sig" {
|
||||
sigs.push(value)
|
||||
continue
|
||||
@@ -75,7 +78,8 @@ pub fn NarInfo::parse(text : String) -> NarInfo raise @store.NixError {
|
||||
.filter(fn(s) { s.length() > 0 })
|
||||
.map(fn(s) { s.to_owned() })
|
||||
.collect()
|
||||
None => raise Parse("narinfo: missing required key References")
|
||||
// cache.nixos.org omits the line entirely when there are no references
|
||||
None => []
|
||||
}
|
||||
for r in references {
|
||||
ignore(@store.StorePath::parse_base(r))
|
||||
|
||||
Reference in new issue
Block a user