[llvm] 2d9b7fd - [utils] Use git to checkout code instead of svn in building docker image
Ben Shi via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 14 18:41:31 PDT 2022
Author: Xiaodong Liu
Date: 2022-04-15T01:41:14Z
New Revision: 2d9b7fdaa379cfa3ce21259bf6669b71cab2b75d
URL: https://github.com/llvm/llvm-project/commit/2d9b7fdaa379cfa3ce21259bf6669b71cab2b75d
DIFF: https://github.com/llvm/llvm-project/commit/2d9b7fdaa379cfa3ce21259bf6669b71cab2b75d.diff
LOG: [utils] Use git to checkout code instead of svn in building docker image
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D123795
Added:
Modified:
llvm/utils/docker/build_docker_image.sh
llvm/utils/docker/debian10/Dockerfile
llvm/utils/docker/nvidia-cuda/Dockerfile
llvm/utils/docker/scripts/checkout.sh
Removed:
################################################################################
diff --git a/llvm/utils/docker/build_docker_image.sh b/llvm/utils/docker/build_docker_image.sh
index 320e64fe678c4..2dfea91719223 100755
--- a/llvm/utils/docker/build_docker_image.sh
+++ b/llvm/utils/docker/build_docker_image.sh
@@ -27,19 +27,16 @@ Available options:
-d|--docker-repository docker repository for the image
-t|--docker-tag docker tag for the image
Checkout arguments:
- -b|--branch svn branch to checkout, i.e. 'trunk',
- 'branches/release_40'
- (default: 'trunk')
- -r|--revision svn revision to checkout
+ -b|--branch git branch to checkout, i.e. 'main',
+ 'release/10.x'
+ (default: 'main')
+ -r|--revision git revision to checkout
-c|--cherrypick revision to cherry-pick. Can be specified multiple times.
Cherry-picks are performed in the sorted order using the
following command:
- 'svn patch <(svn
diff -c \$rev)'.
- -p|--llvm-project name of an svn project to checkout. Will also add the
- project to a list LLVM_ENABLE_PROJECTS, passed to CMake.
- For clang, please use 'clang', not 'cfe'.
- Project 'llvm' is always included and ignored, if
- specified.
+ 'git cherry-pick \$rev'.
+ -p|--llvm-project Add the project to a list LLVM_ENABLE_PROJECTS, passed to
+ CMake.
Can be specified multiple times.
-c|--checksums name of a file, containing checksums of llvm checkout.
Script will fail if checksums of the checkout do not
@@ -110,15 +107,7 @@ while [[ $# -gt 0 ]]; do
;;
-p|--llvm-project)
PROJ="$2"
- if [ "$PROJ" == "cfe" ]; then
- PROJ="clang"
- fi
-
- CHECKOUT_ARGS="$CHECKOUT_ARGS $1 $PROJ"
- if [ "$PROJ" != "clang-tools-extra" ]; then
- CMAKE_ENABLED_PROJECTS="$CMAKE_ENABLED_PROJECTS;$PROJ"
- fi
-
+ CMAKE_ENABLED_PROJECTS="$CMAKE_ENABLED_PROJECTS;$PROJ"
shift 2
;;
-c|--checksums)
diff --git a/llvm/utils/docker/debian10/Dockerfile b/llvm/utils/docker/debian10/Dockerfile
index 3094fed333670..b898c935b9726 100644
--- a/llvm/utils/docker/debian10/Dockerfile
+++ b/llvm/utils/docker/debian10/Dockerfile
@@ -15,7 +15,7 @@ RUN grep deb /etc/apt/sources.list | \
# Install compiler, python and subversion.
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates gnupg \
- build-essential cmake make python3 zlib1g wget subversion unzip && \
+ build-essential cmake make python3 zlib1g wget subversion unzip git && \
rm -rf /var/lib/apt/lists/*
# Install a newer ninja release. It seems the older version in the debian repos
# randomly crashes when compiling llvm.
diff --git a/llvm/utils/docker/nvidia-cuda/Dockerfile b/llvm/utils/docker/nvidia-cuda/Dockerfile
index 5878259c27f4e..91ad53c57b165 100644
--- a/llvm/utils/docker/nvidia-cuda/Dockerfile
+++ b/llvm/utils/docker/nvidia-cuda/Dockerfile
@@ -11,7 +11,7 @@ LABEL maintainer "LLVM Developers"
# Install llvm build dependencies.
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates cmake python \
- subversion ninja-build && \
+ subversion ninja-build git && \
rm -rf /var/lib/apt/lists/*
ADD checksums /tmp/checksums
diff --git a/llvm/utils/docker/scripts/checkout.sh b/llvm/utils/docker/scripts/checkout.sh
index c5e7cc784fdc5..c34cae84fde2e 100755
--- a/llvm/utils/docker/scripts/checkout.sh
+++ b/llvm/utils/docker/scripts/checkout.sh
@@ -13,48 +13,30 @@ function show_usage() {
cat << EOF
Usage: checkout.sh [options]
-Checkout svn sources into /tmp/clang-build/src. Used inside a docker container.
+Checkout git sources into /tmp/clang-build/src. Used inside a docker container.
Available options:
-h|--help show this help message
- -b|--branch svn branch to checkout, i.e. 'trunk',
- 'branches/release_40'
- (default: 'trunk')
- -r|--revision svn revision to checkout
+ -b|--branch git branch to checkout, i.e. 'main',
+ 'release/10.x'
+ (default: 'main')
+ -r|--revision git revision to checkout
-c|--cherrypick revision to cherry-pick. Can be specified multiple times.
Cherry-picks are performed in the sorted order using the
following command:
- 'svn patch <(svn
diff -c \$rev)'.
- -p|--llvm-project name of an svn project to checkout.
- For clang, please use 'clang', not 'cfe'.
- Project 'llvm' is always included and ignored, if
- specified.
- Can be specified multiple times.
+ 'git cherry-pick \$rev)'.
EOF
}
-LLVM_SVN_REV=""
+LLVM_GIT_REV=""
CHERRYPICKS=""
LLVM_BRANCH=""
-# We always checkout llvm
-LLVM_PROJECTS="llvm"
-
-function contains_project() {
- local TARGET_PROJ="$1"
- local PROJ
- for PROJ in $LLVM_PROJECTS; do
- if [ "$PROJ" == "$TARGET_PROJ" ]; then
- return 0
- fi
- done
- return 1
-}
while [[ $# -gt 0 ]]; do
case "$1" in
-r|--revision)
shift
- LLVM_SVN_REV="$1"
+ LLVM_GIT_REV="$1"
shift
;;
-c|--cherrypick)
@@ -67,25 +49,6 @@ while [[ $# -gt 0 ]]; do
LLVM_BRANCH="$1"
shift
;;
- -p|--llvm-project)
- shift
- PROJ="$1"
- shift
-
- if [ "$PROJ" == "cfe" ]; then
- PROJ="clang"
- fi
-
- if ! contains_project "$PROJ" ; then
- if [ "$PROJ" == "clang-tools-extra" ] && [ ! contains_project "clang" ]; then
- echo "Project 'clang-tools-extra' specified before 'clang'. Adding 'clang' to a list of projects first."
- LLVM_PROJECTS="$LLVM_PROJECTS clang"
- fi
- LLVM_PROJECTS="$LLVM_PROJECTS $PROJ"
- else
- echo "Project '$PROJ' is already enabled, ignoring extra occurrences."
- fi
- ;;
-h|--help)
show_usage
exit 0
@@ -97,15 +60,15 @@ while [[ $# -gt 0 ]]; do
done
if [ "$LLVM_BRANCH" == "" ]; then
- LLVM_BRANCH="trunk"
+ LLVM_BRANCH="main"
fi
-if [ "$LLVM_SVN_REV" != "" ]; then
- SVN_REV_ARG="-r$LLVM_SVN_REV"
- echo "Checking out svn revision r$LLVM_SVN_REV."
+if [ "$LLVM_GIT_REV" != "" ]; then
+ GIT_REV_ARG="$LLVM_GIT_REV"
+ echo "Checking out git revision $LLVM_GIT_REV."
else
- SVN_REV_ARG=""
- echo "Checking out latest svn revision."
+ GIT_REV_ARG=""
+ echo "Checking out latest git revision."
fi
# Sort cherrypicks and remove duplicates.
@@ -119,12 +82,8 @@ function apply_cherrypicks() {
# This function is always called on a sorted list of cherrypicks.
for CHERRY_REV in $CHERRYPICKS; do
- echo "Cherry-picking r$CHERRY_REV into $CHECKOUT_DIR"
-
- local PATCH_FILE="$(mktemp)"
- svn
diff -c $CHERRY_REV > "$PATCH_FILE"
- svn patch "$PATCH_FILE"
- rm "$PATCH_FILE"
+ echo "Cherry-picking $CHERRY_REV into $CHECKOUT_DIR"
+ git cherry-pick $CHERRY_REV
done
popd
@@ -132,32 +91,24 @@ function apply_cherrypicks() {
CLANG_BUILD_DIR=/tmp/clang-build
-# Get the sources from svn.
-echo "Checking out sources from svn"
+# Get the sources from git.
+echo "Checking out sources from git"
mkdir -p "$CLANG_BUILD_DIR/src"
-for LLVM_PROJECT in $LLVM_PROJECTS; do
- if [ "$LLVM_PROJECT" == "clang" ]; then
- SVN_PROJECT="cfe"
- else
- SVN_PROJECT="$LLVM_PROJECT"
- fi
-
- if [ "$SVN_PROJECT" != "clang-tools-extra" ]; then
- CHECKOUT_DIR="$CLANG_BUILD_DIR/src/$LLVM_PROJECT"
- else
- CHECKOUT_DIR="$CLANG_BUILD_DIR/src/clang/tools/extra"
- fi
-
- echo "Checking out https://llvm.org/svn/llvm-project/$SVN_PROJECT to $CHECKOUT_DIR"
- svn co -q $SVN_REV_ARG \
- "https://llvm.org/svn/llvm-project/$SVN_PROJECT/$LLVM_BRANCH" \
- "$CHECKOUT_DIR"
+CHECKOUT_DIR="$CLANG_BUILD_DIR/src"
+
+echo "Checking out https://github.com/llvm/llvm-project.git to $CHECKOUT_DIR"
+git clone -b $LLVM_BRANCH --single-branch \
+ "https://github.com/llvm/llvm-project.git" \
+ "$CHECKOUT_DIR"
+
+pushd $CHECKOUT_DIR
+git checkout -q $GIT_REV_ARG
+popd
# We apply cherrypicks to all repositories regardless of whether the revision
# changes this repository or not. For repositories not affected by the
# cherrypick, applying the cherrypick is a no-op.
apply_cherrypicks "$CHECKOUT_DIR"
-done
CHECKSUMS_FILE="/tmp/checksums/checksums.txt"
More information about the llvm-commits
mailing list