diff sources/functions.sh @ 990:00704bb2c556

Add FORK=1 support to download.sh, and work around bash's $$ refusing to give an actual unique $PID for subshells by groveling around in /proc to find something usable.
author Rob Landley <rob@landley.net>
date Mon, 01 Mar 2010 02:21:49 -0600
parents 93830ce35f85
children bbcafba8a594
line wrap: on
line diff
--- a/sources/functions.sh	Mon Mar 01 01:03:04 2010 -0600
+++ b/sources/functions.sh	Mon Mar 01 02:21:49 2010 -0600
@@ -249,16 +249,17 @@
   echo -n "Extracting '${PACKAGE}'"
 
   (
-    trap 'rm -rf "$BUILD/temp-'$$'"' EXIT
+    UNIQUE=$(readlink /proc/self)
+    trap 'rm -rf "$BUILD/temp-'$UNIQUE'"' EXIT
     # Delete the old tree (if any).
     rm -rf "${SRCTREE}/${PACKAGE}" 2>/dev/null
-    mkdir -p "${BUILD}"/{temp-$$,packages} || dienow
+    mkdir -p "${BUILD}"/{temp-$UNIQUE,packages} || dienow
 
-    { tar -xv${DECOMPRESS} -f "${SRCDIR}/${FILENAME}" -C "${BUILD}/temp-$$" ||
+    { tar -xv${DECOMPRESS} -f "${SRCDIR}/${FILENAME}" -C "${BUILD}/temp-$UNIQUE" ||
       dienow
     } | dotprogress
 
-    mv "${BUILD}/temp-$$/"* "${SRCTREE}/${PACKAGE}" &&
+    mv "${BUILD}/temp-$UNIQUE/"* "${SRCTREE}/${PACKAGE}" &&
     echo "$SHA1TAR" > "$SHA1FILE"
   )