aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/build.c8
-rw-r--r--src/package.c130
-rw-r--r--src/package.h1
-rw-r--r--src/repo.c2
4 files changed, 70 insertions, 71 deletions
diff --git a/src/build.c b/src/build.c
index c572242..44767c4 100644
--- a/src/build.c
+++ b/src/build.c
@@ -39,10 +39,12 @@ int pow_package_build(pow_package *pkg) {
pow_log_info("building package %s", pkg->name);
- if (pow_download_source(pkg->sources[0], tmp_path)) {
- pow_log_error("failed to get sources");
+ for (size_t i = 0; i < pkg->source_count; i++) {
+ if (pow_download_source(pkg->sources[0], tmp_path)) {
+ pow_log_error("failed to get sources");
- return 1;
+ return 1;
+ }
}
lua_getfield(pkg->L, -1, "build");
diff --git a/src/package.c b/src/package.c
index 021e8f7..665eeac 100644
--- a/src/package.c
+++ b/src/package.c
@@ -52,117 +52,111 @@ int pow_extract_package_info(lua_State *L, pow_package *pkg) {
lua_getfield(L, -1, "sources");
- if (!lua_istable(L, -1)) {
- free(pkg->name);
- free(pkg->version);
-
- pow_log_error("sources is not table or doesn't exist");
-
- return 1;
- }
-
- size_t sources_len = lua_objlen(L, -1);
+ if (lua_istable(L, -1)) {
+ size_t sources_len = lua_objlen(L, -1);
- for (size_t i = 0; i < sources_len; i++) {
- lua_pushinteger(L, i + 1);
+ for (size_t i = 0; i < sources_len; i++) {
+ lua_pushinteger(L, i + 1);
- lua_gettable(L, -2);
+ lua_gettable(L, -2);
- if (lua_type(L, -1) == LUA_TNIL)
- break;
+ if (lua_type(L, -1) == LUA_TNIL)
+ break;
- lua_getfield(L, -1, "path");
+ lua_getfield(L, -1, "path");
- pow_package_source *src = malloc(sizeof(pow_package_source));
+ pow_package_source *src = malloc(sizeof(pow_package_source));
- if (!src) {
- pow_log_error("failed to malloc pow_package_source\n");
+ if (!src) {
+ pow_log_error("failed to malloc pow_package_source\n");
- return 1;
- }
+ return 1;
+ }
- if (!lua_isstring(L, -1)) {
- lua_pop(L, 1);
+ if (!lua_isstring(L, -1)) {
+ lua_pop(L, 1);
- pow_log_error("path is not string");
+ pow_log_error("path is not string");
- return 1;
- }
+ return 1;
+ }
- const char *in = strdup(lua_tostring(L, -1));
+ const char *in = strdup(lua_tostring(L, -1));
- if (!in) {
- pow_log_error("failed to strdup path?");
+ if (!in) {
+ pow_log_error("failed to strdup path?");
- return 1;
- }
+ return 1;
+ }
- src->in = in;
+ src->in = in;
- lua_pop(L, 1);
+ lua_pop(L, 1);
- lua_getfield(L, -1, "out");
+ lua_getfield(L, -1, "out");
- if (!lua_isstring(L, -1)) {
- lua_pop(L, 1);
+ if (!lua_isstring(L, -1)) {
+ lua_pop(L, 1);
- pow_log_error("out is not string");
+ pow_log_error("out is not string");
- return 1;
- }
+ return 1;
+ }
- const char *out = strdup(lua_tostring(L, -1));
+ const char *out = strdup(lua_tostring(L, -1));
- if (!out) {
- free(in);
+ if (!out) {
+ free(in);
- lua_pop(L, 1);
+ lua_pop(L, 1);
- pow_log_error("out strdup failed?");
+ pow_log_error("out strdup failed?");
- return 1;
- }
+ return 1;
+ }
- src->out = out;
+ src->out = out;
- lua_pop(L, 1);
+ lua_pop(L, 1);
- lua_getfield(L, -1, "hash");
+ lua_getfield(L, -1, "hash");
- if (!lua_isstring(L, -1)) {
- free(in);
- free(out);
+ if (!lua_isstring(L, -1)) {
+ free(in);
+ free(out);
- pow_log_error("hash is not string?");
+ pow_log_error("hash is not string?");
- return 1;
- }
+ return 1;
+ }
- const char *hash = strdup(lua_tostring(L, -1));
+ const char *hash = strdup(lua_tostring(L, -1));
- if (!hash) {
- free(in);
- free(out);
+ if (!hash) {
+ free(in);
+ free(out);
- pow_log_error("failed to strdup hash");
+ pow_log_error("failed to strdup hash");
- return 1;
- }
+ return 1;
+ }
- src->hash = hash;
+ src->hash = hash;
- pkg->source_count++;
+ pkg->source_count++;
- pkg->sources =
+ pkg->sources =
realloc(pkg->sources, pkg->source_count * sizeof(pow_package_source *));
- pkg->sources[pkg->source_count - 1] = src;
+ pkg->sources[pkg->source_count - 1] = src;
+
+ }
lua_pop(L, 1);
+ lua_pop(L, 1);
}
lua_pop(L, 1);
- lua_pop(L, 1);
return 0;
}
@@ -218,7 +212,7 @@ int pow_package_open(lua_State *L_global, pow_package *pkg, pow_config *cfg, con
// push the config object from cfg thread to pkg thread
- pow_lua_load(L, cfg, "einfach/base");
+ pow_lua_load(L, cfg, pkg->fullname);
luaL_loadstring(L, package_buffer);
diff --git a/src/package.h b/src/package.h
index eccbb08..478a142 100644
--- a/src/package.h
+++ b/src/package.h
@@ -10,6 +10,7 @@ typedef struct pow_config pow_config;
typedef struct {
const char *name;
+ const char *fullname;
const char *version;
const char *description;
diff --git a/src/repo.c b/src/repo.c
index 13ada2e..a4e4a26 100644
--- a/src/repo.c
+++ b/src/repo.c
@@ -78,6 +78,8 @@ int pow_repo_get_package(pow_config *cfg, pow_package *pkg,
free(package_path);
+ pkg->fullname = query;
+
pow_package_open(cfg->L_global, pkg, cfg, full_path);
free(full_path);