122 lines
2 KiB
Bash
Executable file
122 lines
2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
: ${DIALOG=dialog}
|
|
: ${SVNBASE=http://devel.egressive.com/egressive/drupal_contrib/modules}
|
|
|
|
norev=0
|
|
|
|
usage() {
|
|
cat <<EOT
|
|
|
|
Usage: $0 [ -h ] [ -r rev ] [ -R ] module
|
|
|
|
Add a module to svn:externals in the current working directory
|
|
|
|
-h - Show this help
|
|
-r rev - Pin at revision 'rev'. Default is most recent change.
|
|
-R - Do not pin at any revision.
|
|
|
|
EOT
|
|
}
|
|
|
|
while getopts "hRr:" opt
|
|
do
|
|
case ${opt} in
|
|
h)
|
|
usage
|
|
exit 0
|
|
;;
|
|
r)
|
|
revision=${OPTARG}
|
|
;;
|
|
R)
|
|
norev=1
|
|
;;
|
|
*)
|
|
usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
shift $(( $OPTIND - 1 ))
|
|
|
|
if [ `basename $PWD` != 'modules' ]
|
|
then
|
|
echo "ERR: You must be in a directory named 'modules' to run this script"
|
|
exit 1
|
|
fi
|
|
|
|
module=$1
|
|
|
|
if [ $# -gt 1 ]
|
|
then
|
|
echo "ERR: Too many arguments"
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "${module}" ]
|
|
then
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
set -e
|
|
|
|
mod_dir=${SVNBASE}/${module}
|
|
|
|
for branch in `svn list ${mod_dir}`
|
|
do
|
|
choices="${choices} ${branch} ${branch}"
|
|
done
|
|
|
|
if [ -z "${choices}" ]
|
|
then
|
|
echo "ERR: Unable to find any branches under ${mod_dir}"
|
|
exit 1
|
|
fi
|
|
|
|
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
|
|
trap "rm -f $tempfile" 0 1 2 5 15
|
|
|
|
$DIALOG --clear --title "Select Branch" \
|
|
--menu "Please select an appropriate branch for your drupal version\n" 0 0 0 \
|
|
$choices 2> $tempfile
|
|
|
|
retval=$?
|
|
|
|
choice=`cat $tempfile`
|
|
|
|
case $retval in
|
|
0)
|
|
echo "'$choice' chosen."
|
|
;;
|
|
1)
|
|
echo "Cancel pressed."
|
|
exit
|
|
;;
|
|
255)
|
|
echo "ESC pressed."
|
|
exit
|
|
;;
|
|
esac
|
|
|
|
mod_dir="${mod_dir}/${choice}"
|
|
|
|
if [ -z "${revision}" ]
|
|
then
|
|
revision=`svn info ${mod_dir} | awk -F: '/^Last Changed Rev/{print $2}'`
|
|
fi
|
|
|
|
if [ $norev -eq 0 ]
|
|
then
|
|
revision_string="-r${revision}"
|
|
fi
|
|
|
|
modline="${module} ${revision_string} ${mod_dir}"
|
|
|
|
externals=`(svn propget svn:externals . | sed -e "/^${module} /d" ; echo $modline) | sort`
|
|
svn propset svn:externals "${externals}" .
|
|
|
|
echo "Added ${modline} to svn:externals, run 'svn update'"
|