Skip to content

Commit

Permalink
CI/travis: move send() function to lib.sh
Browse files Browse the repository at this point in the history
This is a 1-to-1 move, no changes to the code.

Signed-off-by: Alexandru Ardelean <[email protected]>
  • Loading branch information
commodo committed Dec 11, 2018
1 parent 5b9f3e4 commit af5a2fc
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 61 deletions.
62 changes: 1 addition & 61 deletions CI/travis/deploy
Original file line number Diff line number Diff line change
@@ -1,66 +1,6 @@
#!/bin/sh -xe

cd $TRAVIS_BUILD_DIR

send()
{
if [ "$#" -ne 3 ] ; then
echo "skipping deployment of something"
echo "send called with $@"
return
fi

if [ "x$1" = "x" ] ; then
echo no file to send
return
fi

if [ ! -r "$1" ] ; then
echo "file $1 is not readable"
ls -l $1
return
fi

if [ $BRANCH_PULL ] ; then
branch=$BRANCH_PULL
else
branch=$BRANCH
fi

FROM=$1
TO=${branch}_$2
LATE=${branch}_latest_libiio${LDIST}$3
GLOB=${DEPLOY_TO}/${branch}_libiio-*

echo attemting to deploy $FROM to $TO
echo and ${branch}_libiio${LDIST}$3
ssh -V

echo "cd ${DEPLOY_TO}" > script$3
if curl -m 10 -s -I -f -o /dev/null http://swdownloads.analog.com/cse/travis_builds/${TO} ; then
echo "rm ${TO}" >> script$3
fi
echo "put ${FROM} ${TO}" >> script$3
echo "ls -l ${TO}" >> script$3
if curl -m 10 -s -I -f -o /dev/null http://swdownloads.analog.com/cse/travis_builds/${LATE} ; then
echo "rm ${LATE}" >> script$3
fi
echo "symlink ${TO} ${LATE}" >> script$3
echo "ls -l ${LATE}" >> script$3
echo "bye" >> script$3

sftp ${EXTRA_SSH} -b script$3 ${SSHUSER}@${SSHHOST}

# limit things to a few files, so things don't grow forever
if [ "$3" = ".deb" ] ; then
for files in $(ssh ${EXTRA_SSH} ${SSHUSER}@${SSHHOST} \
"ls -lt ${GLOB}" | tail -n +100 | awk '{print $NF}')
do
ssh ${EXTRA_SSH} ${SSHUSER}@${SSHHOST} \
"rm ${DEPLOY_TO}/${files}"
done
fi
}
. CI/travis/lib.sh

# from to suffix
send ${RELEASE_PKG_FILE_DEB} ${TARGET_DEB} .deb
Expand Down
60 changes: 60 additions & 0 deletions CI/travis/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,63 @@ brew_install_or_upgrade() {
shift
done
}

send()
{
if [ "$#" -ne 3 ] ; then
echo "skipping deployment of something"
echo "send called with $@"
return
fi

if [ "x$1" = "x" ] ; then
echo no file to send
return
fi

if [ ! -r "$1" ] ; then
echo "file $1 is not readable"
ls -l $1
return
fi

if [ $BRANCH_PULL ] ; then
branch=$BRANCH_PULL
else
branch=$BRANCH
fi

FROM=$1
TO=${branch}_$2
LATE=${branch}_latest_libiio${LDIST}$3
GLOB=${DEPLOY_TO}/${branch}_libiio-*

echo attemting to deploy $FROM to $TO
echo and ${branch}_libiio${LDIST}$3
ssh -V

echo "cd ${DEPLOY_TO}" > script$3
if curl -m 10 -s -I -f -o /dev/null http://swdownloads.analog.com/cse/travis_builds/${TO} ; then
echo "rm ${TO}" >> script$3
fi
echo "put ${FROM} ${TO}" >> script$3
echo "ls -l ${TO}" >> script$3
if curl -m 10 -s -I -f -o /dev/null http://swdownloads.analog.com/cse/travis_builds/${LATE} ; then
echo "rm ${LATE}" >> script$3
fi
echo "symlink ${TO} ${LATE}" >> script$3
echo "ls -l ${LATE}" >> script$3
echo "bye" >> script$3

sftp ${EXTRA_SSH} -b script$3 ${SSHUSER}@${SSHHOST}

# limit things to a few files, so things don't grow forever
if [ "$3" = ".deb" ] ; then
for files in $(ssh ${EXTRA_SSH} ${SSHUSER}@${SSHHOST} \
"ls -lt ${GLOB}" | tail -n +100 | awk '{print $NF}')
do
ssh ${EXTRA_SSH} ${SSHUSER}@${SSHHOST} \
"rm ${DEPLOY_TO}/${files}"
done
fi
}

0 comments on commit af5a2fc

Please sign in to comment.