Bug 678475 - Make mozconfig-find always return an absolute path. Patch adapted from code by Hiroyuki Ikezoe <hiikezoe@mozilla-japan.org>. r=ted
authorSiddharth Agarwal <sid.bugzilla@gmail.com>
Sun, 14 Aug 2011 22:04:46 +0530
changeset 75292 2fed775753c7c731c1f0852358d4ac35cebba563
parent 74334 31eddfef6549ba56a9f75248f50d671f934773e4
child 75293 2492a2704b6d134d2b11922d2b206480ab8767ee
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersted
bugs678475
milestone8.0a1
Bug 678475 - Make mozconfig-find always return an absolute path. Patch adapted from code by Hiroyuki Ikezoe <hiikezoe@mozilla-japan.org>. r=ted
build/autoconf/mozconfig-find
--- a/build/autoconf/mozconfig-find
+++ b/build/autoconf/mozconfig-find
@@ -41,16 +41,37 @@
 #    command-line. The .mozconfig file is searched for in the 
 #    order:
 #       if $MOZCONFIG is set, use that.
 #       Otherwise, use $TOPSRCDIR/.mozconfig
 #       Otherwise, use $HOME/.mozconfig
 #
 topsrcdir=$1
 
+abspath() {
+  if uname -s | grep -q MINGW; then
+    # We have no way to figure out whether we're in gmake or pymake right
+    # now. gmake gives us Unix-style paths while pymake gives us Windows-style
+    # paths, so attempt to handle both.
+    regexes='^\([A-Za-z]:\|\\\\\|\/\) ^\/'
+  else
+    regexes='^\/'
+  fi
+
+  for regex in $regexes; do
+    if echo $1 | grep -q $regex; then
+      echo $1
+      exit 0
+    fi
+  done
+
+  # If we're at this point, we have a relative path
+  echo `pwd`/$1
+}
+
 for _config in "$MOZCONFIG" \
                "$MOZ_MYCONFIG"
 do
   if [ -n "$_config" ] && ! [ -f "$_config" ]; then
     echo "Specified MOZCONFIG \"$_config\" does not exist!"
     exit 1
   fi
 done
@@ -61,12 +82,12 @@ for _config in "$MOZCONFIG" \
                "$topsrcdir/mozconfig" \
                "$topsrcdir/mozconfig.sh" \
                "$topsrcdir/myconfig.sh" \
                "$HOME/.mozconfig" \
                "$HOME/.mozconfig.sh" \
                "$HOME/.mozmyconfig.sh"
 do
   if test -f "$_config"; then
-    echo "$_config";
+    echo `abspath $_config`
     exit 0
   fi
 done