project-config/roles/copy-wheels/files/wheel-index.sh
Andreas Jaeger 3a806df6c6 Move wheel-build scripts out of jenkins/scripts
We only need the three wheel-X scripts from jenkins/scripts and need
them only for the playbook and its roles. Move the scripts in the
roles directory and copy them only if needed - using the scripts module.

Remove copying of complete jenkins/script for this playbook using the
role legacy-copy-project-config-scripts, it's not needed anymore.

Change-Id: I2e481fcf7ca148aac8a36ae99d8598ba26078a25
2018-02-13 21:12:45 +01:00

37 lines
948 B
Bash
Executable File

#!/bin/bash -xe
# Working variables
MIRROR_ROOT=$1
# A temporary file to which to write the new index
TMP_INDEX_FILE=$(mktemp)
trap "rm -f -- '$TMP_INDEX_FILE'" EXIT
# And the final location
INDEX_FILE=${MIRROR_ROOT}/index.html
# Start building our file
echo -e "<html>\n <head>\n <title>Wheel Index</title>\n </head>" > $TMP_INDEX_FILE
echo -e " <body>\n <ul>" >> $TMP_INDEX_FILE
# Get a list of files
FILES=`find $MIRROR_ROOT -maxdepth 2 -type d`
REGEX="([^/])\/(\1[^/]+)$"
for f in $FILES; do
if [[ $f =~ $REGEX ]]; then
echo " <li><a href=\"./${BASH_REMATCH[2]}/\">${BASH_REMATCH[2]}</a></li>" >> $TMP_INDEX_FILE
fi
done
echo -e " </ul>\n </body>\n</html>" >> $TMP_INDEX_FILE
if ! cmp $TMP_INDEX_FILE $INDEX_FILE >/dev/null 2>&1; then
# Atomically replace the index file
mv $TMP_INDEX_FILE $INDEX_FILE
else
rm $TMP_INDEX_FILE
fi
# The tempfile is gone so we don't need the trap
trap - EXIT