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
|
#!/bin/sh
set -e
CURRENT_PATH=$(pwd)
EXPORT_PATH=$(pwd)
if test -n "${JENKINS_HOME}"; then
echo "Built from Jenkins. Will export the repo in $HOME/"
EXPORT_PATH="$HOME/"
fi
GIT_BASE_URL=https://github.com/llvm/llvm-project
GIT_TOOLCHAIN_CHECK=https://github.com/opencollab/llvm-toolchain-integration-test-suite.git
reset_repo ()
{
cd $1
git clean -qfd
git checkout .
git remote update > /dev/null
git reset --hard origin/main > /dev/null
git clean -qfd
git checkout main > /dev/null
git pull
cd -
}
PATH_DEBIAN="$(pwd)/$(dirname $0)/../"
cd "$PATH_DEBIAN"
git stash && git pull && git stash apply || true
MAJOR_VERSION=$(dpkg-parsechangelog | sed -rne "s,^Version: 1:([0-9]+).*,\1,p")
if test -z "$MAJOR_VERSION"; then
echo "Could not detect the major version"
exit 1
fi
CURRENT_VERSION=$(dpkg-parsechangelog | sed -rne "s,^Version: 1:([0-9.]+)(~|-)(.*),\1,p")
if test -z "$CURRENT_VERSION"; then
echo "Could not detect the full version"
exit 1
fi
cd - &> /dev/null
echo "MAJOR_VERSION=$MAJOR_VERSION / CURRENT_VERSION=$CURRENT_VERSION"
if test -n "$1"; then
BRANCH=$1
if ! echo "$1"|grep -q release/; then
FINAL_RELEASE=true
EXACT_VERSION=$1
fi
else
cd "$PATH_DEBIAN"
SOURCE=$(dpkg-parsechangelog |grep ^Source|awk '{print $2}')
cd - &> /dev/null
if test "$SOURCE" != "llvm-toolchain-snapshot"; then
echo "Checkout of the main is only available for llvm-toolchain-snapshot"
exit 1
fi
BRANCH="main"
fi
if test -n "$1" -a -n "$2"; then
TAG=$2
RCRELEASE="true"
EXACT_VERSION=$1
fi
mkdir -p git-archive
cd git-archive
if test -d $EXPORT_PATH/llvm-project; then
echo "Updating repo in $EXPORT_PATH/llvm-project"
reset_repo $EXPORT_PATH/llvm-project
else
echo "Cloning the repo in $EXPORT_PATH/llvm-project"
git clone $GIT_BASE_URL $EXPORT_PATH/llvm-project
fi
if test -d $EXPORT_PATH/llvm-toolchain-integration-test-suite; then
echo "Updating repo in $EXPORT_PATH/llvm-toolchain-integration-test-suite"
reset_repo $EXPORT_PATH/llvm-toolchain-integration-test-suite
else
echo "Clone llvm-toolchain-integration-test-suite into $EXPORT_PATH/llvm-toolchain-integration-test-suite"
git clone $GIT_TOOLCHAIN_CHECK $EXPORT_PATH/llvm-toolchain-integration-test-suite
fi
cd $EXPORT_PATH/llvm-project
if test -z "$TAG" -a -z "$FINAL_RELEASE"; then
git checkout $BRANCH
git reset --hard origin/$BRANCH
if test $BRANCH != "main"; then
VERSION=$(echo $BRANCH|cut -d/ -f2|cut -d. -f1)
if ! echo "$MAJOR_VERSION"|grep -q "$VERSION"; then
echo "mismatch in version: Dir=$MAJOR_VERSION Provided=$VERSION"
exit 1
fi
else
VERSION=$MAJOR_VERSION
MAJOR_VERSION=snapshot
fi
if test $MAJOR_VERSION != "snapshot"; then
CURRENT_VERSION="$(grep -oP 'set\(\s*LLVM_VERSION_(MAJOR|MINOR|PATCH)\s\K[0-9]+' cmake/Modules/LLVMVersion.cmake | paste -sd '.')"
fi
VERSION="${CURRENT_VERSION}~++$(date +'%Y%m%d%I%M%S')+$(git log -1 --pretty=format:'%h')"
echo "CURRENT = ${CURRENT_VERSION}"
else
if ! echo "$EXACT_VERSION"|grep -q "$MAJOR_VERSION"; then
echo "Mismatch in version: Dir=$MAJOR_VERSION Provided=$EXACT_VERSION"
exit 1
fi
git_tag="llvmorg-$EXACT_VERSION"
VERSION=$EXACT_VERSION
if test -n "$TAG"; then
git_tag="$git_tag-$TAG"
VERSION="$VERSION~+$TAG"
fi
git checkout "$git_tag" > /dev/null
fi
rm -rf */www/ build/ build-llvm/
cd ../
BASE="llvm-toolchain-${MAJOR_VERSION}_${VERSION}"
FILENAME="${BASE}.orig.tar.xz"
cp -R llvm-toolchain-integration-test-suite llvm-project/integration-test-suite
export XZ_OPT="-4 -T$(nproc)"
echo "Compressing to $FILENAME"
time tar Jcf $CURRENT_PATH/"$FILENAME" --exclude .git --exclude .gitattributes --exclude .git-blame-ignore-revs --exclude .gitignore --exclude .github --exclude build-llvm --transform="s|llvm-project|$BASE|" -C $EXPORT_PATH llvm-project
rm -rf llvm-project/integration-test-suite
export DEBFULLNAME="Sylvestre Ledru"
export DEBEMAIL="sylvestre@debian.org"
cd "$PATH_DEBIAN"
if test -z "$DISTRIBUTION"; then
DISTRIBUTION="experimental"
fi
if test -n "$RCRELEASE" -o -n "$BRANCH"; then
EXTRA_DCH_FLAGS="--force-bad-version --allow-lower-version"
fi
dch $EXTRA_DCH_FLAGS --distribution $DISTRIBUTION --newversion 1:"$VERSION"-1~exp1 "New snapshot release"
exit 0
|