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 touch test.lock 13 ( 14 flock -x 200 15 for i in 1 2 3; do 16 if [ -d "$1/bzip2-1.0.8" ];then 17 cp -rf bzip2-1.0.8/* .. 18 break 19 fi 20 tar zxvf bzip2-1.0.8.tar.gz 21 sleep 1s 22 cd $1/bzip2-1.0.8 23 if [ -f "Makefile" ] && [ -f "decompress.c" ] && [ -f "bzip2.c" ] && [ -f "Makefile-libbz2_so" ];then 24 patch -p1 < $1/0002-CVE-2019-12900.patch --fuzz=0 --no-backup-if-mismatch 25 patch -p1 < $1/0001-add-compile-option.patch --fuzz=0 --no-backup-if-mismatch 26 patch -p1 < $1/0003-license-and-version-print-should-output-to-stdout-and-exit-with-code-0.patch --fuzz=0 --no-backup-if-mismatch 27 cp -rf * .. 28 cd .. 29 break 30 fi 31 cd .. 32 sleep 1s 33 done 34 exit 0 35 )200>$1/test.lock 36else 37 for i in 1 2 3; do 38 if [ -d "$1/bzip2-1.0.8" ];then 39 cp -rf bzip2-1.0.8/* .. 40 break 41 fi 42 tar zxvf bzip2-1.0.8.tar.gz 43 cd $1/bzip2-1.0.8 44 if [ -f "Makefile" ] && [ -f "decompress.c" ] && [ -f "bzip2.c" ] && [ -f "Makefile-libbz2_so" ];then 45 patch -p1 < $1/0002-CVE-2019-12900.patch --fuzz=0 --no-backup-if-mismatch 46 patch -p1 < $1/0001-add-compile-option.patch --fuzz=0 --no-backup-if-mismatch 47 patch -p1 < $1/0003-license-and-version-print-should-output-to-stdout-and-exit-with-code-0.patch --fuzz=0 --no-backup-if-mismatch 48 cp -rf * .. 49 cd .. 50 break 51 fi 52 cd .. 53 done 54fi 55exit 0 56