diff options
author | kris <kris@FreeBSD.org> | 2008-06-11 21:25:13 +0800 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2008-06-11 21:25:13 +0800 |
commit | 92953a536c7bc21f5e4c2bfffa52ceb0da861b65 (patch) | |
tree | 1a7cb584d0ee9f67b595da06433787c9e1066a56 /Tools | |
parent | 9db61cd34c11701f3b2d90be5ee7250bafe863c4 (diff) | |
download | freebsd-ports-gnome-92953a536c7bc21f5e4c2bfffa52ceb0da861b65.tar.gz freebsd-ports-gnome-92953a536c7bc21f5e4c2bfffa52ceb0da861b65.tar.zst freebsd-ports-gnome-92953a536c7bc21f5e4c2bfffa52ceb0da861b65.zip |
Major optimizations. Instead of copying the distfiles around, mv
them in batches according to their target directory.
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/portbuild/scripts/dodistfiles | 78 |
1 files changed, 67 insertions, 11 deletions
diff --git a/Tools/portbuild/scripts/dodistfiles b/Tools/portbuild/scripts/dodistfiles index dc80fe95e874..2db265200b02 100755 --- a/Tools/portbuild/scripts/dodistfiles +++ b/Tools/portbuild/scripts/dodistfiles @@ -1,14 +1,70 @@ #!/bin/sh +# +# Process a distfiles/ directory, efficiently moving files from +# .pbtmp/<package>/* into . (relative to distfiles/) +# +# We do this in several stages +# +# 1. Remove incomplete downloads where .pbtmp/<package>/.done does not +# exist (this is an incomplete transfer and may be corrupted) +# +# 2. Populate the directory hierarchy from .pbtmp/*/ into . +# +# 3. For each subdirectory under .pbtmp/*/, group them together by +# subdirectory name and move all of the files at once. +# e.g. .pbtmp/foo-1.0/dir/* and .pbtmp/bar-2.0/dir/* are +# processed at the same time (contents moved to ./dir/). +# +# 4. Once we have handled the subdirectories, everything left +# is a plain file in .pbtmp/*/ so we move those in bulk together +# into . +# +# 5. Clean up -distdir=$1 -if cd ${distdir}/.pbtmp >/dev/null 2>&1; then - set * - while [ $# -gt 0 ]; do - if [ -e $1/.done ]; then - rm -f $1/.done - tar -C $1 -cf - . | tar -C ${distdir} -xpf - - rm -rf $1 - fi - shift - done +if [ $# != 2 ]; then + echo "usage: $0 <arch> <branch>" + exit 1 fi + +arch=$1 +branch=$2 + +distdir=/var/portbuild/${arch}/${branch}/distfiles + +cd ${distdir} || exit 1 + +echo "Removing incomplete downloads" + +find ${distdir}/.pbtmp/ -name .done -depth 2 | sed -e 's,/.done$,/,' | sort > .done || exit 1 +find -d ${distdir}/.pbtmp/ -type d -mindepth 1 |sed -E -e 's,([^/])$,\1/,' > .alldirs || exit 1 + +sed -E -e "s,^(${distdir}/.pbtmp/[^/]+/).*,\1," < .alldirs | sort -u > .pkgdirs + +comm -1 -3 .done .pkgdirs | xargs rm -rf + +# Full path of subdirectories under package dirs +grep -E "^${distdir}/.pbtmp/[^/]+/.+/" .alldirs > .pkgsubdirs + +# All subdirectories under package dirs +sed -E -e "s,^${distdir}/.pbtmp/[^/]+/,," < .pkgsubdirs | grep -v '^$' | sort -u > .subdirs + +echo "Making directories" +cat .subdirs | xargs mkdir -p + +# Move files in each subdir +for i in `cat .pkgsubdirs`; do + find ${i} -type f -depth 1 \! -name .done | xargs -J % mv % ${distdir}/${i#${distdir}/.pbtmp/*/} +# rmdir ${i} || exit 1 +# rm -rf ${distdir}/.pbtmp/$i +done +cat .pkgsubdirs | xargs rmdir || exit 1 + +echo "Moving remaining distfiles" +find ${distdir}/.pbtmp/ -type f -depth 2 \! -name .done | xargs -J % mv % ${distdir} + +echo "Cleaning up" +sed -e 's,$,.done,' < .pkgdirs | xargs rm -f || exit 1 +cat .pkgdirs | xargs rmdir || exit 1 +rmdir .pbtmp || exit 1 + +rm -f .alldirs .done .pkgdirs .pkgsubdirs .subdirs || exit 1 |