@@ -280,19 +280,37 @@ download_packages()
280
280
281
281
run_pip_command ()
282
282
{
283
- parameters=(" $@ " )
283
+ declare -a parameters=(" $@ " )
284
+ PIP_CACHE_PATH=${PKG_CACHE_PATH} /pip
285
+ PKG_CACHE_OPTION=" --cache-dir=${PIP_CACHE_PATH} "
284
286
285
- if [ ! -x " $REAL_COMMAND " ] && [ " $1 " == " freeze" ]; then
287
+ if [[ ! -e ${PIP_CACHE_PATH} ]]; then
288
+ ${SUDO} mkdir -p ${PIP_CACHE_PATH}
289
+ ${SUDO} chmod 777 ${PIP_CACHE_PATH}
290
+ fi
291
+
292
+ if [ ! -x " $REAL_COMMAND " ] && [ " $1 " == " freeze" ]; then
286
293
return 1
287
294
fi
288
295
289
- if [ " $ENABLE_VERSION_CONTROL_PY " != " y" ]; then
296
+ if [[ " $SKIP_BUILD_HOOK " == y || " $ENABLE_VERSION_CONTROL_PY " != " y" ]]; then
297
+ if [ ! -z " $( get_version_cache_option) " ]; then
298
+ FLOCK ${PIP_CACHE_PATH}
299
+ $REAL_COMMAND ${PKG_CACHE_OPTION} " $@ "
300
+ local result=$?
301
+ chmod -f -R 777 ${PIP_CACHE_PATH}
302
+ touch ${PIP_CACHE_PATH}
303
+ FUNLOCK ${PIP_CACHE_PATH}
304
+ return ${result}
305
+ fi
290
306
$REAL_COMMAND " $@ "
291
307
return $?
292
308
fi
293
309
310
+
294
311
local found=n
295
312
local install=n
313
+ local count=0
296
314
local pip_version_file=$PIP_VERSION_FILE
297
315
local tmp_version_file=$( mktemp)
298
316
[ -f " $pip_version_file " ] && cp -f $pip_version_file $tmp_version_file
@@ -301,6 +319,7 @@ run_pip_command()
301
319
([ " $para " == " -c" ] || [ " $para " == " --constraint" ]) && found=y
302
320
if [ " $para " == " install" ]; then
303
321
install=y
322
+ parameters[${count} ]=install
304
323
elif [[ " $para " == * .whl ]]; then
305
324
package_name=$( echo $para | cut -d- -f1 | tr _ .)
306
325
$SUDO sed " /^${package_name} ==/d" -i $tmp_version_file
@@ -309,20 +328,30 @@ run_pip_command()
309
328
package_name=$( echo $para | cut -d= -f1)
310
329
$SUDO sed " /^${package_name} ==/d" -i $tmp_version_file
311
330
fi
331
+ (( count++ ))
312
332
done
313
333
314
334
if [ " $found " == " n" ] && [ " $install " == " y" ]; then
315
335
parameters+=(" -c" )
316
336
parameters+=(" ${tmp_version_file} " )
317
337
fi
318
338
319
- $REAL_COMMAND " ${parameters[@]} "
320
- local result=$?
321
- if [ " $result " != 0 ]; then
322
- echo " Failed to run the command with constraint, try to install with the original command" 1>&2
323
- $REAL_COMMAND " $@ "
324
- result=$?
325
- fi
339
+ if [ ! -z " $( get_version_cache_option) " ]; then
340
+ FLOCK ${PIP_CACHE_PATH}
341
+ $REAL_COMMAND ${PKG_CACHE_OPTION} " ${parameters[@]} "
342
+ local result=$?
343
+ chmod -f -R 777 ${PIP_CACHE_PATH}
344
+ touch ${PIP_CACHE_PATH}
345
+ FUNLOCK ${PIP_CACHE_PATH}
346
+ else
347
+ $REAL_COMMAND " ${parameters[@]} "
348
+ local result=$?
349
+ if [ " $result " != 0 ]; then
350
+ echo " Failed to run the command with constraint, try to install with the original command" 1>&2
351
+ $REAL_COMMAND " $@ "
352
+ result=$?
353
+ fi
354
+ fi
326
355
rm $tmp_version_file
327
356
return $result
328
357
}
@@ -348,7 +377,7 @@ check_apt_install()
348
377
# Print warning message if a debian package version not specified when debian version control enabled.
349
378
check_apt_version ()
350
379
{
351
- VERSION_FILE=" /usr/local/share/buildinfo/versions /versions-deb"
380
+ VERSION_FILE=" ${VERSION_PATH} /versions-deb"
352
381
local install=$( check_apt_install " $@ " )
353
382
if [ " $ENABLE_VERSION_CONTROL_DEB " == " y" ] && [ " $install " == " y" ]; then
354
383
for para in " $@ "
0 commit comments