summaryrefslogtreecommitdiff
path: root/Master/Tools/ctan2tl
blob: 05eeaee221225af307b0b5383ee4e9f16613fdfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/sh
# $Id: //depot/Master/Tools/ctan2tl#23 $
# Public domain.  Originally written 2005, Karl Berry.
#
# Takes a ctan directory, pushes it into TL.  Just an initial attempt.
# --no-place to avoid final place invocation (p4 operations).
# See ./README for a bit more info.

mydir=`dirname $0`  # Master/Tools
cd $mydir/../../Build/cdbuild/raw || exit 1

if test "x$1" = x--place; then
  place=true
  shift
else
  place=false
fi

if test "x$1" = x--no-ctan; then
  copy_from_ctan=false
  shift
else
  copy_from_ctan=true
fi

if test ! -d $1; then
  echo "$0: $1 not a directory." >&2
  exit 1
fi

# xx this should be a separate script, also used by tpm-ctan-check.
pkg=`basename $1`

if $copy_from_ctan; then
case "$pkg" in
  biblio)	   pkg=beebe;;
  fourier-GUT)     pkg=fourier;;
  generic)	   pkg=genmisc;;  # $ctan/macros/generic
  ha-prosper)	   pkg=HA-prosper;;
  misc)		   pkg=ltxmisc;;  # until we do real misc package.
  tex-references)  pkg=tex-refs;;
  velthuis)	   pkg=devanagr;;
  voss)		   pkg=voss-de;;
esac

# lshort is arranged by language.
pkgdir=`dirname $1`
up=`basename $pkgdir`
test "$up" = lshort && pkg=lshort-$pkg

# esint is split into two.
test "$pkg" = esint && test "$up" = ps-type1 && pkg=esint-type1

# vntex is in an unpacked subdir.
test "$pkg" = unpacked && test "$up" = vntex && pkg=vntex

# similarly for powerdot.
test "$pkg" = distrib && test "$up" = powerdot && pkg=powerdot

# powerdot-doc-vn is a couple subdirs down.
test "$pkg" = doc-vn && test "$up" = contrib && pkg=powerdot-doc-vn

# amslatex/vietnamese.
test "$pkg" = vietnamese && test "$up" = amslatex && pkg=amsldoc-vn


# remove whatever old stuff we might have.
rm -rf $pkg

if test "$pkg" = genmisc; then
  # do not copy subdirs, symlinks, or any files but .sty and .tex
  # (that is, no patch.doc or pmat.zip).
  mkdir -p $pkg
  cp -p \
    `find $1/* '(' -type d -o -type l ')' -prune -o \
                   '(' -name '*.sty' -o -name *.tex ')' -print` \
    $pkg
else
  # normal case
  cp -pr $1 $pkg
fi

fi  # end of copying from CTAN.


printf "\n\f ctan2tds\n"
rm -rf ../cooked/$pkg
test -d ../cooked || mkdir ../cooked
../ctan2tds.pl $pkg || exit 1

cd ../cooked || exit 1
printf "\n\f cooked\n"
find -depth -type d | xargs rmdir 2>/dev/null
find $pkg \! -type d -printf "%TY%Tm%Td.%TH%TM %p\n" | sort +1

# compare to tpm.
Master=../../../Master
tpmfile=`ls $Master/texmf*/tpm/$pkg.tpm 2>/dev/null`
if test -z "$tpmfile"; then
  echo "$0: no tpm file for $pkg in `cd $Master; pwd`." >&2
else
  printf "\n\f compared to current tpm $tpmfile\n"
  rm -f /tmp/pkgfiles.*
  # remove leading text in case of lines starting with texmf.
  # Then assume all actual files do start with texmf.
  sed -n -e '/TPM:.*Files/,$s,^texmf,./texmf,p' $tpmfile \
  | grep -v '\.tpm$' \
  | sort >/tmp/pkgfiles.tpm
  #
  # list of files in the new package we've just cooked.
  (cd $pkg && find \! -type d -print) | grep -v '/cooked/' \
  | sort >/tmp/pkgfiles.tl
  #
  comm -3 /tmp/pkgfiles.tpm /tmp/pkgfiles.tl
fi

$place || exit 0

printf "\n\f place\n"
rm -rf $pkg.done
../place $pkg
p4 revert -a

rm -rf ../raw/$pkg