manifest.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) 2023 Dennis Sädtler <[email protected]>
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #pragma once
  17. #include <string>
  18. #include <nlohmann/json.hpp>
  19. using json = nlohmann::json;
  20. namespace updater {
  21. struct File {
  22. /* 160-bit blake2b hashes of zstd compressed and raw file (hex string) */
  23. std::string compressed_hash;
  24. std::string hash;
  25. /* Relative path */
  26. std::string name;
  27. /* Uncompressed size in bytes */
  28. size_t size = 0;
  29. NLOHMANN_DEFINE_TYPE_INTRUSIVE(File, compressed_hash, hash, name, size)
  30. };
  31. struct Package {
  32. std::string name;
  33. std::vector<File> files = {};
  34. /* Relative paths of files to remove */
  35. std::vector<std::string> removed_files = {};
  36. NLOHMANN_DEFINE_TYPE_INTRUSIVE(Package, name, files, removed_files)
  37. };
  38. struct Manifest {
  39. /* Update packages */
  40. std::vector<Package> packages = {};
  41. /* Version information */
  42. uint8_t version_major = 0;
  43. uint8_t version_minor = 0;
  44. uint8_t version_patch = 0;
  45. uint8_t beta = 0;
  46. uint8_t rc = 0;
  47. std::string commit;
  48. /* Hash of VC redist file */
  49. std::string vc2019_redist_x64;
  50. /* Release notes in HTML format */
  51. std::string notes;
  52. NLOHMANN_DEFINE_TYPE_INTRUSIVE(Manifest, packages, version_major, version_minor, version_patch, beta, rc,
  53. commit, vc2019_redist_x64, notes)
  54. };
  55. struct PatchRequest {
  56. /* Relative path of file */
  57. std::string name;
  58. /* 160-bit blake2b hash of existing file */
  59. std::string hash;
  60. NLOHMANN_DEFINE_TYPE_INTRUSIVE(PatchRequest, name, hash)
  61. };
  62. using PatchesRequest = std::vector<PatchRequest>;
  63. struct PatchResponse {
  64. /* Relative path of file */
  65. std::string name;
  66. /* 160-bit blake2b hash of patch file */
  67. std::string hash;
  68. /* Download URL for patch file */
  69. std::string source;
  70. /* Size of patch file */
  71. size_t size = 0;
  72. NLOHMANN_DEFINE_TYPE_INTRUSIVE(PatchResponse, name, hash, size, source)
  73. };
  74. using PatchesResponse = std::vector<PatchResponse>;
  75. } // namespace updater