forked from aix27249/mkpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkpkg_shared_functions
127 lines (119 loc) · 3.55 KB
/
mkpkg_shared_functions
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
d_echo() {
if [ "${MKPKG_DEBUG}" == "ON" ]; then
echo -e "\e[42m===[MKPKG_DEBUG]=== : $1\e[0m"
fi
}
#Loading message file
if [ -f "${MKPKG_DIR}/mkpkg.messages" ]; then
. "${MKPKG_DIR}/mkpkg.messages"
else
echo "Error loading mkpkg.messages file from '${MKPKG_DIR}' !"
exit 1
fi
#Loading normal messages
if [ -f "${MKPKG_DIR}/mkpkg.n_messages" ]; then
. "${MKPKG_DIR}/mkpkg.n_messages"
else
echo "Error loading mkpkg.n_messages file from '${MKPKG_DIR}' !"
exit 1
fi
find_package_directory() {
local result_func="$1"
local pkg_dir="$2"
local pkg_arch="$3"
[ -z "${pkg_arch}" ] && pkg_arch="*"
cd "${pkg_dir}"
for n in ${pkg_arch} ; do
for i in $(find . -name "${newdep_name}-[0-9]*-${n}-[0-9]*.txz") ; do
eval ${result_func}="$i"
return
done
done
eval ${result_func}=""
return 0
}
check_dir_whitelist() {
local DIR=$(echo ${1} | sed 's/^\.//g')
local WHITELIST="/lib /usr/lib /usr/local/lib /usr/i486-slackware-linux/lib /usr/i686-slackware-linux/lib"
local bad=1
for check in ${WHITELIST} ; do
local zzz=$(echo ${DIR} | sed s:^${check}::g)
if [ "${DIR}" != "${zzz}" ] ; then
bad=0
fi
done
if [ "${bad}" = "1" ] ; then
echo "Skipping files from ${DIR}"
fi
return ${bad}
}
#Query function
ask_yn() {
local pressed_key
if [ -n "$1" ] ; then
message_text=`show_message $1`
read -n 1 -p "${message_text} (y/[a]): " pressed_key
else
read -n 1 pressed_key
fi
echo "" 1>&2
if [ "${pressed_key}" = "y" ] ; then
return 0
else
return 1
fi
}
check_deps() {
IP="api.agilialinux.ru"
show_message CHECKING_PACKAGE_DEPS "«${newdep_name}»"
local dep_ver=$(echo ${newdep_tail} | sed 's/^[>=<]*//g')
local find_package=""
local name_four=`echo "${newdep_name}" | sed 's/\(.\{1,4\}\).*/\1/'`
if [ "${name_four}" = "wine" ]; then
echo -e "\e[31mAdd because the first four characters wine\e[0m"
return 1
fi
find_package_directory find_package ${package_out_dir} "i686 noarch"
if [ -z "${find_package}" ]; then
find_package_directory find_package ${mpkg_cache_dir} "i686 noarch"
if [ -z "${find_package}" ]; then
ping_res=1
/bin/ping ${IP} -c 2 > /dev/null 2>&1 && ping_res=0
if [ ${ping_res} -ne 0 ]; then
show_message UNABLE_CONNECT_SERVER "${IP}"
exit 1
fi
if [ -z "${dep_ver}" ]; then
wget --no-check-certificate -P ${package_out_dir}/deps --content-disposition "http://${IP}/pkg/${newdep_name}/i686"
else
wget --no-check-certificate -P ${package_out_dir}/deps --content-disposition "http://${IP}/pkg/${newdep_name}/i686/${dep_ver}"
fi
find_package_directory find_package ${package_out_dir}/deps "i686 noarch"
else
show_message FOUND_PACKAGE_DIR "${find_package}" "${package_out_dir}"
fi
else
show_message FOUND_PACKAGE_DIR "${find_package}" "${package_out_dir}"
fi
if [ -z ${find_package} ]; then
show_message COULD_NOT_FIND_PACKAGE "«${newdep_name}»"
exit 1
fi
local find_package="$(readlink -f ${find_package})"
local deps_dir="${wd}/deps/${newdep_name}-${dep_ver}"
mkdir -p "${deps_dir}"
if ! [ -d "${deps_dir}" ]; then
show_message FAILED_TO_CREATE_DIR "${deps_dir}"
exit 1
fi
cd "${deps_dir}"
tar -xf "${find_package}"
local find_dep_lib=1
for f in $(find . -name '*.so') $(find . -name '*.so.*') ; do
local dir_name=$(dirname $f)
check_dir_whitelist ${dir_name} || continue
find_dep_lib=0
break
done
return ${find_dep_lib}
}