c++/sql-dk/nbproject/Package-Release.bash
author František Kučera <franta-hg@frantovo.cz>
Tue, 26 Feb 2019 18:19:49 +0100
branchv_0
changeset 236 a3ec71fa8e17
parent 230 8bae71482622
permissions -rw-r--r--
Avoid reusing/rewriting the DB connection properties.
There was weird random errors while testing connection to multiple DB in parallel when one of them was meta connection to same DB connection.
Two kinds of exception: 1) missing password 2) „Passing DB password as CLI parameter is insecure!“
franta-hg@230
     1
#!/bin/bash -x
franta-hg@230
     2
franta-hg@230
     3
#
franta-hg@230
     4
# Generated - do not edit!
franta-hg@230
     5
#
franta-hg@230
     6
franta-hg@230
     7
# Macros
franta-hg@230
     8
TOP=`pwd`
franta-hg@230
     9
CND_PLATFORM=GNU-Linux
franta-hg@230
    10
CND_CONF=Release
franta-hg@230
    11
CND_DISTDIR=dist
franta-hg@230
    12
CND_BUILDDIR=build
franta-hg@230
    13
CND_DLIB_EXT=so
franta-hg@230
    14
NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
franta-hg@230
    15
TMPDIRNAME=tmp-packaging
franta-hg@230
    16
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/sql-dk
franta-hg@230
    17
OUTPUT_BASENAME=sql-dk
franta-hg@230
    18
PACKAGE_TOP_DIR=sql-dk/
franta-hg@230
    19
franta-hg@230
    20
# Functions
franta-hg@230
    21
function checkReturnCode
franta-hg@230
    22
{
franta-hg@230
    23
    rc=$?
franta-hg@230
    24
    if [ $rc != 0 ]
franta-hg@230
    25
    then
franta-hg@230
    26
        exit $rc
franta-hg@230
    27
    fi
franta-hg@230
    28
}
franta-hg@230
    29
function makeDirectory
franta-hg@230
    30
# $1 directory path
franta-hg@230
    31
# $2 permission (optional)
franta-hg@230
    32
{
franta-hg@230
    33
    mkdir -p "$1"
franta-hg@230
    34
    checkReturnCode
franta-hg@230
    35
    if [ "$2" != "" ]
franta-hg@230
    36
    then
franta-hg@230
    37
      chmod $2 "$1"
franta-hg@230
    38
      checkReturnCode
franta-hg@230
    39
    fi
franta-hg@230
    40
}
franta-hg@230
    41
function copyFileToTmpDir
franta-hg@230
    42
# $1 from-file path
franta-hg@230
    43
# $2 to-file path
franta-hg@230
    44
# $3 permission
franta-hg@230
    45
{
franta-hg@230
    46
    cp "$1" "$2"
franta-hg@230
    47
    checkReturnCode
franta-hg@230
    48
    if [ "$3" != "" ]
franta-hg@230
    49
    then
franta-hg@230
    50
        chmod $3 "$2"
franta-hg@230
    51
        checkReturnCode
franta-hg@230
    52
    fi
franta-hg@230
    53
}
franta-hg@230
    54
franta-hg@230
    55
# Setup
franta-hg@230
    56
cd "${TOP}"
franta-hg@230
    57
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
franta-hg@230
    58
rm -rf ${NBTMPDIR}
franta-hg@230
    59
mkdir -p ${NBTMPDIR}
franta-hg@230
    60
franta-hg@230
    61
# Copy files and create directories and links
franta-hg@230
    62
cd "${TOP}"
franta-hg@230
    63
makeDirectory "${NBTMPDIR}/sql-dk/bin"
franta-hg@230
    64
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
franta-hg@230
    65
franta-hg@230
    66
franta-hg@230
    67
# Generate tar file
franta-hg@230
    68
cd "${TOP}"
franta-hg@230
    69
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/sql-dk.tar
franta-hg@230
    70
cd ${NBTMPDIR}
franta-hg@230
    71
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/sql-dk.tar *
franta-hg@230
    72
checkReturnCode
franta-hg@230
    73
franta-hg@230
    74
# Cleanup
franta-hg@230
    75
cd "${TOP}"
franta-hg@230
    76
rm -rf ${NBTMPDIR}