parent
e36ec8151f
commit
b430a3e49e
@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the current target version
|
||||
export TARGET=${TARGET:-"14.0.0"}
|
||||
|
||||
# When $SUFFIX = true then the package tarball name will be $package-trinity.
|
||||
# When $SUFFIX != true then the package tarball name will be trinity-$package.
|
||||
# Choose the option that satisfies any distro package name rules.
|
||||
export SUFFIX=${SUFFIX:-"true"}
|
||||
|
||||
# Setting base path for tarballs. Tarballs for indivitual modules
|
||||
# will be created into folders in same structure, as is in 'tde'.
|
||||
# The default is 'tde-tarballs' in parent directory.
|
||||
TARBALLS_BASE=${TARBALLS_BASE:-"$(dirname $PWD)/tde-tarballs/$TARGET"}
|
||||
|
||||
# List of modules to be omitted during creating tarballs.
|
||||
SKIP_MODULES="
|
||||
common
|
||||
defaultsettins
|
||||
experimental
|
||||
infrastructure
|
||||
metapackages
|
||||
scripts
|
||||
tde-construct
|
||||
thirdparty
|
||||
"
|
||||
skip_module() {
|
||||
for skip in $SKIP_MODULES; do
|
||||
[ "/${1/$skip//}/" != "/$1/" ] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Check git-dir
|
||||
if [[ ! -e .git ]] ||
|
||||
[[ -z "`git rev-parse --git-dir 2>/dev/null`" ]]; then
|
||||
echo "This script can only be run from a top level git directory. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check remote branch
|
||||
branch=`git branch --contains HEAD | grep -v "no branch" | head -n1 | cut -c 3-`
|
||||
if [[ -z "$branch" ]] ||
|
||||
[[ -z "`git rev-parse --symbolic-full-name --remotes=\"*/$branch\"`" ]]; then
|
||||
echo "There is not active upstream branch. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create tarballs for submodules
|
||||
if [[ -e .gitmodules ]]; then
|
||||
create_tarball=$(dirname $(readlink -f "$0"))/create_tarball
|
||||
sed -n "s|^\[submodule \"\([^\"]*\)\"\]$|\1|p" <.gitmodules | \
|
||||
while read submodule; do
|
||||
skip_module "$submodule" && continue
|
||||
if [[ ! -e "$submodule/.git" ]]; then
|
||||
git submodule init -- "$submodule"
|
||||
git submodule update -- "$submodule"
|
||||
fi
|
||||
export TARBALL_DIR=$TARBALLS_BASE/$(dirname "$submodule")
|
||||
if [[ ! -d "$TARBALL_DIR" ]]; then
|
||||
mkdir -p "$TARBALL_DIR"
|
||||
fi
|
||||
(cd "$submodule" && "$create_tarball")
|
||||
done
|
||||
fi
|
@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set the current target version
|
||||
TARGET=${TARGET:-"14.0.0"}
|
||||
|
||||
# When $SUFFIX = true then the package tarball name will be $package-trinity.
|
||||
# When $SUFFIX != true then the package tarball name will be trinity-$package.
|
||||
# Choose the option that satisfies any distro package name rules.
|
||||
SUFFIX=${SUFFIX:-"true"}
|
||||
|
||||
# Setting where the tarball will be created.
|
||||
# The default is the parent directory (..).
|
||||
TARBALL_DIR=${TARBALL_DIR:-".."}
|
||||
|
||||
# Check git-dir
|
||||
if [[ ! -e .git ]] ||
|
||||
[[ -z "`git rev-parse --git-dir 2>/dev/null`" ]]; then
|
||||
echo "This script can only be run from a top level git directory. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check remote branch
|
||||
branch=`git branch --contains HEAD | grep -v "no branch" | head -n1 | cut -c 3-`
|
||||
if [[ -z "$branch" ]] ||
|
||||
[[ -z "`git rev-parse --symbolic-full-name --remotes=\"*/$branch\"`" ]]; then
|
||||
echo "There is not active upstream branch. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check submodules
|
||||
if [[ -e .gitmodules ]]; then
|
||||
sed -n "s|^\[submodule \"\([^\"]*\)\"\]$|\1|p" <.gitmodules | \
|
||||
while read submodule; do
|
||||
if [[ ! -e "$submodule/.git" ]]; then
|
||||
git submodule init -- "$submodule"
|
||||
git submodule update -- "$submodule"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Check status
|
||||
if [[ ! -z "`git status --porcelain`" ]]; then
|
||||
echo "Current tree contains changes that have not been committed. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "`git branch -r --contains HEAD`" ]]; then
|
||||
echo "Current tree contains commits not pushed to the server. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
target_tag=`git tag | grep -F "$TARGET" | head -n1`
|
||||
if [[ -n "$target_tag" ]] && \
|
||||
[[ `git log $target_tag..HEAD | wc -l` -gt 0 ]]; then
|
||||
echo "Current tree contains commits beyond target release tag $target_tag. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
if [[ -n "$target_tag" ]] && \
|
||||
[[ `git log HEAD..$target_tag | wc -l` -gt 0 ]]; then
|
||||
echo "Current tree is behind target release tag $target_tag. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Calculate version
|
||||
tag=`git tag | sort -r | while read t; do \
|
||||
git branch --contains $t | cut -c 3- | grep -x "$branch" >/dev/null && \
|
||||
echo "$t..HEAD" && break; done`
|
||||
|
||||
count=`git log $tag --pretty=oneline | wc -l`
|
||||
|
||||
if [ "$SUFFIX" = "true" ]; then
|
||||
package=$(basename $PWD)-trinity-$TARGET
|
||||
else
|
||||
package=trinity-$(basename $PWD)-$TARGET
|
||||
fi
|
||||
if [[ "$count" -gt 0 ]] || [[ -z "$target_tag" ]]; then
|
||||
package=$package~pre$count+$(git rev-parse HEAD | cut -c 1-8)
|
||||
fi
|
||||
|
||||
# Create tarball
|
||||
echo "Package name: $package"
|
||||
if [ ! -e $TARBALL_DIR/$package.tar.xz ]; then
|
||||
echo "Creating tarball in $TARBALL_DIR."
|
||||
trap "rm $TARBALL_DIR/tar-$$; exit 1" INT
|
||||
tar c --owner=root --group=users --exclude .git --exclude .gitmodules --transform "s|^\.|$package|" ./ | \
|
||||
xz -9 >$TARBALL_DIR/tar-$$ && \
|
||||
mv $TARBALL_DIR/tar-$$ $TARBALL_DIR/$package.tar.xz || \
|
||||
rm $TARBALL_DIR/tar-$$
|
||||
else
|
||||
echo "Unchanged tarball in $TARBALL_DIR."
|
||||
exit 2
|
||||
fi
|
Loading…
Reference in new issue