Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Fix bash lint with shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeyeager committed Feb 24, 2017
1 parent 4a28111 commit eb49b3d
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 85 deletions.
8 changes: 4 additions & 4 deletions examples/fine-tuning/create_dataset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ NEW_DATASET_DIR=$1
MNIST_DIR=$2

# create new dataset directories
mkdir -p $NEW_DATASET_DIR/odd
mkdir -p $NEW_DATASET_DIR/even
mkdir -p "$NEW_DATASET_DIR/odd"
mkdir -p "$NEW_DATASET_DIR/even"

# create symbolic links
for digit in 0 2 4 6 8
do cp $MNIST_DIR/$digit/*.png $NEW_DATASET_DIR/even/
do cp "$MNIST_DIR/$digit/*.png" "$NEW_DATASET_DIR/even/"
done
for digit in 1 3 5 7 9
do cp $MNIST_DIR/$digit/*.png $NEW_DATASET_DIR/odd/
do cp "$MNIST_DIR/$digit/*.png" "$NEW_DATASET_DIR/odd/"
done

32 changes: 16 additions & 16 deletions examples/semantic-segmentation/prepare_pascal_voc_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ if [ "$#" -ne 2 ]; then
exit 1
fi

tmp_dir=`pwd`/tmp_files
tmp_dir="$(pwd)/tmp_files"

mkdir -p ${tmp_dir}
mkdir -p "$tmp_dir"

pascal_archive=$1
output_dir=$2

echo "Expanding ${pascal_archive}"

tar xf ${pascal_archive} -C ${tmp_dir}
tar xf "$pascal_archive" -C "$tmp_dir"

pascal_dir=${tmp_dir}/VOCdevkit/VOC2012
pascal_dir="${tmp_dir}/VOCdevkit/VOC2012"

echo "Copying data into ${output_dir}"

rm -rf ${output_dir}
rm -rf "$output_dir"

for stage in 'train' 'val'
do
echo "Processing ${stage} data"
imageset_file=${pascal_dir}/ImageSets/Segmentation/${stage}.txt
image_dir=${pascal_dir}/JPEGImages
label_dir=${pascal_dir}/SegmentationClass
imageset_file="${pascal_dir}/ImageSets/Segmentation/${stage}.txt"
image_dir="${pascal_dir}/JPEGImages"
label_dir="${pascal_dir}/SegmentationClass"

output_image_dir=${output_dir}/${stage}/images/
output_label_dir=${output_dir}/${stage}/labels/
output_image_dir="${output_dir}/${stage}/images/"
output_label_dir="${output_dir}/${stage}/labels/"

mkdir -p ${output_image_dir}
mkdir -p ${output_label_dir}
mkdir -p "$output_image_dir"
mkdir -p "$output_label_dir"

while read -r file; do
cp "${image_dir}/${file}.jpg" ${output_image_dir};
cp "${label_dir}/${file}.png" ${output_label_dir};
done < ${imageset_file}
cp "${image_dir}/${file}.jpg" "$output_image_dir"
cp "${label_dir}/${file}.png" "$output_label_dir"
done <"$imageset_file"
done

rm -rf ${tmp_dir}
rm -rf "$tmp_dir"

echo "Done!"
44 changes: 22 additions & 22 deletions packaging/deb/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

LOCAL_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
SRC_DIR=$(dirname "$(dirname "$LOCAL_DIR")")
cd $SRC_DIR
cd "$SRC_DIR"

################################################################################
### Check for basic requirements
Expand Down Expand Up @@ -50,13 +50,13 @@ echo "DEBIAN_REVISION: $DEBIAN_REVISION"
################################################################################

MODULE_VERSION=$(python -c "execfile('${SRC_DIR}/digits/version.py'); print __version__")
echo MODULE_VERSION: $MODULE_VERSION
GIT_TAG=v${MODULE_VERSION}
if [ $(git tag -l $GIT_TAG | wc -l) -ne 1 ]; then
echo MODULE_VERSION: "$MODULE_VERSION"
GIT_TAG="v${MODULE_VERSION}"
if [ "$(git tag -l "$GIT_TAG" | wc -l)" -ne 1 ]; then
echo "$GIT_TAG is not a git tag"
exit 1
fi
DESCRIBE_VERSION=$(git describe --match $GIT_TAG)
DESCRIBE_VERSION=$(git describe --match "$GIT_TAG")
UPSTREAM_VERSION=${DESCRIBE_VERSION:1}
if [[ "$GIT_TAG" == *"-"* ]]; then
# Replace the first dash with a tilde
Expand All @@ -66,35 +66,35 @@ fi
UPSTREAM_VERSION=${UPSTREAM_VERSION/-/+}
# Replace all dashes with dots
UPSTREAM_VERSION=${UPSTREAM_VERSION//-/.}
echo UPSTREAM_VERSION: $UPSTREAM_VERSION
DEBIAN_VERSION=${UPSTREAM_VERSION}-${DEBIAN_REVISION}
echo DEBIAN_VERSION: $DEBIAN_VERSION
echo UPSTREAM_VERSION: "$UPSTREAM_VERSION"
DEBIAN_VERSION="${UPSTREAM_VERSION}-${DEBIAN_REVISION}"
echo DEBIAN_VERSION: "$DEBIAN_VERSION"

################################################################################
# Create source tarball
################################################################################

TARBALL_DIR="${LOCAL_DIR}/tarball/"
rm -rf $TARBALL_DIR
mkdir -p $TARBALL_DIR
git archive --prefix "digits/" -o $TARBALL_DIR/digits.orig.tar.gz HEAD
rm -rf "$TARBALL_DIR"
mkdir -p "$TARBALL_DIR"
git archive --prefix "digits/" -o "${TARBALL_DIR}/digits.orig.tar.gz" HEAD

################################################################################
# Build
################################################################################

cd $LOCAL_DIR
cd "$LOCAL_DIR"
DOCKER_BUILD_ID="digits-debuild"
docker build --pull -t $DOCKER_BUILD_ID \
--build-arg UPSTREAM_VERSION=$UPSTREAM_VERSION \
--build-arg DEBIAN_VERSION=$DEBIAN_VERSION \
docker build --pull -t "$DOCKER_BUILD_ID" \
--build-arg UPSTREAM_VERSION="$UPSTREAM_VERSION" \
--build-arg DEBIAN_VERSION="$DEBIAN_VERSION" \
.
docker ps -a -f "name=${DOCKER_BUILD_ID}" -q | xargs -r docker rm
docker create --name=$DOCKER_BUILD_ID $DOCKER_BUILD_ID
docker create --name="$DOCKER_BUILD_ID" "$DOCKER_BUILD_ID"
DIST_ROOT=$LOCAL_DIR/dist
DIST_DIR=$LOCAL_DIR/dist/$DEBIAN_VERSION
rm -rf $DIST_DIR
mkdir -p $DIST_ROOT
docker cp $DOCKER_BUILD_ID:/dist $DIST_DIR
docker rm $DOCKER_BUILD_ID
find $DIST_DIR -type f | sort
DIST_DIR="${LOCAL_DIR}/dist/${DEBIAN_VERSION}"
rm -rf "$DIST_DIR"
mkdir -p "$DIST_ROOT"
docker cp "${DOCKER_BUILD_ID}:/dist" "$DIST_DIR"
docker rm "$DOCKER_BUILD_ID"
find "$DIST_DIR" -type f | sort
4 changes: 2 additions & 2 deletions scripts/travis/bust-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
set -e
set -x

WEEK=`date +%Y-%W`
WEEK=$(date +%Y-%W)

# Loop over command-line arguments
for cache_dir
do
if [ -e "$cache_dir" ]; then
cache_version=`cat ${cache_dir}/cache-version.txt || echo '???'`
cache_version=$(cat ${cache_dir}/cache-version.txt || echo '???')
if [ "$WEEK" != "$cache_version" ]; then
echo "Busting old cache (${cache_version}) at $cache_dir ..."
rm -rf $cache_dir
Expand Down
18 changes: 9 additions & 9 deletions scripts/travis/install-caffe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ then
exit 1
fi

INSTALL_DIR=`readlink -f $1`
$LOCAL_DIR/bust-cache.sh $INSTALL_DIR
INSTALL_DIR=$(readlink -f "$1")
"$LOCAL_DIR/bust-cache.sh" "$INSTALL_DIR"
if [ -d "$INSTALL_DIR" ] && [ -e "$INSTALL_DIR/build/tools/caffe" ]; then
echo "Using cached build at $INSTALL_DIR ..."
exit 0
fi
rm -rf $INSTALL_DIR
rm -rf "$INSTALL_DIR"

CAFFE_FORK=${CAFFE_FORK:-"NVIDIA"}
if [ ! -z "$CAFFE_BRANCH" ]; then
Expand All @@ -26,17 +26,17 @@ fi
set -x

# get source
git clone https://github.com/${CAFFE_FORK}/caffe.git ${INSTALL_DIR} ${CAFFE_BRANCH} --depth 1
git clone "https://github.com/${CAFFE_FORK}/caffe.git" "$INSTALL_DIR" $CAFFE_BRANCH --depth 1

# configure project
mkdir -p ${INSTALL_DIR}/build
cd ${INSTALL_DIR}/build
mkdir -p "${INSTALL_DIR}/build"
cd "${INSTALL_DIR}/build"
cmake .. -DCPU_ONLY=On -DBLAS=Open

# build
make --jobs=`nproc`
make --jobs="$(nproc)"

# mark cache
WEEK=`date +%Y-%W`
echo $WEEK > ${INSTALL_DIR}/cache-version.txt
WEEK=$(date +%Y-%W)
echo "$WEEK" > "${INSTALL_DIR}/cache-version.txt"

16 changes: 8 additions & 8 deletions scripts/travis/install-openblas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ then
exit 1
fi

INSTALL_DIR=`readlink -f $1`
if [ -d "$INSTALL_DIR" ] && ls $INSTALL_DIR/*.so >/dev/null 2>&1; then
INSTALL_DIR=$(readlink -f "$1")
if [ -d "$INSTALL_DIR" ] && ls "$INSTALL_DIR/*.so" >/dev/null 2>&1; then
echo "Using cached build at $INSTALL_DIR ..."
else
rm -rf $INSTALL_DIR
git clone https://github.com/xianyi/OpenBLAS.git ${INSTALL_DIR} -b v0.2.18 --depth 1
cd $INSTALL_DIR
rm -rf "$INSTALL_DIR"
git clone https://github.com/xianyi/OpenBLAS.git "$INSTALL_DIR" -b v0.2.18 --depth 1
cd "$INSTALL_DIR"

# Redirect build output to a log and only show it if an error occurs
# Otherwise there is too much output for TravisCI to display properly
LOG_FILE=$LOCAL_DIR/openblas-build.log
make NO_AFFINITY=1 USE_OPENMP=1 >$LOG_FILE 2>&1 || (cat $LOG_FILE && false)
LOG_FILE="$LOCAL_DIR/openblas-build.log"
make NO_AFFINITY=1 USE_OPENMP=1 >"$LOG_FILE" 2>&1 || (cat "$LOG_FILE" && false)
fi

cd $INSTALL_DIR
cd "$INSTALL_DIR"
sudo make install PREFIX=/usr/local
31 changes: 16 additions & 15 deletions scripts/travis/install-torch.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
#!/bin/bash
# Copyright (c) 2015-2017, NVIDIA CORPORATION. All rights reserved.
set -e

Expand All @@ -10,35 +10,36 @@ then
exit 1
fi

INSTALL_DIR=`readlink -f $1`
$LOCAL_DIR/bust-cache.sh $INSTALL_DIR
INSTALL_DIR=$(readlink -f "$1")
"${LOCAL_DIR}/bust-cache.sh" "$INSTALL_DIR"
if [ -d "$INSTALL_DIR" ] && [ -e "$INSTALL_DIR/install/bin/th" ]; then
echo "Using cached build at $INSTALL_DIR ..."
exit 0
fi
rm -rf $INSTALL_DIR
rm -rf "$INSTALL_DIR"

export MAKEFLAGS="-j$(nproc)"
NUMTHREADS=$(nproc)
export MAKEFLAGS="-j$NUMTHREADS"

set -x

# get source
git clone https://github.com/torch/distro.git $INSTALL_DIR --recursive
cd $INSTALL_DIR
git clone https://github.com/torch/distro.git "$INSTALL_DIR" --recursive
cd "$INSTALL_DIR"

# Redirect build output to a log and only show it if an error occurs
# Otherwise there is too much output for TravisCI to display properly
LOG_FILE=$LOCAL_DIR/torch-install.log
./install.sh -b >$LOG_FILE 2>&1 || (cat $LOG_FILE && false)
LOG_FILE="$LOCAL_DIR/torch-install.log"
./install.sh -b >"$LOG_FILE" 2>&1 || (cat "$LOG_FILE" && false)

# install custom packages
${INSTALL_DIR}/install/bin/luarocks install tds
"${INSTALL_DIR}/install/bin/luarocks" install tds
# you can't just install "hdf5" because it will install "lua-hdf5" instead of "torch-hdf5"
${INSTALL_DIR}/install/bin/luarocks install "https://raw.github.com/deepmind/torch-hdf5/master/hdf5-0-0.rockspec"
${INSTALL_DIR}/install/bin/luarocks install "https://raw.github.com/Neopallium/lua-pb/master/lua-pb-scm-0.rockspec"
${INSTALL_DIR}/install/bin/luarocks install lightningmdb 0.9.18.1-1 LMDB_INCDIR=/usr/include LMDB_LIBDIR=/usr/lib/x86_64-linux-gnu
"${INSTALL_DIR}/install/bin/luarocks" install "https://raw.github.com/deepmind/torch-hdf5/master/hdf5-0-0.rockspec"
"${INSTALL_DIR}/install/bin/luarocks" install "https://raw.github.com/Neopallium/lua-pb/master/lua-pb-scm-0.rockspec"
"${INSTALL_DIR}/install/bin/luarocks" install lightningmdb 0.9.18.1-1 LMDB_INCDIR=/usr/include LMDB_LIBDIR=/usr/lib/x86_64-linux-gnu

# mark cache
WEEK=`date +%Y-%W`
echo $WEEK > ${INSTALL_DIR}/cache-version.txt
WEEK=$(date +%Y-%W)
echo "$WEEK" >"${INSTALL_DIR}/cache-version.txt"

16 changes: 8 additions & 8 deletions scripts/travis/ppa-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ PPA_NAME=$1
LOCAL_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ROOT_DIR=$( dirname "$(dirname "$LOCAL_DIR")")

cd $ROOT_DIR/packaging/deb
cd "$ROOT_DIR/packaging/deb"
set +x # double-check that x is unset
openssl aes-256-cbc -in private.key.enc -out private.key -d \
-K $encrypted_34c893741e32_key -iv $encrypted_34c893741e32_iv
-K "$encrypted_34c893741e32_key" -iv "$encrypted_34c893741e32_iv"
gpg --import private.key

cd $ROOT_DIR/packaging/deb/dist/*trusty
debsign -k 97A4B458 *source.changes
dput -U ppa:nvidia-digits/${PPA_NAME}/ubuntu/trusty *source.changes
cd "$ROOT_DIR/packaging/deb/dist/*trusty"
debsign -k 97A4B458 ./*source.changes
dput -U "ppa:nvidia-digits/${PPA_NAME}/ubuntu/trusty" ./*source.changes

cd $ROOT_DIR/packaging/deb/dist/*xenial
debsign -k 97A4B458 *source.changes
dput -U ppa:nvidia-digits/${PPA_NAME}/ubuntu/xenial *source.changes
cd "$ROOT_DIR/packaging/deb/dist/*xenial"
debsign -k 97A4B458 ./*source.changes
dput -U "ppa:nvidia-digits/${PPA_NAME}/ubuntu/xenial" ./*source.changes
2 changes: 1 addition & 1 deletion scripts/travis/pypi-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e
LOCAL_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
ROOT_DIR=$( dirname "$(dirname "$LOCAL_DIR")")

cd $ROOT_DIR
cd "$ROOT_DIR"
set +x # double-check that x is unset
cat > ~/.pypirc << EOF
[pypi]
Expand Down

0 comments on commit eb49b3d

Please sign in to comment.