-
Notifications
You must be signed in to change notification settings - Fork 101
/
thirdparty-deploy.sh
executable file
·184 lines (159 loc) · 3.45 KB
/
thirdparty-deploy.sh
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
top_srcdir=`pwd`
thirdparty_dir="${top_srcdir}/thirdparty"
repo_dir="${top_srcdir}/thirdparty_repo"
repo_tmpdir="${top_srcdir}/thirdparty_tmp"
SHA512SUM=
cleanup()
{
:
}
die()
{
echo $*
cd "${pwd1}"
cleanup
exit 1
}
_get_tar_args()
{
local args=
case "${1}" in
*.tar.gz)
args="z"
;;
*.tar.bz2)
args="j"
;;
*.tar.xz)
args="J"
;;
esac
echo "${args}"
}
find_shasum()
{
if [ "x${SHA512SUM}" = "x" ]
then
which shasum > /dev/null 2>&1 && SHA512SUM=shasum
fi
if [ "x${SHA512SUM}" = "x" ]
then
which sha512sum > /dev/null 2>&1 && SHA512SUM=sha512sum
fi
if [ "x${SHA512SUM}" = "x" ]
then
die "Nor sha512sum nor shasum found!"
fi
}
deploy_package()
{
local pkgname="${1}"
local metafile="${repo_dir}/${pkgname}.meta.sh"
source "${metafile}"
local patchesdir="${repo_dir}/patches/${PN}"
local pkg_datadir="${repo_tmpdir}/${PN}"
local pwd1=`pwd`
if [ ! -d "${pkg_datadir}" ]
then
mkdir "${pkg_datadir}" || die "Failed to create package tmpdir!"
fi
cd "${pkg_datadir}" || die "chdir failed!"
# Check consistency
if [ -f .prepared ]
then
local pkg_rev=`cat .prepared 2>/dev/null`
test "x${pkg_rev}" = "x" && pkg_rev=0
if [ "x${pkg_rev}" != "x${REV}" ]
then
echo "The existing source package is older."
echo -n "Cleaning it... "
rm -r "${thirdparty_dir}/${SOURCESDIR}" >/dev/null 2>&1 || die "rm (dir) failed!"
echo "done"
fi
fi
if [ ! -d "${thirdparty_dir}/${SOURCESDIR}" ]
then
rm -f .unpacked .prepared
fi
if [ ! -f "${SRCFILE}" ]
then
rm -f .downloaded .verified
fi
if [ ! -f .downloaded ]
then
if [ -f "${SRCFILE}" ]
then
rm -f "${SRCFILE}"
fi
curl -f -L -O ${URL} || die "Failed to fetch sources!"
if [ ! -f "${SRCFILE}" ]
then
die "Something wrong... source file not found!"
fi
echo "1" > .downloaded
echo "Downloaded OK."
fi
if [ ! -f .verified ]
then
# make sha512 sum file
echo "${SHA512} *${SRCFILE}" > "${SRCFILE}.sha512"
${SHA512SUM} -c "${SRCFILE}.sha512" || if [ "x" = "x" ]; then rm -f .downloaded; rm -f "${SRCFILE}.sha512"; die "Failed to verify checksum!"; fi
echo "1" > .verified
rm -f "${SRCFILE}.sha512"
echo "Checksum OK."
fi
local tar_args=`_get_tar_args "${SRCFILE}"`
if [ ! -f .unpacked ]
then
cd "${thirdparty_dir}" || die "chdir to thirdparty_dir failed!"
tar -x${tar_args}f "${pkg_datadir}/${SRCFILE}" || die "Failed to unpack sources!"
cd "${pkg_datadir}" || die "chdir failed!"
echo "1" > .unpacked
echo "Unpacked OK."
fi
if [ ! -f .prepared ]
then
cd "${thirdparty_dir}/${SOURCESDIR}" || die "chdir to srcdir failed!"
for p in ${PATCHES}
do
patch -p1 -i "${patchesdir}/${p}" || die "Failed to patch!"
done
cd "${pkg_datadir}" || die "chdir failed!"
echo "${REV}" > .prepared
echo "Prepared OK."
fi
# clean vars
unset -v PN
unset -v PV
unset -v REV
unset -v SRCFILE
unset -v SHA512
unset -v URL
unset -v SOURCEDIR
unset -v PATCHES
cd "${pwd1}"
}
# check current directory
if [ ! -f ./thirdparty-deploy.sh ]
then
die "Error! You must call this script only in top_srcdir!"
fi
if [ ! -d "${thirdparty_dir}" ]
then
mkdir "${thirdparty_dir}" || die "Failed to create thirdparty_dir!"
fi
if [ ! -d "${repo_tmpdir}" ]
then
mkdir "${repo_tmpdir}" || die "Failed to create repo tmpdir!"
fi
find_shasum
deploy_package zlib
deploy_package libpng
deploy_package libjpeg
deploy_package freetype
deploy_package harfbuzz
deploy_package fribidi
deploy_package utf8proc
deploy_package libunibreak
deploy_package zstd