first commit for openGauss connect odbc code
This commit is contained in:
294
third_party/unixodbc/build_unixodbc.sh
vendored
Executable file
294
third_party/unixodbc/build_unixodbc.sh
vendored
Executable file
@ -0,0 +1,294 @@
|
||||
#!/bin/bash
|
||||
# description: the script that make install unixODBC
|
||||
|
||||
######################################################################
|
||||
# Parameter setting
|
||||
######################################################################
|
||||
LOCAL_PATH=${0}
|
||||
FIRST_CHAR=$(expr substr "$LOCAL_PATH" 1 1)
|
||||
if [ "$FIRST_CHAR" = "/" ]; then
|
||||
LOCAL_PATH=${0}
|
||||
else
|
||||
LOCAL_PATH="$(pwd)/${LOCAL_PATH}"
|
||||
fi
|
||||
|
||||
LOCAL_DIR=$(dirname "${LOCAL_PATH}")
|
||||
CONFIG_FILE_NAME=config.ini
|
||||
BUILD_OPTION=release
|
||||
TAR_FILE_NAME=unixODBC-2.3.6.tar.gz
|
||||
SOURCE_CODE_PATH=unixODBC-2.3.6
|
||||
LOG_FILE=${LOCAL_DIR}/build_unixODBC.log
|
||||
BUILD_FAILED=1
|
||||
|
||||
#######################################################################
|
||||
## print help information
|
||||
#######################################################################
|
||||
function print_help()
|
||||
{
|
||||
echo "Usage: $0 [OPTION]
|
||||
-h|--help show help information
|
||||
-m|--build_option provode type of operation, values of paramenter is build, shrink, dist or clean
|
||||
"
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# Print log.
|
||||
#######################################################################
|
||||
log()
|
||||
{
|
||||
echo "[Build unixODBC] $(date +%y-%m-%d' '%T): $@"
|
||||
echo "[Build unixODBC] $(date +%y-%m-%d' '%T): $@" >> "$LOG_FILE" 2>&1
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# print log and exit.
|
||||
#######################################################################
|
||||
die()
|
||||
{
|
||||
log "$@"
|
||||
echo "$@"
|
||||
exit $BUILD_FAILED
|
||||
}
|
||||
|
||||
ls ${LOCAL_DIR}/${CONFIG_FILE_NAME} >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
die "[Error] the file ${CONFIG_FILE_NAME} not exist."
|
||||
fi
|
||||
|
||||
COMPLIE_TYPE_LIST=$(cat ${LOCAL_DIR}/${CONFIG_FILE_NAME} | grep -v '#' | grep -v '^$' | awk -F '=' '{print $2}' | sed 's/|/ /g')
|
||||
COMPONENT_NAME=$(cat ${LOCAL_DIR}/${CONFIG_FILE_NAME} | grep -v '#' | grep -v '^$' |awk -F '=' '{print $1}'| awk -F '@' '{print $2}')
|
||||
COMPONENT_TYPE=$(cat ${LOCAL_DIR}/${CONFIG_FILE_NAME} | grep -v '#' | grep -v '^$' | awk -F '@' '{print $1}')
|
||||
|
||||
if [ "${COMPONENT_NAME}"X = ""X ]
|
||||
then
|
||||
die "[Error] get component name failed!"
|
||||
fi
|
||||
|
||||
if [ "${COMPONENT_TYPE}"X = ""X ]
|
||||
then
|
||||
die "[Error] get component type failed!"
|
||||
fi
|
||||
|
||||
ROOT_DIR="${LOCAL_DIR}/../../"
|
||||
INSTALL_COMPOENT_PATH_NAME="${ROOT_DIR}/${COMPONENT_TYPE}/${COMPONENT_NAME}"
|
||||
|
||||
#######################################################################
|
||||
# build and install component
|
||||
#######################################################################
|
||||
function build_component()
|
||||
{
|
||||
cd ${LOCAL_DIR}
|
||||
tar -xvf ${TAR_FILE_NAME}
|
||||
|
||||
cd ${LOCAL_DIR}/${SOURCE_CODE_PATH}
|
||||
if [ $? -ne 0 ]; then
|
||||
die "[Error] change dir to $SRC_DIR failed."
|
||||
fi
|
||||
|
||||
chmod +x configure
|
||||
for COMPILE_TYPE in ${COMPLIE_TYPE_LIST}
|
||||
do
|
||||
case "${COMPILE_TYPE}" in
|
||||
release)
|
||||
die "[Error] unixODBC not supported build type."
|
||||
;;
|
||||
debug)
|
||||
die "[Error] unixODBC not supported build type."
|
||||
;;
|
||||
comm)
|
||||
mkdir -p ${LOCAL_DIR}/install_comm/unixODBC-2.3.6
|
||||
log "[Notice] unixODBC configure string: ./configure CFLAGS='-fstack-protector-all -Wl,-z,relro,-z,now -Wl,-z,noexecstack -fPIC' --enable-gui=no --prefix=${LOCAL_DIR}/install_comm"
|
||||
./configure CFLAGS='-fstack-protector-all -Wl,-z,relro,-z,now -Wl,-z,noexecstack -fPIC' --enable-gui=no --prefix=${LOCAL_DIR}/install_comm/unixODBC-2.3.6
|
||||
;;
|
||||
release_llt)
|
||||
die "[Error] unixODBC not supported build type."
|
||||
;;
|
||||
debug_llt)
|
||||
die "[Error] unixODBC not supported build type."
|
||||
;;
|
||||
llt)
|
||||
die "[Error] unixODBC not supported build type."
|
||||
;;
|
||||
*)
|
||||
log "Internal Error: option processing error: $1"
|
||||
log "please write right paramenter in ${CONFIG_FILE_NAME}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
die "[Error] unixODBC configure failed."
|
||||
fi
|
||||
log "[Notice] unixODBC End configure"
|
||||
|
||||
log "[Notice] unixODBC using \"${COMPILE_TYPE}\" Begin make"
|
||||
make -sj
|
||||
if [ $? -ne 0 ]; then
|
||||
die "unixODBC make failed."
|
||||
fi
|
||||
log "[Notice] unixODBC End make"
|
||||
|
||||
log "[Notice] unixODBC using \"${COMPILE_TYPE}\" Begin make install"
|
||||
make install -sj
|
||||
if [ $? -ne 0 ]; then
|
||||
die "[Error] unixODBC make install failed."
|
||||
fi
|
||||
log "[Notice] unixODBC using \"${COMPILE_TYPE}\" End make install"
|
||||
|
||||
make clean
|
||||
log "[Notice] unixODBC build using \"${COMPILE_TYPE}\" has been finished"
|
||||
|
||||
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# choose the real files
|
||||
#######################################################################
|
||||
function shrink_component()
|
||||
{
|
||||
for COMPILE_TYPE in ${COMPLIE_TYPE_LIST}
|
||||
do
|
||||
case "${COMPILE_TYPE}" in
|
||||
comm)
|
||||
mkdir ${LOCAL_DIR}/install_comm_dist
|
||||
cp -r ${LOCAL_DIR}/install_comm/* ${LOCAL_DIR}/install_comm_dist
|
||||
if [ $? -ne 0 ]; then
|
||||
die "[Error] \"cp -r ${LOCAL_DIR}/install_comm/* ${LOCAL_DIR}/install_comm_dist\" failed."
|
||||
fi
|
||||
;;
|
||||
release)
|
||||
;;
|
||||
debug)
|
||||
;;
|
||||
llt)
|
||||
;;
|
||||
release_llt)
|
||||
;;
|
||||
debug_llt)
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
log "[Notice] unixODBC shrink using \"${COMPILE_TYPE}\" has been finished!"
|
||||
done
|
||||
}
|
||||
|
||||
##############################################################################################################
|
||||
# dist the real files to the matched path
|
||||
# we could makesure that $INSTALL_COMPOENT_PATH_NAME is not null, '.' or '/'
|
||||
##############################################################################################################
|
||||
function dist_component()
|
||||
{
|
||||
for COMPILE_TYPE in ${COMPLIE_TYPE_LIST}
|
||||
do
|
||||
case "${COMPILE_TYPE}" in
|
||||
comm)
|
||||
rm -rf ${INSTALL_COMPOENT_PATH_NAME}/comm/*
|
||||
cp -r ${LOCAL_DIR}/install_comm_dist/* ${INSTALL_COMPOENT_PATH_NAME}/comm
|
||||
if [ $? -ne 0 ]; then
|
||||
die "[Error] \"cp -r ${LOCAL_DIR}/install_comm_dist/* ${INSTALL_COMPOENT_PATH_NAME}/comm\" failed."
|
||||
fi
|
||||
;;
|
||||
release)
|
||||
;;
|
||||
debug)
|
||||
;;
|
||||
llt)
|
||||
;;
|
||||
release_llt)
|
||||
;;
|
||||
debug_llt)
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
log "[Notice] unixODBC dist using \"${COMPILE_TYPE}\" has been finished!"
|
||||
done
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# clean component
|
||||
#######################################################################
|
||||
function clean_component()
|
||||
{
|
||||
cd ${LOCAL_DIR}/${SOURCE_CODE_PATH}
|
||||
if [ $? -ne 0 ]; then
|
||||
die "[Error] cd ${LOCAL_DIR}/${SOURCE_CODE_PATH} failed."
|
||||
fi
|
||||
|
||||
cd ${LOCAL_DIR}
|
||||
if [ $? -ne 0 ]; then
|
||||
die "[Error] cd ${LOCAL_DIR} failed."
|
||||
fi
|
||||
[ -n "${SOURCE_CODE_PATH}" ] && rm -rf ${SOURCE_CODE_PATH}
|
||||
rm -rf install_*
|
||||
|
||||
log "[Notice] unixODBC clean has been finished!"
|
||||
}
|
||||
#######################################################################
|
||||
#######################################################################
|
||||
#######################################################################
|
||||
# main
|
||||
#######################################################################
|
||||
#######################################################################
|
||||
#######################################################################
|
||||
function main()
|
||||
{
|
||||
case "${BUILD_OPTION}" in
|
||||
build)
|
||||
build_component
|
||||
;;
|
||||
shrink)
|
||||
shrink_component
|
||||
;;
|
||||
dist)
|
||||
dist_component
|
||||
;;
|
||||
clean)
|
||||
clean_component
|
||||
;;
|
||||
all)
|
||||
build_component
|
||||
shrink_component
|
||||
dist_component
|
||||
clean_component
|
||||
;;
|
||||
*)
|
||||
log "Internal Error: option processing error: $2"
|
||||
log "please input right paramenter values build, shrink, dist or clean "
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
########################################################################
|
||||
if [ $# = 0 ] ; then
|
||||
log "missing option"
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
##########################################################################
|
||||
#read command line paramenters
|
||||
##########################################################################
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
print_help
|
||||
exit 1
|
||||
;;
|
||||
-m|--build_option)
|
||||
if [ "$2"X = X ];then
|
||||
die "no given version number values"
|
||||
fi
|
||||
BUILD_OPTION=$2
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
log "Internal Error: option processing error: $1" 1>&2
|
||||
log "please input right paramtenter, the following command may help you"
|
||||
log "./build.sh --help or ./build.sh -h"
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
###########################################################################
|
||||
main
|
5
third_party/unixodbc/config.ini
vendored
Normal file
5
third_party/unixodbc/config.ini
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
###############################
|
||||
# unixodbc support
|
||||
###############################
|
||||
buildtools@unixodbc=comm
|
||||
|
4
third_party/unixodbc/readme
vendored
Normal file
4
third_party/unixodbc/readme
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
tar xzf unixODBC-2.3.6
|
||||
sh build.sh -m build
|
||||
sh build.sh -m shrink
|
||||
sh build.sh -m dist
|
BIN
third_party/unixodbc/unixODBC-2.3.6.tar.gz
vendored
Normal file
BIN
third_party/unixodbc/unixODBC-2.3.6.tar.gz
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user