-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tool
executable file
·92 lines (73 loc) · 2.17 KB
/
run_tool
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
#
# A script to run the tool with all stages
set -e
# Ensure at least two positional parameters are provided
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 <tag1> <tag2> [-c clone_path] [-u repo_link] [-s subsystem]"
echo "error"
exit 1
fi
TAG1="$1"
TAG2="$2"
CLONE_PATH="linux-clone"
REPO_URL="https://github.com/gregkh/linux"
SUBSYS=""
print_usage() {
echo "Usage: $0 <tag1> <tag2> [-c clone_path] [-u repo_link] [-s subsystem]"
}
# Shift positional parameters before processing options
shift 2
# Parse optional arguments
while getopts 'c:u:s:' flag; do
case "${flag}" in
c) CLONE_PATH="${OPTARG}" ;;
u) REPO_URL="${OPTARG}" ;;
s) SUBSYS="${OPTARG}" ;;
*) print_usage
exit 1 ;;
esac
done
# Debug information
echo "TAG1: $TAG1"
echo "TAG2: $TAG2"
echo "CLONE_PATH: $CLONE_PATH"
echo "REPO_URL: $REPO_URL"
echo "SUBSYS: $SUBSYS"
# Determine if REPO_URL is a GitHub or GitLab URL
if [[ "$REPO_URL" == "https://github"* ]]; then
REPO_TYPE="github"
elif [[ "$REPO_URL" == "https://gitlab"* ]]; then
REPO_TYPE="gitlab"
else
REPO_TYPE="Unknown"
echo "Error: The repository URL ($REPO_URL) is neither a GitHub nor a GitLab URL."
exit 1
fi
echo "Repository URL ($REPO_URL) is identified as: $REPO_TYPE"
TARGET_DIR="linux/scripts/change-impact-tools"
# Clone the repository
if [ ! -d linux/.git ]; then
git clone "$REPO_URL"
fi
# Create the target directory if it doesn't exist
mkdir -p $TARGET_DIR
# Copy necessary scripts to the target directory
cp -rf build_scripts $TARGET_DIR/
cp -rf web_scripts $TARGET_DIR/
cp -f fixdep-patch.file $TARGET_DIR/
cp -f generate_build_filelists $TARGET_DIR/
cp -f generate_web_reports $TARGET_DIR/
mkdir -p $TARGET_DIR/web_source_code
cp web_source_template/* $TARGET_DIR/web_source_code/
# Save the current directory
CUR_DIR=$(pwd)
# Navigate to the target directory and execute the scripts
cd "$TARGET_DIR" || exit
./generate_build_filelists "$TAG1" "$TAG2" "$CLONE_PATH" "$SUBSYS"
./generate_web_reports "$TAG1" "$TAG2" "$REPO_URL"
# Return to the original directory
cd "$CUR_DIR" || exit
# Copy the web source code to the current directory
cp -rf $TARGET_DIR/web_source_code .
cp -rf $TARGET_DIR/build_data .