Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit

Permalink
Move rangeset.h and print_sha1.h into otautil.
Browse files Browse the repository at this point in the history
Also drop the "bootable/recovery" path in LOCAL_C_INCLUDES from
applypatch modules.

Test: lunch aosp_{angler,bullhead,fugu,dragon,sailfish}-userdebug;
      mmma bootable/recovery
Change-Id: Idd602a796894f971ee4f8fa3eafe36c42d9de986
  • Loading branch information
Tao Bao committed Oct 10, 2017
1 parent eb8a064 commit 09e468f
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 40 deletions.
1 change: 1 addition & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ LOCAL_SRC_FILES := \
asn1_decoder.cpp \
verifier.cpp
LOCAL_STATIC_LIBRARIES := \
libotautil \
libcrypto_utils \
libcrypto \
libbase
Expand Down
34 changes: 17 additions & 17 deletions applypatch/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ LOCAL_SRC_FILES := \
LOCAL_MODULE := libapplypatch
LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
bootable/recovery
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
$(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH)/include
LOCAL_STATIC_LIBRARIES := \
libedify \
libotafault \
libotautil \
libbase \
libcrypto \
libbspatch \
Expand All @@ -50,11 +51,12 @@ LOCAL_SRC_FILES := \
imgpatch.cpp
LOCAL_MODULE := libimgpatch
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
bootable/recovery
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
$(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH)/include
LOCAL_STATIC_LIBRARIES := \
libedify \
libotautil \
libcrypto \
libbspatch \
libbase \
Expand All @@ -75,11 +77,12 @@ LOCAL_SRC_FILES := \
LOCAL_MODULE := libimgpatch
LOCAL_MODULE_HOST_OS := linux
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
bootable/recovery
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
$(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(LOCAL_PATH)/include
LOCAL_STATIC_LIBRARIES := \
libedify \
libotautil \
libcrypto \
libbspatch \
libbase \
Expand All @@ -97,9 +100,9 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
applypatch_modes.cpp
LOCAL_MODULE := libapplypatch_modes
LOCAL_C_INCLUDES := bootable/recovery
LOCAL_STATIC_LIBRARIES := \
libapplypatch \
libotautil \
libbase \
libedify \
libcrypto
Expand All @@ -111,7 +114,6 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := applypatch_main.cpp
LOCAL_MODULE := applypatch
LOCAL_C_INCLUDES := bootable/recovery
LOCAL_STATIC_LIBRARIES := \
libapplypatch_modes \
libapplypatch \
Expand Down Expand Up @@ -141,6 +143,7 @@ libimgdiff_cflags := \
-DZLIB_CONST

libimgdiff_static_libraries := \
libotautil \
libbsdiff \
libdivsufsort \
libdivsufsort64 \
Expand All @@ -161,8 +164,7 @@ LOCAL_CFLAGS := \
LOCAL_STATIC_LIBRARIES := \
$(libimgdiff_static_libraries)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
bootable/recovery
$(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
include $(BUILD_STATIC_LIBRARY)

Expand All @@ -177,8 +179,7 @@ LOCAL_CFLAGS := \
LOCAL_STATIC_LIBRARIES := \
$(libimgdiff_static_libraries)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
bootable/recovery
$(LOCAL_PATH)/include
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
include $(BUILD_HOST_STATIC_LIBRARY)

Expand All @@ -193,6 +194,5 @@ LOCAL_STATIC_LIBRARIES := \
$(libimgdiff_static_libraries) \
libbz
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
bootable/recovery
$(LOCAL_PATH)/include
include $(BUILD_HOST_EXECUTABLE)
2 changes: 1 addition & 1 deletion applypatch/applypatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#include "edify/expr.h"
#include "otafault/ota_io.h"
#include "print_sha1.h"
#include "otautil/print_sha1.h"

static int LoadPartitionContents(const std::string& filename, FileContents* file);
static size_t FileSink(const unsigned char* data, size_t len, int fd);
Expand Down
2 changes: 1 addition & 1 deletion applypatch/bspatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "applypatch/applypatch.h"
#include "edify/expr.h"
#include "print_sha1.h"
#include "otautil/print_sha1.h"

void ShowBSDiffLicense() {
puts("The bsdiff library used herein is:\n"
Expand Down
2 changes: 1 addition & 1 deletion applypatch/imgdiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
#include <zlib.h>

#include "applypatch/imgdiff_image.h"
#include "rangeset.h"
#include "otautil/rangeset.h"

using android::base::get_unaligned;

Expand Down
2 changes: 1 addition & 1 deletion applypatch/include/applypatch/imgdiff_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <zlib.h>

#include "imgdiff.h"
#include "rangeset.h"
#include "otautil/rangeset.h"

class ImageChunk {
public:
Expand Down
20 changes: 10 additions & 10 deletions print_sha1.h → otautil/include/otautil/print_sha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@
#include <openssl/sha.h>

static std::string print_sha1(const uint8_t* sha1, size_t len) {
const char* hex = "0123456789abcdef";
std::string result = "";
for (size_t i = 0; i < len; ++i) {
result.push_back(hex[(sha1[i]>>4) & 0xf]);
result.push_back(hex[sha1[i] & 0xf]);
}
return result;
const char* hex = "0123456789abcdef";
std::string result = "";
for (size_t i = 0; i < len; ++i) {
result.push_back(hex[(sha1[i] >> 4) & 0xf]);
result.push_back(hex[sha1[i] & 0xf]);
}
return result;
}

[[maybe_unused]] static std::string print_sha1(const uint8_t sha1[SHA_DIGEST_LENGTH]) {
return print_sha1(sha1, SHA_DIGEST_LENGTH);
return print_sha1(sha1, SHA_DIGEST_LENGTH);
}

[[maybe_unused]] static std::string short_sha1(const uint8_t sha1[SHA_DIGEST_LENGTH]) {
return print_sha1(sha1, 4);
return print_sha1(sha1, 4);
}

[[maybe_unused]] static std::string print_hex(const uint8_t* bytes, size_t len) {
return print_sha1(bytes, len);
return print_sha1(bytes, len);
}

#endif // RECOVERY_PRINT_SHA1_H
File renamed without changes.
1 change: 1 addition & 0 deletions tests/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libimgdiff \
libimgpatch \
libotautil \
libbsdiff \
libbspatch \
libziparchive \
Expand Down
2 changes: 1 addition & 1 deletion tests/component/applypatch_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "applypatch/applypatch.h"
#include "applypatch/applypatch_modes.h"
#include "common/test_constants.h"
#include "print_sha1.h"
#include "otautil/print_sha1.h"

static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) {
ASSERT_NE(nullptr, sha1);
Expand Down
2 changes: 1 addition & 1 deletion tests/component/updater_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "edify/expr.h"
#include "otautil/SysUtil.h"
#include "otautil/error_code.h"
#include "print_sha1.h"
#include "otautil/print_sha1.h"
#include "updater/blockimg.h"
#include "updater/install.h"
#include "updater/updater.h"
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/rangeset_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <gtest/gtest.h>

#include "rangeset.h"
#include "otautil/rangeset.h"

TEST(RangeSetTest, Parse_smoke) {
RangeSet rs = RangeSet::Parse("2,1,10");
Expand Down Expand Up @@ -156,4 +156,4 @@ TEST(SortedRangeSetTest, file_range) {
ASSERT_EQ(static_cast<size_t>(40970), rs.GetOffsetInRangeSet(4096 * 16 + 10));
// block#10 not in range.
ASSERT_EXIT(rs.GetOffsetInRangeSet(40970), ::testing::KilledBySignal(SIGABRT), "");
}
}
4 changes: 2 additions & 2 deletions updater/blockimg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
#include "edify/expr.h"
#include "otafault/ota_io.h"
#include "otautil/error_code.h"
#include "print_sha1.h"
#include "rangeset.h"
#include "otautil/print_sha1.h"
#include "otautil/rangeset.h"
#include "updater/install.h"
#include "updater/updater.h"

Expand Down
4 changes: 2 additions & 2 deletions updater/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@
#include <openssl/sha.h>
#include <selinux/label.h>
#include <selinux/selinux.h>
#include <tune2fs.h>
#include <ziparchive/zip_archive.h>

#include "edify/expr.h"
#include "mounts.h"
#include "otafault/ota_io.h"
#include "otautil/DirUtil.h"
#include "otautil/error_code.h"
#include "print_sha1.h"
#include "tune2fs.h"
#include "otautil/print_sha1.h"
#include "updater/updater.h"

// Send over the buffer to recovery though the command pipe.
Expand Down
2 changes: 1 addition & 1 deletion verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <openssl/obj_mac.h>

#include "asn1_decoder.h"
#include "print_sha1.h"
#include "otautil/print_sha1.h"

static constexpr size_t MiB = 1024 * 1024;

Expand Down

0 comments on commit 09e468f

Please sign in to comment.