2005-06-24 22:13:57 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# $Source$
|
|
|
|
# $State$
|
|
|
|
|
|
|
|
# Set up default variables.
|
|
|
|
|
|
|
|
destdir=
|
|
|
|
srcdir=`pwd`
|
2016-06-02 10:35:38 +00:00
|
|
|
aal=/usr/local/bin/aal
|
2005-06-24 22:13:57 +00:00
|
|
|
delete=no
|
2007-02-25 20:56:41 +00:00
|
|
|
copy="ln"
|
2005-06-24 22:13:57 +00:00
|
|
|
|
|
|
|
# --- Options parsing -------------------------------------------------------
|
|
|
|
|
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case "$1" in
|
|
|
|
-s|--srcdir)
|
|
|
|
srcdir="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
-d|--destdir)
|
|
|
|
destdir="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
-x|--delete)
|
|
|
|
delete=yes
|
|
|
|
;;
|
|
|
|
|
|
|
|
-c|--copy)
|
2007-02-25 20:56:41 +00:00
|
|
|
copy="cp -Rp"
|
|
|
|
;;
|
|
|
|
|
|
|
|
-S|--symlink)
|
|
|
|
copy="ln -s"
|
2005-06-24 22:13:57 +00:00
|
|
|
;;
|
|
|
|
|
2016-06-02 10:35:38 +00:00
|
|
|
-a|--aal)
|
|
|
|
aal="$2"
|
2005-06-24 22:13:57 +00:00
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
-h|--help)
|
|
|
|
echo "mkdist [options]"
|
|
|
|
echo "Options are:"
|
|
|
|
echo " -s --srcdir <path> The CVS tree to read from. (default: CWD)"
|
|
|
|
echo " -d --destdir <path> The directory to create the distribution in."
|
|
|
|
echo " -x --delete Erase the destination directory first."
|
|
|
|
echo " -c --copy Make physical copies of the files. (default: hardlink)"
|
2007-02-25 20:56:41 +00:00
|
|
|
echo " -S --symlink Make symbolic links instead of copying or hardlinking."
|
2016-06-02 10:35:38 +00:00
|
|
|
echo " -a --aal <path> Where the ACK 'aal' tool is."
|
2005-06-24 22:13:57 +00:00
|
|
|
echo " -h --help Display this message."
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Unrecognised option. Try --help for help."
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2007-04-24 19:48:41 +00:00
|
|
|
if [ "$destdir" = "" ]; then
|
2005-06-24 22:13:57 +00:00
|
|
|
echo "You must specify a destination directory. (Try --help for help.)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# --- Main routines ---------------------------------------------------------
|
|
|
|
|
|
|
|
# These two routines do the work of traversing the source tree and building
|
|
|
|
# the distribution tree.
|
|
|
|
|
|
|
|
addfile() {
|
|
|
|
local f
|
|
|
|
f="${1##$srcdir/}"
|
|
|
|
mkdir -p $destdir/`dirname $f`
|
|
|
|
$copy "$1" "$destdir/$f"
|
|
|
|
}
|
|
|
|
|
|
|
|
process_dir() {
|
|
|
|
local path
|
|
|
|
local archivename
|
|
|
|
|
|
|
|
path=$1
|
|
|
|
cd $path
|
2007-02-24 02:05:56 +00:00
|
|
|
echo $PWD
|
2005-06-24 22:13:57 +00:00
|
|
|
|
|
|
|
# Look for a LIST file and cache the first line.
|
|
|
|
|
|
|
|
archivename=
|
|
|
|
if [ -f LIST ]; then
|
|
|
|
archivename=`head -1 LIST`
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in `cat $path/.distr`; do
|
2007-02-25 20:56:41 +00:00
|
|
|
case "$i" in
|
|
|
|
\#*) # Comment. Do nothing.
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
if [ -d $i ]; then
|
|
|
|
# This is a directory. Recurse into it.
|
|
|
|
|
|
|
|
( process_dir $path/$i )
|
|
|
|
elif [ -f $i ]; then
|
|
|
|
# This is a file.
|
|
|
|
|
|
|
|
addfile $path/$i
|
|
|
|
elif [ "$i" = "$archivename" ]; then
|
|
|
|
# Build the named archive.
|
2005-06-24 22:13:57 +00:00
|
|
|
|
2016-06-02 10:35:38 +00:00
|
|
|
$aal cDr `cat LIST`
|
2007-02-25 20:56:41 +00:00
|
|
|
addfile $path/$archivename
|
|
|
|
else
|
|
|
|
echo "Don't know what to do with $i, listed in $PWD/.distr."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2005-06-24 22:13:57 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# --- Main program ----------------------------------------------------------
|
|
|
|
|
2016-06-02 10:35:38 +00:00
|
|
|
# Test to make sure that $aal points to the right thing.
|
2005-06-24 22:13:57 +00:00
|
|
|
|
2016-06-02 10:35:38 +00:00
|
|
|
if !(strings $aal | grep archiver > /dev/null); then
|
|
|
|
echo "$aal does not seem to point at the ACK archiver tool."
|
2005-06-24 22:13:57 +00:00
|
|
|
echo ""
|
|
|
|
echo "Press RETURN to go ahead anyway, or CTRL+C to abort."
|
2007-04-24 19:48:41 +00:00
|
|
|
read ignored
|
2005-06-24 22:13:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Actually do the work.
|
|
|
|
|
|
|
|
echo "Creating distribution from CVS tree: $srcdir"
|
|
|
|
echo " into destination tree: $destdir"
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
if [ -e $destdir ]; then
|
2007-04-24 19:48:41 +00:00
|
|
|
if [ "$delete" = "yes" ]; then
|
2005-06-24 22:13:57 +00:00
|
|
|
echo "Press RETURN to erase $destdir and its contents, or CTRL+C to abort."
|
2013-05-15 22:46:15 +00:00
|
|
|
read _ _
|
2005-06-24 22:13:57 +00:00
|
|
|
echo "Erasing..."
|
|
|
|
rm -rf "$destdir"
|
|
|
|
else
|
|
|
|
echo "$destdir exists. Aborting."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Working..."
|
|
|
|
mkdir -p $destdir
|
|
|
|
process_dir $srcdir
|
|
|
|
echo "Done."
|
|
|
|
|
|
|
|
# Revision history
|
|
|
|
# $Log$
|
2007-04-24 19:48:41 +00:00
|
|
|
# Revision 1.5 2007-04-24 19:48:41 dtrg
|
|
|
|
# Removed bashish.
|
|
|
|
#
|
|
|
|
# Revision 1.4 2007/02/25 20:56:41 dtrg
|
2007-02-25 20:56:41 +00:00
|
|
|
# Performed major renovations to make the script work on OpenBSD.
|
|
|
|
#
|
|
|
|
# Revision 1.3 2007/02/24 02:05:56 dtrg
|
2007-02-24 02:05:56 +00:00
|
|
|
# Removed some bashish; added comment support; removed the make
|
|
|
|
# distr functionality, as nothing was using it any more and it was
|
|
|
|
# causing problems.
|
|
|
|
#
|
|
|
|
# Revision 1.2 2005/06/24 23:19:23 dtrg
|
2005-06-24 23:19:24 +00:00
|
|
|
# Added new mkdist tool.
|
2005-06-24 22:13:57 +00:00
|
|
|
#
|
2005-06-24 23:19:24 +00:00
|
|
|
# Revision 1.1 2005/06/24 22:13:57 dtrg
|
|
|
|
# Created new tool to generate distributions.
|