@@ -23,8 +23,8 @@ usage: release-build.sh <package|docs|publish-snapshot|publish-release>
2323Creates build deliverables from a Spark commit.
2424
2525Top level targets are
26- package: Create binary packages and copy them to people .apache
27- docs: Build docs and copy them to people .apache
26+ package: Create binary packages and copy them to home .apache
27+ docs: Build docs and copy them to home .apache
2828 publish-snapshot: Publish snapshot release to Apache snapshots
2929 publish-release: Publish a release to Apache release repo
3030
@@ -64,13 +64,16 @@ for env in ASF_USERNAME ASF_RSA_KEY GPG_PASSPHRASE GPG_KEY; do
6464 fi
6565done
6666
67+ # Explicitly set locale in order to make `sort` output consistent across machines.
68+ # See https://stackoverflow.com/questions/28881 for more details.
69+ export LC_ALL=C
70+
6771# Commit ref to checkout when building
6872GIT_REF=${GIT_REF:- master}
6973
7074# Destination directory parent on remote server
7175REMOTE_PARENT_DIR=${REMOTE_PARENT_DIR:-/ home/ $ASF_USERNAME / public_html}
7276
73- SSH=" ssh -o ConnectTimeout=300 -o StrictHostKeyChecking=no -i $ASF_RSA_KEY "
7477GPG=" gpg --no-tty --batch"
7578NEXUS_ROOT=https://repository.apache.org/service/local/staging
7679NEXUS_PROFILE=d63f592e7eac0 # Profile for Spark staging uploads
@@ -97,18 +100,35 @@ if [ -z "$SPARK_PACKAGE_VERSION" ]; then
97100fi
98101
99102DEST_DIR_NAME=" spark-$SPARK_PACKAGE_VERSION "
100- USER_HOST=" $ASF_USERNAME @people.apache.org"
103+
104+ function LFTP {
105+ SSH=" ssh -o ConnectTimeout=300 -o StrictHostKeyChecking=no -i $ASF_RSA_KEY "
106+ COMMANDS=$( cat << EOF
107+ set net:max-retries 1 &&
108+ set sftp:connect-program $SSH &&
109+ connect -u $ASF_USERNAME ,p sftp://home.apache.org &&
110+ $@
111+ EOF
112+ )
113+ lftp --norc -c " $COMMANDS "
114+ }
115+ export -f LFTP
116+
101117
102118git clean -d -f -x
103119rm .gitignore
104120rm -rf .git
105121cd ..
106122
107123if [ -n " $REMOTE_PARENT_MAX_LENGTH " ]; then
108- old_dirs=$( $SSH $USER_HOST ls -t $REMOTE_PARENT_DIR | tail -n +$REMOTE_PARENT_MAX_LENGTH )
124+ old_dirs=$(
125+ LFTP nlist $REMOTE_PARENT_DIR \
126+ | grep -v " ^\." \
127+ | sort -r \
128+ | tail -n +$REMOTE_PARENT_MAX_LENGTH )
109129 for old_dir in $old_dirs ; do
110130 echo " Removing directory: $old_dir "
111- $SSH $USER_HOST rm -r $REMOTE_PARENT_DIR /$old_dir
131+ LFTP " rm -rf $REMOTE_PARENT_DIR /$old_dir && exit 0 "
112132 done
113133fi
114134
@@ -180,11 +200,15 @@ if [[ "$1" == "package" ]]; then
180200 # Copy data
181201 dest_dir=" $REMOTE_PARENT_DIR /${DEST_DIR_NAME} -bin"
182202 echo " Copying release tarballs to $dest_dir "
183- $SSH $USER_HOST mkdir $dest_dir
184- rsync -e " $SSH " spark-* $USER_HOST :$dest_dir
185- echo " Linking /latest to $dest_dir "
186- $SSH $USER_HOST rm -f " $REMOTE_PARENT_DIR /latest"
187- $SSH $USER_HOST ln -s $dest_dir " $REMOTE_PARENT_DIR /latest"
203+ # Put to new directory:
204+ LFTP mkdir -p $dest_dir
205+ LFTP mput -O $dest_dir ' spark-*'
206+ # Delete /latest directory and rename new upload to /latest
207+ LFTP " rm -r -f $REMOTE_PARENT_DIR /latest || exit 0"
208+ LFTP mv $dest_dir " $REMOTE_PARENT_DIR /latest"
209+ # Re-upload a second time and leave the files in the timestamped upload directory:
210+ LFTP mkdir -p $dest_dir
211+ LFTP mput -O $dest_dir ' spark-*'
188212 exit 0
189213fi
190214
@@ -198,11 +222,15 @@ if [[ "$1" == "docs" ]]; then
198222 # TODO: Make configurable to add this: PRODUCTION=1
199223 PRODUCTION=1 RELEASE_VERSION=" $SPARK_VERSION " jekyll build
200224 echo " Copying release documentation to $dest_dir "
201- $SSH $USER_HOST mkdir $dest_dir
202- echo " Linking /latest to $dest_dir "
203- $SSH $USER_HOST rm -f " $REMOTE_PARENT_DIR /latest"
204- $SSH $USER_HOST ln -s $dest_dir " $REMOTE_PARENT_DIR /latest"
205- rsync -e " $SSH " -r _site/* $USER_HOST :$dest_dir
225+ # Put to new directory:
226+ LFTP mkdir -p $dest_dir
227+ LFTP mirror -R _site $dest_dir
228+ # Delete /latest directory and rename new upload to /latest
229+ LFTP " rm -r -f $REMOTE_PARENT_DIR /latest || exit 0"
230+ LFTP mv $dest_dir " $REMOTE_PARENT_DIR /latest"
231+ # Re-upload a second time and leave the files in the timestamped upload directory:
232+ LFTP mkdir -p $dest_dir
233+ LFTP mirror -R _site $dest_dir
206234 cd ..
207235 exit 0
208236fi
0 commit comments