Skip to content

Commit

Permalink
CI/travis/lib.sh: rename & indent send() function
Browse files Browse the repository at this point in the history
Rename send() -> upload_file_to_swdownloads().
Since it's in lib.sh, it needs a better name to avoid potential name
clashes with other local functions/code.

Indent the code to make it a bit more readable.

Signed-off-by: Alexandru Ardelean <[email protected]>
  • Loading branch information
commodo committed Dec 11, 2018
1 parent af5a2fc commit ae08593
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 62 deletions.
8 changes: 4 additions & 4 deletions CI/travis/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
. CI/travis/lib.sh

# from to suffix
send ${RELEASE_PKG_FILE_DEB} ${TARGET_DEB} .deb
send ${RELEASE_PKG_FILE_RPM} ${TARGET_RPM} .rpm
send ${RELEASE_PKG_FILE_TGZ} ${TARGET_TGZ} .tar.gz
send ${RELEASE_PKG_FILE_PKG} ${TARGET_PKG} .pkg
upload_file_to_swdownloads ${RELEASE_PKG_FILE_DEB} ${TARGET_DEB} .deb
upload_file_to_swdownloads ${RELEASE_PKG_FILE_RPM} ${TARGET_RPM} .rpm
upload_file_to_swdownloads ${RELEASE_PKG_FILE_TGZ} ${TARGET_TGZ} .tar.gz
upload_file_to_swdownloads ${RELEASE_PKG_FILE_PKG} ${TARGET_PKG} .pkg

116 changes: 58 additions & 58 deletions CI/travis/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,62 +138,62 @@ brew_install_or_upgrade() {
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
upload_file_to_swdownloads() {

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 ae08593

Please sign in to comment.