118f54607Sopenharmony_ci#!/bin/bash
218f54607Sopenharmony_ci
318f54607Sopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd.
418f54607Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
518f54607Sopenharmony_ci# you may not use this file except in compliance with the License.
618f54607Sopenharmony_ci# You may obtain a copy of the License at
718f54607Sopenharmony_ci#
818f54607Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
918f54607Sopenharmony_ci#
1018f54607Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
1118f54607Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
1218f54607Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1318f54607Sopenharmony_ci# See the License for the specific language governing permissions and
1418f54607Sopenharmony_ci# limitations under the License.
1518f54607Sopenharmony_ci
1618f54607Sopenharmony_ciSRC_DIR="$1"
1718f54607Sopenharmony_ciCODE_DIR="$2"
1818f54607Sopenharmony_ciOPEN_EULER_BROTLI_SOURCE_PATH="brotli-1.0.9"
1918f54607Sopenharmony_ciOPEN_EULER_BROTLI_TAR="v1.0.9.tar.gz"
2018f54607Sopenharmony_ci
2118f54607Sopenharmony_ciset -e
2218f54607Sopenharmony_ciecho "brotli test : $SRC_DIR" > brotlitest.txt
2318f54607Sopenharmony_ciecho "brotli test : $CODE_DIR" > brotlitest.txt
2418f54607Sopenharmony_ciif [ "$SRC_DIR" == "" ] || [ "$CODE_DIR" == "" ]; then
2518f54607Sopenharmony_ci    echo "brotli test :src_dir or code_dir empty" > brotlitest.txt
2618f54607Sopenharmony_ci    exit 1
2718f54607Sopenharmony_cifi
2818f54607Sopenharmony_ci
2918f54607Sopenharmony_ciif [ -d "$CODE_DIR" ]; then
3018f54607Sopenharmony_ci    rm -rf "$CODE_DIR"
3118f54607Sopenharmony_cifi
3218f54607Sopenharmony_ci
3318f54607Sopenharmony_cimkdir -p $CODE_DIR
3418f54607Sopenharmony_ci
3518f54607Sopenharmony_citar zxvf $SRC_DIR/$OPEN_EULER_BROTLI_TAR -C $CODE_DIR
3618f54607Sopenharmony_ciecho "brotli test :unzip brotli" > brotlitest.txt
3718f54607Sopenharmony_ci
3818f54607Sopenharmony_ci_all_patchs=(
3918f54607Sopenharmony_ci    "backport-Revert-Add-runtime-linker-path-to-pkg-config-files.patch"
4018f54607Sopenharmony_ci)
4118f54607Sopenharmony_cifor file in "${_all_patchs[@]}"
4218f54607Sopenharmony_ci    do 
4318f54607Sopenharmony_ci        patch -d $CODE_DIR/$OPEN_EULER_BROTLI_SOURCE_PATH -p1 < $SRC_DIR/$file --fuzz=0 --no-backup-if-mismatch
4418f54607Sopenharmony_ci    done
4518f54607Sopenharmony_ciexit 0