From fbb4d165a9dc6b9e04270e21b4a1bc471922c2a5 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 20 Jun 2007 09:24:45 +0000 Subject: add first versions of ctan2tl and place for new infrastructure delete strnage ctan2tl.new which I once adapted git-svn-id: svn://tug.org/texlive/trunk@4481 c570f23f-e606-0410-a88d-b1316a301751 --- Build/cdbuild/place.newinfra | 262 +++++++++++++++++++++++++++++++++++++++++++ Build/tools/ctan2tl.new | 168 --------------------------- Build/tools/ctan2tl.newinfra | 153 +++++++++++++++++++++++++ 3 files changed, 415 insertions(+), 168 deletions(-) create mode 100755 Build/cdbuild/place.newinfra delete mode 100755 Build/tools/ctan2tl.new create mode 100755 Build/tools/ctan2tl.newinfra (limited to 'Build') diff --git a/Build/cdbuild/place.newinfra b/Build/cdbuild/place.newinfra new file mode 100755 index 00000000000..35820be9c12 --- /dev/null +++ b/Build/cdbuild/place.newinfra @@ -0,0 +1,262 @@ +#!/usr/bin/env perl +# $Id: place 2045 2006-08-27 18:21:49Z karl $ +# License: public domain. Originally written by Sebastian Rahtz. +# +# Process a tree in the Build/cdbuild/cooked directory (probably created +# by ctan2tds.pl) and integrate into the main texmf trees. +# +# Basic usage: place PKG +# to process Build/cdbuild/cooked/PKG. + +BEGIN { + chomp ($mydir = `dirname $0`); + unshift (@INC, "$mydir/../../Master/tlpkg"); +} + +use File::Basename; +use File::Find; +use Cwd; +use TeXLive::TLPSRC; +use TeXLive::TLPOBJ; +use TeXLive::TLPDB; +use TeXLive::TLTREE; + +$newpackage = 0; +%dirs = (); # dirs we make changes in + +if ($ARGV[0] eq "-n") { + $chicken = 1; + shift; +} else { + $chicken = 0; +} +print "place: chicken mode = $chicken\n"; + +die "usage: $0 PKGNAME\n" unless @ARGV == 1; +$package = $ARGV[0]; + +xchdir (dirname($0) . "/cooked"); +$mydir = getcwd(); +-d "$mydir/$package" || die "$0: No such package in $mydir: $package\n"; + +xchdir ("../../../Master"); +$M = getcwd(); + +xchdir ("$mydir/$package"); +if (-d "texmf-dist") {$Root="texmf-dist"; } +elsif (-d "texmf-doc") {$Root="texmf-doc"; } +elsif (-d "texmf") {$Root="texmf"; } + + +# initialize TLPDB +my $tlpdb = new TeXLive::TLPDB ( location => "$M/texlive.tlpdb" ); + +# get package from TLPDB; +my $tlp = $tlpdb->get_package("$package"); +if (defined($tlp)) { + # what to do with binfiles, but they are not place-ed!!! + foreach ($tlp->srcfiles, $tlp->runfiles, $tlp->docfiles) { + $Old{$_} = 1; + } +} else { + $newpackage = 1; +} +# TLP REPLACES: +# get list of existing files +#my $listsfile = "$M/texmf/lists/$package"; +#if (-f $listsfile) { +# open (LIST, $listsfile) || die "open($listsfile) failed: $!"; +# while () { +# chomp; +# s/\r$//; +# $Old{$_} = 1 if /^[A-z]/; +# } +# close (LIST); +#} +#else { +# $newpackage=1; +#} + +&xchdir ("$mydir/$package"); +find (\&files,"."); +foreach $file (sort keys %Old) { + print "* $file: [retained=$New{$file}]\n"; + + # and if the file does not exist, don't try to remove it -- we + # probably did so by hand and didn't bother to update the tpm. + next unless -f "$M/$file"; + + # don't remove tpm or lists file, they won't be in the new package. + if (! $New{$file} && $file !~ /\.tpm$/ && $file !~ m,/lists/[^/]+$,) { + &my_system ("svn remove $M/$file"); + } + $dirs{dirname ("$M/$file")}++; +} + +# copy files +my $Job = "tar cf - . | (cd $M && tar xf - )"; +&my_system ($Job); + +# sort so dirs will be added before subdirs. +foreach $file (sort keys %New) { + if (! $Old{$file}) { + &add_file ("$M/$file"); + } +} + +my $tpmdir = "$M/$Root/tpm"; + +xchdir ($mydir); +&my_system ("mv $package $package.done"); + +if ($Root eq 'texmf-doc') { + $Type = 'Documentation'; +} elsif ($Root eq 'texmf-dist') { + $Type = 'Package'; +} else { + die "cannot handle Root=$Root"; +} + +chomp (my $tools = `cd $mydir/../../tools && pwd`); + +# TLP removed +#$SETUP = "$tools/tpm-factory.pl --master=$M --tpm_dir=$tpmdir" +# . " --ftp_dir=/var/tmp --arch=all --patterns=auto" +# . " --name=$Type/$package"; + +# TLP changed: +my $tlpsrc = TeXLive::TLPSRC; +if (! -r "$M/tlpkg/tlpsrc/$package.tlpsrc") { + $tlpsrc->name("$package"); + $tlpsrc->category($Type); + if (!$chicken) { + open TMP, ">$M/tlpkg/tlpsrc/$package.tlpsrc" or die "Cannot open tlpsrc file!"; + $tlpsrc->writeout(\*TMP); + close TMP + } +} + +# TLP replaces +# create tpm if needed +#&my_system ("perl $SETUP --new") unless -f "$tpmdir/$package.tpm"; + +# update tpm +#&my_system ("perl $SETUP --clean"); + +# create/update lists file +#&my_system ("xsltproc --stringparam ROOT $M" +# . " $tools/tpm2list.xsl $M/$Root/tpm/$package.tpm"); + + +# add tpm and lists files after they are created. +if ($newpackage) { + # TLP MISSING, do we generate the list file? + #&add_file ($listsfile); + # TLP changed + &add_file ("$M/tlpkg/tlpsrc/$package.tlpsrc"); + #&add_file ("$tpmdir/$package.tpm"); +} + +# these two dirs will essentially always change, so just list them. +$dirs{"$M/tlpkg/tlpsrc/$package.tlpsrc"}++; +#$dirs{$tpmdir}++; +#$dirs{"$M/texmf/lists"}++; + +# print dirs with changed files, for svn commit purposes. +# if other files have been modified in those same dirs, though, this +# won't detect it. It would be better to list exactly the *files* which +# should be committed, but ... lazy. +# +# also write dir list to a separate file, for easy passing to a commit. +# +$DIRLIST = ">" . ($ENV{"TMPDIR"} || "/tmp") . "/tlplace.dirs"; +open (DIRLIST) || die "open($DIRLIST) failed: $!"; +# +for my $dir (sort keys %dirs) { + print "$dir\n"; + print DIRLIST "$dir\n"; +} +# +close (DIRLIST) || warn "close($DIRLIST) failed: $!"; + +exit (0); + + + +#-------------------------------------- +sub dirs +{ + local @filenames; + if (-d) { + @filenames=&buildfilelist($File::Find::name); + if (!@filenames) { rmdir $File::Find::name;} + }} + +sub buildfilelist +{ + my($me) = @_; + my @files; + opendir(DIR,$me) || cleanup ("cannot open directory $me"); + @files =grep(!/^\.\.?/,readdir(DIR)); + closedir(DIR); + return @files; +} + + +sub files +{ + if (-f) { + $This=$File::Find::name; + $This =~ s/^\.\///; + $New{$This}=1; + } +} + + +# add a file to the repository. for svn, we also have to add the +# containing dir, and the parent of that dir, if they are new. +# (Should really just traverse ) +# +sub add_file +{ + my ($newfile) = @_; + + my $newdir = dirname ($newfile); + + # when it's needed, parent must come first, else have svn "not working copy". + my $parentdir = dirname ($newdir); + unless (-d "$parentdir/.svn") { + &my_system ("svn add -N $parentdir"); + $dirs{$parentdir}++; + } + + unless (-d "$newdir/.svn") { + &my_system ("svn add -N $newdir"); + } + + &my_system ("svn add $newfile"); + + # remember that we changed this directory. + $dirs{$newdir}++; +} + + +sub xchdir +{ + my ($dir) = @_; + chdir ($dir) || die "chdir($dir) failed: $!"; + print "place: chdir($dir)\n"; +} + + +sub my_system +{ + my ($cmd) = @_; + + print "place: SYSTEM $cmd\n"; + + unless ($chicken) { + my $ret = system ($cmd); + die "`$cmd' failed, status=$ret, goodbye\n" if $ret != 0; + } +} diff --git a/Build/tools/ctan2tl.new b/Build/tools/ctan2tl.new deleted file mode 100755 index 1a486865b34..00000000000 --- a/Build/tools/ctan2tl.new +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/sh -# $Id: ctan2tl 2084 2006-09-05 22:03:38Z karl $ -# Public domain. Originally written 2005, Karl Berry. -# -# Initial attempt at pushing a ctan directory into TL. -# See ./README for a bit more info. -# -# Basic usage: ctan2tl TLPKGNAME -# --place to include final `place' invocation (repository adds/removes). -# --no-ctan if already have files in ../cdbuild/raw/PKG. -# Unlikely to work without GNU utilities. -# -# This does not actually commit anything to the repository. Without -# --place, it doesn't even create any files in the repository outside of -# cdbuild/{raw,cooked}. - -unset CDPATH # avoid extraneous output - -mydir=`cd \`dirname $0\` && pwd` # Build/tools -raw=$mydir/../cdbuild/raw -test -d $raw || mkdir $raw -cd $raw || exit 1 - -if test "x$1" = x--place; then - place_chicken= - shift -else - place_chicken=-n -fi - -if test "x$1" = x--no-ctan; then - copy_from_ctan=false - shift -else - copy_from_ctan=true -fi - -pkg=$1 -if test -z "$pkg"; then - echo "$0: no TL package name specified." >&2 - exit 1 -fi - -ctan_dir1=`tlpkginfo --ctan-dir $pkg` -if test -z "$ctan_dir1"; then - echo "$0: can't find CTAN directory for $pkg." >&2 - exit 1 -fi -echo "$0: ctan dir for $pkg is $ctan_dir1" - -if $copy_from_ctan; then - -# remove whatever old stuff we might have. -rm -rf $pkg - -# An important special case: the latex-tds project contains tds-ready -# zip files for the base latex distribution and amslatex. -# We want to use them. -corelatex_tds_pkglist="babel|cyrillic|graphics|latex|psnfss|tools" -amslatex_tds_pkglist="ams|amscls|amsltx2|amsmath|amsrefs" # dup in tlpkginfo -latex_tds_pkglist="latex-tds|$amslatex_tds_pkglist|$corelatex_tds_pkglist" - -if echo "$pkg" | egrep "^($latex_tds_pkglist)\$" >/dev/null; then - mkdir $pkg - ctan_root=`tlpkginfo --ctan-root` - # - # complications: the latex-tds package, for our purposes, is the - # sources for the tools that do the process; that's in the zip file - # source.zip, in the latex-tds directory. Similarly, the zip file for - # latex itself is named "base.zip". Finally, amslatex.zip actually - # contains several packages (= directories) -- such as ams, amscls, - # etc. AMS sets it up that way. - # - if test $pkg = latex-tds; then - zipname=source.zip - elif test $pkg = latex; then - zipname=base.zip - elif echo "$pkg" | egrep "^($amslatex_tds_pkglist)\$" >/dev/null; then - zipname=amslatex.zip - else - zipname=$pkg.zip - fi - (cd $pkg && unzip -qq $ctan_root/macros/latex/contrib/latex-tds/$zipname) - -elif test "$pkg" = rsc; then - # single bst file. - mkdir -p $pkg - cp -p $ctan_dir1 $pkg - -elif 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 $ctan_dir1/* '(' -type d -o -type l ')' -prune -o \ - '(' -name '*.sty' -o -name *.tex ')' -print` \ - $pkg - -else - # normal case (/. to deref symlinks, e.g., arabtex) - cp -pr $ctan_dir1/. $pkg -fi - -# Another special case: annoyingly, tugboat plain and tugboat latex are -# stored in two different places on ctan. we'll assume we're invoked -# with the latex dir, and now arrange to also copy in the plain stuff to -# a `plain' subdirectory, which ctan2tds.pl has a further special case -# to handle. Maybe we'll come across other cases like this, in which -# case we can generalize this. -# -if test "$pkg" = tugboat; then - ctan_dir2=`echo $ctan_dir1 | sed s/latex/plain/` - destdir2=$pkg/plain - cp -r $ctan_dir2 $destdir2 -fi - -fi # end of copying from CTAN. - - -# -printf "\n 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 -r +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 "\nBEGIN COMPARE DATA" - printf "\n\f new vs. present $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.new - # - comm -3 /tmp/pkgfiles.new /tmp/pkgfiles.tpm - # - for common_file in `comm -12 /tmp/pkgfiles.new /tmp/pkgfiles.tpm`; do - diff --ignore-all-space -u0 $Master/$common_file $pkg/$common_file - done >/tmp/tldiff - diff_lines=`wc -l &2 + exit 1 +fi + +ctan_dir1=`tlpkginfo --ctan-dir $pkg` +if test -z "$ctan_dir1"; then + echo "$0: can't find CTAN directory for $pkg." >&2 + exit 1 +fi +echo "$0: ctan dir for $pkg" +echo "$0: is $ctan_dir1" + +if $copy_from_ctan; then + +# remove whatever old stuff we might have. +rm -rf $pkg + +# An important special case: the latex-tds project contains tds-ready +# zip files for the base latex distribution and amslatex. +# We want to use them. +corelatex_tds_pkglist="babel|cyrillic|graphics|latex|psnfss|tools" +amslatex_tds_pkglist="ams|amscls|amsltx2|amsmath|amsrefs" # dup in tlpkginfo +latex_tds_pkglist="latex-tds|$amslatex_tds_pkglist|$corelatex_tds_pkglist" + +if echo "$pkg" | egrep "^($latex_tds_pkglist)\$" >/dev/null; then + mkdir $pkg + ctan_root=`tlpkginfo --ctan-root` + # + # complications: the latex-tds package, for our purposes, is the + # sources for the tools that do the process; that's in the zip file + # source.zip, in the latex-tds directory. Similarly, the zip file for + # latex itself is named "base.zip". Finally, amslatex.zip actually + # contains several packages (= directories) -- such as ams, amscls, + # etc. AMS sets it up that way. + # + if test $pkg = latex-tds; then + zipname=source.zip + elif test $pkg = latex; then + zipname=base.zip + elif echo "$pkg" | egrep "^($amslatex_tds_pkglist)\$" >/dev/null; then + zipname=amslatex.zip + else + zipname=$pkg.zip + fi + (cd $pkg && unzip -qq $ctan_root/macros/latex/contrib/latex-tds/$zipname) + +elif 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 $ctan_dir1/* '(' -type d -o -type l ')' -prune -o \ + '(' -name '*.sty' -o -name *.tex ')' -print` \ + $pkg + +else + # normal case (/. to deref symlinks, e.g., arabtex) + cp -pr $ctan_dir1/. $pkg +fi + +fi # end of copying from CTAN. + + +# +printf "\n 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 -r +1 + +# compare to tpm. +Master=../../../Master +. $Master/tlpkg/lib/TeXLiveInfra.sh +tpmfile=`ls $Master/texmf*/tpm/$pkg.tpm 2>/dev/null` +if ! grep -q "^name $pkg" $Master/texlive.tlpdb ; then + echo "$0: not present in $Master/texlive.tlpdb" >&2 +else + printf "\n\f new vs. present $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. + tldb_tlp_get_srcfiles $Master/texlive.tlpdb $pkg > /tmp/pkgfiles.tpm.foo + tldb_tlp_get_runfiles $Master/texlive.tlpdb $pkg >> /tmp/pkgfiles.tpm.foo + tldb_tlp_get_docfiles $Master/texlive.tlpdb $pkg >> /tmp/pkgfiles.tpm.foo + sort /tmp/pkgfiles.tpm.foo >/tmp/pkgfiles.tpm + # + # list of files in the new package we've just cooked. + (cd $pkg && find \! -type d -print) | grep -v '/cooked/' \ + | sed -e 's,^\./,,' | sort >/tmp/pkgfiles.new + # + comm -3 /tmp/pkgfiles.new /tmp/pkgfiles.tpm + # + comm -12 /tmp/pkgfiles.new /tmp/pkgfiles.tpm >/tmp/tldiff.com + # + for common_file in `cat /tmp/tldiff.com`; do + diff --ignore-all-space -u -U 0 $Master/$common_file $pkg/$common_file + done >/tmp/tldiff + diff_lines=`wc -l