-
Notifications
You must be signed in to change notification settings - Fork 65
/
deploy_dep
74 lines (62 loc) · 2.43 KB
/
deploy_dep
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
# SPDX-FileCopyrightText: 2023-2024 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: GPL-3.0-or-later
#!/bin/bash
set -e
# 生成安装目录/文件和运行时依赖的必要库
# 获取应用id
ID_VALUE=$(awk -F ': ' '/^ id: / {print $2}' linglong.yaml)
## 获取安装的文件列表并写入安装脚本(排除头文件、pc和cmake文件)
# cmake 安装
if ! grep -- "-- Installing:" install.log | awk '{print $NF}' | grep -vE '\.(h|cmake|pc)$' > ${ID_VALUE}.install; then
echo "cmake install files are empty!"
fi
# qmake 安装
if ! grep -- "-install qinstall" install.log | awk '{print $NF}' | grep -vE '\.(h|cmake|pc)$' >> ${ID_VALUE}.install; then
echo "qmake install files are empty!"
fi
# 动态库软连接
if ! grep -- "^ln -f -s " install.log | awk '{print $NF}' >> ${ID_VALUE}.install; then
echo "Get library softlink empty!"
fi
# glib-compile-schemas 文件添加到 install 文件
for SCHEMAS in "${PREFIX}"/share/glib-2.0/schemas/gschema*; do
if [[ -f "$SCHEMAS" ]]; then
echo "$SCHEMAS" >> "${ID_VALUE}.install"
fi
done
# 获取依赖的所有文件
for LDFILE in "$@"; do
# 判断文件是否以 .so 结尾
if [[ "$LDFILE" == *.so ]]; then
FILE_PATH="${PREFIX}/lib/${TRIPLET}/$LDFILE"
# 添加依赖库到 install 文件
for SOFILE in "${PREFIX}/lib/${TRIPLET}"/${LDFILE}*; do
if [[ -f "$SOFILE" ]]; then
echo "$SOFILE" >> "${ID_VALUE}.install"
fi
done
else
FILE_PATH="${PREFIX}/bin/$LDFILE"
fi
# 获取依赖库
DEPENDENCIES=$(ldd "$FILE_PATH" | grep "$PREFIX") || continue
if [[ ! -z "$DEPENDENCIES" ]]; then
echo "$DEPENDENCIES" | while IFS= read -r line; do
LIB_PATH=${line##*=> }
LIB_PATH=${LIB_PATH%%(*}
# 获取基本库名并匹配相关库
LIB_DIR=$(dirname "$LIB_PATH")
BASE_LIB_NAME=$(basename "$LIB_PATH")
# 使用通配符查找相关库文件并将结果倒序存储到 install 文件
for FILE in "$LIB_DIR"/${BASE_LIB_NAME%.*}*; do
if [[ -f "$FILE" ]]; then
echo "$FILE"
fi
done | sort -r >> "${ID_VALUE}.install"
done
fi
done
# 排除静态链接库
#echo '^'${PREFIX}'/'${TRIPLET}'/.+(?<!\.a)$' >> "${ID_VALUE}.install"
#echo '^'${PREFIX}'/lib/.+(?<!\.a|\.pc|\.cmake|\.h|\.sh|\.prf|\.inc)$' >> "${ID_VALUE}.install"