forked from jconway/plr
-
Notifications
You must be signed in to change notification settings - Fork 27
/
after_build.sh
135 lines (114 loc) · 4.25 KB
/
after_build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
cd "$(dirname "$0")"
. ./init.sh
logok "BEGIN after_build.sh"
set -v -x -e
# set -e
# put this in all non-init.sh scripts - pgroot is empty, if using an msys2 binary
# but psql is already in the path
if [ -f "${pgroot}/bin/psql" ]
then
export PATH=${pgroot}/bin:${PATH}
fi
#
# cygwin # pgroot: /usr - is the general location of binaries (psql) and already in the PATH
#
# $ echo $(cygpath "C:\cygwin\bin")
# /usr/bin
#
# cygwin # initdb, postgres, and pg_ctl are here "/usr/sbin"
if [ -f "${pgroot}/sbin/postgres" ]
then
export PATH=${pgroot}/sbin:${PATH}
fi
pg_ctl -D ${PGDATA} -l logfile start
if [ "${compiler}" == "msys2" ]
then
winpty -Xallow-non-tty psql -d postgres --quiet --tuples-only -c "\pset footer off" -c "\timing off" -c "select current_setting('server_version_num')::integer;" --output=${APPVEYOR_BUILD_FOLDER}/server_version_num.txt
else
psql -d postgres --quiet --tuples-only -c "\pset footer off" -c "\timing off" -c "select current_setting('server_version_num')::integer;" --output=${APPVEYOR_BUILD_FOLDER}/server_version_num.txt
fi
# also used in compiler - msvc
#
./server_version_num.sh
export server_version_num=$(cat ${APPVEYOR_BUILD_FOLDER}/server_version_num.txt)
loginfo "server_version_num ${server_version_num}"
#
# also works
# export A_VAR=$(echo -n $(sed -r 's/\s+//g' a_version.txt))
loginfo "server_version_num ${server_version_num}"
loginfo "OLD pgversion ${pgversion}"
loginfo "OLD pg ${pg}"
#
# override - msys2 and cygwin binary case
if [ "${pg}" == "none" ]
then
export pg=$(postgres -V | grep -oP '(?<=\) ).*$')
loginfo "NEW pg ${pg}"
if [ ${server_version_num} -gt 999999 ]
then
export pgversion=$(echo ${pg} | grep -oP '^\d+')
else
export pgversion=$(echo ${pg} | grep -oP '^\d+[.]\d+')
fi
loginfo "NEW pgversion ${pgversion}"
fi
loginfo "OLD or NEW pgversion ${pgversion}"
pg_config | grep "^PKGLIBDIR\|^SHAREDIR" | sed "s/ = /=/" | sed s"/^/export /" > newvars.sh
. ./newvars.sh
mkdir tmp
cp LICENSE tmp/PLR_LICENSE
mkdir -p tmp/lib
cp ${PKGLIBDIR}/plr.dll tmp/lib
mkdir -p tmp/share/extension
cp ${SHAREDIR}/extension/plr.control tmp/share/extension
cp ${SHAREDIR}/extension/plr--*.sql tmp/share/extension
if ([ "${rversion}" == "" ] || [ "${rversion}" == "none" ])
then
# later(now) - dynamically determing the R version
#
# Tomas Kalibera custom build may contain spaces
# so gsub replaces spaces with underscores
#
# avoid cywin error - WARNING: ignoring environment value of R_HOME
export R_HOME_OLD=${R_HOME}
unset R_HOME
export rversion=$(Rscript --vanilla -e 'cat(gsub('\'' '\'', replacement = '\''_'\'', x = paste0(R.version$major,'\''.'\'',R.version$minor,tolower(R.version$status))))' 2>/dev/null)
export R_HOME=${R_HOME_OLD}
fi
export var7z=plr-${gitrevshort}-pg${pgversion}-R${rversion}${rversion_more}-${Platform}-${Configuration}-${compiler}.7z
loginfo "${var7z}"
echo ${APPVEYOR_BUILD_FOLDER}
loginfo "BEGIN plr 7z CREATION"
7z a -t7z -mmt24 -mx7 -r ${APPVEYOR_BUILD_FOLDER}/${var7z} ./tmp/*
ls -alrt ${APPVEYOR_BUILD_FOLDER}/${var7z}
loginfo "BEGIN plr 7z LISTING"
7z l ${APPVEYOR_BUILD_FOLDER}/${var7z}
loginfo "END plr 7z LISTING"
loginfo "END plr 7z CREATION"
if [ "${compiler}" == "cygwin" ]
then
# command will automatically pre-prepend A DIRECTORY (strange!)
# e.g.
pushd ${APPVEYOR_BUILD_FOLDER}
loginfo "appveyor PushArtifact ${var7z}"
appveyor PushArtifact ${var7z}
popd
#
# BAD PUSH-ARTIFACT - DEFINITELY A BUG
#
# loginfo "appveyor PushArtifact ${APPVEYOR_BUILD_FOLDER}/${var7z}"
# appveyor PushArtifact ${APPVEYOR_BUILD_FOLDER}/${var7z}
#
# appveyor PushArtifact /cygdrive/c/projects/plr/plr-761a5fbc-pg12-R4.1.0alpha-x86-Debug-cygwin.7z
# File not found: C:\projects\plr\cygdrive\c\projects\plr\plr-761a5fbc-pg12-R4.1.0alpha-x86-Debug-cygwin.7z
# Command exited with code 2
#
else
loginfo "appveyor PushArtifact ${APPVEYOR_BUILD_FOLDER}/${var7z}"
appveyor PushArtifact ${APPVEYOR_BUILD_FOLDER}/${var7z}
fi
# must stop, else Appveyor job will hang.
pg_ctl -D ${PGDATA} -l logfile stop
set +v +x +e
# set +e
logok "END after_build.sh"