autoport: optimize get_pkg_buildinfo() calls for speed avoiding unnecessary sourcing of input files

This commit is contained in:
Silvan Calarco 2012-05-10 13:42:05 +02:00
parent 465e63d0ef
commit c49d56bd9e

View File

@ -4,7 +4,7 @@
#
# Released under the terms of the GNU GPL release 3 license
#
VERSION=0.9.0
VERSION=0.9.1
BASE_ARCH=i586
BASE_REPOSITORY=devel
PORT_REPOSITORY=devel
@ -64,6 +64,7 @@ function get_pkg_buildinfo() {
pkg_archs=();
for a in ${archs[*]}; do
[ "$a" = "${local_arch}" ] && continue
pkg_header=();
DISTROMATIC_BUILD_FILE=$local_distromatic/builds-$a.sh
[ -e $DISTROMATIC_BUILD_FILE ] && . $DISTROMATIC_BUILD_FILE
@ -77,6 +78,7 @@ function get_pkg_buildinfo() {
DISTROMATIC_BUILD_FILE=$local_distromatic/builds-${local_arch}.sh
[ -e $DISTROMATIC_BUILD_FILE ] && . $DISTROMATIC_BUILD_FILE
[ ${pkg_header[0]} ] && pkg_archs=(${pkg_archs[*]} ${local_arch})
# {
# echo "Error: missing distromatic generated file $DISTROMATIC_BUILD_FILE; aborting."
@ -102,7 +104,6 @@ function get_pkg_buildinfo() {
return 0
fi
done
unset pkg_name pkg_arch pkg_version pkg_release \
pkg_group pkg_license pkg_size pkg_buildtime pkg_altrep pkg_repository
@ -279,10 +280,16 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
echo "Error: unable to fetch $BASE_REPOSITORY_DISTROMATIC_URL/builds-$TARGET_ARCH.sh"
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $BASE_ARCH
port_pkg_list=${pkg_list[*]}
for p in ${port_pkg_list}; do
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH $p || get_pkg_buildinfo $DATADIR/$BASE_REPOSITORY $TARGET_ARCH $p
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH $p
target_pkg_name=$pkg_name
target_pkg_ver=$pkg_version
target_pkg_rel=$pkg_release
[ "$pkg_name" ] || get_pkg_buildinfo $DATADIR/$BASE_REPOSITORY $TARGET_ARCH $p
if [ "$pkg_name" ]; then
base_pkg_ver=$pkg_version
base_pkg_rel=$pkg_release
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $BASE_ARCH $p
[ "$pkg_name" ] || {
@ -292,23 +299,22 @@ for TARGET_ARCH in ${TARGET_ARCHS}; do
port_pkg_ver=$pkg_version
port_pkg_rel=$pkg_release
get_pkg_buildinfo $DATADIR/$PORT_REPOSITORY $TARGET_ARCH $p
if [ "$pkg_name" ]; then
pkg_milestone=`echo $pkg_release | sed "s|[0-9.]*\(.*\)|\1|"`
if [ "$pkg_version" != "$port_pkg_ver" ]; then
echo "Package $pkg_name#${port_pkg_ver}($TARGET_ARCH) differs from $pkg_name#${pkg_version}($BASE_ARCH); port needed."
if [ "$target_pkg_name" ]; then
pkg_milestone=`echo $target_pkg_release | sed "s|[0-9.]*\(.*\)|\1|"`
if [ "$target_pkg_ver" != "$port_pkg_ver" ]; then
echo "Package $pkg_name#${port_pkg_ver}-${port_pkg_rel}($TARGET_ARCH) differs from $pkg_name#${target_pkg_ver}-${target_pkg_rel}($BASE_ARCH); port needed."
JOB=(${JOB[*]} $p)
elif [ "$pkg_release" != "$port_pkg_rel" ]; then
echo "Package $pkg_name#${port_pkg_ver}-${port_pkg_rel}($TARGET_ARCH) differs from $pkg_name#${pkg_version}-${pkg_release}($BASE_ARCH); port needed."
elif [ "$target_pkg_rel" != "$port_pkg_rel" ]; then
echo "Package $pkg_name#${port_pkg_ver}-${port_pkg_rel}($TARGET_ARCH) differs from $pkg_name#${target_pkg_ver}-${target_pkg_rel}($BASE_ARCH); port needed."
JOB=(${JOB[*]} $p)
elif [ "$REBUILD_MILESTONE" -a "$pkg_milestone" != "$REBUILD_MILESTONE" ]; then
echo "Package $pkg_name($TARGET_ARCH) was not built for '$REBUILD_MILESTONE' milestone; rebuild needed."
JOB=(${JOB[*]} $p)
else
echo "Package $pkg_name#${port_pkg_ver}($TARGET_ARCH) is up to date."
echo "Package $pkg_name#${port_pkg_ver}-${port_pkg_rel}($TARGET_ARCH) is up to date."
fi
else
echo "$p#${port_pkg_ver}($BASE_ARCH) is in port repository but $p#${base_pkg_ver}($TARGET_ARCH) is in base repository; port needed."
echo "$p#${port_pkg_ver}-${port_pkg_rel}($BASE_ARCH) is in port repository but $p#${base_pkg_ver}-${base_pkg_rel}($TARGET_ARCH) is in base repository; port needed."
JOB=(${JOB[*]} $p)
fi
fi