Bug #27833 Bourne shell string comparison issue in scripts/make_win_bin_dist
Submitted: 15 Apr 2007 5:17 Modified: 21 May 2007 15:16
Reporter: Dhiren Patel Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Packaging Severity:S3 (Non-critical)
Version:5.0.40-BK, 5.0.38 OS:Windows
Assigned to: Joerg Bruehe CPU Architecture:Any
Tags: Contribution, scripts make_win_bin_dist

[15 Apr 2007 5:17] Dhiren Patel
Description:
There are several instances of string comparison in scripts/make_win_bin_dist where the comparison will never succeed. For example:

if [ x"$PACK_DEBUG" = "" -a -f "sql/debug/$BASENAME.exe" -o \
     x"$PACK_DEBUG" = "yes" ] ; then

  . . .

It appears that the corresponding 'x' is missing after the '='.

How to repeat:
Run scripts/make_win_bin_dist with --debug. The debug bits will not get packaged.

Suggested fix:
Add 'x' on both sides of all comparisons. Here's the unified diff:

--- make_win_bin_dist   2007-04-14 22:13:34.513129600 -0700
+++ C:\temp\make_win_bin_dist   2007-03-20 20:12:10.000000000 -0700
@@ -172,8 +172,8 @@
   BASENAME="mysqld"        # New style CMake build
 fi

-if [ x"$PACK_DEBUG" = x"" -a -f "sql/debug/$BASENAME.exe" -o \
-     x"$PACK_DEBUG" = x"yes" ] ; then
+if [ x"$PACK_DEBUG" = "" -a -f "sql/debug/$BASENAME.exe" -o \
+     x"$PACK_DEBUG" = "yes" ] ; then
   cp sql/debug/$BASENAME.exe   $DESTDIR/bin/mysqld-debug.exe
   cp sql/debug/$BASENAME.pdb   $DESTDIR/bin/mysqld-debug.pdb
   cp sql/debug/$BASENAME.map   $DESTDIR/bin/mysqld-debug.map || true
@@ -221,8 +221,8 @@
   cp libmysqld/$TARGET/libmysqld.exp   $DESTDIR/Embedded/DLL/release/
   cp libmysqld/$TARGET/libmysqld.lib   $DESTDIR/Embedded/DLL/release/

-  if [ x"$PACK_DEBUG" = x"" -a -f "libmysqld/debug/libmysqld.lib" -o \
-       x"$PACK_DEBUG" = x"yes" ] ; then
+  if [ x"$PACK_DEBUG" = "" -a -f "libmysqld/debug/libmysqld.lib" -o \
+       x"$PACK_DEBUG" = "yes" ] ; then
     mkdir -p $DESTDIR/Embedded/DLL/debug
     cp libmysqld/debug/libmysqld.dll     $DESTDIR/Embedded/DLL/debug/
     cp libmysqld/debug/libmysqld.exp     $DESTDIR/Embedded/DLL/debug/
@@ -230,10 +230,10 @@
   fi
 }

-if [ x"$PACK_EMBEDDED" = x"" -a \
+if [ x"$PACK_EMBEDDED" = "" -a \
      -f "libmysqld/$TARGET/mysqlserver.lib" -a \
      -f "libmysqld/$TARGET/libmysqld.lib" -o \
-     x"$PACK_EMBEDDED" = x"yes" ] ; then
+     x"$PACK_EMBEDDED" = "yes" ] ; then
   copy_embedded
 fi

@@ -271,8 +271,8 @@
    strings/$TARGET/strings.lib \
    zlib/$TARGET/zlib.lib $DESTDIR/lib/opt/

-if [ x"$PACK_DEBUG" = x"" -a -f "libmysql/debug/libmysql.lib" -o \
-     x"$PACK_DEBUG" = x"yes" ] ; then
+if [ x"$PACK_DEBUG" = "" -a -f "libmysql/debug/libmysql.lib" -o \
+     x"$PACK_DEBUG" = "yes" ] ; then
   mkdir -p $DESTDIR/lib/debug
   cp libmysql/debug/libmysql.dll \
      libmysql/debug/libmysql.lib \
[15 Apr 2007 5:23] Dhiren Patel
Diff with fix attached for convenience.

Attachment: diff.txt (text/plain), 1.85 KiB.

[15 Apr 2007 5:34] Dhiren Patel
My mistake: this is for the enterprise make_win_bin_dist script, not the community one. The attached diff was produced with 5.0.38.

Incidentally, the community and enterprise versions of this script seem to be significantly different.
[16 Apr 2007 12:26] Valeriy Kravchuk
Thank you for a bug report and patch. Verified with code review on latest 5.0.40-BK sources.
[15 May 2007 16:19] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/26719

ChangeSet@1.2485, 2007-05-15 18:19:18+02:00, joerg@trift2. +1 -0
  Fix bug#27833 "Bourne shell string comparison issue in scripts/make_win_bin_dist":
  
  Several string comparisons could never yield true because they had an 'x' guard
  added to the variable but not to the constant value. Fix that by guarding both sides.
[18 May 2007 9:09] Bugs System
Pushed into 5.1.19-beta
[18 May 2007 9:11] Bugs System
Pushed into 5.0.44
[21 May 2007 15:16] Paul DuBois
No changelog entry needed.