-
Notifications
You must be signed in to change notification settings - Fork 124
new OTA mechanism #2113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
benoit-pierre
wants to merge
16
commits into
koreader:master
Choose a base branch
from
benoit-pierre:pr/new_ota
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
new OTA mechanism #2113
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
844fdee
ffi/xxhash: add cdecls
benoit-pierre a18b0b4
hashoir: new module for hashing memory
benoit-pierre e5bcd5e
zstd: build a static library too
benoit-pierre 2146224
libarchive: enable LZMA support on OTA platforms
benoit-pierre 55fc8be
unpack: add tool
benoit-pierre 6a12c2d
ffi/posix: minor cleanup
benoit-pierre 7b8913a
ffi/posix: add `ftruncate`, `mkstemps` and `posix_fallocate`
benoit-pierre d0537bd
ffi/zstd: allow setting compression level
benoit-pierre 6a740b1
ffi/xz: add cdecls
benoit-pierre 3725bc3
downloader: new module to HTTP fetch data
benoit-pierre 38caf18
luajit: set install prefix to `/usr`
benoit-pierre f721040
kotasync: new module for OTA
benoit-pierre 76d3777
kotasync: add command line script + rules to build an AppImage
benoit-pierre 8fe0426
tar: drop project
benoit-pierre 1c0a28b
zsync2: drop project
benoit-pierre 78ef473
curl: drop project
benoit-pierre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #include <xxhash.h> | ||
|
|
||
| #include "ffi-cdecl.h" | ||
|
|
||
| cdecl_type(XXH3_state_t) | ||
| cdecl_c99_type(XXH64_hash_t, uint64_t) | ||
|
|
||
| cdecl_type(XXH_errorcode) | ||
|
|
||
| cdecl_func(XXH3_createState) | ||
| cdecl_func(XXH3_freeState) | ||
| cdecl_func(XXH3_64bits_reset) | ||
| cdecl_func(XXH3_64bits_update) | ||
| cdecl_func(XXH3_64bits_digest) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #include <lzma.h> | ||
|
|
||
| #include "ffi-cdecl.h" | ||
|
|
||
| // base {{{ | ||
|
|
||
| cdecl_const(LZMA_FILTERS_MAX); | ||
| cdecl_const(LZMA_STREAM_HEADER_SIZE); | ||
|
|
||
| cdecl_c99_type(lzma_vli, uint64_t); | ||
| cdecl_type(lzma_allocator); | ||
| cdecl_type(lzma_bool); | ||
| cdecl_type(lzma_reserved_enum); | ||
| cdecl_type(lzma_ret); | ||
|
|
||
| // }}} | ||
|
|
||
| /// check {{{ | ||
|
|
||
| cdecl_type(lzma_check); | ||
|
|
||
| cdecl_func(lzma_check_size); | ||
|
|
||
| /// }}} | ||
|
|
||
| /// filter {{{ | ||
|
|
||
| cdecl_type(lzma_filter); | ||
|
|
||
| /// }}} | ||
|
|
||
| /// stream {{{ | ||
|
|
||
| cdecl_type(lzma_stream_flags); | ||
|
|
||
| cdecl_func(lzma_stream_flags_compare); | ||
| cdecl_func(lzma_stream_footer_decode); | ||
| cdecl_func(lzma_stream_footer_encode); | ||
| cdecl_func(lzma_stream_header_decode); | ||
| cdecl_func(lzma_stream_header_encode); | ||
|
|
||
| // }}} | ||
|
|
||
| /// index {{{ | ||
|
|
||
| cdecl_type(lzma_index); | ||
| cdecl_type(lzma_index_iter); | ||
| cdecl_type(lzma_index_iter_mode); | ||
|
|
||
| cdecl_func(lzma_index_append); | ||
| cdecl_func(lzma_index_block_count); | ||
| cdecl_func(lzma_index_buffer_decode); | ||
| cdecl_func(lzma_index_buffer_encode); | ||
| cdecl_func(lzma_index_end); | ||
| cdecl_func(lzma_index_init); | ||
| cdecl_func(lzma_index_iter_init); | ||
| cdecl_func(lzma_index_iter_next); | ||
| cdecl_func(lzma_index_iter_rewind); | ||
| cdecl_func(lzma_index_size); | ||
| cdecl_func(lzma_index_stream_count); | ||
|
|
||
| /// }}} | ||
|
|
||
| /// block {{{ | ||
|
|
||
| cdecl_type(lzma_block); | ||
|
|
||
| cdecl_func(lzma_block_buffer_decode); | ||
| cdecl_func(lzma_block_compressed_size); | ||
| cdecl_func(lzma_block_header_decode); | ||
| cdecl_func(lzma_block_total_size); | ||
| cdecl_func(lzma_block_unpadded_size); | ||
|
|
||
| /// }}} | ||
|
|
||
| // vim: foldmethod=marker foldlevel=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| local http = require("socket.http") | ||
| local ffi = require("ffi") | ||
|
|
||
| local Downloader = {} | ||
|
|
||
| function Downloader:new() | ||
| local o = {} | ||
| setmetatable(o, self) | ||
| self.__index = self | ||
| return o | ||
| end | ||
|
|
||
| function Downloader:free() | ||
| self.ce:free() | ||
| self.ce = nil | ||
| end | ||
|
|
||
| local function merge_ranges(ranges) | ||
| local new_ranges = {} | ||
| for i, r in ipairs(ranges) do | ||
| if #new_ranges > 0 and new_ranges[#new_ranges][2] == r[1] - 1 then | ||
| new_ranges[#new_ranges][2] = r[2] | ||
| else | ||
| table.insert(new_ranges, r) | ||
| end | ||
| end | ||
| return new_ranges | ||
| end | ||
|
|
||
| function Downloader:fetch(url, callback, ranges, etag, stats) | ||
| assert(not (ranges and etag)) | ||
| self.status_code = nil | ||
| self.etag = nil | ||
| local ok | ||
| local sink = function(s) | ||
| return s and callback(ffi.cast("uint8_t *", s), #s) | ||
| end | ||
| local body, status_code, resp_headers, status_line | ||
| if ranges then | ||
| ranges = merge_ranges(ranges) | ||
| local range_support_checked = false | ||
| local ranges_index = 1 | ||
| repeat | ||
| body, status_code, resp_headers, status_line = http.request{ | ||
| url = url, | ||
| headers = { ["Range"] = string.format("bytes=%u-%u", ranges[ranges_index][1], ranges[ranges_index][2]) }, | ||
| sink = sink, | ||
| } | ||
| if not body then | ||
| self.err = status_code | ||
| return false | ||
| end | ||
| if not range_support_checked then | ||
| if resp_headers["accept-ranges"] ~= "bytes" then | ||
| self.err = "server does not support range requests!" | ||
| return false | ||
| end | ||
| range_support_checked = true | ||
| end | ||
| ok = status_code == 206 | ||
| if not ok then | ||
| self.err = status_line | ||
| return false | ||
| end | ||
| ranges_index = ranges_index + 1 | ||
| until ranges_index > #ranges | ||
| else | ||
| body, status_code, resp_headers, status_line = http.request{ | ||
| url = url, | ||
| headers = etag and { ["If-None-Match"] = etag }, | ||
| sink = sink, | ||
| } | ||
| if not body then | ||
| self.err = status_code | ||
| return false | ||
| end | ||
| self.etag = resp_headers['etag'] | ||
| ok = status_code == 200 or status_code == 304 | ||
| if not ok then | ||
| self.err = status_line | ||
| end | ||
| end | ||
| self.status_code = status_code | ||
| return ok | ||
| end | ||
|
|
||
| return Downloader | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| local ffi = require("ffi") | ||
| require "ffi/xxhash_h" | ||
|
|
||
| local xxhash = ffi.loadlib("xxhash", "0") | ||
|
|
||
| local Hashoir = {} | ||
|
|
||
| function Hashoir:new() | ||
| local o = {} | ||
| setmetatable(o, self) | ||
| self.__index = self | ||
| o.hs = ffi.gc(xxhash.XXH3_createState(), xxhash.XXH3_freeState) | ||
| assert(o.hs ~= nil) | ||
| xxhash.XXH3_64bits_reset(o.hs) | ||
| return o | ||
| end | ||
|
|
||
| function Hashoir:free() | ||
| xxhash.XXH3_freeState(ffi.gc(self.hs, nil)) | ||
| self.hs = nil | ||
| end | ||
|
|
||
| function Hashoir:reset() | ||
| xxhash.XXH3_64bits_reset(self.hs) | ||
| return self | ||
| end | ||
|
|
||
| function Hashoir:update(ptr, len) | ||
| xxhash.XXH3_64bits_update(self.hs, ptr, len) | ||
| return self | ||
| end | ||
|
|
||
| function Hashoir:digest() | ||
| return xxhash.XXH3_64bits_digest(self.hs) | ||
| end | ||
|
|
||
| function Hashoir:hexdigest() | ||
| return string.format("%016x", xxhash.XXH3_64bits_digest(self.hs)) | ||
| end | ||
|
|
||
| return Hashoir |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.