changeset 1010:98dbfffd3b0a

Allow existing extracted source directry to be patched if necessary, even if tarball doesn't exist. (This lets a git bisect happen in situ under build/packages.)
author Rob Landley <rob@landley.net>
date Fri, 26 Mar 2010 04:57:11 -0500
parents 6762d6b8d5fc
children 1b364391e821
files sources/functions.sh
diffstat 1 files changed, 22 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/sources/functions.sh	Fri Mar 26 00:52:05 2010 -0500
+++ b/sources/functions.sh	Fri Mar 26 04:57:11 2010 -0500
@@ -199,11 +199,25 @@
   noversion $1 | sed 's/\.tar\..z2*$//'
 }
 
+# Apply any patches to this package
+function patch_package()
+{
+  ls "$PATCHDIR/${PACKAGE}"-* 2> /dev/null | sort | while read i
+  do
+    if [ -f "$i" ]
+    then
+      echo "Applying $i"
+      (cd "${SRCTREE}/${PACKAGE}" && patch -p1 -i "$i") || dienow
+      sha1file "$i" >> "$SHA1FILE"
+    fi
+  done
+}
+
 # Extract tarball named in $1 and apply all relevant patches into
 # "$BUILD/packages/$1".  Record sha1sum of tarball and patch files in
 # sha1-for-source.txt.  Re-extract if tarball or patches change.
 
-function extract()
+function extract_package()
 {
   FILENAME="$1"
   SHA1FILE="$(echo "${SRCTREE}/${PACKAGE}/sha1-for-source.txt")"
@@ -218,7 +232,11 @@
   # If the source tarball doesn't exist, but the extracted directory is there,
   # assume everything's ok.
 
-  [ ! -e "$FILENAME" ] && [ -e "$SHA1FILE" ] && return 0
+  if [ ! -e "$FILENAME" ]
+  then
+    [ ! -e "$SHA1FILE" ] && patch_package
+    return 0
+  fi
 
   SHA1TAR="$(sha1file "${SRCDIR}/${FILENAME}")"
 
@@ -265,17 +283,7 @@
 
   [ $? -ne 0 ] && dienow
 
-  # Apply any patches to this package
-
-  ls "$PATCHDIR/${PACKAGE}"-* 2> /dev/null | sort | while read i
-  do
-    if [ -f "$i" ]
-    then
-      echo "Applying $i"
-      (cd "${SRCTREE}/${PACKAGE}" && patch -p1 -i "$i") || dienow
-      sha1file "$i" >> "$SHA1FILE"
-    fi
-  done
+  patch_package
 }
 
 # Confirm that a file has the appropriate checksum (or exists but SHA1 is blank)
@@ -409,7 +417,7 @@
 
   # Make sure the source is already extracted and up-to-date.
   cd "${SRCDIR}" &&
-  extract "${PACKAGE}-"*.tar* || exit 1
+  extract_package "${PACKAGE}-"*.tar* || exit 1
 
   # If all we want to do is extract source, bail out now.
   [ ! -z "$EXTRACT_ONLY" ] && return 0