aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lpm.c14
-rw-r--r--src/lpm.lua7
2 files changed, 13 insertions, 8 deletions
diff --git a/src/lpm.c b/src/lpm.c
index fef74cc..e63ff78 100644
--- a/src/lpm.c
+++ b/src/lpm.c
@@ -35,7 +35,11 @@
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/ssl.h>
#include <mbedtls/error.h>
-#include <mbedtls/net.h>
+#if MBEDTLS_VERSION_MAJOR < 3
+ #include <mbedtls/net.h>
+#else
+ #include <mbedtls/net_sockets.h>
+#endif
#ifdef MBEDTLS_DEBUG_C
#include <mbedtls/debug.h>
#endif
@@ -133,7 +137,7 @@ static int lpm_hash(lua_State* L) {
unsigned char buffer[digest_length];
mbedtls_sha256_context hash_ctx;
mbedtls_sha256_init(&hash_ctx);
- mbedtls_sha256_starts_ret(&hash_ctx, 0);
+ mbedtls_sha256_starts(&hash_ctx, 0);
if (strcmp(type, "file") == 0) {
FILE* file = lua_fopen(L, data, "rb");
if (!file) {
@@ -143,15 +147,15 @@ static int lpm_hash(lua_State* L) {
while (1) {
unsigned char chunk[4096];
size_t bytes = fread(chunk, 1, sizeof(chunk), file);
- mbedtls_sha256_update_ret(&hash_ctx, chunk, bytes);
+ mbedtls_sha256_update(&hash_ctx, chunk, bytes);
if (bytes < sizeof(chunk))
break;
}
fclose(file);
} else {
- mbedtls_sha256_update_ret(&hash_ctx, data, len);
+ mbedtls_sha256_update(&hash_ctx, data, len);
}
- mbedtls_sha256_finish_ret(&hash_ctx, buffer);
+ mbedtls_sha256_finish(&hash_ctx, buffer);
mbedtls_sha256_free(&hash_ctx);
lua_pushhexstring(L, buffer, digest_length);
return 1;
diff --git a/src/lpm.lua b/src/lpm.lua
index 631f1ee..250e507 100644
--- a/src/lpm.lua
+++ b/src/lpm.lua
@@ -1097,7 +1097,7 @@ end
function Repository:parse_manifest(repo_id)
if self.manifest then return self.manifest, self.remotes end
- if system.stat(self.local_path) then
+ if system.stat(self.local_path) then
self.manifest_path = self.local_path .. PATHSEP .. "manifest.json"
if not system.stat(self.manifest_path) then
log.warning("Can't find manifest.json for " .. self:url() .. "; automatically generating manifest.")
@@ -1219,14 +1219,15 @@ function Repository:fetch()
local status, err = pcall(function()
if not self.branch and not self.commit then
temporary_path = TMPDIR .. PATHSEP .. "transient-repo"
- path = self.repo_path .. PATHSEP .. "master"
common.rmrf(temporary_path)
common.mkdirp(temporary_path)
log.progress_action("Fetching " .. self.remote .. "...")
system.init(temporary_path, self.remote)
- self.branch = system.fetch(temporary_path, write_progress_bar)
+ self.branch = system.fetch(temporary_path, write_progress_bar):gsub("^refs/heads/", "")
if not self.branch then error("Can't find remote branch for " .. self.remote) end
+ path = self.repo_path .. PATHSEP .. self.branch
self.local_path = path
+ common.reset(temporary_path, self.branch, "hard")
else
path = self.local_path
local exists = system.stat(path)