From df2c0f7f690891667629a7be69d675196d615a64 Mon Sep 17 00:00:00 2001 From: Jorrit Wronski Date: Sun, 7 Dec 2014 17:35:43 +0100 Subject: [PATCH] Merging changes for the development scripts. Buildbot, git mirror to SourceForge and release management. No code changes. --- dev/scripts/buildbot.sh | 47 ++++++++++++++++++++++++++++++++++++ dev/scripts/gitMirror.bsh | 31 ++++++++++++++++++++++++ dev/scripts/release.bsh | 33 ++++++++++++++++--------- dev/scripts/sfManageTime.bsh | 18 ++++++++++++++ 4 files changed, 118 insertions(+), 11 deletions(-) create mode 100644 dev/scripts/buildbot.sh create mode 100644 dev/scripts/gitMirror.bsh create mode 100644 dev/scripts/sfManageTime.bsh diff --git a/dev/scripts/buildbot.sh b/dev/scripts/buildbot.sh new file mode 100644 index 00000000..84c856cd --- /dev/null +++ b/dev/scripts/buildbot.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# Work around for Cron: +USER=coolprop +source /home/$USER/.bash_profile +source /home/$USER/buildbot/server-master-sandbox/bin/activate +# +function start { + buildbot start /home/$USER/buildbot/server-master/ +} +function reconfig { + buildbot reconfig /home/$USER/buildbot/server-master/ +} +function git_pull { + pushd /home/$USER/buildbot/CoolProp.git + git pull + popd +} +function stop { +# PID=$(ps aux | grep -m 1 'python=buildbot.tac' | tr -s " " | cut -d " " -s -f 2) +# if [ "$PID" -eq "$PID" ] 2>/dev/null; then +# echo "Killing $PID" +# kill $PID +# fi + buildbot stop /home/$USER/buildbot/server-master/ +} +# +# Check for input +CMD="$1" +if [ "$CMD" = "restart" ]; then + stop + git_pull + start +elif [ "$CMD" = "reconfig" ]; then + git_pull + reconfig +elif [ "$CMD" = "start" ]; then + git_pull + start +elif [ "$CMD" = "stop" ]; then + stop +else + git_pull + start +fi +# +echo "Script executed, terminating" +exit 0 diff --git a/dev/scripts/gitMirror.bsh b/dev/scripts/gitMirror.bsh new file mode 100644 index 00000000..5dbef444 --- /dev/null +++ b/dev/scripts/gitMirror.bsh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Work around for Cron: +USER=coolprop +source /home/$USER/.bash_profile +# +SFPASS="/home/$USER/etc_opt/id_jorritw" +# +FOLDER="/home/$USER/src/CoolProp.git" +ORIGIN="https://github.com/CoolProp/CoolProp.git" +MIRROR="ssh://jorritw@git.code.sf.net/p/coolprop/git" +# +if [ ! -d $FOLDER ]; then # repo does not exist, clone it + BASEFOLDER=${FOLDER%/*} + REPOFOLDER=${FOLDER##*/} + mkdir -p $BASEFOLDER + pushd $BASEFOLDER + git clone --bare $ORIGIN $REPOFOLDER + #pushd $REPOFOLDER + #git remote add sfmirror $MIRROR + #popd + popd +fi +echo "Preparing the ssh key for SourceForge" +eval $(ssh-agent) # Make sure ssh-agent is running +ssh-add "$SFPASS" +pushd $FOLDER +#git push --force --mirror +git push --mirror $MIRROR +popd +exit 0 diff --git a/dev/scripts/release.bsh b/dev/scripts/release.bsh index b7390025..32eb9eb7 100755 --- a/dev/scripts/release.bsh +++ b/dev/scripts/release.bsh @@ -5,15 +5,17 @@ if [ $# != 1 ]; then echo "Only one argument should be passed to this script - the version that will be released; like release.bsh 5.0.0" exit 1 fi -echo "DRYRUN=${DRYRUN}" +echo "DRYRUN=$DRYRUN" CPVERSION="$1" -BASEDIR="${HOME}/buildbot/server-master/public_html" +BASEDIR="$HOME/buildbot/server-master/public_html" +BINFOLDER="binaries" +DOCFOLDER="sphinx" # #SFUSER="ibell" -#SFPASS="${HOME}/etc_opt/id_ibell" +#SFPASS="$HOME/etc_opt/id_ibell" # SFUSER="jorritw" -SFPASS="${HOME}/etc_opt/id_jorritw" +SFPASS="$HOME/etc_opt/id_jorritw" # #set -x #echo on # Change the folder @@ -21,18 +23,27 @@ pushd ${BASEDIR} #echo "Fixing the permissions of directories and files" # This is not needed, just ignore the perms in rsync #find . -type d ! -perm 0775 -exec chmod 0775 {} \; #find . -type f ! -perm 0664 -exec chmod 0664 {} \; +# if [ "$DRYRUN" = "true" ]; then echo "Dry run; no zipping of the docs" echo "Dry run; skipping python upload" + echo "Dry run; skipping folder date" RSYNC_DRY_RUN=--dry-run else - echo "Zipping up the docs and moving them into the binaries folder for staging" + echo "Zipping up the docs and moving them into the $BINFOLDER folder for staging" rm -f documentation.zip - zip -rq documentation.zip sphinx/* - mkdir -p binaries/docs - cp documentation.zip binaries/docs + zip -rq documentation.zip $DOCFOLDER/* + mkdir -p "$BINFOLDER/docs" + cp documentation.zip "$BINFOLDER/docs" echo "Uploading the python binaries to pypi" - twine upload binaries/Python/*.whl binaries/Python/*.tar.gz + twine upload $BINFOLDER/Python/*.whl $BINFOLDER/Python/*.tar.gz + # + NEWEST=$(find "$BINFOLDER" ! -type d -printf "%T@ %p\n" | sort -n | tail -n1) + FDATE=${NEWEST:0:10} + FNAME=${NEWEST:22} + echo "Changing the folder date to the newest file date - $(date -d @$FDATE +%F)" + touch -r "$FNAME" "$BINFOLDER" + # RSYNC_DRY_RUN= fi echo "Preparing the ssh key for SourceForge" @@ -40,9 +51,9 @@ eval $(ssh-agent) # Make sure ssh-agent is running ssh-add "$SFPASS" # echo "Copying the binaries to SourceForge" -rsync $RSYNC_DRY_RUN -a --no-perms -z --stats binaries/ ${SFUSER},coolprop@frs.sf.net:/home/pfs/project/c/co/coolprop/CoolProp/${CPVERSION} +rsync $RSYNC_DRY_RUN -a --no-perms -z --stats "$BINFOLDER/" $SFUSER@frs.sourceforge.net:/home/frs/project/coolprop/CoolProp/$CPVERSION echo "Publishing the docs on SourceForge" -rsync $RSYNC_DRY_RUN -a --no-perms -z --stats sphinx/ ${SFUSER}@web.sourceforge.net:/home/project-web/coolprop/htdocs +rsync $RSYNC_DRY_RUN -a --no-perms -z --stats "$DOCFOLDER/" $SFUSER@web.sourceforge.net:/home/project-web/coolprop/htdocs # Change back to where we came from popd echo "All done, goodbye." diff --git a/dev/scripts/sfManageTime.bsh b/dev/scripts/sfManageTime.bsh new file mode 100644 index 00000000..b942294c --- /dev/null +++ b/dev/scripts/sfManageTime.bsh @@ -0,0 +1,18 @@ +#!/bin/bash +# +#rsync -aP jorritw@frs.sourceforge.net:/home/frs/project/coolprop/ /home/jorrit/tmp/sourceforge/ +# Scan the tree and change the folder date to the date +# of the oldest file in it +#for DIR in /home/jorrit/tmp/sourceforge/CoolProp/*/; do +for DIR in ../coolprop/CoolProp/*/; do + NEWEST=$(find "$DIR" ! -type d -printf "%T@ %p\n" | sort -n | tail -n1) + FDATE=${NEWEST:0:10} + FNAME=${NEWEST:22} + echo "$DIR: $(date -d @$FDATE +%F) of $FNAME" + touch -r "$FNAME" "$DIR"* +done +# # +# #rsync -a -f"+ */" -f"- *" /home/jorrit/tmp/sourceforge/ jorritw@frs.sourceforge.net:/home/frs/project/coolprop/ +# rsync -t /home/jorrit/tmp/sourceforge/ jorritw@frs.sourceforge.net:/home/frs/project/coolprop/ +#rsync -rtcv -f"+ */" -f"- *" /home/jorrit/tmp/sourceforge/ jorritw@frs.sourceforge.net:/home/frs/project/coolprop/ +exit 0