summaryrefslogtreecommitdiff
path: root/src/CI/travis/before_deploy
blob: 9d3fd0553bec2f6a9961ac8e3280178d40fef851 (plain)
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/sh -e

. CI/travis/lib.sh

# Don't prepare a deploy on a Coverity build
if [ "x${COVERITY_SCAN_PROJECT_NAME}" != "x" ] ; then exit 0; fi

deploy=0
if [ -z "$TRAVIS_BUILD_DIR" ] ; then
	t=$(find ./ -name CMakeCache.txt|head -1)
	if [ -n "${t}" ] ; then
		cd $(dirname $(dirname ${t}))
		TRAVIS_BUILD_DIR=$(pwd)
	else
		echo "I am confused - can't find CMakeCache.txt"
		exit
	fi
else
	cd $TRAVIS_BUILD_DIR
fi
pwd

if [ -z "${LDIST}" -a -f "build/.LDIST" ] ; then
	export LDIST="-$(cat build/.LDIST)"
fi
if [ -z "${LDIST}" ] ; then
	export LDIST="-$(get_ldist)"
fi

check_file()
{
temp=""
for i in $(find ./ -name CMakeCache.txt)
do
hit=$(find $(dirname ${i}) -maxdepth 1 -name "libiio*.$1" -a ! -name "*${LDIST}*")
if [ "$(echo ${hit} | wc -w)" -gt "1"  ] ; then
	echo "I am confused - more than 2 $1 files!"
	echo $hit
	exit 1
else
	if [ "$(echo ${hit} | wc -w)" -eq "1" ] ; then
		if [ -z "${temp}" ] ; then
			temp=$hit
		else
			echo "I am confused - more than 2 $1 files"
			echo $temp
			echo $hit
			exit 1
		fi
	fi
fi
done
}

check_file deb
if [ -n "${temp}" ] ; then
	deploy=$(expr ${deploy} + 1)
	if [ -z "${TARGET_DEB}" ] ; then
		export TARGET_DEB=$(echo ${temp} | \
			sed -e 's:^./.*/::' -e 's:-Linux::' -e 's:.deb$::')${LDIST}.deb
	fi
	echo "deploying ${temp} to nightly $TARGET_DEB"
	if [ -z "${RELEASE_PKG_FILE_DEB}" ] ; then
		export RELEASE_PKG_FILE_DEB=$(dirname ${temp})/${TARGET_DEB}
		cp ${temp} ${RELEASE_PKG_FILE_DEB}
	fi
	echo ${TARGET_DEB}
	ls -lh ${temp}
	echo ${RELEASE_PKG_FILE_DEB}
	ls -lh ${RELEASE_PKG_FILE_DEB}
else
	echo "Skipping deployment of debian package"
fi

check_file rpm
if [ -n "${temp}" ] ; then
	deploy=$(expr ${deploy} + 1)
	if [ -z "${TARGET_RPM}" ] ; then
		export TARGET_RPM=$(echo ${temp} | \
			sed -e 's:^./.*/::' -e 's:-Linux::' -e 's:.rpm$::')${LDIST}.rpm
	fi
	echo "deploying ${temp} to nightly $TARGET_RPM"
	if [ -z "${RELEASE_PKG_FILE_RPM}" ] ; then
		export RELEASE_PKG_FILE_RPM=$(dirname ${temp})/${TARGET_RPM}
		cp ${temp}  ${RELEASE_PKG_FILE_RPM}
	fi
	echo ${TARGET_RPM}
	ls -lh ${temp}
	echo ${RELEASE_PKG_FILE_RPM}
	ls -lh ${RELEASE_PKG_FILE_RPM}
else
	echo "Skipping deployment of rpm package"
fi

check_file tar.gz
if [  -n "${temp}"  ] ; then
	deploy=$(expr ${deploy} + 1)
	if [ -z "${TARGET_TGZ}" ] ; then
		echo Add the MATLAB bindings into the tar file
		(
		cd $(dirname ${temp})
		if [ -d tarball_fixup ] ; then
			rm -rf tarball_fixup
		fi
		mkdir tarball_fixup && cd tarball_fixup

		if [ "$TRAVIS_OS_NAME" = "osx" ] ; then
			tar --strip-components=1 -xzf ${TRAVIS_BUILD_DIR}/${temp}
		else
			tar -xzf ${TRAVIS_BUILD_DIR}/${temp}
		fi

		mkdir -p usr/include usr/lib/matlab/iio
		cp ${TRAVIS_BUILD_DIR}/bindings/matlab/iio-wrapper.h usr/include/
		cp ${TRAVIS_BUILD_DIR}/bindings/matlab/*.m usr/lib/matlab/iio/

		if [ "$TRAVIS_OS_NAME" = "osx" ] ; then
			cd usr/lib
			ln -fs ../../Library/Frameworks/iio.framework/iio libiio.dylib
			install_name_tool -change /usr/local/opt/libusb/lib/libusb-1.0.0.dylib @rpath/libusb-1.0.dylib libiio.dylib
			install_name_tool -add_rpath @loader_path/../../../../../usr/lib libiio.dylib
			install_name_tool -add_rpath /usr/local/opt/libusb/lib libiio.dylib

			cd ../include
			ln -s ../../Library/Frameworks/iio.framework/Headers/iio.h iio.h

			# Update references for tools
			cd ../..
			TOOLS=Library/Frameworks/iio.framework/Tools/*
			for tool in $TOOLS
			do
				install_name_tool -add_rpath @loader_path/../../ $tool
			done
			cp /usr/local/lib/libusb-1.0.dylib usr/lib/
			chmod +w usr/lib/libusb-1.0.dylib
			install_name_tool -id @rpath/libusb-1.0.dylib usr/lib/libusb-1.0.dylib

			tar -czf ${TRAVIS_BUILD_DIR}/${temp} usr Library
		else
			tar -czf ${TRAVIS_BUILD_DIR}/${temp} usr lib
		fi
		)

		export TARGET_TGZ=$(echo ${temp} | \
			sed -e 's:^./.*/::' -e 's:-Linux::' -e 's:-Darwin::' -e 's:.tar.gz$::')${LDIST}.tar.gz;
	fi
	echo "deploying ${temp} to $TARGET_TGZ"
	if [ -z "${RELEASE_PKG_FILE_TGZ}" ] ; then
		export RELEASE_PKG_FILE_TGZ=$(dirname ${temp})/${TARGET_TGZ}
		cp ${temp} ${RELEASE_PKG_FILE_TGZ}
	fi
	echo ${TARGET_TGZ}
	ls -lh ${temp}
	echo ${RELEASE_PKG_FILE_TGZ}
	ls -lh ${RELEASE_PKG_FILE_TGZ}
else
	echo "Skipping deployment of tarball"
fi

check_file pkg
if [ -n "${temp}" ] ; then
	deploy=$(expr ${deploy} + 1)
	if [ -z "${TARGET_PKG}" ] ; then
		export TARGET_PKG=$(echo ${temp} | \
			sed -e 's:^./.*/::' -e 's:.pkg$::')${LDIST}.pkg
	fi
	echo "deploying ${temp} to nightly $TARGET_PKG"
	if [ -z "${RELEASE_PKG_FILE_PKG}" ] ; then
		export RELEASE_PKG_FILE_PKG=$(dirname ${temp})/${TARGET_PKG}
		cp ${temp} ${RELEASE_PKG_FILE_PKG}
	fi
	echo ${TARGET_PKG}
	ls -lh ${temp}
	echo ${RELEASE_PKG_FILE_PKG}
	ls -lh ${RELEASE_PKG_FILE_PKG}
else
	echo "Skipping deployment of OS X package"
fi

if [ "${deploy}" -eq "0" ] ; then
	echo did not deploy any files
	exit 1
fi