release-tools/functions

40 lines
855 B
Bash

#!/bin/bash
#
# Shared functions for shell scripts
#
function lp_project_to_repo {
typeset proj="$1"
if [[ $proj == python-*client* ]]; then
echo $proj
else
# Some of the repository names don't match the launchpad names, e.g.
# python-stevedore and python-cliff.
echo $proj | sed -e 's|python-||'
fi
}
function title {
echo
echo "$(tput bold)$(tput setaf 1)[ $1 ]$(tput sgr0)"
}
function _cleanup_tmp {
title "Cleaning up"
rm -rf $MYTMPDIR
}
function setup_temp_space {
MYTMPDIR=`mktemp -d ${1}-XXX`
mkdir -p "$MYTMPDIR"
trap _cleanup_tmp EXIT
cd "$MYTMPDIR"
# NOTE(dhellmann): On some platforms mktemp returns a short name
# instead of a full path, so expand the full path by looking at
# where we ended up after the cd operation.
MYTMPDIR="$(pwd)"
}