• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15set -e
16
17<<COMMENT
18
19# -p NUM  --strip=NUM  Strip NUM leading components from file names.
20# -i PATCHFILE  --input=PATCHFILE  Read patch from PATCHFILE instead of stdin.
21# -d DIR  --directory=DIR  Change the working directory to DIR first.
22
23bash -x  ./apply_patch.sh  \
24  ../../../../third_party/libinput/ \
25  ../../../../out/ohos-arm-release/libinput_mmi \
26 ./diff_libinput_mmi
27
28COMMENT
29
30curdir=$(pwd)
31source_dir=$1
32out_dir=$2
33path_file_dir=$3
34
35echo "curdir: $curdir"
36echo "source_dir: $source_dir"
37echo "out_dir: $out_dir"
38echo "path_file_dir: $path_file_dir"
39
40if [ "$source_dir" == "" ] || [ "$out_dir" == "" ] || [ "$path_file_dir" == "" ]; then
41    echo "param is invalid."
42    exit 1
43fi
44
45echo "check out_dir: $out_dir"
46if [ -d "$out_dir" ]; then
47    echo "remove $out_dir begin"
48    rm -rf "$out_dir"
49fi
50
51echo "mkdir out_dir: $out_dir"
52mkdir -p $out_dir
53
54echo "cp $source_dir/* to $out_dir/"
55cp -fra $source_dir/* $out_dir
56
57if [ -e "$out_dir/install.sh" ]; then
58    cd $out_dir
59    tar xvf mtdev-1.1.6.tar.bz2
60    cp -rf mtdev-1.1.6/* ./
61    ./configure
62    cd -
63fi
64
65ls -l $path_file_dir/*.diff
66if [ $? -ne 0 ]; then
67    echo "WARNING: no patch."
68    exit 0
69fi
70
71PATCH_FILE=$(realpath $(ls $path_file_dir/*.diff | tail -n 1))
72
73echo "PATCH_FILE: $PATCH_FILE"
74
75cd $out_dir
76echo "pwd: $(pwd)"
77patch -p1 -i $PATCH_FILE
78if [ $? -ne 0 ]; then
79    echo "patch fail. path_file_dir=$path_file_dir"
80    exit 1
81fi
82
83cd $curdir
84exit 0
85