-
Notifications
You must be signed in to change notification settings - Fork 2
/
b2code-create
executable file
·88 lines (77 loc) · 2.54 KB
/
b2code-create
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
#!/bin/bash
# comparison of versions
function version_greater_equal
{
test "$(echo -e "$1\n$2" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1)" = "$1"
}
# check for help option
if [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "-?" ]; then
echo
echo "Usage: `basename $0` [--light] directory"
echo
echo "- This command creates a local directory with the given name"
echo " as basis for a working copy of the Belle II software."
echo " It also prepares the build system."
echo "- The --light option can be used to check out only the packages"
echo " of a light release."
echo
exit 0
fi
# check for light option
LIGHT=0
if [ "$1" = "--light" ]; then
LIGHT=1
shift
fi
# check number of arguments
if [ $# -ne 1 ]; then
echo "Usage: `basename $0` [--light] directory" 1>&2
if [ $# -eq 2 ]; then
echo "The creation of central + local releases is not supported any more."
fi
exit 1
fi
# check remote git access
git ls-remote ${BELLE2_SOFTWARE_REPOSITORY} main > /dev/null
if [ "$?" != "0" ]; then
echo "Error: Could not access the remote git repository." 1>&2
exit 1
fi
# read arguments
DIR=$1
# create release directory and write release version to .release
if [ -d ${DIR} ]; then
echo "Error: The directory ${DIR} already exists." 1>&2
exit 1
fi
# clone the repository and checkout site-scons
git clone --no-checkout ${BELLE2_SOFTWARE_REPOSITORY} ${DIR}
cd ${DIR}
git config branch.main.rebase true
GIT_VERSION=$(git --version | awk '{print $3}')
if version_greater_equal ${GIT_VERSION} 1.7.4 ; then
git config core.sparsecheckout true
else
echo "Warning: Because your git version (${GIT_VERSION}) is older than 1.7.4 the support of sparse checkouts is disabled."
echo "=> When you have set up a git version >= 1.7.4, e.g. from the externals development version, you can re-enable it by executing 'git config core.sparsecheckout true' in your local release directory."
fi
if [ "${LIGHT}" == "1" ]; then
echo "/.light" >> .git/info/sparse-checkout
git checkout main
rm -f .git/info/sparse-checkout
ln -s ${PWD}/.light .git/info/sparse-checkout
else
echo "/*" >> .git/info/sparse-checkout
for PACKAGE in ${BELLE2_EXCLUDE_PACKAGES}; do
echo "!/${PACKAGE}/" >> .git/info/sparse-checkout
done
fi
git checkout main
echo head > .release
ln -s site_scons/SConstruct .
# install hooks
rm -rf .git/hooks
ln -sf ${BELLE2_TOOLS}/hooks .git/hooks
# inform user about successful completion
echo "New local directory created for head version: ${DIR}"
echo "-> change to the new directory and set up the environment: cd ${DIR}; b2setup"