1#!/bin/bash
2# This library is free software; you can redistribute it and/or
3# modify it under the terms of the GNU Lesser General Public
4# License as published by the Free Software Foundation version 2.1
5# of the License.
6#
7# Copyright(c) 2023 Huawei Device Co., Ltd.
8
9set -e
10cd $1
11if [ "$(uname)" == "Linux" ];then
12    flock -x "README" -c "tar xvf bzip2-1.0.8.tar.gz &&
13        cd bzip2-1.0.8 &&
14        patch -p1 < $1/0002-CVE-2019-12900.patch --fuzz=0 --no-backup-if-mismatch &&
15        patch -p1 < $1/0001-add-compile-option.patch --fuzz=0 --no-backup-if-mismatch &&
16		patch -p1 < $1/0003-license-and-version-print-should-output-to-stdout-and-exit-with-code-0.patch --fuzz=0 --no-backup-if-mismatch &&
17        mv * .."
18    exit 0
19fi
20tar xvf bzip2-1.0.8.tar.gz
21cd bzip2-1.0.8
22patch -p1 < $1/0002-CVE-2019-12900.patch --fuzz=0 --no-backup-if-mismatch
23patch -p1 < $1/0001-add-compile-option.patch --fuzz=0 --no-backup-if-mismatch
24patch -p1 < $1/0003-license-and-version-print-should-output-to-stdout-and-exit-with-code-0.patch --fuzz=0 --no-backup-if-mismatch
25mv * ..
26exit 0