usr/src/cmd/mysql-5-0/install-mysql-64
author Jon Tibble <meths@btinternet.com>
Mon, 04 May 2015 14:04:39 +0100
branchoi_151a
changeset 254 9c2a4ac793f0
parent 0 b34509ac961f
permissions -rwxr-xr-x
Bash patch catchup including shellshock

#!/usr/bin/ksh93
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident	"@(#)install-mysql-64	1.6	09/05/13 SMI"

# stop at the first error
set -o errexit

# use builtin commands (faster)
builtin cp
builtin rm
builtin mv
builtin chmod
source "${SRC}/tools/install.subr"
typeset PREFIX="${ROOT}/usr/mysql/5.0"
typeset CWD="$PWD"

# ----- Common Utility Functions -----

function fix_install
{
	# exit function on error
	set -o errexit

# remove the unwanted files that are installed by make install
	cd "${ROOT}/usr/mysql/5.0/lib/64/mysql"
	rm -f *.la libvio.a libheap.a
	chmod +x *.a
	rm -f *.a

	return 0
}

# This function changes the perl path to the standard perl path
function fix_perl_path
{

for dirs in "$PREFIX/mysql-test" "$PREFIX/mysql-test/suite/funcs_1/lib" "$PREFIX/sql-bench" \
 "$PREFIX/bin/64" "$PREFIX/mysql-test/suite/funcs_2/lib" ;do
      cd $dirs
      echo "Changing perl PATH for `pwd`"
      grep -l '#!/usr/bin/perl' * | awk '{ print $1 }' >> /tmp/file$$.text
      for file in `cat /tmp/file$$.text` ;do
      echo "file is $file"
      if [ $(basename $dirs) = 'lib' ]; then
             perm=644
      else
             perm=755
      fi
      _install P $file "$file"_new ${perm}
      mv "$file"_new $file
      done
      rm /tmp/file$$.text
done

return 0 ;

}


#Appropriate permissions for the directories share,bin,docs,include

function fix_permissions
{

for dirs in "$PREFIX/share/mysql" \
        "$PREFIX/include/mysql" \
        "$PREFIX/man/man1" \
        "$PREFIX/man/man8" \
        "$PREFIX/docs"
do
        cd "$dirs"
        find . -type f -exec chmod 444 {} \;
        echo "Permissions have been fixed for $dirs......"
done

for dirs in "$PREFIX/bin" "$PREFIX/bin/64" "$PREFIX/lib/mysql" "$PREFIX/lib/64/mysql"
do
        cd "$dirs"
        find . -perm u=rwx,g=rx,o=rx -type f -exec chmod 555 {} \;
        echo "Permissions have been fixed for $dirs......"

done

return 0;
}


# ----- START HERE - actual script processing starts here -----

# Even though this is called "install-mysql-64", it doesn't really
# install the whole thing.  Much of mysql itself is installed by
# make install - we need to fix only permissions.  What we install here
# are stuffs that mysql won't install as part of its normal build.
# Each install task is a function, so it's relatively easy to add new
# stuff.
#
fix_install
fix_perl_path
fix_permissions
exit 0