aboutsummaryrefslogtreecommitdiff
path: root/platforms-ci.sh
blob: 6eadfd8cf7b8cfd306df1c63dd25b351a3f47f99 (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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#!/bin/bash

# UEFI builds use the WORSKPACE variable, so save it and restore it later
JENKINS_WORKSPACE=${WORKSPACE}
unset WORKSPACE

if [ "$1" == "" ]; then
	#YYMM=`date +%y`.`date +%m`
	YYMM=master
else
	YYMM=$1
fi

# pre-requisites

# 32 bit libraries needed for BusyBox
sudo apt-get update
sudo apt-get install -y --force-yes gcc-multilib
sudo apt-get install -y --force-yes zip
sudo apt-get install -y --force-yes libssl-dev

wget http://ftp.de.debian.org/debian/pool/main/a/acpica-unix/acpica-tools_20140926-1_amd64.deb http://de.archive.ubuntu.com/ubuntu/pool/main/m/make-dfsg/make_3.81-8.2ubuntu3_amd64.deb
sudo dpkg -i --force-all *.deb

# Toolchain
# Use pre-installed linaro toolchain
export PATH="${HOME}/srv/toolchain/arm-tc-15.02/bin:${HOME}/srv/toolchain/arm64-tc-15.02/bin:$PATH"

# REPO
curl https://storage.googleapis.com/git-repo-downloads/repo > ./repo
chmod a+x repo
repo=$PWD/repo
ls -al


# functions

function quit
{
	echo "ERROR: It doesn't look like you're in a platforms repo"
	echo "ERROR: This is missing: $1"
	exit
}

function gitnuke
{
	echo "cleaning directory $*"
	pushd $*
	git reset --hard HEAD && git clean -dfx
	popd
}
function clean_workspace
{
	export -f gitnuke
	find . -name ".git" -type d -exec bash -c 'gitnuke "{}/.."' \;
	rm ramdisk.img
}
function check_workspace
{
	mandatory_dirs=(
		.repo
		arm-tf
		build-scripts
		busybox
		linux
		model-scripts
		ramdisk
		recovery
		u-boot
		uefi/edk2
		vexpress-firmware
	)

	for ((i=0;i<${#mandatory_dirs[@]};++i)); do
		if [ ! -e ${mandatory_dirs[i]} ]; then
			quit ${mandatory_dirs[i]}
		else
			#debugging - make sure we have what we expected to have in each dir
			pushd ${mandatory_dirs[i]}
			git log --pretty=format:"%h  %ad  %s%x09[%an]" --date=short -5
			ls -al
			popd
		fi
	done
}
function show_commit
{
	gitdir=$1
	dir=`echo $gitdir | sed -e "s#^\.\/##g" -e "s#\\/\.git/\.\.##g"`
	pushd $dir > /dev/null
	#git remote -v | grep fetch
	commitid=`git log --oneline -1 --pretty=format:"%h" --date=short`
	echo "$commitid $dir" >> $report
	popd > /dev/null
}
function create_release_zip
{
	local variant=$1        # variant (eg. juno, fvp, ...)
	local kernel=$2         # kernel type (latest or lsk)
	local os=$3             # OS (eg. oe, android, ...)
	local boot=$4           # bootloader (uboot or uefi)

	local workspace=workspace-${kernel}
	local from=$workspace/output/${variant}-${os}/${boot}
	local to=${variant}-${kernel}-${os}-${boot}

	echo copying output $from $to

	mkdir -p $to
	case $variant in
		juno )
			cp -R $workspace/recovery/* $to
			cp -R $from/* $to/SOFTWARE
			;;
		fvp )
			cp $workspace/model-scripts/run_model.sh $to
			cp -R $from/* $to
			;;
		tc2 )
			cp -R $workspace/vexpress-firmware/* $to
			cp -R $from/* $to/SOFTWARE
			;;
		* )
			echo "WARNING: variant not recognised"
			echo "         you will get a default set of files in your ZIP"
			echo "         and you may not be expecting that."
			cp -R $from/* $to
			;;
	esac

	pushd ${to}

	# Generate report for this build
	# First decide the report filename - use an absolute path so we can change
	# directories and still write to the correct report file
	if [ "$YYMM" == "master" ]; then
		# use date and time in the marker file
		report=$PWD/${to}-`date +%Y%m%d-%H%M`.txt
	else
		report=$PWD/${to}-${YYMM}.txt
	fi
	rm ${report}

	# Add the ms5sums of the files for this build
	echo "md5sum                            file" > ${report}
	echo "--------------------------------  -----------------------------------" >> ${report}
	find . -name "*" -type f | grep -v -e ${report} | sort | xargs md5sum >> ${report}

	# Add the commit ids for the repos we built from
	echo "" >> $report
	echo "commit  repo" >> $report
	echo "------- --------------------- " >> $report
	export report
	export -f show_commit
	pushd ../$workspace
	find . -name ".git" -type d  -exec bash -c 'show_commit "{}/.."' \;
	popd

	# zip up the build
	zip -r ../${to}.zip *
	popd
}
function dobuilds
{
	ver=$1 # lsk or latest
	yymm=$2

	workspace=workspace-$1
	mkdir -p $workspace
	pushd $workspace

	# remove old code and builds before syncing to pinned version
	rm -rf *

	# choose the manifest to sync to
	if [ "$yymm" == "master" ]; then
		manifest=${ver}
	else
		manifest=pinned-${ver}
	fi

	# just for debugging purposes
	ls -al

	${repo} init -u https://git.linaro.org/landing-teams/working/arm/manifest -b ${yymm} -m ${manifest}.xml
	${repo} sync -j8

	# just for debugging purposes
	ls -al

	check_workspace

	variants=(
		fvp-busybox
		fvp-oe
		fvp-android
		tc2-busybox
		tc2-oe
		tc2-android
		juno-busybox
		juno-oe
		juno-android
	)
	for ((i=0;i<${#variants[@]};++i)); do
		# we want to clean the workspace before building each variant
		clean_workspace
		if [ "${variants[i]}" == "fvp-android" ]; then
			wget https://releases.linaro.org/android/reference-lcr/fvp/15.09/ramdisk.img
		elif [ "${variants[i]}" == "juno-android" ]; then
			wget https://releases.linaro.org/android/reference-lcr/juno/15.09/ramdisk.img
		elif [ "${variants[i]}" == "tc2-android" ]; then
			wget https://releases.linaro.org/android/reference-lcr/vexpress/15.09/ramdisk.img
		fi
		./build-scripts/build-all.sh ${variants[i]}
		./build-scripts/build-all.sh ${variants[i]} package
	done
	popd
}

which aarch64-linux-gnu-gcc && aarch64-linux-gnu-gcc -v

# build the two kernel variants
dobuilds lsk    $YYMM
dobuilds latest $YYMM

# Create the recovery directories for each variant
create_release_zip juno latest busybox  uboot
create_release_zip juno latest oe       uefi
create_release_zip juno lsk    android  uboot
create_release_zip fvp  latest busybox  uboot
create_release_zip fvp  latest oe       uefi
create_release_zip fvp  lsk    android  uboot
create_release_zip tc2  latest busybox  uefi
create_release_zip tc2  latest oe       uefi
create_release_zip tc2  lsk    android  uefi

# create the final release zips
if [ "$PLATFORMS_ZIPS" == "yes" ]; then
	zip juno-platforms.zip juno-l*.zip
	zip fvp-platforms.zip  fvp-l*.zip
	zip tc2-platforms.zip  tc2-l*.zip
fi
if [ "$UBER_ZIP" == "yes" ]; then
	zip platforms.zip juno-l*.zip fvp-l*.zip tc2-l*.zip
fi

ls -al

# restore the WORKSPACE variable now we're finished building
unset WORKSPACE
export WORKSPACE=${JENKINS_WORKSPACE}