Skip to content

Commit

Permalink
fix tmpfolder used by jbosstools-cleanup.sh; use correct parent-paren…
Browse files Browse the repository at this point in the history
…t folder for running jbosstools-cleanup.sh
  • Loading branch information
nickboldt committed Mar 7, 2015
1 parent 4efee0a commit 96893f0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
11 changes: 6 additions & 5 deletions publish/rsync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ fi
# copy the source into the target
rsync -arzq --protocol=28 ${SOURCE_PATH}/* $DESTINATION/${TARGET_PATH}/

# given /downloads_htdocs/tools/mars/snapshots/builds/jbosstools-build-sites.aggregate.earlyaccess-site_master/B13-2015-03-06_17-58-07/all/repo/
# return mars/snapshots/builds/jbosstools-build-sites.aggregate.earlyaccess-site_master
PARENT_PATH=$(echo $TARGET_PATH | sed -e "s#/\?downloads_htdocs/tools/##" -e "s#/\?all/repo/\?##" -e "s#/\$##" -e "s#^/##" -e "s#\(.\+\)/[^/]\+#\1#")

# for published builds on download.jboss.org ONLY!
# regenerate http://download.jboss.org/jbosstools/builds/${TARGET_PATH}/composite*.xml files for up to 5 builds, cleaning anything older than 5 days old
if [[ ${TARGET_PATH/builds/} != ${TARGET_PATH} ]] && [[ ${DESTINATION} = "tools@filemgmt.jboss.org:/downloads_htdocs/tools" ]] && [[ -f ${WORKSPACE}/sources/util/cleanup/jbosstools-cleanup.sh ]]; then
# given /downloads_htdocs/tools/mars/snapshots/builds/jbosstools-build-sites.aggregate.earlyaccess-site_master/B13-2015-03-06_17-58-07/all/repo/
# return mars/snapshots/builds/jbosstools-build-sites.aggregate.earlyaccess-site_master
PARENT_PATH=$(echo $TARGET_PATH | sed -e "s#/\?downloads_htdocs/tools/##" -e "s#/\?all/repo/\?##" -e "s#/\$##" -e "s#^/##" -e "s#\(.\+\)/[^/]\+#\1#")
. ${WORKSPACE}/sources/util/cleanup/jbosstools-cleanup.sh -d ${PARENT_PATH} --no-subdirs --childFolderSuffix /all/repo/ --keep 5 --age-to-delete 5
. ${WORKSPACE}/sources/util/cleanup/jbosstools-cleanup.sh -d ${PARENT_PATH} --no-subdirs --childFolderSuffix /all/repo/ --regen-metadata-only
PARENT_PARENT_PATH=$(echo $PARENT_PATH | sed -e "s#\(.\+\)/[^/]\+#\1#")
. ${WORKSPACE}/sources/util/cleanup/jbosstools-cleanup.sh -d ${PARENT_PARENT_PATH} --no-subdirs --childFolderSuffix /all/repo/ --keep 5 --age-to-delete 5
fi

wgetParams="--timeout=900 --wait=10 --random-wait --tries=10 --retry-connrefused --no-check-certificate -q"
Expand Down
23 changes: 15 additions & 8 deletions util/cleanup/jbosstools-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
# --------------------------------------------------------------------------------
# clean JBT builds from sftp://tools@filemgmt.jboss.org/downloads_htdocs/tools/builds/nightly

log=/tmp/${0##*/}.log.`date +%Y%m%d-%H%M`.txt
#set up tmpdir
tmpdir=`mktemp -d`
mkdir -p $tmpdir

log=${tmpdir}/${0##*/}.log.`date +%Y%m%d-%H%M`.txt

echo "Logfile: $log" | tee -a $log
echo "" | tee -a $log
Expand Down Expand Up @@ -131,10 +135,10 @@ clean ()
if [[ $delete -eq 1 ]]; then
if [[ $USER == "hudson" ]]; then
# can't delete the dir, but can at least purge its contents
rm -fr /tmp/$dd; mkdir /tmp/$dd; pushd /tmp/$dd >/dev/null
rm -fr ${tmpdir}/$dd; mkdir ${tmpdir}/$dd; pushd ${tmpdir}/$dd >/dev/null
rsync --rsh=ssh --protocol=28 -r --delete . tools@filemgmt.jboss.org:$sd/$dd 2>&1 | tee -a $log
echo -e "rmdir $dd" | sftp tools@filemgmt.jboss.org:$sd/
popd >/dev/null; rm -fr /tmp/$dd
popd >/dev/null; rm -fr ${tmpdir}/$dd
fi
echo "" | tee -a $log
else
Expand Down Expand Up @@ -175,11 +179,11 @@ regenProcess ()
if [[ $subdirCount -gt 0 ]]; then
siteName=${sd##*/downloads_htdocs/tools/}
echo "Generate metadata for ${subdirCount} subdir(s) in $sd/ (siteName = ${siteName}" | tee -a $log
mkdir -p /tmp/cleanup-fresh-metadata/
regenCompositeMetadata "$siteName" "$all" "$subdirCount" "org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository" "/tmp/cleanup-fresh-metadata/compositeContent.xml"
regenCompositeMetadata "$siteName" "$all" "$subdirCount" "org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository" "/tmp/cleanup-fresh-metadata/compositeArtifacts.xml"
rsync --rsh=ssh --protocol=28 -q /tmp/cleanup-fresh-metadata/composite*.xml tools@filemgmt.jboss.org:$sd/
rm -fr /tmp/cleanup-fresh-metadata/
mkdir -p ${tmpdir}/cleanup-fresh-metadata/
regenCompositeMetadata "$siteName" "$all" "$subdirCount" "org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository" "${tmpdir}/cleanup-fresh-metadata/compositeContent.xml"
regenCompositeMetadata "$siteName" "$all" "$subdirCount" "org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository" "${tmpdir}/cleanup-fresh-metadata/compositeArtifacts.xml"
rsync --rsh=ssh --protocol=28 -q ${tmpdir}/cleanup-fresh-metadata/composite*.xml tools@filemgmt.jboss.org:$sd/
rm -fr ${tmpdir}/cleanup-fresh-metadata/
else
echo "No subdirs found in $sd/" | tee -a $log
# TODO delete composite*.xml from $sd/ folder if there are no subdirs present
Expand Down Expand Up @@ -212,3 +216,6 @@ regenCompositeMetadata ()
for dir in $dirsToScan; do
clean $dir $numbuildstokeep $threshholdwhendelete
done

# purge temp folder
rm -fr ${tmpdir}

0 comments on commit 96893f0

Please sign in to comment.