Skip to content
Closed
Next Next commit
Chages for people.apache.org -> home.apache.org migration.
  • Loading branch information
JoshRosen committed Feb 24, 2016
commit 4d07db44f5304757711ab623b84f5c7cc9a7469c
37 changes: 23 additions & 14 deletions dev/create-release/release-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ usage: release-build.sh <package|docs|publish-snapshot|publish-release>
Creates build deliverables from a Spark commit.

Top level targets are
package: Create binary packages and copy them to people.apache
docs: Build docs and copy them to people.apache
package: Create binary packages and copy them to home.apache
docs: Build docs and copy them to home.apache
publish-snapshot: Publish snapshot release to Apache snapshots
publish-release: Publish a release to Apache release repo

Expand Down Expand Up @@ -64,13 +64,16 @@ for env in ASF_USERNAME ASF_RSA_KEY GPG_PASSPHRASE GPG_KEY; do
fi
done

# Explicitly set locale in order to make `sort` output consistent across machines.
# See https://stackoverflow.com/questions/28881 for more details.
export LC_ALL=C

# Commit ref to checkout when building
GIT_REF=${GIT_REF:-master}

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

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

DEST_DIR_NAME="spark-$SPARK_PACKAGE_VERSION"
USER_HOST="[email protected]"

function LFTP {
COMMANDS="set sftp:auto-confirm true && connect -u $ASF_USERNAME,p sftp://home.apache.org && $@"
lftp --norc -c "$COMMANDS"
}
export -f LFTP


git clean -d -f -x
rm .gitignore
rm -rf .git
cd ..

if [ -n "$REMOTE_PARENT_MAX_LENGTH" ]; then
old_dirs=$($SSH $USER_HOST ls -t $REMOTE_PARENT_DIR | tail -n +$REMOTE_PARENT_MAX_LENGTH)
old_dirs=$(LFTP nlist $REMOTE_PARENT_DIR | sort | head -n +$REMOTE_PARENT_MAX_LENGTH)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that nlist will return ./ and ../, so we need to filter those out here.

for old_dir in $old_dirs; do
echo "Removing directory: $old_dir"
$SSH $USER_HOST rm -r $REMOTE_PARENT_DIR/$old_dir
LFTP rm -r $REMOTE_PARENT_DIR/$old_dir
done
fi

Expand Down Expand Up @@ -178,11 +187,11 @@ if [[ "$1" == "package" ]]; then
# Copy data
dest_dir="$REMOTE_PARENT_DIR/${DEST_DIR_NAME}-bin"
echo "Copying release tarballs to $dest_dir"
$SSH $USER_HOST mkdir $dest_dir
rsync -e "$SSH" spark-* $USER_HOST:$dest_dir
LFTP mkdir -p $dest_dir
LFTP mput spark-* $dest_dir
echo "Linking /latest to $dest_dir"
$SSH $USER_HOST rm -f "$REMOTE_PARENT_DIR/latest"
$SSH $USER_HOST ln -s $dest_dir "$REMOTE_PARENT_DIR/latest"
LFTP rm "$REMOTE_PARENT_DIR/latest"
LFTP ln -s $dest_dir "$REMOTE_PARENT_DIR/latest"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FTP protocol itself does not support symlinks and the older versions of lftp don't have the ln command. I'm going to work around this by uploading the binaries twice, once to the latest folder and once to the other one. With the symlink, at least the change to /latest appeared relatively atomic so you wouldn't see half-uploaded files in there. I'll try to work around this by uploading to dest_dir, moving, then uploading again. This isn't perfect but seems like a decent hack.

exit 0
fi

Expand All @@ -196,11 +205,11 @@ if [[ "$1" == "docs" ]]; then
# TODO: Make configurable to add this: PRODUCTION=1
PRODUCTION=1 RELEASE_VERSION="$SPARK_VERSION" jekyll build
echo "Copying release documentation to $dest_dir"
$SSH $USER_HOST mkdir $dest_dir
LFTP mkdir -p $dest_dir
echo "Linking /latest to $dest_dir"
$SSH $USER_HOST rm -f "$REMOTE_PARENT_DIR/latest"
$SSH $USER_HOST ln -s $dest_dir "$REMOTE_PARENT_DIR/latest"
rsync -e "$SSH" -r _site/* $USER_HOST:$dest_dir
LFTP rm "$REMOTE_PARENT_DIR/latest"
LFTP ln -s $dest_dir "$REMOTE_PARENT_DIR/latest"
LFTP mput _site/* $dest_dir
cd ..
exit 0
fi
Expand Down