kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

release.h (1989B)


      1 #ifndef KIT_DIST_RELEASE_H
      2 #define KIT_DIST_RELEASE_H
      3 
      4 #include <kit/core.h>
      5 #include <kit/package.h> /* KitReleaseIndex / KitReleaseHost */
      6 #include <stddef.h>
      7 #include <stdint.h>
      8 
      9 #include "dist.h"
     10 
     11 /* The signed channel index ("kit-release"). Byte-stable canonical text in the
     12  * same idiom as the package manifest (src/dist/manifest.{h,c}); the detached
     13  * minisign signature and trust policy live in the caller. Operates directly on
     14  * the public KitReleaseIndex so the driver (which sees only include/kit/) and
     15  * the library share one representation. See doc/plan/SELFDIST.md. */
     16 
     17 #define DIST_RELEASE1_MAGIC "kit-release 1"
     18 #define DIST_RELEASE1_HASH "blake2b-256"
     19 
     20 /* Emit the canonical `kit-release 1` text for *idx* to *out*. Returns DIST_OK,
     21  * or DIST_ERR on a writer failure or an invalid index (validated first). */
     22 int dist_release_index_emit(const KitReleaseIndex* idx, KitWriter* out);
     23 
     24 /* Parse `kit-release 1` text into *out* (zeroed first). Returns DIST_OK, or
     25  * DIST_ERR with a human-readable reason in err[0..errcap) (when errcap > 0) on
     26  * a malformed magic/version, unknown key/section, bad hex id, non-canonical
     27  * [host] ordering (must be ascending by target), or any table overflow. */
     28 int dist_release_index_parse(const uint8_t* data, size_t len,
     29                              KitReleaseIndex* out, char* err, size_t errcap);
     30 
     31 /* Structural validation shared by emit and parse: non-empty channel, valid
     32  * CalVer version, each host has a valid target triple, ascending unique
     33  * targets, url/host counts within caps. Returns DIST_OK or DIST_ERR (+err). */
     34 int dist_release_index_validate(const KitReleaseIndex* idx, char* err,
     35                                 size_t errcap);
     36 
     37 /* Compare two CalVer strings ("YYYY.MINOR.PATCH") numerically, field by field.
     38  * Stores the sign of a-b in *cmp. Returns DIST_OK, or DIST_ERR when either
     39  * string is not three non-negative decimal fields. */
     40 int dist_calver_compare(const char* a, const char* b, int* cmp);
     41 
     42 #endif