File: make_source_package.sh

package info (click to toggle)
spring 106.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 55,260 kB
  • sloc: cpp: 543,946; ansic: 44,800; python: 12,575; java: 12,201; awk: 5,889; sh: 1,796; asm: 1,546; xml: 655; perl: 405; php: 211; objc: 194; makefile: 76; sed: 2
file content (114 lines) | stat: -rwxr-xr-x 2,846 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

# tarball generation script

. buildbot/slave/prepare.sh

# Quit on error.
set -e

OUTPUTDIR=${TMP_PATH}

if [ -z "${TMP_PATH}" ]  || [ "${TMP_PATH}" == "/" ]; then
	echo "Invalid path: ${TMP_PATH}"
	exit 1;
fi

echo Using OUTPUTDIR=${OUTPUTDIR}

# create output dir
mkdir -p "$OUTPUTDIR/source"

# Sanity check.
if [ ! -x /usr/bin/git ]; then
	echo "Error: Could not find /usr/bin/git" >&2
	exit 1
fi

# Find correct working directory.
# (Compatible with SConstruct, which is in trunk root)

while [ ! -d rts ]; do
	if [ "${PWD}" = "/" ]; then
		echo "Error: Could not find installer directory." >&2
		echo "Make sure to run this script from a directory below your checkout directory." >&2
		exit 2
	fi
	cd ..
done

SOURCEROOT=$(pwd)

describe=$(git describe --abbrev=7 --tags --candidates 999 --match "*.*")

set +e # turn of quit on error
# Check if current HEAD has a version tag
git describe --abbrev=7 --tags --candidates 0 --match "*.*" &> /dev/null
onVersionTag=$(if [ $? -eq "0" ]; then echo "true"; else echo "false"; fi)
set -e # turn it on again

isRelease=${onVersionTag}

if [ "${BRANCH}" = "master" -a ! ${onVersionTag} ]; then
	echo "Error: On branch master but not on a version tag." >&2
	echo "This indicates a tagging, branching or push error." >&2
	exit 3
fi

if ${isRelease}; then
	echo "Making release-packages"
	versionString=${describe}
	versionInfo=${describe}
else
	echo "Making test-packages"
	# Insert the branch name as the patch-set part.
	# (double-quotation is required because of the sub-shell)
	versionString="${describe}_${BRANCH}"
	versionInfo="${describe} ${BRANCH}"
fi

echo "Using version \"${versionInfo}\" as source"
dir="spring_${versionString}"

# Each one of these that is set, is built when running this script.
# Linux archives
# * linux (LF) line endings
# * GPL compatible
lzma="spring_${versionString}_src.tar.lzma"
tgz="spring_${versionString}_src.tar.gz"


echo 'Cleaning source dir'
git clean -f -d -x
git submodule foreach git clean -f -d -x

echo 'Exporting checkout dir with LF line endings'
rsync -a --exclude .git --delete --delete-excluded ${SOURCEROOT}/ ${OUTPUTDIR}/${dir}/

cd ${OUTPUTDIR}/${dir}

# Add the engine version info, as we can not fetch it through git
# when using a source archive
echo "${versionInfo}" > ./VERSION
echo "cleaning files"
rm -rf .git \
	.gitignore \
	.gitmodules \
	.mailmap \
	tools/pr-downloader/src/lsl/lsl \
	tools/pr-downloader/src/lsl/lslextract \
	tools/pr-downloader/src/lsl/lslunitsync \
	tools/pr-downloader/src/lib/cimg \
	tools/pr-downloader/src/lib/libgit2

cd ..

echo "Creating .tar.lzma archive (${lzma})"
tar -c --lzma -v -f "${OUTPUTDIR}/source/${lzma}" ${dir}

echo "Creating .tar.gz archive (${tgz})"
tar -c --gzip -f "${OUTPUTDIR}/source/${tgz}" ${dir}

echo "Cleaning up ${OUTPUTDIR}/${dir}"
rm -rf "${OUTPUTDIR}/${dir}"