summaryrefslogtreecommitdiff
path: root/Master/tlpkg
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2007-06-16 16:40:35 +0000
committerNorbert Preining <preining@logic.at>2007-06-16 16:40:35 +0000
commit743cca7613b9a0948fa316f703a5861b4ba4e516 (patch)
treedcf1336c07536754972ef8214e96f7d04d205f6a /Master/tlpkg
parent8e0118f7fbebfae6bab089e5d7b16fb86d3a5deb (diff)
reshuffle and clean up
git-svn-id: svn://tug.org/texlive/trunk@4442 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg')
-rw-r--r--Master/tlpkg/bin/create-package-list.pl23
-rw-r--r--Master/tlpkg/bin/create_tlp_simple.pl30
-rw-r--r--Master/tlpkg/bin/tlp2tldb.pl82
-rw-r--r--Master/tlpkg/bin/tlsrc2tlp.pl114
-rw-r--r--Master/tlpkg/bin/updater.pl80
-rw-r--r--Master/tlpkg/doc/Shell-API.txt37
-rw-r--r--Master/tlpkg/doc/list-file-format.txt33
-rw-r--r--Master/tlpkg/lib/TeXLiveInfra.sh264
8 files changed, 663 insertions, 0 deletions
diff --git a/Master/tlpkg/bin/create-package-list.pl b/Master/tlpkg/bin/create-package-list.pl
new file mode 100644
index 00000000000..1f2b4906b39
--- /dev/null
+++ b/Master/tlpkg/bin/create-package-list.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/env perl -w
+#
+# create-package-list.pl
+# Create thepackage list of the current installation
+# Copyright 2007 Norbert Preining
+#
+# This file is licensed under the GNU General Public Licence version 2
+# or any later version
+
+use strict;
+
+use TLDB;
+use Data::Dumper;
+
+my $TLRoot = ".";
+my $tldblocation = "$TLRoot/local.tldb";
+
+my $tldb = TLDB->new;
+$tldb->from_file($tldblocation);
+
+$tldb->generate_packagelist;
+
+
diff --git a/Master/tlpkg/bin/create_tlp_simple.pl b/Master/tlpkg/bin/create_tlp_simple.pl
new file mode 100644
index 00000000000..e8911e190ae
--- /dev/null
+++ b/Master/tlpkg/bin/create_tlp_simple.pl
@@ -0,0 +1,30 @@
+#!/usr/bin/env perl -w
+
+use strict;
+use lib '../new-infra';
+
+use TLSRC;
+use TLP;
+use TLTREE;
+use Data::Dumper;
+
+#our $opt_debug=1;
+
+my $tltree = TLTREE->new( 'svnroot' => "/src/TeX/texlive-svn/Master" );
+print "Initializing tltree start: ", `date`;
+$tltree->init_from_statusfile("/src/TeX/texlive-svn/Master/svn.status");
+print "Initializing tltree stop: ", `date`;
+
+foreach my $f (@ARGV) {
+ my $tlsrc = new TLSRC;
+ $tlsrc->from_file($f);
+ print "WORKING ON $f\n";
+ my $tlp = $tlsrc->make_tlp($tltree);
+ my $name = $tlp->name;
+ open(FOO,">tlp/$name.tlp");
+ $tlp->writeout_simple(\*FOO);
+ close(FOO);
+}
+
+
+print "End of operation: ", `date`;
diff --git a/Master/tlpkg/bin/tlp2tldb.pl b/Master/tlpkg/bin/tlp2tldb.pl
new file mode 100644
index 00000000000..0d70aff7423
--- /dev/null
+++ b/Master/tlpkg/bin/tlp2tldb.pl
@@ -0,0 +1,82 @@
+#!/usr/bin/env perl -w
+#
+# tlp2tldb.pl
+# convert a set of tlp files (given as arguments) into a tldb
+# Copyright 2007 Norbert Preining
+#
+# This file is licensed under the GNU General Public Licence version 2
+# or any later version
+#
+
+BEGIN {
+ ($mydir = $0) =~ s,/[^/]*$,,;
+ unshift (@INC, $mydir);
+}
+
+use strict;
+
+use TLP;
+use TLDB;
+use Getopt::Long;
+use Pod::Usage;
+use File::Path;
+
+our $opt_debug = 0;
+my $man = 0;
+my $help = 0;
+
+GetOptions("debug!", 'help|?' => \$help, man => \$man) or pod2usage(2);
+
+pod2usage(1) if $help;
+pod2usage(-exitstatus => 0, -verbose => 2) if $man;
+
+my $tldb = TLDB->new;
+foreach my $f (@ARGV) {
+ my $tlp = new TLP;
+ $tlp->from_file($f);
+ $tldb->add_tlp($tlp);
+}
+$tldb->writeout;
+
+
+__END__
+
+=head1 NAME
+
+tlp2tldb - Converting tlp files into a tldb file
+
+=head1 SYNOPSIS
+
+tlp2tldb [options] [tlsrcfiles ...]
+
+ Options:
+ -help brief help message
+ -man full documentation
+ -debug get debug messages from TL* modules
+
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<-help>
+
+Print a brief help message and exits.
+
+=item B<-man>
+
+Prints the manual page and exits.
+
+=item B<-debug>
+
+Give debug messages from the TeX Live modules
+
+=back
+
+=head1 DESCRIPTION
+
+B<tlp2tldb> converts TeX Live Package (tlp) files into TeX Live Database
+(tldb).
+
+=cut
+
diff --git a/Master/tlpkg/bin/tlsrc2tlp.pl b/Master/tlpkg/bin/tlsrc2tlp.pl
new file mode 100644
index 00000000000..2c888af4e68
--- /dev/null
+++ b/Master/tlpkg/bin/tlsrc2tlp.pl
@@ -0,0 +1,114 @@
+#!/usr/bin/env perl -w
+#
+# tlsrc2tlp.pl
+# convert a set of tlsrc files (given as arguments) into tlp
+# Copyright 2007 Norbert Preining
+#
+# This file is licensed under the GNU General Public Licence version 2
+# or any later version
+#
+
+BEGIN {
+ ($mydir = $0) =~ s,/[^/]*$,,;
+ unshift (@INC, $mydir);
+}
+
+use strict;
+
+use TLSRC;
+use TLP;
+use TLTREE;
+use Getopt::Long;
+use Pod::Usage;
+use File::Path;
+
+
+my $opt_master = "/src/TeX/texlive-svn/Master";
+my $opt_outputdir = "./tlp";
+our $opt_debug = 0;
+my $man = 0;
+my $help = 0;
+
+GetOptions("debug!", # debug mode
+ "master=s" => \$opt_master, # location of the tree
+ "outputdir=s" => \$opt_outputdir,
+ 'help|?' => \$help, man => \$man
+ ) or pod2usage(2);
+
+pod2usage(1) if $help;
+pod2usage(-exitstatus => 0, -verbose => 2) if $man;
+
+if (! -d "$opt_master") {
+ die "Master $opt_master does not exists!";
+}
+
+if (! -d "$opt_outputdir") {
+ mkpath("$opt_outputdir") or die "Cannot mkdir $opt_outputdir!";
+}
+
+my $tltree = TLTREE->new( 'svnroot' => "$opt_master" );
+$tltree->init_from_svn;
+
+foreach my $f (@ARGV) {
+ my $tlsrc = new TLSRC;
+ $tlsrc->from_file($f);
+ my $tlp = $tlsrc->make_tlp($tltree);
+ my $name = $tlp->name;
+ open(FOO,">$opt_outputdir/$name.tlp") or die "Cannot create $opt_outputdir/$name.tlp!";
+ $tlp->writeout(\*FOO);
+ close(FOO);
+}
+
+
+__END__
+
+=head1 NAME
+
+tlsrc2tlp - Converting tlsrc files into tlp files
+
+=head1 SYNOPSIS
+
+tlsrc2tlp [options] [tlsrcfiles ...]
+
+ Options:
+ -help brief help message
+ -man full documentation
+ -master=s set Master of TeX Live tree
+ -outputdir=s specify the directory where tlp files are created
+ -debug get debug messages from TL* modules
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<-help>
+
+Print a brief help message and exits.
+
+=item B<-man>
+
+Prints the manual page and exits.
+
+=item B<-master>
+
+The location given by B<-master> must point to a valid svn repository
+of TeX Live Master direcory. Defaults to /src/TeX/texlive-svn/Master
+
+=item B<-outputdir>
+
+Specifies the location where tlp files are created. Defaults to ./tlp
+
+=item B<-debug>
+
+Give debug messages from the TeX Live modules
+
+=back
+
+=head1 DESCRIPTION
+
+B<tlsrc2tlp> converts TeX Live Source (tlsrc) files into TeX Live Package
+files (tlp).
+
+=cut
+
+
diff --git a/Master/tlpkg/bin/updater.pl b/Master/tlpkg/bin/updater.pl
new file mode 100644
index 00000000000..1f161ec619b
--- /dev/null
+++ b/Master/tlpkg/bin/updater.pl
@@ -0,0 +1,80 @@
+#!/usr/bin/env perl -w
+#
+# updater.pl
+# test implementation of an update program
+# Copyright 2007 Norbert Preining
+#
+# This file is licensed under the GNU General Public Licence version 2
+# or any later version
+
+use strict;
+
+use TLP;
+use TLDB;
+
+my $TEXLIVEROOT = ".";
+my $tldblocation = "$TEXLIVEROOT/local.tldb";
+
+# setting the location at new time also initializes the tldb!
+my $tldb = TLDB->new ( location => $tldblocation );
+
+# read package/revision list from stdin
+# format: package revision
+# later on this should be read from the tug.org server to get the
+# information which packages/revisions are available on the net.
+
+my %netavailable;
+while (<>) {
+ chomp;
+ next if m/^\s*#/;
+ if (m/^(\w+)\s+(\d+)$/) {
+ $netavailable{$1} = $2;
+ } else {
+ die "Wrong format of package list: $_!";
+ }
+}
+
+foreach (keys %netavailable) {
+ my $localrev = $tldb->package_revision($_);
+ if ($localrev) {
+ # the package is installed
+ if ($localrev < $netavailable{$_}) {
+ update_one_package($_,$localrev,$netavailable{$_});
+ }
+ }
+}
+
+
+sub update_one_package {
+ my ($pkgname,$localrev,$netrev) = @_;
+ print "update local/$localrev -> net/$netrev\n";
+ return 1;
+ # ideas on implementation
+ # - make temporary directory
+ # - cd there
+ # - get package to be updated
+ # - unpack it there
+ # - check the included tlp/$package.tlp for NOT satisfied dependencies
+ my $newtlp = TLP->new;
+ $newtlp->from_file("tlp/$pkgname.tlp");
+ my @deps = $newtlp->depends;
+ # - if there are unsatisfied deps
+ # . for each unsatisfied dep do
+ # update_one_package (in the same dir should work)
+ # - collect all actions to be carried out from the tlps
+ # - cp -a * TEXLIVEROOT (this installs all updated packages)
+ # - update mktexlsr
+ # - call actions
+ # - update tldb
+ $tldb->add_tlp($newtlp);
+ $tldb->save;
+ # - remove temporary directory
+}
+
+
+### Local Variables:
+### perl-indent-level: 4
+### tab-width: 4
+### indent-tabs-mode: t
+### End:
+# vim:set tabstop=4: #
diff --git a/Master/tlpkg/doc/Shell-API.txt b/Master/tlpkg/doc/Shell-API.txt
new file mode 100644
index 00000000000..b4bae1b6448
--- /dev/null
+++ b/Master/tlpkg/doc/Shell-API.txt
@@ -0,0 +1,37 @@
+API for Shell interface for new infra
+=====================================
+
+bash will be used, POSIX maybe later
+
+
+Module TLP
+----------
+
+Read/Write functions (with argument set, without arg read)
+
+ tlp_get_{name,category,revision,shortdesc,longdesc,catalogue} $tlpfile
+ gets the respective field of the TLP
+ tlp_get_{src,doc,run}files $tlpfile
+ gets the list of {src,doc,run}files
+ tlp_get_{src,doc,run}size $tlpfile
+ gets the of the respective group of files
+ tlp_get_available_archs $tlpfile
+ returns the list of archs present in $tlpfile for binfiles
+ tlp_get_binfiles $tlpfle $arch
+ gets the list of binfiles for $arch
+ tlp_get_binsize $tlpfile $arch
+ gets the size of binfiles for $arch
+ tlp_get_{depends,executes} $tlpfile
+ returns a list depends/executes
+
+
+Module TLDB
+-----------
+ all function under TLP can be used with a tldb_ prefix:
+ tldb_tlp_get_{name,category,revision,...} $tldbfile "packagename"
+ gets the respective field of the TLP
+
+ tldb_list_installed_packages $tldbfile
+
+ what else do we need?
+
diff --git a/Master/tlpkg/doc/list-file-format.txt b/Master/tlpkg/doc/list-file-format.txt
new file mode 100644
index 00000000000..72306b1dc77
--- /dev/null
+++ b/Master/tlpkg/doc/list-file-format.txt
@@ -0,0 +1,33 @@
+for collections:
+================
+first line
+ *Title: title
+second line
+ *Size: size-in-bytes
++name
+ included Packages/TPM
+ depending TLCore/TPM
+[a-zA-A0-9]+
+ included file
+
+for schemes:
+============
+first line
+ *Title: title
+second line
+ *Size: size-in-bytes
++name
+ included Packages/TPM
+-name
+ included TLCore/TPM
+
+
+all
+===
+!addMap name.map
+!addMixedMap name.map
+!BuildFormat name
+!BuildLanguageDat name
+
+
+
diff --git a/Master/tlpkg/lib/TeXLiveInfra.sh b/Master/tlpkg/lib/TeXLiveInfra.sh
new file mode 100644
index 00000000000..e4a6500dd64
--- /dev/null
+++ b/Master/tlpkg/lib/TeXLiveInfra.sh
@@ -0,0 +1,264 @@
+#
+# TeXLiveInfra.sh
+# shell library for the access to TLDB and TLP
+#
+# Copyright 2007 Norbert Preining
+#
+# This file is licensed under the GNU General Public Licence version 2
+# or any later version
+#
+
+die() {
+ echo $*
+ exit 1
+}
+
+test_tlp() {
+ tlpfile="$1"
+ if [ ! -r "$tlpfile" ] ; then
+ die "tlp file not readable: $tlpfile"
+ fi
+}
+
+# we read the whole tlp again and again
+# if we could use some multi-line grepping this could be speed up
+# but I guess we would need perl regexp grepping
+# BETTER: use an awk program for this, but I am not able to write
+# such an awk program. And do we have it available everywhere?
+_tlp_get_multi() {
+ entry="$1"
+ tlpfile="$2"
+ arch="$3"
+ test_tlp "$tlpfile"
+ ( SAVEDIFS=$IFS ; IFS= ; cat "$tlpfile" | __tlp_get_multi "$entry" "$arch" )
+}
+__tlp_get_multi() {
+ entry="$1"
+ arch="$2"
+ if [ "$arch" = "" ] ; then
+ pat="$entry*"
+ else
+ pat="$entry*arch=$arch*"
+ fi
+ reading_multi=0
+ while read line ; do
+ case "$line" in
+ $pat)
+ reading_multi=1
+ ;;
+ \ *)
+ if [ $reading_multi = 1 ] ; then
+ ( IFS=$SAVEDIFS ; echo $line )
+ fi
+ ;;
+ *)
+ if [ $reading_multi = 1 ] ; then
+ # we already have read the interesting part, return now
+ return
+ fi
+ ;;
+ esac
+ done
+}
+
+_tlp_get_multi_simple() {
+ entry="$1"
+ tlpfile="$2"
+ test_tlp "$tlpfile"
+ grep "^$entry" "$tlpfile" | sed -e "s@^$entry[ \t]*@@"
+}
+
+_tlp_get_simple() {
+ entry="$1"
+ tlpfile="$2"
+ field="$3"
+ prefix="$4"
+ test_tlp "$tlpfile"
+ cat "$tlpfile" | __tlp_get_simple $entry $field $prefix
+}
+
+__tlp_get_simple() {
+ entry="$1"
+ field="$2"
+ prefix="$3"
+ if [ "$field" = "" ] ; then
+ grep -m 1 "^$entry " | sed -e "s@^$entry[ \t]*@@" | sed -e "s@^$prefix@@"
+ else
+ grep -m 1 "^$entry " | awk "{print\$${field}}" | sed -e "s@^$prefix@@"
+ fi
+}
+
+tlp_get_name()
+{
+ _tlp_get_simple name "$1"
+}
+tlp_get_revision()
+{
+ _tlp_get_simple revision "$1"
+}
+tlp_get_category ()
+{
+ _tlp_get_simple category "$1"
+}
+tlp_get_shortdesc ()
+{
+ _tlp_get_simple shortdesc "$1"
+}
+tlp_get_catalogue ()
+{
+ _tlp_get_simple catalogue "$1"
+}
+tlp_get_longdesc ()
+{
+ _tlp_get_multi longdesc "$1"
+}
+tlp_get_depends ()
+{
+ _tlp_get_multi_simple depend "$1"
+}
+tlp_get_executes ()
+{
+ _tlp_get_multi_simple execute "$1"
+}
+tlp_get_srcfiles ()
+{
+ _tlp_get_multi srcfiles "$1"
+}
+tlp_get_docfiles () {
+ _tlp_get_multi docfiles "$1"
+}
+tlp_get_runfiles () {
+ _tlp_get_multi runfiles "$1"
+}
+tlp_get_srcsize () {
+ _tlp_get_simple srcfiles "$1" 2 "size="
+}
+tlp_get_docsize ()
+{
+ _tlp_get_simple docfiles "$1" 2 "size="
+}
+tlp_get_runsize ()
+{
+ _tlp_get_simple runfiles "$1" 2 "size="
+}
+
+tlp_get_binsize ()
+{
+ tlpfile="$1"
+ arch="$2"
+ _tlp_get_simple "binfiles[ \t]*arch=$arch" "$1" 3 "size="
+}
+tlp_get_binfiles ()
+{
+ _tlp_get_multi binfile "$1" "$2"
+}
+
+tlp_get_available_arch ()
+{
+ test_tlp "$tlpfile"
+ grep 'binfiles[ \t]*arch=' "$tlpfile" | awk '{print$2}' | sed -e 's/arch=//'
+}
+
+test_tldb() {
+ tldbfile="$1"
+ if [ ! -r "$tldbfile" ] ; then
+ die "tldb file not readable: $tldbfile"
+ fi
+}
+
+_tldb_tlp_get_multi()
+{
+ tldb="$1"
+ tlp="$2"
+ entry="$3"
+ arch="$4"
+ test_tldb "$tldb"
+ foundpackage=0
+ ( SAVEDIFS=$IFS ; IFS= ; while read line ; do
+ case "$line" in
+ name\ $tlp*)
+ foundpackage=1
+ __tlp_get_multi $entry $arch
+ ;;
+ *)
+ if [ $foundpackage = 1 ] ; then
+ return
+ fi
+ ;;
+ esac
+ done ) <$tldb
+}
+_tldb_tlp_get_simple()
+{
+ tldb="$1"
+ tlp="$2"
+ entry="$3"
+ field="$4"
+ prefix="$5"
+ test_tldb "$tldb"
+ foundpackage=0
+ ( SAVEDIFS=$IFS ; IFS= ; while read line ; do
+ case "$line" in
+ name\ $tlp*)
+ foundpackage=1
+ __tlp_get_simple $entry $field $prefix
+ ;;
+ *)
+ if [ $foundpackage = 1 ] ; then
+ return
+ fi
+ ;;
+ esac
+ done ) <$tldb
+}
+
+
+tldb_tlp_get_revision()
+{
+ _tldb_tlp_get_simple "$1" "$2" revision "$3" "$4"
+}
+tldb_tlp_get_category ()
+{
+ _tldb_tlp_get_simple "$1" "$2" category "$3" "$4"
+}
+tldb_tlp_get_shortdesc ()
+{
+ _tldb_tlp_get_simple "$1" "$2" shortdesc "$3" "$4"
+}
+tldb_tlp_get_catalogue ()
+{
+ _tldb_tlp_get_simple "$1" "$2" catalogue "$3" "$4"
+}
+tldb_tlp_get_longdesc ()
+{
+ _tldb_tlp_get_multi "$1" "$2" longdesc "$3"
+}
+tldb_tlp_get_srcfiles ()
+{
+ _tldb_tlp_get_multi "$1" "$2" srcfiles "$3"
+}
+tldb_tlp_get_docfiles () {
+ _tldb_tlp_get_multi "$1" "$2" docfiles "$3"
+}
+tldb_tlp_get_runfiles () {
+ _tldb_tlp_get_multi "$1" "$2" runfiles "$3"
+}
+tldb_tlp_get_binfiles ()
+{
+ _tldb_tlp_get_multi "$1" "$2" binfile "$3"
+}
+
+tldb_get_installed_packages ()
+{
+ tldb="$1"
+ test_tldb "$tldb"
+ grep ^name "$tldb" | awk '{print$2}'
+}
+
+
+### Local Variables:
+### perl-indent-level: 4
+### tab-width: 4
+### indent-tabs-mode: t
+### End:
+# vim:set tabstop=4: #