Skip to content

Commit f77dc4e

Browse files
committed
[SPARK-13474][PROJECT INFRA] Update packaging scripts to push artifacts to home.apache.org
Due to the people.apache.org -> home.apache.org migration, we need to update our packaging scripts to publish artifacts to the new server. Because the new server only supports sftp instead of ssh, we need to update the scripts to use lftp instead of ssh + rsync. Author: Josh Rosen <[email protected]> Closes #11350 from JoshRosen/update-release-scripts-for-apache-home.
1 parent ad61529 commit f77dc4e

File tree

1 file changed

+44
-16
lines changed

1 file changed

+44
-16
lines changed

dev/create-release/release-build.sh

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ usage: release-build.sh <package|docs|publish-snapshot|publish-release>
2323
Creates build deliverables from a Spark commit.
2424
2525
Top 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
6565
done
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
6872
GIT_REF=${GIT_REF:-master}
6973

7074
# Destination directory parent on remote server
7175
REMOTE_PARENT_DIR=${REMOTE_PARENT_DIR:-/home/$ASF_USERNAME/public_html}
7276

73-
SSH="ssh -o ConnectTimeout=300 -o StrictHostKeyChecking=no -i $ASF_RSA_KEY"
7477
GPG="gpg --no-tty --batch"
7578
NEXUS_ROOT=https://repository.apache.org/service/local/staging
7679
NEXUS_PROFILE=d63f592e7eac0 # Profile for Spark staging uploads
@@ -97,18 +100,35 @@ if [ -z "$SPARK_PACKAGE_VERSION" ]; then
97100
fi
98101

99102
DEST_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

102118
git clean -d -f -x
103119
rm .gitignore
104120
rm -rf .git
105121
cd ..
106122

107123
if [ -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
113133
fi
114134

@@ -178,11 +198,15 @@ if [[ "$1" == "package" ]]; then
178198
# Copy data
179199
dest_dir="$REMOTE_PARENT_DIR/${DEST_DIR_NAME}-bin"
180200
echo "Copying release tarballs to $dest_dir"
181-
$SSH $USER_HOST mkdir $dest_dir
182-
rsync -e "$SSH" spark-* $USER_HOST:$dest_dir
183-
echo "Linking /latest to $dest_dir"
184-
$SSH $USER_HOST rm -f "$REMOTE_PARENT_DIR/latest"
185-
$SSH $USER_HOST ln -s $dest_dir "$REMOTE_PARENT_DIR/latest"
201+
# Put to new directory:
202+
LFTP mkdir -p $dest_dir
203+
LFTP mput -O $dest_dir 'spark-*'
204+
# Delete /latest directory and rename new upload to /latest
205+
LFTP "rm -r -f $REMOTE_PARENT_DIR/latest || exit 0"
206+
LFTP mv $dest_dir "$REMOTE_PARENT_DIR/latest"
207+
# Re-upload a second time and leave the files in the timestamped upload directory:
208+
LFTP mkdir -p $dest_dir
209+
LFTP mput -O $dest_dir 'spark-*'
186210
exit 0
187211
fi
188212

@@ -196,11 +220,15 @@ if [[ "$1" == "docs" ]]; then
196220
# TODO: Make configurable to add this: PRODUCTION=1
197221
PRODUCTION=1 RELEASE_VERSION="$SPARK_VERSION" jekyll build
198222
echo "Copying release documentation to $dest_dir"
199-
$SSH $USER_HOST mkdir $dest_dir
200-
echo "Linking /latest to $dest_dir"
201-
$SSH $USER_HOST rm -f "$REMOTE_PARENT_DIR/latest"
202-
$SSH $USER_HOST ln -s $dest_dir "$REMOTE_PARENT_DIR/latest"
203-
rsync -e "$SSH" -r _site/* $USER_HOST:$dest_dir
223+
# Put to new directory:
224+
LFTP mkdir -p $dest_dir
225+
LFTP mirror -R _site $dest_dir
226+
# Delete /latest directory and rename new upload to /latest
227+
LFTP "rm -r -f $REMOTE_PARENT_DIR/latest || exit 0"
228+
LFTP mv $dest_dir "$REMOTE_PARENT_DIR/latest"
229+
# Re-upload a second time and leave the files in the timestamped upload directory:
230+
LFTP mkdir -p $dest_dir
231+
LFTP mirror -R _site $dest_dir
204232
cd ..
205233
exit 0
206234
fi

0 commit comments

Comments
 (0)