private static async Task ReadControlArchive(ArFile archive, DebPackage package) { package.ControlExtras = new Dictionary <string, DebPackageControlFileData>(); package.Md5Sums = new Dictionary <string, string>(); using (Stream stream = archive.Open()) using (GZipDecompressor decompressedStream = new GZipDecompressor(stream, leaveOpen: true)) using (TarFile tarFile = new TarFile(decompressedStream, leaveOpen: true)) { while (tarFile.Read()) { switch (tarFile.FileName) { case "./control": case "control": using (Stream controlFile = tarFile.Open()) { package.ControlFile = ControlFileParser.Read(controlFile); } break; case "./md5sums": using (var sums = new StreamReader(tarFile.Open())) { string line; while ((line = await sums.ReadLineAsync()) != null) { var s = line.Split(new[] { " " }, 2, StringSplitOptions.None); package.Md5Sums[s[1]] = s[0]; } } break; case "./preinst": package.PreInstallScript = tarFile.ReadAsUtf8String(); break; case "./postinst": package.PostInstallScript = tarFile.ReadAsUtf8String(); break; case "./prerm": package.PreRemoveScript = tarFile.ReadAsUtf8String(); break; case "./postrm": package.PostRemoveScript = tarFile.ReadAsUtf8String(); break; case "./": tarFile.Skip(); break; default: package.ControlExtras[tarFile.FileName] = new DebPackageControlFileData { Mode = tarFile.FileHeader.FileMode, Contents = tarFile.ReadAsUtf8String() }; break; } } } }