#!/bin/sh
|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: bin/sde-create-tree
|
|
# Copyright (C) 2008 - 2009 The OpenSDE Project
|
|
#
|
|
# More information can be found in the files COPYING and README.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; version 2 of the License. A copy of the
|
|
# GNU General Public License can be found in the file COPYING.
|
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
|
|
|
#Description: Creates a new OpenSDE working tree
|
|
|
|
[ -n "$SDEROOT" ] ||
|
|
export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
|
|
|
|
. "$SDEROOT/lib/libsde.in"
|
|
|
|
create_usage() {
|
|
local progname=$(echo ${0##*/} | tr '-' ' ')
|
|
|
|
echo "Usage: $progname <dirname>"
|
|
}
|
|
|
|
create_origin()
|
|
{
|
|
if [ -d "$SDEROOT/.git/" ]; then
|
|
GIT_DIR="$SDEROOT/.git" git config remote.origin.url
|
|
fi
|
|
}
|
|
|
|
shortopts=''
|
|
longopts=''
|
|
options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
|
|
if [ $? -ne 0 ]; then
|
|
create_usage
|
|
exit -1
|
|
fi
|
|
|
|
# load new arguments list
|
|
eval set -- "$options"
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
|
|
--) shift; break ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# dirname
|
|
if [ $# -ne 1 ]; then
|
|
create_usage
|
|
exit 1
|
|
fi
|
|
|
|
here=$(pwd -P)
|
|
if [ "$SDEROOT" = "$here" ] || expr "$here" : "$SDEROOT/" > /dev/null; then
|
|
echo_abort 1 "Already inside a working tree."
|
|
fi
|
|
|
|
origin=$(create_origin)
|
|
origin="${origin:-git://git.opensde.net/opensde/opensde-nopast.git}"
|
|
target="$1"
|
|
|
|
echo_info "Cloning $origin"
|
|
if git clone "$origin" "$target"; then
|
|
cd "$target"
|
|
export SDEROOT="$(pwd -P)"
|
|
exec sde up
|
|
fi
|