adbsign: support compressed adb files
parent
7af34db6cf
commit
69bcdd23b9
|
@ -11,7 +11,7 @@
|
|||
|
||||
struct apk_istream *adb_decompress(struct apk_istream *is, adb_comp_t *compression)
|
||||
{
|
||||
adb_comp_t c = ADB_COMP_NONE;
|
||||
adb_comp_t c = -1;
|
||||
|
||||
if (IS_ERR_OR_NULL(is)) return is;
|
||||
|
||||
|
@ -22,9 +22,11 @@ struct apk_istream *adb_decompress(struct apk_istream *is, adb_comp_t *compressi
|
|||
break;
|
||||
case 'd':
|
||||
c = ADB_COMP_DEFLATE;
|
||||
apk_istream_get(is, 4);
|
||||
is = apk_istream_deflate(is);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
if (c == -1) {
|
||||
apk_istream_close(is);
|
||||
return ERR_PTR(-APKE_ADB_COMPRESSION);
|
||||
}
|
||||
|
|
|
@ -66,13 +66,14 @@ static int adbsign_main(void *pctx, struct apk_ctx *ac, struct apk_string_array
|
|||
{
|
||||
struct apk_out *out = &ac->out;
|
||||
struct sign_ctx *ctx = pctx;
|
||||
adb_comp_t comp;
|
||||
char **arg;
|
||||
int r;
|
||||
|
||||
ctx->ac = ac;
|
||||
foreach_array_item(arg, args) {
|
||||
ctx->xfrm.is = apk_istream_from_file(AT_FDCWD, *arg);
|
||||
ctx->xfrm.os = apk_ostream_to_file(AT_FDCWD, *arg, 0644);
|
||||
ctx->xfrm.is = adb_decompress(apk_istream_from_file(AT_FDCWD, *arg), &comp);
|
||||
ctx->xfrm.os = adb_compress(apk_ostream_to_file(AT_FDCWD, *arg, 0644), comp);
|
||||
adb_c_xfrm(&ctx->xfrm, update_signatures);
|
||||
apk_istream_close(ctx->xfrm.is);
|
||||
r = apk_ostream_close(ctx->xfrm.os);
|
||||
|
|
|
@ -320,7 +320,7 @@ static int apk_extract_pkg(struct extract_ctx *ctx, const char *fn)
|
|||
int r;
|
||||
|
||||
r = adb_m_stream(&ctx->db,
|
||||
apk_istream_gunzip(apk_istream_from_fd_url(AT_FDCWD, fn, apk_ctx_since(ac, 0))),
|
||||
adb_decompress(apk_istream_from_fd_url(AT_FDCWD, fn, apk_ctx_since(ac, 0)), 0),
|
||||
ADB_SCHEMA_PACKAGE, trust, apk_extract_data_block);
|
||||
if (r == 0) {
|
||||
r = apk_extract_next_file(ctx);
|
||||
|
|
|
@ -264,7 +264,7 @@ static int mkpkg_main(void *pctx, struct apk_ctx *ac, struct apk_string_array *a
|
|||
|
||||
// construct package with ADB as header, and the file data in
|
||||
// concatenated data blocks
|
||||
os = apk_ostream_gzip(apk_ostream_to_file(AT_FDCWD, ctx->output, 0644));
|
||||
os = adb_compress(apk_ostream_to_file(AT_FDCWD, ctx->output, 0644), ADB_COMP_DEFLATE);
|
||||
adb_c_adb(os, &ctx->db, trust);
|
||||
int files_fd = openat(AT_FDCWD, ctx->files_dir, O_RDONLY);
|
||||
for (i = ADBI_FIRST; i <= adb_ra_num(&ctx->paths); i++) {
|
||||
|
|
Loading…
Reference in New Issue