From 443ec9cded5e793d1f7f9c306af436ac74c60156 Mon Sep 17 00:00:00 2001 From: zhongluping <278527840@qq.com> Date: Mon, 3 Apr 2023 23:58:20 -0700 Subject: [PATCH 1/8] add bsdiff lib Signed-off-by: zhongluping <278527840@qq.com> --- bsdiff/BUILD.gn | 81 ++++++++++++++++++++++++++++++++++ bsdiff/README.OpenSource | 11 +++++ bsdiff/bundle.json | 30 +++++++++++++ bsdiff/export_api.txt | 2 + bsdiff/run_test.sh | 84 ++++++++++++++++++++++++++++++++++++ bsdiff/testdata/note.txt | 13 ++++++ bsdiff/testdata/note_new.txt | 19 ++++++++ bsdiff/tested_api.txt | 2 + 8 files changed, 242 insertions(+) create mode 100755 bsdiff/BUILD.gn create mode 100755 bsdiff/README.OpenSource create mode 100755 bsdiff/bundle.json create mode 100755 bsdiff/export_api.txt create mode 100755 bsdiff/run_test.sh create mode 100755 bsdiff/testdata/note.txt create mode 100755 bsdiff/testdata/note_new.txt create mode 100755 bsdiff/tested_api.txt diff --git a/bsdiff/BUILD.gn b/bsdiff/BUILD.gn new file mode 100755 index 00000000..931b0cc3 --- /dev/null +++ b/bsdiff/BUILD.gn @@ -0,0 +1,81 @@ + +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") + +declare_args() { + enable_bsdiff_test = false +} + +ohos_shared_library("bsdiff_bspatch") { + sources = [ + "bsdiff/bsdiff.c", + "bsdiff/bspatch.c" + ] + + include_dirs = [ + "./bsdiff" + ] + + part_name = "bsdiff" +} + +ohos_executable("bsdiff_example") { + sources = [ + "bsdiff/bsdiff.c" + ] + include_dirs = [ + "./bsdiff", + "//third_party/bzip2" + ] + + deps = [ + "//third_party/bzip2:libbz2" + ] + cflags = [ + "-DBSDIFF_EXECUTABLE" + ] + + part_name = "bsdiff" +} + +ohos_executable("bspatch_example") { + sources = [ + "bsdiff/bspatch.c" + ] + include_dirs = [ + "./bsdiff", + "//third_party/bzip2" + ] + + deps = [ + "//third_party/bzip2:libbz2" + ] + cflags = [ + "-DBSPATCH_EXECUTABLE" + ] + part_name = "bsdiff" +} + +group("bsdiff") { + deps = [ + ":bsdiff_bspatch" + ] + if (enable_bsdiff_test) { + deps += [ + ":bsdiff_example", + ":bspatch_example" + ] + } +} diff --git a/bsdiff/README.OpenSource b/bsdiff/README.OpenSource new file mode 100755 index 00000000..47e90462 --- /dev/null +++ b/bsdiff/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "bsdiff", + "License": "BSD 2-clause license", + "License File": "LICENSE", + "Version Number": "0.1", + "Owner": "zhongluping@h-partners.com", + "Upstream URL": "https://github.com/mendsley/bsdiff.git", + "Description": "bsdiff and bspatch are libraries for building and applying patches to binary files." + } +] diff --git a/bsdiff/bundle.json b/bsdiff/bundle.json new file mode 100755 index 00000000..985a97dd --- /dev/null +++ b/bsdiff/bundle.json @@ -0,0 +1,30 @@ +{ + "name": "@ohos/bsdiff", + "description": "bsdiff and bspatch are libraries for building and applying patches to binary files.", + "version": "v4.3", + "license": "BSD 2-clause license", + "publishAs": "code-segment", + "segment": { + "destPath": "third_party/bsdiff" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "bsdiff", + "subsystem": "", + "syscap": [], + "features": [], + "adapted_system_type": [], + "rom": "", + "ram": "", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": ["//third_party/bsdiff:bsdiff"], + "inner_kits": [], + "test": [] + } + } +} \ No newline at end of file diff --git a/bsdiff/export_api.txt b/bsdiff/export_api.txt new file mode 100755 index 00000000..557776c8 --- /dev/null +++ b/bsdiff/export_api.txt @@ -0,0 +1,2 @@ +int bsdiff(const uint8_t* old, int64_t oldsize, const uint8_t* new, int64_t newsize, struct bsdiff_stream* stream); +int bspatch(const uint8_t* old, int64_t oldsize, uint8_t* new, int64_t newsize, struct bspatch_stream* stream); diff --git a/bsdiff/run_test.sh b/bsdiff/run_test.sh new file mode 100755 index 00000000..ccd219c5 --- /dev/null +++ b/bsdiff/run_test.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +ERROR_MSG="run bsdiff demo failed!" +SUCCESS_MSG="run bsdiff demo over!!" + +BSDIFF=bsdiff +BSPATCH=bspatch +OLD_FILE=note.txt +DIFF_NEW_FILE=note_new.txt +PATCH_FILE=note.patch +PATCH_NEW_FILE=note_news.txt +MD5_CMD=md5sum + +if [[ ! -z "$1" ]] && [[ $1 == "linux" ]]; then +TEST_RESULT_FILE=test_result_linux.txt +else +TEST_RESULT_FILE=test_result_ohos.txt +BSDIFF=bsdiff_example +BSPATCH=bspatch_example +fi + +echo "" +echo "bsdiff demo run notice:" +echo "the demo file[$BSDIFF/$BSPATCH] &&" +echo "the test file[note.txt/note_new.txt]" +echo "must be setted the same folder with $0" +echo "" + +if [[ ! -f "$BSDIFF" ]] || [[ ! -f "$BSPATCH" ]]; then + echo "no test demo file!" + echo $ERROR_MSG > $TEST_RESULT_FILE + exit 1 +fi + +if [[ ! -f "$OLD_FILE" ]] || [[ ! -f "$DIFF_NEW_FILE" ]]; then + echo "this test demo need a old file(note.txt) and a new file(note_new.txt)!" + echo $ERROR_MSG > $TEST_RESULT_FILE + exit 1 +fi + +echo "start run bsdiff test" > $TEST_RESULT_FILE +./$BSDIFF $OLD_FILE $DIFF_NEW_FILE $PATCH_FILE + +if [ $? -ne 0 ]; then + echo "run bsdiff test failed!" >> $TEST_RESULT_FILE + echo $ERROR_MSG >> $TEST_RESULT_FILE + exit 1 +fi +echo "run bsdiff test success!" >> $TEST_RESULT_FILE +echo "" >> $TEST_RESULT_FILE + +echo "start run bspatch test" >> $TEST_RESULT_FILE +./$BSPATCH $OLD_FILE $PATCH_NEW_FILE $PATCH_FILE +if [[ $? -ne 0 ]] || [[ ! -f "$PATCH_NEW_FILE" ]]; then + echo "run bspatch test failed!" >> $TEST_RESULT_FILE + echo $ERROR_MSG >> $TEST_RESULT_FILE + exit 1 +fi +echo "run bspatch test success!" >> $TEST_RESULT_FILE +echo "" >> $TEST_RESULT_FILE + +echo "start compare diff new file and patch new file:" >> $TEST_RESULT_FILE +MD5_OLD=`$MD5_CMD $DIFF_NEW_FILE` +MD5_OLD=${MD5_OLD:0:32} +echo "$MD5_OLD" >> $TEST_RESULT_FILE +MD5_NEW=`$MD5_CMD $DIFF_NEW_FILE` +MD5_NEW=${MD5_NEW:0:32} +echo "$MD5_NEW" >> $TEST_RESULT_FILE + +if [ "$MD5_OLD" = "$MD5_NEW" ]; then + echo "check MD5 success" >> $TEST_RESULT_FILE +else + echo "check MD5 failed" >> $TEST_RESULT_FILE +fi +echo "" >> $TEST_RESULT_FILE +echo "#########################" >> $TEST_RESULT_FILE +echo $SUCCESS_MSG >> $TEST_RESULT_FILE +echo "#########################" >> $TEST_RESULT_FILE +echo "" >> $TEST_RESULT_FILE + +cat $TEST_RESULT_FILE + +#eof + diff --git a/bsdiff/testdata/note.txt b/bsdiff/testdata/note.txt new file mode 100755 index 00000000..48778cbc --- /dev/null +++ b/bsdiff/testdata/note.txt @@ -0,0 +1,13 @@ +Overview +There are two separate libraries in the project, bsdiff and bspatch. Each are self contained in bsdiff.c and bspatch.c The easiest way to integrate is to simply copy the c file to your source folder and build it. + +The overarching goal was to modify the original bsdiff/bspatch code from Colin and eliminate external dependencies and provide a simple interface to the core functionality. + +I've exposed relevant functions via the _stream classes. The only external dependency not exposed is memcmp in bsdiff. + +This library generates patches that are not compatible with the original bsdiff tool. The incompatibilities were motivated by the patching needs for the game AirMech https://www.carbongames.com and the following requirements: + +1. Eliminate/minimize any seek operations when applying patches +2. Eliminate any required disk I/O and support embedded streams +3. Ability to easily embed the routines as a library instead of an external binary +4. Compile+run on all platforms we use to build the game (Windows, Linux, NaCl, OSX) \ No newline at end of file diff --git a/bsdiff/testdata/note_new.txt b/bsdiff/testdata/note_new.txt new file mode 100755 index 00000000..1093e10a --- /dev/null +++ b/bsdiff/testdata/note_new.txt @@ -0,0 +1,19 @@ +License +Copyright 2003-2005 Colin Percival +Copyright 2012 Matthew Endsley + +This project is governed by the BSD 2-clause license. For details see the file titled LICENSE in the project root folder. + +Overview +There are two separate libraries in the project, bsdiff and bspatch. Each are self contained in bsdiff.c and bspatch.c The easiest way to integrate is to simply copy the c file to your source folder and build it. + +The overarching goal was to modify the original bsdiff/bspatch code from Colin and eliminate external dependencies and provide a simple interface to the core functionality. + +I've exposed relevant functions via the _stream classes. The only external dependency not exposed is memcmp in bsdiff. + +This library generates patches that are not compatible with the original bsdiff tool. The incompatibilities were motivated by the patching needs for the game AirMech https://www.carbongames.com and the following requirements: + +1. Eliminate/minimize any seek operations when applying patches +2. Eliminate any required disk I/O and support embedded streams +3. Ability to easily embed the routines as a library instead of an external binary +4. Compile+run on all platforms we use to build the game (Windows, Linux, NaCl, OSX) \ No newline at end of file diff --git a/bsdiff/tested_api.txt b/bsdiff/tested_api.txt new file mode 100755 index 00000000..557776c8 --- /dev/null +++ b/bsdiff/tested_api.txt @@ -0,0 +1,2 @@ +int bsdiff(const uint8_t* old, int64_t oldsize, const uint8_t* new, int64_t newsize, struct bsdiff_stream* stream); +int bspatch(const uint8_t* old, int64_t oldsize, uint8_t* new, int64_t newsize, struct bspatch_stream* stream); -- Gitee From d9764ab8b91c15b415c8d400a3660a4e84d5bf20 Mon Sep 17 00:00:00 2001 From: zhongluping <278527840@qq.com> Date: Sun, 16 Apr 2023 23:20:24 -0700 Subject: [PATCH 2/8] add bsdiff readme docs Signed-off-by: zhongluping <278527840@qq.com> --- bsdiff/README_zh.md | 16 ++++ bsdiff/docs/rom_integrate.md | 145 +++++++++++++++++++++++++++++++++++ bsdiff/media/ohos_result.png | Bin 0 -> 9761 bytes 3 files changed, 161 insertions(+) create mode 100755 bsdiff/README_zh.md create mode 100755 bsdiff/docs/rom_integrate.md create mode 100755 bsdiff/media/ohos_result.png diff --git a/bsdiff/README_zh.md b/bsdiff/README_zh.md new file mode 100755 index 00000000..2316e41e --- /dev/null +++ b/bsdiff/README_zh.md @@ -0,0 +1,16 @@ +# bisdiff 三方库说明 + +## 功能简介 + +bsdiff是一个提供二进制文件拆分以及合并能力的三方库。 + +## 使用约束 + ++ Rom版本:OpenHarmony3.2 beta3 ++ 三方库版本:1.7.2 ++ 当前适配的功能:实现文件的拆分以及合并功能。 ++ License:[BSD 2-clause license](https://github.com/mendsley/bsdiff/blob/master/LICENSE) + +## 集成方式 + ++ [系统Rom包集成](docs/rom_integrate.md) diff --git a/bsdiff/docs/rom_integrate.md b/bsdiff/docs/rom_integrate.md new file mode 100755 index 00000000..6082018b --- /dev/null +++ b/bsdiff/docs/rom_integrate.md @@ -0,0 +1,145 @@ +# bsdiff 如何集成到系统Rom + +## 准备源码工程 + +本库是基于OpenHarmony 3.2 beta3版本适配,并在润和RK3568开发板上验证的。 +RK3568开发板如何使用可以参照[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/rk3568_helloworld/README.md)。 + +### 准备系统Rom源码 + +源码获取方法请参照:[OpenHarmony3.2beta3源码下载](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta5/zh-cn/release-notes/OpenHarmony-v3.2-beta3.md#%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96) + +### 增加构建脚本及配置文件 + +- 下载本仓库代码 + + ```sh + cd ~/ + git clone git@gitee.com:openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 仓库代码目录结构说明 + + ```shell + cd ~/tpc_c_cplusplus/bsdiff/ ## 进入到仓库代码库目录 + ``` + + ```sh + bsdiff + |-- BUILD.gn ## Rom版编译构建脚本 + |-- export_api.txt ## bsdiff库对外导出的api接口 + |-- tested_api.txt ## 测试用例已测试的api接口 + |-- run_test.sh ## 测试用例运行脚本 + |-- bundle.json ## 组件定义文件 + |-- README_zh.md ## bsdiff 说明文档 + |-- README.OpenSource ## bsdiff 开源信息说明文档 + |-- docs ## 存放nsdiff相关文档 + |-- media ## 存放图片的文件夹 + |-- testdata ## 存放测试数据 + ``` + +- 将本仓库bsdiff文件夹拷贝到OpenHarmony的third_party下 + + ```shell + cp -arf ~/tpc_c_cplusplus/bsdiff ~/OpenHarmony/third_party + ``` + +### 准备三方库源码 + +- 将源码下载到bsdiff目录并将其解压出来。 + + ```shell + cd ~/OpenHarmony/third_party/bsdiff ## 进入到bsdiff目录 + git clone https://github.com/mendsley/bsdiff.git ## 下载三方库 + ``` + +## 系统Rom中引入三方库 + +准备完三方库代码后,我们需要将三方库加入到编译构建体系中。标准系统编译构建可以参考文档[标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md)。 +这里我们三方库默认添加到thirdparty子系统中(详细信息参照文档[如何添加一个三方库到OpenHarmony系统中](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md#%E5%8A%A0%E5%85%A5%E7%BC%96%E8%AF%91%E6%9E%84%E5%BB%BA%E4%BD%93%E7%B3%BB))。相关配置已在bundle.json中完成,我们只需要在产品定义中添加iconv组件即可。 + +- 在产品配置文件中添加bsdiff的组件 + + 打开//vendor/hihope/rk3568/config.json文件,找到thirdparty子系统并添加bsdiff的组件,如果文件中未指定thirdparty子系统,需要手动将子系统信息加上: + + ```json + { + "subsystem": "thirdparty", + "components": [ + { + "component": "bsdiff", + "features": [] + } + ] + } + ``` + +## 系统Rom中引入三方库测试程序 + +bsdiff原生库提供了测试用例,如需要引入测试程序,在OpenHarmony源码的vendor/hihope/rk3568/config.json文件,对应组件的features中打开编译选项: + +```json +{ + "subsystem": "thirdparty", + "components": [ + { + "component": "bsdiff", + "features": [ "enable_bsdiff_test=true" ] + } + ] +} +``` + +## 编译工程 + +- 选择产品 + + ``` shell + hb set ## 运行hb set后会出现产品列表,在此我们选择 rk3568 + ``` + +- 运行编译 + + ``` shell + hb build --target-cpu arm -f ## --target-cpu arm 编译32位系统(未配置默认编译32位),如果需要编译64位的需要改为--target-cpu arm64; -f 全量编译,不加-f则为增量编译。每次设置完产品后建议进行全量编译。 + ``` + +- 正常编译完后会在out/rk3568/packages/phone/system/bin下生成bsdiff_example和bspatch_example2个测试用例以及在out/rk3568/packages/phone/system/lib下生成libbsdiff_bspatch.z.so。 + +## 安装应用程序 + +将编译生成的库和测试文件放到板子上运行,为避免每次将文件推入设备都烧录整个镜像,我们使用hdc_std工具将文件推到开发板上。 + +- 通过源码编译生成hdc_std工具 + + ```shell + hb set # 源码根目录下使用hb set 选择产品ohos-sdk + hb build # 最后工具编译出来在out/sdk/ohos-sdk/windows/toolchains/hdc_std.exe + ``` + +- 将工具拷贝到Windows,可以为工具目录配置环境变量,也可以在工具所在目录打开windows命令 +- 将原生库测试需要的所有文件打包成bsdiff.tar,并拷贝到windows下 +- 将文件推送到开发板 ,具体步骤如下: + + ```shell + hdc_std.exe file send bsdiff.tar /data/ ## 推送文件到开发板系统的data目录 + hdc_std.exe shell + cd /data/ + tar -xvf bsdiff.tar ## 解压文件包 + cd bsdiff + cp libbsdiff_bspatch.z.so /lib/ ## 将库文件拷贝到系统lib目录 + ``` + +## 运行效果 + +运行测试脚本`./run_test.sh ohos`,测试结果如下图所示: + +![result](../media/ohos_result.png) + +## 参考资料 + +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/rk3568_helloworld/README.md)。 +- [如何添加一个三方库到OpenHarmony的thirdparty子系统中](../../common/add_thirdparty_component.md)。 +- [OpenHarmony3.2beta3介绍](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta5/zh-cn/release-notes/OpenHarmony-v3.2-beta3.md)。 +- [OpenHarmony三方库组织地址](https://gitee.com/openharmony-tpc)。 +- [知识体系](https://gitee.com/openharmony-sig/knowledge)。 diff --git a/bsdiff/media/ohos_result.png b/bsdiff/media/ohos_result.png new file mode 100755 index 0000000000000000000000000000000000000000..b50cab0b4d851d04f549f23f90c58410a67989c7 GIT binary patch literal 9761 zcmeHteL#};-uKn&)I4YDPMx*2Qs+JIyqB(K&MXN%n_F5d-DXG_$jXETPE$e@6+G2* ztX1M}XZePn%`J-yVM?r!H_xUym6tU`LIr$DNDwFq5ka^wY}?uPoaev$Ie(o$#EXmH zb^WgE`}@9pKA-RJ{JW{iYk&XZ?*RZFo=Srz)J^hJ_VBE`<|(pd=0$FIj?zU(A0hb@Q!nTjzBXcWm=4>=51?yAs%QyG^?9 z`}|c5&(&us4EG7L4cBQd(SJ$Oc=9-KkWJ)gX9?Nw;HNwy=qe;HXm3ZmLx~R325CE>aEvO5+jV zmd{261DFhPzGF{BqkyRHZ@y^lT4WQv1nZ&Qz&Ku8l=8w7Qu+#euCCW8(5NH_zUGZ! zr#TzA7~c&Z5iy9?(qq>Eds^~g;fGL%9KEIOLS3+?$$GIwc8r78G2h#EM71@(l@t-% zE{rlj4{x8Tewb304%wPtHX1e&(d%2YNw5(BblM}E*Fh#v2!x!Zd$Jl@ov8m$hiv+i zG11rY_m|7c$~+T0JT%YZ%5I`dP4~I=m1V_3rq+0(OqaWvsF#KVH%Q6k4)_Vx|`D~S1p~q6nevYhN6Hu0BZ z6-`sr6@c?zeE3@p6eFc59?^VVmtz!IN90IYD}v7Vne4U^EIei~%?JPt`&aau*R0@1 zBcb^`X)24Dmw)-m^r5^0Zfu-z~PxZ68m7Z<_OrS+j8XYYFA;(ceIsDJ^5_BM_%R#8dbHV@ARGHs#Gm4kgp&q zYUL}|lFMAxOsVHKmT0VMG4=;C3+#x%te$H98h2rsyRpDJ- zOi5q9kK7XCFk|m*jKfa<*bZUXMu84rB131Lw-+Q|?(H(kC_S28Evi-o2i7TJ zWy$wy$5fvhINSkPhP^{KQ{YIk7h4Y17sAgB;y#Ln#eC@~4wlQN8*<Wj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eH_r!_3bA zSYXCl#+X>uRh0s9S=;A=453ODA0Zvn--0BtpbF_YuBO@%+F-nq%sYWYFu*j>g)qz&2NP2-%LN}o916e5zTP6w^JCU5 z^MK=-jv%0dawi_bS(^;OZgS=5&C(#CTS)XBgvi?YEN!B}7$_b_+p^`;kO&YH7+`o2 z0P2#y@vPn?J)v+%G3p1i)7VIOfSBgj-h-!cQ1wuitB%w!J?g7# z(IL^&;V~K#CSE2F{)vXdj=rFO;c8@Td*qeAOcB(}KwdDgS#!@ZzudM2J3l8dnw0?S;mllkR)={(b9hBIqrc9onf10R%w#*p!ie#eP!Nk&m?va+HZx+Uxd!vQwzelw|YI&rh4;`bD zV-B9MF0w?eBcJ4SaN_M4O&PnlRNaPxKBoz+0jRU@dK?$<=nPC)#NV~azQ4&fo9VFK zWo<-ELt6rh3MmkGgv4{C6U7*gk9n_lC18b?_ivxE621pTg`HS(3%xTL;Rle+F$~gP zOGq%N#Gs)0nrUVh0LG?r0t4(>kVjGore*AnhN1FB!+s8?#UxHi@c*t3Z3%Gy(5;Xpg z^qQBx>(|BtqR7C2(@kTTmEFS0>K{*m(8ds`?|J@TCrm>&F%O1KOig{8wGxW(Z~o!k z4rldifvZwCLnCYx{y_SyVkHy+woAWwxMlq<%Dd&~ka%SCxv-xQ&yj(@gJ+;CfqieM LzQuX-gVX;5Z25>! literal 0 HcmV?d00001 -- Gitee From 0a821aa2a716c844be15251e055289975123881e Mon Sep 17 00:00:00 2001 From: zhongluping <278527840@qq.com> Date: Fri, 21 Apr 2023 09:32:04 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhongluping <278527840@qq.com> --- bsdiff/docs/rom_integrate.md | 4 +++- bsdiff/{ => testdata}/run_test.sh | 0 2 files changed, 3 insertions(+), 1 deletion(-) rename bsdiff/{ => testdata}/run_test.sh (100%) diff --git a/bsdiff/docs/rom_integrate.md b/bsdiff/docs/rom_integrate.md index 6082018b..b9201e3f 100755 --- a/bsdiff/docs/rom_integrate.md +++ b/bsdiff/docs/rom_integrate.md @@ -29,13 +29,15 @@ RK3568开发板如何使用可以参照[润和RK3568开发板标准系统快速 |-- BUILD.gn ## Rom版编译构建脚本 |-- export_api.txt ## bsdiff库对外导出的api接口 |-- tested_api.txt ## 测试用例已测试的api接口 - |-- run_test.sh ## 测试用例运行脚本 |-- bundle.json ## 组件定义文件 |-- README_zh.md ## bsdiff 说明文档 |-- README.OpenSource ## bsdiff 开源信息说明文档 |-- docs ## 存放nsdiff相关文档 |-- media ## 存放图片的文件夹 |-- testdata ## 存放测试数据 + |-- run_test.sh ## 测试用例运行脚本,注意:在运行该测试用例时,需要将做拆分与合并的2个测试应用程序放到当前路径下。 + |-- note.txt ## 测试用例文件 + |-- note_new.txt ## 测试用例新文件,与之前文件存在差异,通过测试用例做拆分与合并,最终生成一个新的文件与该文件一致。 ``` - 将本仓库bsdiff文件夹拷贝到OpenHarmony的third_party下 diff --git a/bsdiff/run_test.sh b/bsdiff/testdata/run_test.sh similarity index 100% rename from bsdiff/run_test.sh rename to bsdiff/testdata/run_test.sh -- Gitee From f710445cf8d5e003c43d73d674843ed44f5a5ba2 Mon Sep 17 00:00:00 2001 From: zhongluping <278527840@qq.com> Date: Fri, 21 Apr 2023 10:53:04 +0800 Subject: [PATCH 4/8] modify bsdiff version Signed-off-by: zhongluping <278527840@qq.com> --- bsdiff/README_zh.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsdiff/README_zh.md b/bsdiff/README_zh.md index 2316e41e..379ed1cc 100755 --- a/bsdiff/README_zh.md +++ b/bsdiff/README_zh.md @@ -7,7 +7,7 @@ bsdiff是一个提供二进制文件拆分以及合并能力的三方库。 ## 使用约束 + Rom版本:OpenHarmony3.2 beta3 -+ 三方库版本:1.7.2 ++ 三方库版本:master + 当前适配的功能:实现文件的拆分以及合并功能。 + License:[BSD 2-clause license](https://github.com/mendsley/bsdiff/blob/master/LICENSE) -- Gitee From dcf8bca7053daa88e85ea572106a92b29dd17915 Mon Sep 17 00:00:00 2001 From: zhongluping <278527840@qq.com> Date: Fri, 21 Apr 2023 11:02:41 +0800 Subject: [PATCH 5/8] modify email description Signed-off-by: zhongluping <278527840@qq.com> --- bsdiff/README.OpenSource | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsdiff/README.OpenSource b/bsdiff/README.OpenSource index 47e90462..99596cd4 100755 --- a/bsdiff/README.OpenSource +++ b/bsdiff/README.OpenSource @@ -4,7 +4,7 @@ "License": "BSD 2-clause license", "License File": "LICENSE", "Version Number": "0.1", - "Owner": "zhongluping@h-partners.com", + "Owner": "zhongluping1@huawei.com", "Upstream URL": "https://github.com/mendsley/bsdiff.git", "Description": "bsdiff and bspatch are libraries for building and applying patches to binary files." } -- Gitee From 209d843d8acfcf492d8f41b3a7ae52d07b738d09 Mon Sep 17 00:00:00 2001 From: zhongluping <278527840@qq.com> Date: Fri, 21 Apr 2023 11:17:27 +0800 Subject: [PATCH 6/8] modify bsdiff version Signed-off-by: zhongluping <278527840@qq.com> --- bsdiff/README.OpenSource | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsdiff/README.OpenSource b/bsdiff/README.OpenSource index 99596cd4..1256fa9e 100755 --- a/bsdiff/README.OpenSource +++ b/bsdiff/README.OpenSource @@ -3,9 +3,9 @@ "Name": "bsdiff", "License": "BSD 2-clause license", "License File": "LICENSE", - "Version Number": "0.1", + "Version Number": "master", "Owner": "zhongluping1@huawei.com", - "Upstream URL": "https://github.com/mendsley/bsdiff.git", + "Upstream URL": "https://github.com/mendsley/bsdiff", "Description": "bsdiff and bspatch are libraries for building and applying patches to binary files." } ] -- Gitee From 0584c0fd10231512e6758b8526b3ce4d00385880 Mon Sep 17 00:00:00 2001 From: zhongluping <278527840@qq.com> Date: Fri, 21 Apr 2023 15:12:12 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9bsdiff=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E4=B8=AD=E6=97=A0=E6=95=88=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhongluping <278527840@qq.com> --- bsdiff/docs/rom_integrate.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsdiff/docs/rom_integrate.md b/bsdiff/docs/rom_integrate.md index b9201e3f..41adb558 100755 --- a/bsdiff/docs/rom_integrate.md +++ b/bsdiff/docs/rom_integrate.md @@ -141,7 +141,7 @@ bsdiff原生库提供了测试用例,如需要引入测试程序,在OpenHarm ## 参考资料 - [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/rk3568_helloworld/README.md)。 -- [如何添加一个三方库到OpenHarmony的thirdparty子系统中](../../common/add_thirdparty_component.md)。 +- [如何为三方库组件中添加一个三方库](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md)。 - [OpenHarmony3.2beta3介绍](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta5/zh-cn/release-notes/OpenHarmony-v3.2-beta3.md)。 - [OpenHarmony三方库组织地址](https://gitee.com/openharmony-tpc)。 - [知识体系](https://gitee.com/openharmony-sig/knowledge)。 -- Gitee From 394759a085525e0c1cbd22f19a739b542657a72e Mon Sep 17 00:00:00 2001 From: zhongluping <278527840@qq.com> Date: Thu, 27 Apr 2023 08:41:08 +0800 Subject: [PATCH 8/8] modify bsdiff BUILD.gn with gn format Signed-off-by: zhongluping <278527840@qq.com> --- bsdiff/BUILD.gn | 143 +++++++++++++++++++++--------------------------- 1 file changed, 63 insertions(+), 80 deletions(-) diff --git a/bsdiff/BUILD.gn b/bsdiff/BUILD.gn index 931b0cc3..93f0194f 100755 --- a/bsdiff/BUILD.gn +++ b/bsdiff/BUILD.gn @@ -1,81 +1,64 @@ - -# Copyright (c) 2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and # limitations under the License. - -import("//build/ohos.gni") - -declare_args() { - enable_bsdiff_test = false -} - -ohos_shared_library("bsdiff_bspatch") { - sources = [ - "bsdiff/bsdiff.c", - "bsdiff/bspatch.c" - ] - - include_dirs = [ - "./bsdiff" - ] - - part_name = "bsdiff" -} - -ohos_executable("bsdiff_example") { - sources = [ - "bsdiff/bsdiff.c" - ] - include_dirs = [ - "./bsdiff", - "//third_party/bzip2" - ] - - deps = [ - "//third_party/bzip2:libbz2" - ] - cflags = [ - "-DBSDIFF_EXECUTABLE" - ] - - part_name = "bsdiff" -} - -ohos_executable("bspatch_example") { - sources = [ - "bsdiff/bspatch.c" - ] - include_dirs = [ - "./bsdiff", - "//third_party/bzip2" - ] - - deps = [ - "//third_party/bzip2:libbz2" - ] - cflags = [ - "-DBSPATCH_EXECUTABLE" - ] - part_name = "bsdiff" -} - -group("bsdiff") { - deps = [ - ":bsdiff_bspatch" - ] - if (enable_bsdiff_test) { - deps += [ - ":bsdiff_example", - ":bspatch_example" - ] - } -} + +import("//build/ohos.gni") + +declare_args() { + enable_bsdiff_test = false +} + +ohos_shared_library("bsdiff_bspatch") { + sources = [ + "bsdiff/bsdiff.c", + "bsdiff/bspatch.c", + ] + + include_dirs = [ "./bsdiff" ] + + part_name = "bsdiff" +} + +ohos_executable("bsdiff_example") { + sources = [ "bsdiff/bsdiff.c" ] + include_dirs = [ + "./bsdiff", + "//third_party/bzip2", + ] + + deps = [ "//third_party/bzip2:libbz2" ] + cflags = [ "-DBSDIFF_EXECUTABLE" ] + + part_name = "bsdiff" +} + +ohos_executable("bspatch_example") { + sources = [ "bsdiff/bspatch.c" ] + include_dirs = [ + "./bsdiff", + "//third_party/bzip2", + ] + + deps = [ "//third_party/bzip2:libbz2" ] + cflags = [ "-DBSPATCH_EXECUTABLE" ] + part_name = "bsdiff" +} + +group("bsdiff") { + deps = [ ":bsdiff_bspatch" ] + if (enable_bsdiff_test) { + deps += [ + ":bsdiff_example", + ":bspatch_example", + ] + } +} -- Gitee