staging 4.0.0-rc
This commit is contained in:
1 parent
ae54f74070
commit
fb02622b5b
30 files changed
+2346
-2671
No files matched your search
+92
-1
@@ -10,6 +10,10 @@
|
||||
* NAME-VER.gpkg as the manifest names it. The server is then any static
|
||||
* file host serving DIR.
|
||||
*
|
||||
* A REPO named X-src is a recipe repository (BUILD_DESIGN.txt section
|
||||
* 3): DIR holds recipe bundles, NAME-VER.grcp, each read with
|
||||
* gl_recipe_read; the recipe's REPO must be X.
|
||||
*
|
||||
* SERIAL (decided 2026-10-06) is the date form YYYYMMDDNN: the larger
|
||||
* of the previous DIR/repo.idx's SERIAL + 1 and today (UTC) * 100 + 1.
|
||||
* -n sets it explicitly; it must still be above the previous one, or
|
||||
@@ -38,6 +42,7 @@
|
||||
#include "istoreutils.h"
|
||||
#include "log.h"
|
||||
#include "pkg.h"
|
||||
#include "recipe.h"
|
||||
#include "sha256.h"
|
||||
#include "sign.h"
|
||||
|
||||
@@ -148,6 +153,89 @@ relation(FILE *f, const char *path, const char *what, const char *name,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Whether REPO is a recipe repository, "X-src" (X not empty). */
|
||||
static int
|
||||
is_src(const char *repo)
|
||||
{
|
||||
size_t l = strlen(repo);
|
||||
return l > 4 && strcmp(repo + l - 4, "-src") == 0;
|
||||
}
|
||||
|
||||
/* gl_recipe_t relation lines ("NAME VER[ IF]\n") as an index list. */
|
||||
static void
|
||||
relation_lines(FILE *f, const char *key, const char *lines)
|
||||
{
|
||||
fprintf(f, "\n\t %s = (", key);
|
||||
const char *sep = "";
|
||||
for (const char *p = lines; *p; p = strchr(p, '\n') + 1) {
|
||||
/* One line: "NAME VER" or "NAME VER IF", never more. */
|
||||
char line[512];
|
||||
snprintf(line, sizeof line, "%.*s", (int)(strchr(p, '\n') - p), p);
|
||||
char *ver = strchr(line, ' ');
|
||||
*ver++ = '\0';
|
||||
char *cond = strchr(ver, ' ');
|
||||
if (cond)
|
||||
*cond++ = '\0';
|
||||
fprintf(f, "%s { NAME = \"%s\"; VER = \"%s\";", sep, line, ver);
|
||||
if (cond)
|
||||
fprintf(f, " IF = \"%s\";", cond);
|
||||
fprintf(f, " }");
|
||||
sep = ",";
|
||||
}
|
||||
fprintf(f, "%s);", *sep ? " " : "");
|
||||
}
|
||||
|
||||
/* One recipe bundle's PKGS entry (REPO is X-src). */
|
||||
static int
|
||||
write_src_entry(FILE *f, const char *path, const char *file, const char *repo)
|
||||
{
|
||||
gl_recipe_t r;
|
||||
gl_recipe_status_t st = gl_recipe_read(path, &r);
|
||||
if (st != GL_RECIPE_OK) {
|
||||
lg_printf(LG_ERR, "%s is %s: %s.", path,
|
||||
st == GL_RECIPE_ERR_READ ? "not a readable recipe bundle" :
|
||||
st == GL_RECIPE_ERR_BUNDLE ? "not a valid recipe bundle" :
|
||||
"a bundle with a malformed recipe", gl_recipe_error());
|
||||
return -1;
|
||||
}
|
||||
int rc = -1;
|
||||
char want[PATH_MAX];
|
||||
snprintf(want, sizeof want, "%s-%s.grcp", r.name, r.ver);
|
||||
if (strlen(r.repo) != strlen(repo) - 4 || strncmp(r.repo, repo, strlen(r.repo)) != 0) {
|
||||
lg_printf(LG_ERR, "%s builds %s packages, not %.*s.", path, r.repo,
|
||||
(int)(strlen(repo) - 4), repo);
|
||||
goto out;
|
||||
}
|
||||
if (strcmp(file, want) != 0) {
|
||||
lg_printf(LG_ERR, "%s must be named %s, as its recipe says.", path, want);
|
||||
goto out;
|
||||
}
|
||||
char sha[72];
|
||||
int64_t size;
|
||||
if (hash_file(path, sha, &size) != 0) {
|
||||
lg_printf(LG_ERR, "Cannot read %s.", path);
|
||||
goto out;
|
||||
}
|
||||
fprintf(f, "\t{ NAME = \"%s\"; VER = \"%s\"; FILE = \"%s\";\n"
|
||||
"\t SHA256 = \"%s\"; SIZE = %" PRId64 "L;", r.name, r.ver, file, sha, size);
|
||||
relation_lines(f, "DEPS", r.deps);
|
||||
relation_lines(f, "CONFS", r.confs);
|
||||
relation_lines(f, "BUILD_DEPS", r.build_deps);
|
||||
fprintf(f, "\n\t TRAITS = (");
|
||||
const char *sep = "";
|
||||
for (const char *p = r.traits; *p; p = strchr(p, '\n') + 1) {
|
||||
size_t l = (size_t)(strchr(p, ' ') - p);
|
||||
fprintf(f, "%s { NAME = \"%.*s\"; DEFAULT = %s; }", sep, (int)l, p,
|
||||
p[l + 1] == '1' ? "true" : "false");
|
||||
sep = ",";
|
||||
}
|
||||
fprintf(f, "%s); }", *sep ? " " : "");
|
||||
rc = 0;
|
||||
out:
|
||||
gl_recipe_free(&r);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* One package's PKGS entry, appended to f. 0, or -1 having said why. */
|
||||
static int
|
||||
write_entry(FILE *f, const char *dir, const char *file, const char *repo)
|
||||
@@ -160,6 +248,8 @@ write_entry(FILE *f, const char *dir, const char *file, const char *repo)
|
||||
lg_printf(LG_ERR, "Refusing %s: not a regular file.", path);
|
||||
return -1;
|
||||
}
|
||||
if (is_src(repo))
|
||||
return write_src_entry(f, path, file, repo);
|
||||
gl_pkg_t pkg = {0};
|
||||
if (gl_read_pkg_manifest(path, &pkg) != 0) {
|
||||
lg_printf(LG_ERR, "Cannot read the manifest of %s.", path);
|
||||
@@ -323,7 +413,8 @@ main(int argc, char *argv[])
|
||||
struct dirent *de;
|
||||
while ((de = readdir(d))) {
|
||||
size_t l = strlen(de->d_name);
|
||||
if (de->d_name[0] == '.' || l < 6 || strcmp(de->d_name + l - 5, ".gpkg") != 0)
|
||||
if (de->d_name[0] == '.' || l < 6 ||
|
||||
strcmp(de->d_name + l - 5, is_src(repo) ? ".grcp" : ".gpkg") != 0)
|
||||
continue;
|
||||
char **grown = realloc(names, (n + 1) * sizeof *names);
|
||||
if (!grown || !(grown[n] = strdup(de->d_name))) {
|
||||
|
||||
Reference in new issue
Block a user