-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathbuild
executable file
·210 lines (163 loc) · 6.71 KB
/
build
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/bin/bash
cd $(dirname ${0})
#######################################################################################################################
# check arguments
PLATFORM=$1
PACKAGE=$2
if [ -z "${PLATFORM}" ] || [ -z "${PACKAGE}" ] || [ ! -e "plugins-dep/configs/${PLATFORM}_defconfig" ]; then
echo "Usage: $0 <platform> <plugin-package-name>"
echo " Where platform can be one of: $(echo $(ls plugins-dep/configs | grep _defconfig | sed 's/_defconfig//g' | sort))"
echo " and plugin-package-name is a folder inside ./plugins/package"
exit 1
fi
if [[ "${PACKAGE}" == "kernel" ]]; then
PLATFORM+="-kernel"
fi
#######################################################################################################################
# Import common code and variables
source .common
#######################################################################################################################
# cleanup "package"
if [[ "${PACKAGE}" == "cleanup" ]]; then
# cleanup previous
rm -rf ${WORKDIR}/tmp-lv2-spec
# make sure plugins dir exists and it's clean
mkdir -p ${PLUGINS_DIR}
rm -rf ${PLUGINS_DIR}/plugins/*
# move lv2 spec to a temp dir so we can delete everything else
mkdir ${WORKDIR}/tmp-lv2-spec
mv ${BR2_TARGET}/usr/lib/lv2/{atom,buf-size,data-access,dynmanifest,event,instance-access,log,lv2core,midi,morph,options,parameters,patch,port-groups,port-props,presets,resize-port,schemas,state,time,ui,units,urid,uri-map,worker}.lv2 ${WORKDIR}/tmp-lv2-spec/
rm -rf ${BR2_TARGET}/usr/lib/lv2/*
mv ${WORKDIR}/tmp-lv2-spec/* ${BR2_TARGET}/usr/lib/lv2/
rmdir ${WORKDIR}/tmp-lv2-spec
# just in case
rm -rf ${BR2_TARGET}/usr/local/lib/lv2
# all done!
exit 0
fi
#######################################################################################################################
# kernel "package"
if [[ "${PACKAGE}" == "kernel" ]]; then
PACKAGE="linux"
PKGSUFFIX="-rebuild"
fi
#######################################################################################################################
# if rebuilding, strip "-rebuild" suffix from PACKAGE
if [[ "${PACKAGE}" == *"-rebuild" ]]; then
PACKAGE=$(echo ${PACKAGE} | awk 'sub("-rebuild","")')
PKGSUFFIX="-rebuild"
fi
#######################################################################################################################
# if -publish suffix is used, call publish script and exit this script
if [[ "${PACKAGE}" == *"-publish" ]]; then
PACKAGE=$(echo ${PACKAGE} | awk 'sub("-publish","")')
./publish "${PLATFORM}" "${PACKAGE}"
exit 0
fi
#######################################################################################################################
# Check if requested plugin package exists
if [[ "${PACKAGE}" != *"-dirclean" ]] && [[ "${PACKAGE}" != "linux" ]] && [[ "${PACKAGE}" != "menuconfig" ]]; then
PACKAGE=$(basename ${PACKAGE} | sed "s|\.mk||")
PKGNAME=$(echo ${PACKAGE} | tr a-z- A-Z_)
if [ ! -d ${SOURCE_DIR}/plugins/package/${PACKAGE} ]; then
error "Plugin package name '${PACKAGE}' does not exist"
exit 1
fi
if [ ! -f ${SOURCE_DIR}/plugins/package/${PACKAGE}/${PACKAGE}.mk ]; then
error "Requested plugin package has no 'mk' file"
exit 1
fi
bundles=($(cat ${SOURCE_DIR}/plugins/package/${PACKAGE}/${PACKAGE}.mk | awk 'sub("'${PKGNAME}'_BUNDLES = ","")'))
if [[ "${bundles}" == "" ]]; then
error "Requested plugin package has no bundles"
exit 1
fi
fi
#######################################################################################################################
# custom skeleton with merged /usr mode
if [ "${BUILDROOT_VERSION}" = "buildroot-2016.02" ]; then
mkdir -p /tmp/skeleton/usr/bin
mkdir -p /tmp/skeleton/usr/lib
mkdir -p /tmp/skeleton/usr/sbin
ln -sf usr/bin /tmp/skeleton/
ln -sf usr/lib /tmp/skeleton/
ln -sf usr/sbin /tmp/skeleton/
fi
#######################################################################################################################
# buildroot setup
export DOWNLOAD_PATH=${DOWNLOAD_DIR}
export TOOLCHAIN_PATH=${TOOLCHAIN_DIR}
#######################################################################################################################
# now building...
cd ${BUILD_DIR}/${BUILDROOT_VERSION}
${BR2_MAKE} ${BR2_PLATFORM}_defconfig &>/dev/null
${BR2_MAKE} ${PACKAGE}${PKGSUFFIX}
#######################################################################################################################
# if cleaning, stop here
if [[ "${PACKAGE}" == *"-dirclean" ]]; then
# run host-*-dirclean
${BR2_MAKE} host-${PACKAGE} &>/dev/null
exit 0
fi
#######################################################################################################################
# internal: check for a menuconfig "package" to automatically save config
if [[ "${PACKAGE}" == *"menuconfig"* ]]; then
PREFIX=$(echo ${PACKAGE} | sed 's/menuconfig//g')
if [[ "$PREFIX" == "" ]]; then
${BR2_MAKE} savedefconfig
else
${BR2_MAKE} "$PREFIX"update-config
fi
info "Changes of ${PACKAGE} saved to correspondent configuration file"
fi
#######################################################################################################################
# copy the requested plugin bundles
function bundle_has_binaries
{
for f in "$1"/*.so; do
if [ -e "$f" ]; then
return 1;
fi
done
return 0
}
function try_copy_plugin_bundles
{
path="$1"
for bundle in ${bundles[@]}; do
if [ ! -d ${path}/${bundle} ]; then
return
fi
done
ls ${WORKDIR}/${PLATFORM}/plugins
if [ -z "`ls ${WORKDIR}/${PLATFORM}/plugins`" ]; then
was_empty="1"
else
was_empty="0"
fi
for bundle in ${bundles[@]}; do
rm -rf ${WORKDIR}/${PLATFORM}/plugins/${bundle}
cp -rL ${path}/${bundle} ${WORKDIR}/${PLATFORM}/plugins/${bundle}
info "Finished copying ${bundle}"
done
if [ ${was_empty} == "1" ]; then
for bundle in `ls ${path}`; do
if ( bundle_has_binaries ${path}/${bundle} ); then
continue
fi
if [[ " ${bundles[@]} " =~ " ${bundle} " ]]; then true; else
echo "NOTE: Bundle '$bundle' possibly missing from _BUNDLES definition"
fi
done
fi
exit 0
}
#######################################################################################################################
# copy the requested plugin projects
if [[ "${PACKAGE}" != "linux" ]] && [[ "${PACKAGE}" != "menuconfig" ]] && [[ -z "${MPB_SKIP_PLUGIN_COPY}" ]]; then
mkdir -p ${WORKDIR}/${PLATFORM}/plugins
try_copy_plugin_bundles ${BR2_TARGET}/usr/lib/lv2
try_copy_plugin_bundles ${BR2_TARGET}/usr/local/lib/lv2
error "Failed to find plugin installed bundles"
fi
#######################################################################################################################