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
|
#!/bin/bash
min_modules="Linux/backtrace
mps"
all_modules=$(sed -En "s|^[\t ]*path = (.*)$|\1|p" ${STORM_ROOT}/.gitmodules)
selected_modules=""
version=$(find_version)
tar_file=${STORM_ROOT}/storm_${version}.tar
case "$1" in
minimal)
selected_modules="$min_modules"
shift
;;
full)
selected_modules="$all_modules"
shift
;;
*)
>&2 echo "Expected one of the base modes: minimal, full"
exit 1
;;
esac
function find_module() {
matches=$(echo "$all_modules" | grep ${1})
count=$(echo "$matches" | wc -l)
if [[ $count -lt 1 || "$matches" == "" ]]
then
>&2 echo "No match for ${1}. Available modules are:"
>&2 echo "$all_modules"
exit 1
elif [ $count -gt 1 ]
then
>&2 echo "Multiple possible matches for ${1}:"
>&2 echo "$matches"
exit 1
else
echo "$matches"
fi
}
while [ $# -gt 0 ]
do
case "$1" in
--output)
shift
tar_file="$1"
;;
+*)
module=$(find_module "${1:1}")
if [ $? != 0 ]
then
exit 1
fi
selected_modules="$selected_modules
$module"
;;
-*)
module=$(find_module "${1:1}")
if [ $? != 0 ]
then
exit 1
fi
selected_modules=$(echo "$selected_modules" | grep -v "$module")
;;
*)
>&2 echo "Unknown extra parameter: $1"
exit 1
;;
esac
shift
done
selected_modules=$(echo "$selected_modules" | sort | uniq)
>&2 echo "Generating tar file with modules:"
>&2 echo "$selected_modules"
# Clean up build files.
git clean -xdf > /dev/null
# Make sure the submodules are up to date. Also clean them.
for x in $selected_modules
do
git submodule init $x
git submodule update $x
pushd $x > /dev/null
git clean -xdf > /dev/null
popd > /dev/null
done
function find_current_version() {
tag=`git describe --abbrev=0 HEAD`
desc=`git describe HEAD`
if [[ $tag != $desc ]]
then
# Format the extra information.
tag=`echo $desc | sed -E 's/-([0-9]+)-([a-zA-Z0-9]+)$/+git.\1.\2/'`
fi
echo $tag | sed 's!^release/!!'
}
# Build the tar file...
echo "core.info" > ${STORM_ROOT}/Compiler/COMPILER.version
echo "$version" >> ${STORM_ROOT}/Compiler/COMPILER.version
tar -cf $tar_file --exclude="*/.git" -X<(sed -En "s|^[\t ]*path = (.*)$|./\1|p" ${STORM_ROOT}/.gitmodules) .
for x in $selected_modules
do
tar -rf $tar_file ./$x
done
|