#!/bin/sh

# Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Remove old versioned directories from an .app bundle.  The built-up bundle
# only needs to contain the current versioned directory.

set -e

if [ $# -ne 1 ] ; then
  echo "usage: ${0} VERSION" >& 2
  exit 1
fi

VERSION="${1}"
CONTENTS_DIR="${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}"
VERSIONED_DIR="${CONTENTS_DIR}/Versions"
CURRENT_VERSIONED_DIR="${VERSIONED_DIR}/${VERSION}"

for dir in "${VERSIONED_DIR}/"* ; do
  if [ "${dir}" != "${CURRENT_VERSIONED_DIR}" ] ; then
    rm -rf "${dir}"
  fi
done
