DBD-cubrid

 view release on metacpan or  search on metacpan

cci-src/build.sh  view on Meta::CPAN

    target_dir=$target_input
fi

echo "Install ${PRODUCT_NAME} to '$target_dir' ..."

XDBMS_ENV_FILE1=$HOME/.${PRODUCT_CODE}.csh
XDBMS_ENV_FILE2=$HOME/.${PRODUCT_CODE}.sh

if [ -d $target_dir ]; then
    echo "Directory '$target_dir' exist! "
    echo "If a ${PRODUCT_NAME} service is running on this directory, it may be terminated abnormally."
    echo "And if you don't have right access permission on this directory(subdirectories or files), install operation will be failed."
    echo -n "Overwrite anyway? (yes or no) [Default: no] : "
    read overwrite

    if [ "$overwrite" != "y" ] && [ "$overwrite" != "yes" ]; then
        exit 0
    fi
else
    mkdir -p $target_dir
fi

. ./version.sh
echo "Since CUBRID broker and server versions should match, please make sure that you are running the same version if you operate them in separate machines. For installation of CUBRID tools like Query Browser, Manager and Web Manager, please refer to...
echo -n "Do you want to continue? (yes or no) [Default: yes] : "
read cont
if [ "$cont" = "n" ] || [ "$cont" = "no" ]; then
    exit 0
fi

if [ -w $XDBMS_ENV_FILE1 ]; then
    echo "Copying old .${PRODUCT_CODE}.csh to .${PRODUCT_CODE}.csh.bak ..."
    rm -f ${XDBMS_ENV_FILE1}.bak
    cp $XDBMS_ENV_FILE1 ${XDBMS_ENV_FILE1}.bak
fi

if [ -w $XDBMS_ENV_FILE2 ]; then
    echo "Copying old .${PRODUCT_CODE}.sh to .${PRODUCT_CODE}.sh.bak ..."
    rm -f ${XDBMS_ENV_FILE2}.bak
    cp $XDBMS_ENV_FILE2 ${XDBMS_ENV_FILE2}.bak
fi

if [ ! -w $target_dir/databases/databases.txt ]; then
    if [ -w $target_dir/CUBRID_DATABASES/databases.txt ]; then
        cp_old_dbtxt="yes"
    fi
fi

#gzip -d ${PRODUCT_CODE}-product.tar.gz
gzip -d ${PRODUCT_NAME}-product.tar.gz

(cd $target_dir && tar --extract --no-same-owner --file=$cwd/${PRODUCT_NAME}-product.tar > /dev/null 2>&1)
if [ $? != 0 ]; then
    (cd $target_dir && tar xfo $cwd/${PRODUCT_NAME}-product.tar)
    if [ $? != 0 ]; then
        exit 1
    fi
fi

mkdir -p $target_dir/var/log/error_log
chmod 777 $target_dir/var/log/error_log

target_dir=`readlink -f $target_dir`

sh_profile=""

if [ -w $target_dir/protego_manager ]; then
    is_protego="yes"
fi

case $SHELL in 
    */csh ) sh_profile=$HOME/.cshrc;;
    */tcsh )
        if [ ! -r "$HOME/.tcshrc" ]; then
            sh_profile=$HOME/.cshrc
        else
            sh_profile=$HOME/.tcshrc
        fi
        ;;
    */bash )
        if [ -r $HOME/.bash_profile ]; then
            sh_profile=$HOME/.bash_profile
        elif [ -r $HOME/.bashrc ]; then
            sh_profile=$HOME/.bashrc
        elif [ -r $HOME/.bash_login ]; then
            sh_profile=$HOME/.bash_login
        else
            sh_profile=$HOME/.profile
        fi
        ;;
    */zsh )
        if [ -r $HOME/.zprofile ]; then
            sh_profile=$HOME/.zprofile
        elif [ -r $HOME/.zshrc ]; then
            sh_profile=$HOME/.zshrc
        elif [ -r $HOME/.zshenv ]; then
            sh_profile=$HOME/.zshenv
        elif [ -r $HOME/.zlogin ]; then
            sh_profile=$HOME/.zlogin
        else
            sh_profile=$HOME/.profile
        fi 
        ;;
    */sh | */ksh | */ash | */bsh )
        sh_profile=$HOME/.profile
        ;;
esac

case $SHELL in
    */csh | */tcsh ) 
    echo "setenv    CUBRID                  $target_dir"             > $XDBMS_ENV_FILE1
    echo "setenv    CUBRID_DATABASES        $target_dir/databases"          >> $XDBMS_ENV_FILE1

    echo 'if (${?LD_LIBRARY_PATH}) then' >> $XDBMS_ENV_FILE1
    echo 'setenv    LD_LIBRARY_PATH         $CUBRID/lib:${LD_LIBRARY_PATH}'  >> $XDBMS_ENV_FILE1
    echo 'else'                                                                                     >> $XDBMS_ENV_FILE1
    echo 'setenv    LD_LIBRARY_PATH         $CUBRID/lib'     >> $XDBMS_ENV_FILE1
    echo 'endif'                                                                                    >> $XDBMS_ENV_FILE1
    echo 'setenv    SHLIB_PATH              $LD_LIBRARY_PATH'                                       >> $XDBMS_ENV_FILE1
    echo 'setenv    LIBPATH                 $LD_LIBRARY_PATH'                                       >> $XDBMS_ENV_FILE1
    echo 'set       path=($CUBRID/{bin,cubridmanager} $path)'      >> $XDBMS_ENV_FILE1

cci-src/build.sh  view on Meta::CPAN



function print_check_glibc_version_c ()
{
cat << \END_OF_FILE
#include <stdio.h>
#include <gnu/libc-version.h>

int build_version = BUILD_VERSION;

int (main)(void)
{
    const char *v = gnu_get_libc_version();
    if (v == NULL)
        return 1;

    switch (build_version) {
    case 232:
        if (strcmp(v, "2.3.2") == 0)
            return 0;
        break;
    case 234:
        if (strcmp(v, "2.3.4") >= 0)
            return 0;
        break;
    }

    return 1;
}

END_OF_FILE
}


function build_bin_pack ()
{
  if [ $# -lt 2 ]; then
    print_error "Missing product name or target"
    return 1
  else
    package_file="$1"
    pack_target="$2"
  fi

  archive_dir="$install_dir/$product_name"
  if [ "$prefix_dir" != "$archive_dir" ]; then
    cp -rf $prefix_dir $archive_dir
  fi

  if [ "$pack_target" = "tarball" ]; then
    (cd $install_dir && tar czf $package_file $product_name)
    return $?
  elif [ "$pack_target" != "shell" ]; then
    print_error "Unknown target"
    return 1
  fi

  # prepare extra files
  cp $source_dir/COPYING $install_dir
  print_install_sh > $install_dir/CUBRID_Install.sh
  chmod a+x $install_dir/CUBRID_Install.sh
  print_setup_sh > $install_dir/CUBRID_Setup.sh
  chmod a+x $install_dir/CUBRID_Setup.sh
  print_check_glibc_version_c > $install_dir/check_glibc_version.c
  if ! gcc -o $install_dir/check_glibc_version -DBUILD_VERSION=234 $install_dir/check_glibc_version.c; then
    print_fatal "Check_glibc_version build error"
  fi

  echo "version=\"$major.$minor\"" > $install_dir/version.sh
  echo "BuildNumber=$build_number" >> $install_dir/version.sh

  conf_files=$(ls $archive_dir/conf/*.conf $archive_dir/conf/*.pass $archive_dir/conf/*.txt 2> /dev/null)
  for file in $conf_files; do
    if [ -f $file ]; then
      mv -f $file $file-dist
    fi
    if [ ! -f $file-dist ]; then
      print_fatal "Config file [$file-dist] not found"
    fi
  done

  (cd $install_dir/$product_name &&
    tar zcf $install_dir/CUBRID-product.tar.gz * &&
    cd $install_dir && mv -f CUBRID_Install.sh $package_file &&
    tar cf - CUBRID-product.tar.gz CUBRID_Setup.sh COPYING version.sh check_glibc_version >> $package_file)

  for file in $conf_files; do
    mv -f $file-dist $file
  done
}


function build_rpm ()
{
  print_check "Preparing RPM package directory"

  if [ $# -lt 2 ]; then
    print_error "Missing source tarball filename or target"
    return 1
  else
    source_tarball="$1"
    rpm_target="$2"
  fi

  if [ ! -f "$source_tarball" ]; then
    print_error "Source tarball [$source_tarball] is not exist"
    return 1
  else
    print_info "Using source tarball [$source_tarball]"
    rpm_output_dir=$(dirname $source_tarball)
  fi

  mkdir -p $install_dir/rpmbuild/{BUILD,RPMS,SPECS,SOURCES,SRPMS}
  print_result "OK"

  case $rpm_target in
    srpm)
      rpmbuild --define="_topdir $install_dir/rpmbuild" --clean -ts $source_tarball
      [ $? -eq 0 ] && mv -f $install_dir/rpmbuild/SRPMS/$product_name_lower-$build_number-*.src.rpm $rpm_output_dir
    ;;
    rpm)
      rpmbuild --define="_topdir $install_dir/rpmbuild" --define="_tmppath $install_dir/rpmbuild/tmp" --clean -tb --target=$build_target $source_tarball
      [ $? -eq 0 ] && mv -f $install_dir/rpmbuild/RPMS/$build_target/$product_name_lower-$build_number-*.$build_target.rpm $rpm_output_dir



( run in 1.164 second using v1.01-cache-2.11-cpan-f56aa216473 )