Switch to using $() for subshells, part 2
Cleanup every use of `` for subshells in the jenkins/scripts directory, replacing them with $(), and finally making the scripts consistent. Change-Id: Id3e45fb873c1ebeae6ab63a0caa4c427a7ccbb62
This commit is contained in:
parent
85a0f4f44f
commit
e3060b094c
@ -1,9 +1,9 @@
|
||||
#!/bin/bash -xe
|
||||
|
||||
WORKSPACE=`pwd`
|
||||
WORKSPACE=$(pwd)
|
||||
mkdir -p logs
|
||||
rm -f logs/*
|
||||
cd `dirname "$0"`
|
||||
cd $(dirname "$0")
|
||||
|
||||
echo "Jenkins: resetting hosts..."
|
||||
for host in $HEAD_HOST ${COMPUTE_HOSTS//,/ }; do
|
||||
@ -33,8 +33,8 @@ cd ~/devstack
|
||||
source stackrc
|
||||
for image_url in ${IMAGE_URLS//,/ }; do
|
||||
# Downloads the image (uec ami+aki style), then extracts it.
|
||||
IMAGE_FNAME=`echo "$image_url" | python -c "import sys; print sys.stdin.read().split('/')[-1]"`
|
||||
IMAGE_NAME=`echo "$IMAGE_FNAME" | python -c "import sys; print sys.stdin.read().split('.tar.gz')[0].split('.tgz')[0]"`
|
||||
IMAGE_FNAME=$(echo "$image_url" | python -c "import sys; print sys.stdin.read().split('/')[-1]")
|
||||
IMAGE_NAME=$(echo "$IMAGE_FNAME" | python -c "import sys; print sys.stdin.read().split('.tar.gz')[0].split('.tgz')[0]")
|
||||
if [ ! -f files/$IMAGE_FNAME ]; then
|
||||
wget -c $image_url -O files/$IMAGE_FNAME
|
||||
fi
|
||||
|
@ -37,7 +37,7 @@ fi
|
||||
# Normally a branch name will just be a file, but we can have branches
|
||||
# like stable/diablo, so in that case, make the "stable/" directory
|
||||
# if needed:
|
||||
mkdir -p `dirname $BRANCH`
|
||||
mkdir -p $(dirname $BRANCH)
|
||||
|
||||
# Read and update the value for the branch
|
||||
if [ -e "$BRANCH" ]; then
|
||||
|
@ -175,10 +175,10 @@ EOF
|
||||
# See if there is an open change in the transifex/translations
|
||||
# topic. If so, get the change id for the existing change for use
|
||||
# in the commit msg.
|
||||
change_info=`ssh -p 29418 proposal-bot@review.openstack.org gerrit query --current-patch-set status:open project:$FULL_PROJECT topic:transifex/translations owner:proposal-bot`
|
||||
previous=`echo "$change_info" | grep "^ number:" | awk '{print $2}'`
|
||||
change_info=$(ssh -p 29418 proposal-bot@review.openstack.org gerrit query --current-patch-set status:open project:$FULL_PROJECT topic:transifex/translations owner:proposal-bot)
|
||||
previous=$(echo "$change_info" | grep "^ number:" | awk '{print $2}')
|
||||
if [ -n "$previous" ]; then
|
||||
change_id=`echo "$change_info" | grep "^change" | awk '{print $2}'`
|
||||
change_id=$(echo "$change_info" | grep "^change" | awk '{print $2}')
|
||||
# Read returns a non zero value when it reaches EOF. Because we use a
|
||||
# heredoc here it will always reach EOF and return a nonzero value.
|
||||
# Disable -e temporarily to get around the read.
|
||||
@ -199,7 +199,7 @@ EOF
|
||||
# run.
|
||||
if [ -n "$previous" ]; then
|
||||
# Use the JSON format since it is very compact and easy to grep
|
||||
change_info=`ssh -p 29418 proposal-bot@review.openstack.org gerrit query --current-patch-set --format=JSON $change_id`
|
||||
change_info=$(ssh -p 29418 proposal-bot@review.openstack.org gerrit query --current-patch-set --format=JSON $change_id)
|
||||
# Check for:
|
||||
# 1) Workflow approval (+1)
|
||||
# 2) no -1/-2 by Jenkins
|
||||
@ -228,7 +228,7 @@ function send_patch {
|
||||
fi
|
||||
|
||||
# Don't send a review if nothing has changed.
|
||||
if [ `git diff --cached |wc -l` -gt 0 ]; then
|
||||
if [ $(git diff --cached | wc -l) -gt 0 ]; then
|
||||
# Commit and review
|
||||
git commit -F- <<EOF
|
||||
$COMMIT_MSG
|
||||
@ -298,7 +298,7 @@ function setup_django_openstack_auth {
|
||||
# Filter out files that we do not want to commit
|
||||
function filter_commits {
|
||||
# Don't add new empty files.
|
||||
for f in `git diff --cached --name-only --diff-filter=A`; do
|
||||
for f in $(git diff --cached --name-only --diff-filter=A); do
|
||||
# Files should have at least one non-empty msgid string.
|
||||
if ! grep -q 'msgid "[^"]' "$f" ; then
|
||||
git reset -q "$f"
|
||||
@ -312,7 +312,7 @@ function filter_commits {
|
||||
# Also, don't send files if only .pot files would be changed.
|
||||
PO_CHANGE=0
|
||||
# Don't iterate over deleted files
|
||||
for f in `git diff --cached --name-only --diff-filter=AM`; do
|
||||
for f in $(git diff --cached --name-only --diff-filter=AM); do
|
||||
# It's ok if the grep fails
|
||||
set +e
|
||||
changed=$(git diff --cached "$f" \
|
||||
@ -337,7 +337,7 @@ function filter_commits {
|
||||
# and those changes can be ignored as they give no benefit on
|
||||
# their own.
|
||||
if [ $PO_CHANGE -eq 0 ] ; then
|
||||
for f in `git diff --cached --name-only` ; do
|
||||
for f in $(git diff --cached --name-only) ; do
|
||||
git reset -q "$f"
|
||||
git checkout -- "$f"
|
||||
done
|
||||
@ -349,21 +349,21 @@ function filter_commits {
|
||||
function cleanup_po_files {
|
||||
local project=$1
|
||||
|
||||
for i in `find $project/locale -name *.po `; do
|
||||
for i in $(find $project/locale -name *.po) ; do
|
||||
# Output goes to stderr, so redirect to stdout to catch it.
|
||||
trans=`msgfmt --statistics -o /dev/null "$i" 2>&1`
|
||||
trans=$(msgfmt --statistics -o /dev/null "$i" 2>&1)
|
||||
check="^0 translated messages"
|
||||
if [[ $trans =~ $check ]] ; then
|
||||
# Nothing is translated, remove the file.
|
||||
git rm -f "$i"
|
||||
else
|
||||
if [[ $trans =~ " translated message" ]] ; then
|
||||
trans_no=`echo $trans|sed -e 's/ translated message.*$//'`
|
||||
trans_no=$(echo $trans|sed -e 's/ translated message.*$//')
|
||||
else
|
||||
trans_no=0
|
||||
fi
|
||||
if [[ $trans =~ " untranslated message" ]] ; then
|
||||
untrans_no=`echo $trans|sed -e 's/^.* \([0-9]*\) untranslated message.*/\1/'`
|
||||
untrans_no=$(echo $trans|sed -e 's/^.* \([0-9]*\) untranslated message.*/\1/')
|
||||
else
|
||||
untrans_no=0
|
||||
fi
|
||||
@ -388,7 +388,7 @@ function cleanup_po_files {
|
||||
function compress_po_files {
|
||||
local directory=$1
|
||||
|
||||
for i in `find $directory -name *.po `; do
|
||||
for i in $(find $directory -name *.po) ; do
|
||||
msgattrib --translated --no-location --sort-output "$i" \
|
||||
--output="${i}.tmp"
|
||||
mv "${i}.tmp" "$i"
|
||||
@ -404,7 +404,7 @@ function compress_po_files {
|
||||
function compress_manual_po_files {
|
||||
local directory=$1
|
||||
local glossary=$2
|
||||
for i in `find $directory -name *.po `; do
|
||||
for i in $(find $directory -name *.po) ; do
|
||||
if [ "$glossary" -eq "0" ] ; then
|
||||
if [[ $i =~ "/glossary/" ]] ; then
|
||||
continue
|
||||
@ -425,7 +425,7 @@ function compress_manual_po_files {
|
||||
function compress_non_en_po_files {
|
||||
local directory=$1
|
||||
|
||||
for i in `find $directory -name *.po `; do
|
||||
for i in $(find $directory -name *.po); do
|
||||
if [[ $i =~ "/locale/en/LC_MESSAGES/" ]] ; then
|
||||
continue
|
||||
fi
|
||||
|
@ -22,10 +22,10 @@ META_DATA_FILE=$3
|
||||
PLUGIN_FILE=$4
|
||||
|
||||
# Strip project name and extension leaving only the version.
|
||||
VERSION=`echo ${PLUGIN_FILE} | sed -n "s/${PROJECT}-\(.*\).hpi/\1/p"`
|
||||
VERSION=$(echo ${PLUGIN_FILE} | sed -n "s/${PROJECT}-\(.*\).hpi/\1/p")
|
||||
|
||||
# generate pom file with version info
|
||||
POM_IN_ZIP=`unzip -Z -1 ${PLUGIN_FILE}|grep pom.xml`
|
||||
POM_IN_ZIP=$(unzip -Z -1 ${PLUGIN_FILE}|grep pom.xml)
|
||||
unzip -o -j ${PLUGIN_FILE} ${POM_IN_ZIP}
|
||||
sed "s/\${{project-version}}/${VERSION}/g" <pom.xml >${META_DATA_FILE}
|
||||
|
||||
|
@ -2,6 +2,6 @@
|
||||
lvremove -f /dev/main/last_root
|
||||
lvrename /dev/main/root last_root
|
||||
lvcreate -L20G -s -n root /dev/main/orig_root
|
||||
APPEND="`cat /proc/cmdline`"
|
||||
APPEND="$(cat /proc/cmdline)"
|
||||
kexec -l /vmlinuz --initrd=/initrd.img --append="$APPEND"
|
||||
nohup bash -c "sleep 2; kexec -e" </dev/null >/dev/null 2>&1 &
|
||||
|
@ -22,10 +22,10 @@ META_DATA_FILE=$3
|
||||
PLUGIN_FILE=$4
|
||||
|
||||
# Strip project name and extension leaving only the version.
|
||||
VERSION=`echo ${PLUGIN_FILE} | sed -n "s/${PROJECT}-\(.*\).jar/\1/p"`
|
||||
VERSION=$(echo ${PLUGIN_FILE} | sed -n "s/${PROJECT}-\(.*\).jar/\1/p")
|
||||
|
||||
# generate pom file with version info
|
||||
POM_IN_ZIP=`unzip -Z -1 ${PLUGIN_FILE}|grep pom.xml`
|
||||
POM_IN_ZIP=$(unzip -Z -1 ${PLUGIN_FILE}|grep pom.xml)
|
||||
unzip -o -j ${PLUGIN_FILE} ${POM_IN_ZIP}
|
||||
sed "s/\${{project-version}}/${VERSION}/g" <pom.xml >${META_DATA_FILE}
|
||||
|
||||
|
@ -34,8 +34,8 @@ git review -s
|
||||
git remote update
|
||||
git checkout master
|
||||
git reset --hard origin/master
|
||||
MASTER_MINOR=`git describe|cut -d. -f-2`
|
||||
TAG_MINOR=`echo $TAG|cut -d. -f-2`
|
||||
MASTER_MINOR=$(git describe|cut -d. -f-2)
|
||||
TAG_MINOR=$(echo $TAG | cut -d. -f-2)
|
||||
|
||||
# If the tag is for an earlier version than master's, skip
|
||||
if [ "$(echo $(echo -e "$MASTER_MINOR\n$TAG_MINOR"|sort -V))" \
|
||||
|
@ -44,7 +44,7 @@ tx pull -f
|
||||
extract_messages_log "$PROJECT"
|
||||
|
||||
# Update existing translation files with extracted messages.
|
||||
PO_FILES=`find ${PROJECT}/locale -name "${PROJECT}.po"`
|
||||
PO_FILES=$(find ${PROJECT}/locale -name "${PROJECT}.po")
|
||||
if [ -n "$PO_FILES" ]; then
|
||||
# Use updated .pot file to update translations
|
||||
python setup.py $QUIET update_catalog \
|
||||
@ -55,7 +55,7 @@ fi
|
||||
# add the messages with the default keywords. Therefore use msgmerge
|
||||
# directly.
|
||||
for level in $LEVELS ; do
|
||||
PO_FILES=`find ${PROJECT}/locale -name "${PROJECT}-log-${level}.po"`
|
||||
PO_FILES=$(find ${PROJECT}/locale -name "${PROJECT}-log-${level}.po")
|
||||
if [ -n "$PO_FILES" ]; then
|
||||
for f in $PO_FILES ; do
|
||||
echo "Updating $f"
|
||||
|
@ -36,7 +36,7 @@ tx pull -f
|
||||
|
||||
# Update the .pot file
|
||||
python setup.py extract_messages
|
||||
PO_FILES=`find openstack_auth/locale -name '*.po'`
|
||||
PO_FILES=$(find openstack_auth/locale -name '*.po')
|
||||
if [ -n "$PO_FILES" ]; then
|
||||
# Use updated .pot file to update translations
|
||||
python setup.py update_catalog --no-fuzzy-matching --ignore-obsolete=true
|
||||
|
@ -59,7 +59,7 @@ for PROJECT in $(cat projects.txt); do
|
||||
if git branch -a | grep -q "^ remotes/origin/$ZUUL_REF$" ; then
|
||||
BRANCH=$ZUUL_REF
|
||||
elif echo $ZUUL_REF | grep -q "^stable/" ; then
|
||||
FALLBACK=`echo $ZUUL_REF | sed s,^stable/,proposed/,`
|
||||
FALLBACK=$(echo $ZUUL_REF | sed s,^stable/,proposed/,)
|
||||
if git branch -a | grep -q "^ remotes/origin/$FALLBACK$" ; then
|
||||
BRANCH=$FALLBACK
|
||||
fi
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
PROJECT=$1
|
||||
TARBALL_SITE=$2
|
||||
TAG=`echo $ZUUL_REF | sed 's/^refs.tags.//'`
|
||||
TAG=$(echo $ZUUL_REF | sed 's/^refs.tags.//')
|
||||
|
||||
# Look in the setup.cfg to determine if a package name is specified, but
|
||||
# fall back on the project name if necessary
|
||||
DISTNAME=`/usr/local/jenkins/slave_scripts/pypi-extract-name.py --tarball \
|
||||
|| echo $PROJECT`
|
||||
DISTNAME=$(/usr/local/jenkins/slave_scripts/pypi-extract-name.py --tarball \
|
||||
|| echo $PROJECT)
|
||||
FILENAME="$DISTNAME-$TAG.tar.gz"
|
||||
|
||||
rm -rf *tar.gz
|
||||
|
@ -19,14 +19,14 @@
|
||||
|
||||
PROJECT=$1
|
||||
TARBALL_SITE=$2
|
||||
TAG=`echo $ZUUL_REF | sed 's/^refs.tags.//'`
|
||||
TAG=$(echo $ZUUL_REF | sed 's/^refs.tags.//')
|
||||
|
||||
# Look in the setup.cfg to determine if a package name is specified, but
|
||||
# fall back on the project name if necessary
|
||||
DISTNAME=`/usr/local/jenkins/slave_scripts/pypi-extract-name.py --wheel \
|
||||
|| echo $PROJECT`
|
||||
DISTNAME=$(/usr/local/jenkins/slave_scripts/pypi-extract-name.py --wheel \
|
||||
|| echo $PROJECT)
|
||||
# Look in the setup.cfg to see if this is a universal wheel or not
|
||||
WHEELTYPE=`/usr/local/jenkins/slave_scripts/pypi-extract-universal.py`
|
||||
WHEELTYPE=$(/usr/local/jenkins/slave_scripts/pypi-extract-universal.py)
|
||||
FILENAME="$DISTNAME-$TAG-$WHEELTYPE-none-any.whl"
|
||||
|
||||
rm -rf *.whl
|
||||
|
@ -29,16 +29,16 @@ elif `echo $ZUUL_REFNAME | grep refs/tags/ >/dev/null` ; then
|
||||
# at BUILD_DIR remains. When Jenkins copies this file the root developer
|
||||
# docs are always the latest release with older tags available under the
|
||||
# root in the tagname dir.
|
||||
TAG=`echo $ZUUL_REFNAME | sed 's/refs.tags.//'`
|
||||
TAG=$(echo $ZUUL_REFNAME | sed 's/refs.tags.//')
|
||||
if [ ! -z $TAG ] ; then
|
||||
if echo $ZUUL_PROJECT | grep 'python-.*client' ; then
|
||||
# This is a hack to ignore the year.release tags in python-*client
|
||||
# projects.
|
||||
LATEST=`git tag | sed -n -e '/^2012\..*$/d' -e '/^\([0-9]\+\.\?\)\+$/p' | sort -V | tail -1`
|
||||
LATEST=$(git tag | sed -n -e '/^2012\..*$/d' -e '/^\([0-9]\+\.\?\)\+$/p' | sort -V | tail -1)
|
||||
else
|
||||
# Take all tags of the form (number.)+, sort them, then take the
|
||||
# largest
|
||||
LATEST=`git tag | sed -n '/^\([0-9]\+\.\?\)\+$/p' | sort -V | tail -1`
|
||||
LATEST=$(git tag | sed -n '/^\([0-9]\+\.\?\)\+$/p' | sort -V | tail -1)
|
||||
fi
|
||||
if [ "$TAG" = "$LATEST" ] ; then
|
||||
# Copy the docs into a subdir if this is a tagged build
|
||||
@ -56,7 +56,7 @@ elif `echo $ZUUL_REFNAME | grep stable/ >/dev/null` ; then
|
||||
# Put stable release changes in dir named after stable release under the
|
||||
# build dir. When Jenkins copies these files they will be accessible under
|
||||
# the developer docs root using the stable release's name.
|
||||
BRANCH=`echo $ZUUL_REFNAME | sed 's/stable.//'`
|
||||
BRANCH=$(echo $ZUUL_REFNAME | sed 's/stable.//')
|
||||
if [ ! -z $BRANCH ] ; then
|
||||
# Move the docs into a subdir if this is a stable branch build
|
||||
mkdir doc/build/$BRANCH
|
||||
|
@ -117,7 +117,7 @@ export PYTHON=$bin_path/python
|
||||
export NOSE_WITH_XUNIT=1
|
||||
export NOSE_WITH_HTML_OUTPUT=1
|
||||
export NOSE_HTML_OUT_FILE='nose_results.html'
|
||||
export TMPDIR=`/bin/mktemp -d`
|
||||
export TMPDIR=$(/bin/mktemp -d)
|
||||
trap "rm -rf $TMPDIR" EXIT
|
||||
|
||||
cat /etc/image-hostname.txt
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash -xe
|
||||
|
||||
mkdir -p target/
|
||||
/usr/bin/xmllint -noent $1 > target/`basename $1`
|
||||
/usr/bin/xmllint -noent $1 > target/$(basename $1)
|
||||
|
@ -37,7 +37,7 @@ setup_horizon
|
||||
git add ${PROJECT}/locale/en/LC_MESSAGES/*
|
||||
git add openstack_dashboard/locale/en/LC_MESSAGES/*
|
||||
|
||||
if [ `git diff --cached | egrep -v "(POT-Creation-Date|^[\+\-]#|^\+{3}|^\-{3})" | egrep -c "^[\-\+]"` -gt 0 ]; then
|
||||
if [ $(git diff --cached | egrep -v "(POT-Creation-Date|^[\+\-]#|^\+{3}|^\-{3})" | egrep -c "^[\-\+]") -gt 0 ]; then
|
||||
# Push source file changes to transifex
|
||||
tx --debug --traceback push -s
|
||||
fi
|
||||
|
@ -5,11 +5,11 @@
|
||||
#
|
||||
|
||||
# get version info from scm
|
||||
SCM_TAG=`git describe --abbrev=0 --tags` || true
|
||||
SCM_SHA=`git rev-parse --short HEAD` || true
|
||||
SCM_TAG=$(git describe --abbrev=0 --tags) || true
|
||||
SCM_SHA=$(git rev-parse --short HEAD) || true
|
||||
|
||||
# assumes format is like this '0.0.4-2-g135721c'
|
||||
COMMITS_SINCE_TAG=`git describe | awk '{split($0,a,"-"); print a[2]}'` || true
|
||||
COMMITS_SINCE_TAG=$(git describe | awk '{split($0,a,"-"); print a[2]}') || true
|
||||
|
||||
# just use git sha if there is no tag yet.
|
||||
if [[ "${SCM_TAG}" == "" ]]; then
|
||||
|
Loading…
Reference in New Issue
Block a user