Skip to content

Commit 173b8a3

Browse files
committed
Move magiskboot cli to argh
1 parent 0be081c commit 173b8a3

File tree

13 files changed

+450
-302
lines changed

13 files changed

+450
-302
lines changed

native/src/Android.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ LOCAL_STATIC_LIBRARIES := \
9595
libboot-rs
9696

9797
LOCAL_SRC_FILES := \
98-
boot/main.cpp \
9998
boot/bootimg.cpp \
10099
boot/compress.cpp \
101100
boot/format.cpp \
@@ -105,7 +104,7 @@ LOCAL_LDFLAGS := -static
105104

106105
ifdef B_CRT0
107106
LOCAL_STATIC_LIBRARIES += crt0
108-
LOCAL_LDFLAGS += -lm
107+
LOCAL_LDFLAGS += -lm -Wl,--defsym=vfprintf=musl_vfprintf
109108
endif
110109

111110
include $(BUILD_EXECUTABLE)

native/src/boot/bootimg.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ bool boot_img::parse_image(const uint8_t *p, format_t type) {
537537
return true;
538538
}
539539

540-
bool boot_img::verify(const char *cert) const {
541-
return rust::verify_boot_image(*this, cert);
540+
bool boot_img::verify() const {
541+
return flags[AVB1_SIGNED_FLAG];
542542
}
543543

544544
int split_image_dtb(const char *filename, bool skip_decomp) {
@@ -987,17 +987,6 @@ void repack(const char *src_img, const char *out_img, bool skip_comp) {
987987
close(fd);
988988
}
989989

990-
int verify(const char *image, const char *cert) {
991-
const boot_img boot(image);
992-
if (cert == nullptr) {
993-
// Boot image parsing already checks if the image is signed
994-
return boot.flags[AVB1_SIGNED_FLAG] ? 0 : 1;
995-
} else {
996-
// Provide a custom certificate and re-verify
997-
return boot.verify(cert) ? 0 : 1;
998-
}
999-
}
1000-
1001990
int sign(const char *image, const char *name, const char *cert, const char *key) {
1002991
const boot_img boot(image);
1003992
auto sig = rust::sign_boot_image(boot.payload, name, cert, key);

native/src/boot/bootimg.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,5 +678,9 @@ struct boot_img {
678678
// Rust FFI
679679
rust::Slice<const uint8_t> get_payload() const { return payload; }
680680
rust::Slice<const uint8_t> get_tail() const { return tail; }
681-
bool verify(const char *cert = nullptr) const;
681+
bool verify() const;
682+
683+
static std::unique_ptr<boot_img> load(::rust::Utf8CStr const file) {
684+
return std::make_unique<boot_img>(file.data());
685+
}
682686
};

0 commit comments

Comments
 (0)