#!/bin/sh
# $Id: tlcom 75647 2025-06-29 22:08:13Z karl $
# Commit after TL package update. We rely on PATH to deal with trunk vs.
# branch (see c2a and c2b). See also libexec/ctan2tds for the real work
# of importing from CTAN; c2l and ctan2tl are additional wrappers
# (called by c2a).

if test $# -eq 0; then
  echo "$0: missing message argument." >&2
  exit 1
fi
msg=`echo "$1" | sed "s/^-m//"`
shift

# If no other args, cd / in case we're in a deleted directory.
# If there are other args, they might include "." or such, so don't cd.
test $# -eq 0 && cd /

# The commit will fail if we're in a deleted directory.
/bin/pwd >/dev/null || exit 1

dirlist=${TMPDIR-/tmp}/`id -u`.tlplace.dirs
tlroot=`tail -n 1 $dirlist | sed 's,/Master.*,,'`
if test ! -d "$tlroot/Master"; then
  echo "$0: failed to get tlroot from $dirlist: $tlroot" >&2
  exit 1
fi
echo "$tlroot"
sleep 1

svn commit -m"$msg" `cat $dirlist` \
  "$tlroot"/Master/tlpkg/bin/tlpkg-ctan-check \
  "$tlroot"/Master/tlpkg/bin/tlpkginfo \
  "$tlroot"/Master/tlpkg/libexec/ctan2tds \
  "$tlroot"/Master/tlpkg/bin/ctan2tl \
  "$tlroot"/Master/tlpkg/bin/c2lx \
  "$tlroot"/Master/tlpkg/tlpsrc/ \
  "$tlroot"/TODO \
  "$@"
