changeset 1257:1461d20bb6a7

Genericize the noversion() regex a bit, and make sure to only apply patches in the sources/patches directory that end in ".patch".
author Rob Landley <rob@landley.net>
date Thu, 07 Oct 2010 23:46:30 -0500
parents df70740df1a5
children c264495fbf21
files sources/download_functions.sh
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sources/download_functions.sh	Tue Oct 05 21:18:36 2010 -0500
+++ b/sources/download_functions.sh	Thu Oct 07 23:46:30 2010 -0500
@@ -1,16 +1,20 @@
 #!/bin/echo "This file is sourced, not run"
 
-# Give filename.tar.ext minus the version number.
+# Remove version information and extension tarball name "$1".
+# If "$2", add that version number back, keeping original extension.
 
 noversion()
 {
-  echo "$1" | sed -e 's/-*\(\([0-9\.]\)*\([_-]rc\)*\(-pre\)*\([0-9][a-zA-Z]\)*\)*\(\.tar\..z2*\)$/'"$2"'\6/'
+  LOGRUS='s/-*\(\([0-9\.]\)*\([_-]rc\)*\(-pre\)*\([0-9][a-zA-Z]\)*\)*\(\.tar\(\..z2*\)*\)$'
+  [ -z "$2" ] && LOGRUS="$LOGRUS//" || LOGRUS="$LOGRUS/$2\\6/"
+
+  echo "$1" | sed -e "$LOGRUS"
 }
 
 # Apply any patches to this package
 patch_package()
 {
-  ls "$PATCHDIR/${PACKAGE}"-* 2> /dev/null | sort | while read i
+  ls "$PATCHDIR/${PACKAGE}"-*.patch 2> /dev/null | sort | while read i
   do
     if [ -f "$i" ]
     then
@@ -54,7 +58,11 @@
   SHA1FILE="$SRCTREE/$PACKAGE/sha1-for-source.txt"
   if [ -z "$FILENAME" ]
   then
-    [ ! -e "$SRCTREE/$PACKAGE" ] && dienow "No tarball for $PACKAGE"
+    if [ ! -e "$SRCTREE/$PACKAGE" ]
+    then
+      echo "No tarball for $PACKAGE" >&2
+      dienow
+    fi
 
     # If the sha1sum file isn't there, re-patch the package.
     [ ! -e "$SHA1FILE" ] && patch_package
@@ -169,7 +177,7 @@
   touch -c "$SRCDIR"/{"$FILENAME","$ALTFILENAME"} 2>/dev/null
 
   # Give package name, minus file's version number and archive extension.
-  BASENAME="$(noversion "$FILENAME" | sed 's/\.tar\..z2*$//')"
+  BASENAME="$(noversion "$FILENAME")"
 
   # If unstable version selected, try from listed location, and fall back
   # to PREFERRED_MIRROR.  Do not try normal mirror locations for unstable.