Name: infobright Group: Applications/Database Version: 3.3.1 Release: 0 Source: http://www.infobright.org/downloads/ice/%{name}-%{version}.tar.gz URL: http://www.infobright.com/ Packager: Infobright Vendor: Infobright Provides: Infobright Summary: Infobright %define license "GNU GENERAL PUBLIC LICENSE Version 2, June 1991. Please see the infobright.license file inside the installed folder." %define pkg_type "" License: %{license} %define mysql_user mysql %define mysql_group mysql %define ib_daemon /etc/init.d/mysqld-ib %define ib_client /usr/bin/mysql-ib %define my_conf /etc/my-ib.cnf %define ib_prefix /usr/local %define ib_log /tmp/ib%{version}-install.log Prefix: /usr/local BuildRequires: gperf, readline-devel, openssl-devel BuildRequires: gcc-c++, ncurses-devel, zlib-devel BuildRequires: libtool automake BuildRequires: autoconf BuildRequires: boost >= 1.33.1 BuildRequires: time procps BuildRequires: perl(Socket) Prereq: /sbin/install-info, grep, fileutils Prereq: /sbin/install-info, grep, fileutils Prereq: /sbin/chkconfig, /usr/sbin/useradd Requires: bash Requires: sh-utils Requires: boost >= 1.33.1 %description Infobright combines a column-oriented database with our Knowledge Grid architecture to deliver a self-managing data warehouse optimized for analytics. Available as commercial and community editions, it eliminates the time-consuming effort typically involved in implementing and managing a data warehouse, freeing up your time and your budget. Please visit www.infobright.com or www.infobright.org for more details. %prep rm -rf $RPM_BUILD_DIR/%{name}-%{version} tar -xvzf $RPM_SOURCE_DIR/%{name}-%{version}.tar.gz ############################# %build cd %{name}-%{version} make EDITION=community PREFIX="/usr/local/infobright" release -j4 %install ibbuild_dir=$RPM_BUILD_DIR/%{name}-%{version} cd %{name}-%{version} cd build/vendor/release scripts/make_binary_distribution --ib-licensetype=community ib_tar=$ibbuild_dir/build/vendor/release/infobright-%{version}-%{_target_cpu}.tar.gz post_config=$ibbuild_dir/vendor/mysql/support-files/postconfig.sh README=$ibbuild_dir/vendor/mysql/support-files/README_DISTRO_ICE ib_dir="infobright-%{version}-%{_target_cpu}" mkdir -p $RPM_BUILD_ROOT%{ib_prefix} cd $RPM_BUILD_ROOT%{ib_prefix} rm -rf $ib_dir/* tar -xvzf $ib_tar # we do not need these files for users rm -rf $ib_dir/mysql-test \ $ib_dir/tests \ $ib_dir/sql-bench \ $ib_dir/bin/mysqlhotcopy \ $ib_dir/bin/mysql_setpermission \ $ib_dir/bin/mysqld_multi \ $ib_dir/bin/mysql_fix_extensions \ $ib_dir/bin/mysql_zap \ $ib_dir/bin/mysqlaccess \ $ib_dir/bin/mysql_find_rows \ $ib_dir/bin/mysql_convert_table_format \ $ib_dir/bin/mysqltest \ $ib_dir/bin/mysql_zap \ $ib_dir/bin/mysqldumpslow \ $ib_dir/data \ $ib_dir/install-infobright.sh cp -f $post_config $ib_dir/ cp -f $README $ib_dir/README cd - %clean rm -rf %{name}-* ############################# %files %defattr(-,root,root,0755) %{ib_prefix}/infobright-%{version}-%{_target_cpu}/* %pre create_log() { echo "" > %{ib_log}; } noecho_log() { echo "`date +%T` $@" >> %{ib_log}; } echo_log() { echo $@; noecho_log $@; } create_log echo_log "Installing infobright %{version} %{_target_cpu}%{pkg_type}" echo_log "The installer will generate %{ib_log} install trace log." mysql_conf=%{my_conf} client_script=%{ib_client} daemon=%{ib_daemon} pkg_name= pkg_version_old= shutdown_infobright() { if test -x $daemon ; then echo_log "Shutting down infobright server..." $daemon stop >> %{ib_log} sleep 5 fi } pkg_name="rpm -q infobright" pkg_version_old="rpm -q --queryformat=%{VERSION} infobright" rm -rf ${mysql_conf}.upgrade ${mysql_conf}.old if test -f $mysql_conf ; then echo_log "A $mysql_conf is found. Checking if infobright is already installed..." installed=`$pkg_name 2>/dev/null` installed_version=`$pkg_version_old 2>/dev/null` # do not modify this line. We read installed_version from the log in the next step # to detect the old version number noecho_log "Installed=$installed, installed_version=$installed_version" shutdown_infobright if [ $? -eq 0 -a -n "$installed" -a ! -z "$installed_version" ]; then cp -f $mysql_conf ${mysql_conf}.upgrade echo_log "Infobright $installed_version is installed. Upgrading to %{version}." else echo_log "Warning, moving existing ${mysql_conf} to ${mysql_conf}.old." mv -f $mysql_conf ${mysql_conf}.old fi fi ################################ %post noecho_log() { echo "`date +%T` $@" >> %{ib_log}; } echo_log() { echo $@; noecho_log $@; } bh_datadir= bh_cachedir= mysql_conf=%{my_conf} parse_arguments() { # We only need to pass arguments through to the server if we don't # handle them here. So, we collect unrecognized options (passed on # the command line) into the args variable. pick_args= if test "$1" = PICK-ARGS-FROM-ARGV then pick_args=1 shift fi for arg do case "$arg" in # these get passed explicitly to mysqld --basedir=*) MY_BASEDIR=`echo "$arg" | sed -e "s;--basedir=;;"` ;; --datadir=*) bh_datadir=`echo "$arg" | sed -e "s;--datadir=;;"` ;; esac done } create_daemon() { daemon=%{ib_daemon} if test -f "$daemon" ; then return fi service_tmplt=%{ib_prefix}/infobright-%{version}-%{_target_cpu}/support-files/mysql.server cmd_sed="sed -e 's+@BH_CONF@+$mysql_conf+'\ -e 's+@BH_USER@+$user+' < $service_tmplt> $daemon" eval $cmd_sed chmod 755 $daemon if test -x /sbin/insserv # use insserv for older SuSE Linux versions then /sbin/insserv $daemon elif test -x /sbin/chkconfig # use chkconfig on Red Hat and newer SuSE releases then /sbin/chkconfig --add mysqld-ib elif test -x /sbin/update-rc.d then /sbin/update-rc.d mysqld-ib start 99 2 3 4 5 . stop 01 0 1 6 . > /dev/null elif test -x /usr/sbin/update-rc.d then /usr/sbin/update-rc.d mysqld-ib start 99 2 3 4 5 . stop 01 0 1 6 . > /dev/null fi } create_client() { echo "#!/bin/sh"> %{ib_client} echo "%{ib_prefix}/infobright-%{version}-%{_target_cpu}/bin/mysql --defaults-file=$mysql_conf --user=root \"\$@\"" >> %{ib_client} chmod 755 %{ib_client} } upgrade= client_script=%{ib_client} daemon=%{ib_daemon} user=%{mysql_user} group=%{mysql_group} if [ "$1" = "2" ] ; then # first upgrade upgrade="true"; fi prev_version=`cat %{ib_log}| grep "installed_version="|sed -e 's/.*=//'|sed -e 's/-.*$//'` old_dir=/usr/local/infobright-$prev_version-%{_target_cpu} PREFIX=%{ib_prefix}/infobright PREFIX_ACTUAL=$PREFIX-%{version}-%{_target_cpu} if test ! -z "$upgrade" then create_daemon create_client if test "$prev_version" != "%{version}" then PREFIX_temp=`echo $PREFIX/ | sed -e 's/\//\\\\\//g'` PREFIX_NEWBASE=`echo $PREFIX | sed -e 's/\//\\\\\//g'` old_dir_temp=`echo $old_dir/ | sed -e 's/\//\\\\\//g'` conf_change="sed \ -e 's/$PREFIX_temp/$old_dir_temp/' \ -e 's/\(^\s*basedir.*\)/basedir=$PREFIX_NEWBASE/' \ -e 's/\(^\s*log\s*=\)/general_log=1\ngeneral_log_file=/' \ -e 's/\(^\s*log_slow_queries\s*=\)/slow_query_log=1\nslow_query_log_file=/' < $mysql_conf.upgrade > $mysql_conf.tmp" noecho_log "conf_change=$conf_change." >> %{ib_log} eval $conf_change if test $? != 0 then echo_log "Error, during updating $my_conf file." fi mv $mysql_conf.tmp $mysql_conf.upgrade fi # Get first arguments from the my-ib.cnf file, groups [mysqld] if test -x $PREFIX_ACTUAL/bin/my_print_defaults then print_defaults="$PREFIX_ACTUAL/bin/my_print_defaults" else echo_log "conf file parser tool $PREFIX_ACTUAL/bin/my_print_defaults was not found" exit 1 fi parse_arguments `$print_defaults --defaults-file=${mysql_conf}.upgrade mysqld` if [ -z "$bh_datadir" ] then echo_log "Error: Invalid datadir in $mysql_conf. Upgrade incompleted." exit 0 fi BH_INI="brighthouse.ini" if [ ! -f "$bh_datadir/$BH_INI" ] then echo_log "Error: $bh_datadir/$BH_INI was not found. Upgrade incompleted." exit 0 fi bh_cachedir=`grep "\(\s*CacheFolder\)" $bh_datadir/$BH_INI|grep -v "\(^\s*#\)"|awk -F"=" '{print $2}'` if [ -z "$bh_cachedir" ]; then echo_log "Error: Invalid cache folder in $bh_datadir/$BH_INI. Upgrade incompleted." exit 0 fi fi rm -rf $PREFIX ; noecho_log "$PREFIX removed." ; ln -s $PREFIX-%{version}-%{_target_cpu} $PREFIX if [ ! -z "$upgrade" ] then if [ ! -d $bh_cachedir ]; then mkdir -p -m 755 $bh_cachedir; chown -R $user:$group $bh_cachedir fi # Work around in case we to upgrade from 3.1.1 to higher. echo_log "$bh_datadir will be used as data directory for current upgrade." echo_log "$bh_cachedir will be used as cache directory for current upgrade." if test -d "$old_dir" -a "$prev_version" != "%{version}" then echo_log "Note, $old_dir was not deleted. It may contain datadir / cachedir." fi mv $mysql_conf.upgrade $mysql_conf echo_log "Upgrade to %{version} completed." exit 0 fi my_sock=/tmp/mysql-ib.sock port=5029 my_conf_in=$PREFIX/support-files/my.cnf.in bh_datadir=$PREFIX/data bh_cachedir=$PREFIX/cache cmd_sed="sed -e 's+@BH_PORT@+$port+'\ -e 's+@BH_BASEDIR@+$PREFIX+'\ -e 's+@BH_SOCK@+$my_sock+'\ -e 's+@BH_DATADIR@+$bh_datadir+' < $my_conf_in > $mysql_conf" eval $cmd_sed chmod 755 $mysql_conf echo_log "Creating/Updating datadir and cachedir" [ ! -d $bh_datadir ] && mkdir -p -m 755 $bh_datadir [ ! -d $bh_datadir/mysql ] && mkdir $bh_datadir/mysql [ ! -d $bh_datadir/test ] && mkdir $bh_datadir/test [ ! -d $bh_cachedir ] && mkdir -p -m 755 $bh_cachedir echo_log "Creating user $user and group $group" groupadd -r $group 2>> %{ib_log} || true useradd -M -r -d $bh_datadir -s /bin/bash -c "Infobright server" -g $group $user 2>> %{ib_log} || true usermod -g $group $user 2>> %{ib_log} || true # Initiate databases if needed cd $PREFIX echo_log "Installing default databases" cmd_sed="scripts/mysql_install_db\ --defaults-file=$mysql_conf\ --user=$user\ --basedir=$PREFIX\ --datadir="$bh_datadir"\ --cachedir=$bh_cachedir" eval $cmd_sed [ $? != 0 ] && echo_log "Failed on infobright initialization. You can investigate log files inside $bh_datadir." noecho_log "$cmd_sed" ###############memory settings ############### # minimal memory settings in MB memory=`cat /proc/meminfo | grep -i MemTotal|sed -e 's/[a-zA-Z\: ]*//' -e 's/[a-zA-Z]*$//'` mem=`expr $memory / 1024` echo_log "System Physical memory: $mem(MB)" if [ $mem -lt 2000 ]; then echo "System memory too low!" SMHeapSize="400" SCHeapSize="200" LMHeapSize="300" elif [ $mem -ge 2000 ] && [ $mem -lt 3500 ]; then SMHeapSize="600" SCHeapSize="250" LMHeapSize="320" elif [ $mem -ge 3500 ] && [ $mem -lt 6000 ]; then SMHeapSize="1300" SCHeapSize="400" LMHeapSize="400" elif [ $mem -ge 6000 ] && [ $mem -lt 8000 ]; then SMHeapSize="3000" SCHeapSize="400" LMHeapSize="400" elif [ $mem -ge 8000 ] && [ $mem -lt 12000 ]; then SMHeapSize="4000" SCHeapSize="500" LMHeapSize="800" elif [ $mem -ge 12000 ] && [ $mem -lt 16000 ]; then SMHeapSize="6000" SCHeapSize="500" LMHeapSize="800" elif [ $mem -ge 16000 ] && [ $mem -lt 32000 ]; then SMHeapSize="10000" SCHeapSize="1000" LMHeapSize="800" elif [ $mem -ge 32000 ] && [ $mem -lt 48000 ]; then SMHeapSize="24000" SCHeapSize="4000" LMHeapSize="800" else SMHeapSize="32000" SCHeapSize="4000" LMHeapSize="800" fi memchange="sed -e 's/\#[ ]*ServerMainHeapSize[ ]*=[ 0-9]*/ServerMainHeapSize=$SMHeapSize/' \ -e 's/\#[ ]*ServerCompressedHeapSize[ ]*=[ 0-9]*/ServerCompressedHeapSize=$SCHeapSize/' \ -e 's/\#[ ]*LoaderMainHeapSize[ ]*=[ 0-9]*/LoaderMainHeapSize=$LMHeapSize/' \ < $bh_datadir/brighthouse.ini > $bh_datadir/brighthouse.ini.tmp" eval $memchange mv -f $bh_datadir/brighthouse.ini.tmp $bh_datadir/brighthouse.ini echo_log "Infobright optimal ServerMainHeapSize is set to "$SMHeapSize"(MB)" echo_log "Infobright optimal ServerCompressedHeapSize is set to "$SCHeapSize"(MB)" echo_log "Infobright optimal LoaderMainHeapSize is set to "$LMHeapSize"(MB)" cd - >/dev/null # Change permissions so that the user that will run the MySQL daemon # owns all database files. chown -R $user:$group $bh_datadir chown -R $user:$group $bh_cachedir # minor correction in the text based eval license file which contain "Press Q" words [ -f "$PREFIX/infobright.license" ] && sed -i '/Press Q/d' "$PREFIX/infobright.license" create_daemon create_client echo_log "Infobright server installed into folder $PREFIX" echo_log "Installation log file %{ib_log}" ##################################### # user registration script is included only in ice. ##################################### ibregis=$PREFIX_ACTUAL/support-files/ibregis ##################################### if test -f "$ibregis" then mv -f $mysql_conf ${mysql_conf}.inactive echo_log "--------------------------------------" echo_log "To activate infobright server, please run ./postconfig.sh script from $PREFIX_ACTUAL." echo_log "Example command: cd $PREFIX_ACTUAL; ./postconfig.sh" else echo_log "Installation of %{version} completed!" fi ##################################### %preun # If not uninstall then exit if [ "$1" != "0" ] ; then exit 0; fi daemon=%{ib_daemon} # Stop MySQL before uninstalling it if test -x $daemon then $daemon stop >> %{ib_log} echo "Shutting down infobright server....."; sleep 5 # Remove autostart of infobright for older SuSE Linux versions if test -x /sbin/insserv then /sbin/insserv -r $daemon test -f $daemon && rm -f $daemon # use chkconfig on Red Hat and newer SuSE releases elif test -x /sbin/chkconfig then /sbin/chkconfig --del mysqld-ib 2>> %{ib_log} test -f $daemon && rm -f $daemon elif test -x /sbin/update-rc.d then test -f $daemon && rm -f $daemon /sbin/update-rc.d mysqld-ib remove 2>> %{ib_log} elif test -x /usr/sbin/update-rc.d then test -f $daemon && rm -f $daemon /usr/sbin/update-rc.d mysqld-ib remove 2>> %{ib_log} fi fi %postun # upgrade, or reinstall #################################### if [ "$1" != "0" ] ; then exit 0; fi datadir= cachedir= PREFIX=%{ib_prefix}/infobright PREFIX_ACTUAL=$PREFIX-%{version}-%{_target_cpu} mysql_conf=%{my_conf} if test -f $mysql_conf then datadir=`grep "\(\s*datadir\)" $mysql_conf|grep -v "\(^\s*#\)"|awk -F"=" '{print $2}'` test -f $datadir/brighthouse.ini && cachedir=`grep "\(\s*CacheFolder\)" $datadir/brighthouse.ini|grep -v "\(^\s*#\)"|awk -F"=" '{print $2}'` fi rm -rf \ $mysql_conf \ $cachedir \ $PREFIX/mysql-test \ $PREFIX/tests \ $PREFIX/sql-bench \ $PREFIX/bin \ $PREFIX/install-infobright.sh \ $PREFIX/iblicense* \ /usr/bin/mysql-ib isempty=`ls $PREFIX_ACTUAL 2>> %{ib_log}` [ -z "$isempty" ] && rm -rf $PREFIX_ACTUAL echo "Uninstaller does not remove data folder. Please remove it manually." [ -h $PREFIX ] && rm -rf $PREFIX && echo "Symlink $PREFIX removed." echo "Uninstallation of %{version} completed."