diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2015-05-17 15:01:06 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2015-05-26 07:21:42 +0200 |
commit | 4111f6560d0909f7368a21727fdf56e067100968 (patch) | |
tree | 06ec3755c75393b6785b56840825ebcbdd64add7 | |
parent | 1528dd4e357d41617c82b1dbd2c4f3dbc6af71ea (diff) | |
download | ptxdist-4111f6560d0909f7368a21727fdf56e067100968.tar.gz ptxdist-4111f6560d0909f7368a21727fdf56e067100968.tar.xz |
limit parallel downloading and extracting for parallel building
Currently the number of parallel downloads is limited to 4 and the number
of extract jobs to 2.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r-- | scripts/lib/ptxd_make_get.sh | 3 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_serialize.sh | 50 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_world_extract.sh | 2 |
3 files changed, 55 insertions, 0 deletions
diff --git a/scripts/lib/ptxd_make_get.sh b/scripts/lib/ptxd_make_get.sh index 9b7bfd192..fe2613f11 100644 --- a/scripts/lib/ptxd_make_get.sh +++ b/scripts/lib/ptxd_make_get.sh @@ -51,6 +51,7 @@ ptxd_make_get_http() { # remove any pending or half downloaded files rm -f -- "${path}."* + ptxd_make_serialize_take local temp_file="$(mktemp "${path}.XXXXXXXXXX")" || ptxd_bailout "failed to create tempfile" wget \ --passive-ftp \ @@ -66,8 +67,10 @@ ptxd_make_get_http() { file "${temp_file}" | grep -vq " HTML " && touch -- "${temp_file}" && mv -- "${temp_file}" "${path}" + ptxd_make_serialize_put return } + ptxd_make_serialize_put rm -f -- "${temp_file}" diff --git a/scripts/lib/ptxd_make_serialize.sh b/scripts/lib/ptxd_make_serialize.sh new file mode 100644 index 000000000..2515cd2a0 --- /dev/null +++ b/scripts/lib/ptxd_make_serialize.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Copyright (C) 2015 by Michael Olbrich <mol@pengutronix.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +ptxd_make_serialize_take() { + local readptr="ptxd_make_serialize_${pkg_stage}_readfd" + local tmp + if [ -n "${!readptr}" ]; then + read -n 1 -u "${!readptr}" tmp + fi +} +export -f ptxd_make_serialize_take + +ptxd_make_serialize_put() { + local writeptr="ptxd_make_serialize_${pkg_stage}_writefd" + if [ -n "${!writeptr}" ]; then + echo -n '+' >&${!writeptr} + fi +} +export -f ptxd_make_serialize_put + +ptxd_make_serialize_setup() { + local name="${1}" + local count="${2}" + local fifo="${PTXDIST_TEMPDIR}/${name}-fifo" + local writeptr="ptxd_make_serialize_${name}_writefd" + local readptr="ptxd_make_serialize_${name}_readfd" + local writefd readfd + + mkfifo "${fifo}" || return + echo -n "$(seq -s "+" 0 ${count} | sed 's/[^+]//g')" > "${fifo}" & + exec {readfd}< "${fifo}" && + exec {writefd}> "${fifo}" && + eval "${readptr}"="${readfd}" && + eval "${writeptr}"="${writefd}" && + export "${readptr}" "${writeptr}" +} +export -f ptxd_make_serialize_setup + +ptxd_make_serialize_init() { + ptxd_make_serialize_setup get 4 && + ptxd_make_serialize_setup extract 2 +} +ptxd_make_serialize_init diff --git a/scripts/lib/ptxd_make_world_extract.sh b/scripts/lib/ptxd_make_world_extract.sh index dc32f7548..955c4872b 100644 --- a/scripts/lib/ptxd_make_world_extract.sh +++ b/scripts/lib/ptxd_make_world_extract.sh @@ -60,6 +60,7 @@ ptxd_make_world_extract() { mkdir -p "${pkg_extract_dir}" || return + ptxd_make_serialize_take echo "\ extract: pkg_src=$(ptxd_print_path ${pkg_src}) extract: pkg_extract_dir=$(ptxd_print_path ${pkg_dir})" @@ -83,6 +84,7 @@ extract: pkg_extract_dir=$(ptxd_print_path ${pkg_dir})" fi local ret=$? rm -rf "${tmpdir}" + ptxd_make_serialize_put return ${ret} } |