diff options
author | stephen <stephen@FreeBSD.org> | 2011-07-01 04:52:08 +0800 |
---|---|---|
committer | stephen <stephen@FreeBSD.org> | 2011-07-01 04:52:08 +0800 |
commit | ff61be1523ad90380a4bd3bca83c2bacea0dbd33 (patch) | |
tree | 816f48907debe72e94701e86172ec126eb856fe8 /math | |
parent | cc126b9a210f41b261ab5ef3cd3252fd20962cb4 (diff) | |
download | freebsd-ports-graphics-ff61be1523ad90380a4bd3bca83c2bacea0dbd33.tar.gz freebsd-ports-graphics-ff61be1523ad90380a4bd3bca83c2bacea0dbd33.tar.zst freebsd-ports-graphics-ff61be1523ad90380a4bd3bca83c2bacea0dbd33.zip |
- Update math/octave-forge-base to 1.1. Now includes the script
load-octave-pkg to link the octave packaging system to the FreeBSD ports.
- Update Mk/bsd.octave.mk so that octave-forge-* ports use this script.
Approved by: gabor (mentor)
Diffstat (limited to 'math')
-rw-r--r-- | math/octave-forge-base/Makefile | 28 | ||||
-rw-r--r-- | math/octave-forge-base/files/load-octave-pkg.in | 224 | ||||
-rw-r--r-- | math/octave-forge-base/pkg-descr | 12 | ||||
-rw-r--r-- | math/octave-forge-base/pkg-plist | 10 |
4 files changed, 253 insertions, 21 deletions
diff --git a/math/octave-forge-base/Makefile b/math/octave-forge-base/Makefile index 5c00af3cc4c..fbf766f60bc 100644 --- a/math/octave-forge-base/Makefile +++ b/math/octave-forge-base/Makefile @@ -5,16 +5,8 @@ # $FreeBSD$ # -# The reason for this port is because the octave packaging system and the -# FreeBSD packaging system are not very robust. When it works, it works -# beautifully. But if something goes wrong, the octave packaging system -# can be left in a rather unusable stat. -# pkg_delete -r octave-forge-base-${PORTVERSION} -# gives the user an opportunity to start with a completely new slate. - PORTNAME= octave-forge-base -PORTVERSION= 1.0 -PORTREVISION= 4 +PORTVERSION= 1.1 CATEGORIES= math MASTER_SITES= #none DISTFILES= #none @@ -23,14 +15,24 @@ EXTRACT_ONLY= #none MAINTAINER= stephen@FreeBSD.org COMMENT= Octave-forge baseport for all packages -RUN_DEPENDS+= octave:${PORTSDIR}/math/octave +RUN_DEPENDS+= octave:${PORTSDIR}/math/octave \ + gmake:${PORTSDIR}/devel/gmake \ + p5-Archive-Tar>=0:${PORTSDIR}/archivers/p5-Archive-Tar \ + p5-IO-Zlib>=0:${PORTSDIR}/archivers/p5-IO-Zlib \ + p5-File-Remove>=0:${PORTSDIR}/devel/p5-File-Remove + +USE_PERL= yes +SUB_FILES= load-octave-pkg +SUB_LIST+= PERL=${PERL} do-build: @${DO_NADA} do-install: - ${MKDIR} ${LOCALBASE}/share/octave/tarballs - ${MKDIR} ${LOCALBASE}/share/octave/packages - ${MKDIR} ${LOCALBASE}/libexec/octave/packages + ${MKDIR} ${PREFIX}/share/octave/tarballs + ${MKDIR} ${PREFIX}/share/octave/packages + ${MKDIR} ${PREFIX}/libexec/octave/packages + ${INSTALL_SCRIPT} ${WRKDIR}/load-octave-pkg ${PREFIX}/libexec/octave + ${PREFIX}/libexec/octave/load-octave-pkg .include <bsd.port.mk> diff --git a/math/octave-forge-base/files/load-octave-pkg.in b/math/octave-forge-base/files/load-octave-pkg.in new file mode 100644 index 00000000000..50ffbaad3e8 --- /dev/null +++ b/math/octave-forge-base/files/load-octave-pkg.in @@ -0,0 +1,224 @@ +#!%%PERL%% -w + +# This script synchronizes the packages in $tardir with those installed by the +# octave packaging system. It uninstalls those packages for which it or its +# dependencies are not contained $tardir. It installs those packages for which +# it and its dependencies are in $tardir. Packages are uninstalled or +# installed in the correct order, so that dependency requirements are always +# satisfied. + +my $tardir = "%%PREFIX%%/share/octave/tarballs"; + +use strict; +use Archive::Tar; +use IO::Zlib; +use File::Remove qw(remove); + +# %long_form is a hash that does conversions like +# $long_form{"odepkg"} == "odepkg-0.8.8.tar.gz" + +my %long_form; +while (<$tardir/*>) { + if (!-l && /([^\/]+)$/) { + my $n = $1; + $n =~ /(.*)\-/; + $long_form{$1} = $n; + } +} +while (my $p = <%%PREFIX%%/share/octave/packages/*>) { + $p =~ s+.*/++; + $p =~ /(.*)\-/; + $long_form{$1} = "$p.tar.gz"; +} + +# Get the list of packages in $tardir. + +my %in_tarballs; +while (<$tardir/*>) { + if (!-l && /([^\/]+)$/) { + my $n = $1; + $in_tarballs{$n} = 1; + } +} + +my %is_installed; # Those packages that are installed. For these the hash + # returns a list of the packages requiring it. +my %to_remove; # Those packages that need to be uninstalled. For these + # the hash returns a list of the packages requiring it. +my $nr_to_remove; # The number of packages that need to be uninstalled. +my %to_install; # Those packages that remain to be installed. For these + # the hash returns a list of the dependencies. + +# Calculate which entries of %is_installed exist. + +%is_installed = (); +while (my $p = <%%PREFIX%%/share/octave/packages/*>) { + $p =~ s+.*/++; + $is_installed{"$p.tar.gz"} = ""; +} + +# Compare %is_installed with the output of pkg('list') in octave. If it is +# different then the octave packaging system is probably corrupt, so we clean +# out everything. + +my %check_installed; +open(O,"octave -H -q --no-site-file --eval \"pkg('list')\" |") || die; +<O>; +my $out = join "",<O>; +while ($out =~ s/^\s*(\S+)\s*\|\s*(\S+).*$//m) { + $check_installed{"$1-$2.tar.gz"} = ""; +} +close O; +foreach my $p (sort keys %is_installed) { + if (defined($is_installed{$p}) && !defined($check_installed{$p})) { + print "The octave packaging system is probably corrupt, so it will be rebuilt.\n"; + remove( \1, "%%PREFIX%%/libexec/octave/packages", + "%%PREFIX%%/share/octave/octave_packages", + "%%PREFIX%%/share/octave/packages"); + %is_installed = (); + last; + } +} + +# Fill in the values of %is_installed by checking the dependencies. + +while (my $p = <%%PREFIX%%/share/octave/packages/*>) { + $p =~ s+.*/++; + open(D,"%%PREFIX%%/share/octave/packages/$p/packinfo/DESCRIPTION") || die $!; + foreach my $l (<D>) { + if ($l=~s/Depends:\s*//) { + foreach my $ll (split ",",$l) { + chomp($ll); + $ll = lc($ll); + $ll =~ s/^\s+//; + $ll =~ s/\s.*//; + if (defined $long_form{$ll}) { + my $depends = $long_form{$ll}; + if (defined $is_installed{$depends}) { + $is_installed{$depends} .= ($is_installed{$depends} eq ""?"":"|")."$p.tar.gz"; + } + } + } + } + } + close D; +} + +# Find which packages need to be uninstalled. + +%to_remove = (); +$nr_to_remove = 0; +foreach (keys %is_installed) { + if (defined($is_installed{$_}) && !defined($in_tarballs{$_})) { + $to_remove{$_} = $is_installed{$_}; + $nr_to_remove++; + } +} + +if ($nr_to_remove>0) { + +# The function make_ordered_list_to_remove() is a recursive depth first +# search to put the packages to be removed in correct order according to +# dependency. The result is put into @ordered_list_to_remove. + + my @ordered_list_to_remove; + + sub make_ordered_list_to_remove { + foreach my $p (split /\|/,$_[0]) { + if (defined $to_remove{$p} || defined $is_installed{$p}) { + make_ordered_list_to_remove($is_installed{$p}); + push @ordered_list_to_remove,$p; + undef $to_remove{$p}; + undef $is_installed{$p}; + } + } + } + + + make_ordered_list_to_remove(join("|",sort keys %to_remove)); + +# Remove the packages that need to be uninstalled. + + foreach my $p (@ordered_list_to_remove) { + print "load-octave-pkg: octave is uninstalling $p.\n"; + $p =~ s/\-[\d\.]+\.tar\.gz//; + system "octave -H -q --no-site-file --eval \"pkg('uninstall','$p')\" > /dev/null"; + } +} + +# Clean out any crud that might be left over. + +my @pkg = <%%PREFIX%%/share/octave/packages/*>; +if ($#pkg==-1) { + print "load-octave-pkg: there are currently no octave packages installed.\n"; + remove( \1, "%%PREFIX%%/libexec/octave/packages", + "%%PREFIX%%/share/octave/octave_packages", + "%%PREFIX%%/share/octave/packages"); +} + +# Recalculate which entries of %is_installed exist. + +%is_installed = (); +while (my $p = <%%PREFIX%%/share/octave/packages/*>) { + $p =~ s+.*/++; + $is_installed{"$p.tar.gz"} = ""; +} + +# Calculate which packages need to be installed, and fill in the values of +# %is_tarballs by checking the dependencies. + +%to_install = (); +foreach (keys %in_tarballs) { + if (defined($in_tarballs{$_}) && !defined($is_installed{$_})) { + my $tar = Archive::Tar->new("$tardir/$_",COMPRESS_GZIP); + die if !defined($tar); + my @list_of_files = grep /^.*\/DESCRIPTION$/, $tar->list_files(); + die if $#list_of_files!=0; + my $descr = $tar->get_content($list_of_files[0]); + foreach my $l (split /\n/,$descr) { + if ($l=~s/Depends:\s*//) { + foreach my $ll (split ",",$l) { + $ll = lc($ll); + $ll =~ s/^\s+//; + $ll =~ s/\s.*//; + if ($ll ne "octave") { + $to_install{$_} .= (defined($to_install{$_})?"|":"").(defined($long_form{$ll})?$long_form{$ll}:$ll); + } + } + } + } + $to_install{$_} .= ""; + } +} + +# The function make_ordered_list_to_install() is a recursive depth first +# search to put the packages to be installed in correct order according to +# dependency. The result is put into @ordered_list_to_install. + +my @ordered_list_to_install; + +sub make_ordered_list_to_install { + my $retval = 1; + foreach my $p (split /\|/,$_[0]) { + if (!defined $in_tarballs{$p}) { + $retval = 0; + } elsif (defined $to_install{$p}) { + if (make_ordered_list_to_install($to_install{$p})) { + push @ordered_list_to_install,$p; + undef $to_install{$p}; + } else { + $retval = 0; + } + } + } + return $retval; +} + +make_ordered_list_to_install(join("|",sort keys %to_install)); + +# Now install the packages that need to be installed. + +foreach my $p (@ordered_list_to_install) { + print "load-octave-pkg: octave is installing $p.\n"; + system "octave -H -q --no-site-file --eval \"pkg('install','$tardir/$p')\" > /dev/null\n"; +} diff --git a/math/octave-forge-base/pkg-descr b/math/octave-forge-base/pkg-descr index 44089dbad7f..143b3ab6957 100644 --- a/math/octave-forge-base/pkg-descr +++ b/math/octave-forge-base/pkg-descr @@ -3,9 +3,13 @@ which is intended to be a central location for custom scripts, functions and extensions for GNU Octave. contains the source for all the functions plus build and install scripts. -This baseport provides the basic directory structure. Deleting this package -will completely erase all the structure, and remaining files, associated with -the octave packaging system. This is useful if things go wrong with the -octave packaging system. +This baseport provides the basic directory structure, and installs a script +"load-octave-pkg", that synchronizes the FreeBSD ports structure to the octave +packaging system. + +Another purpose of the script "load-octave-pkg" is to attempt to correct any +errors created by the octave packaging system. + +Also, deinstalling this port will completely clean the octave packages. WWW: http://octave.sourceforge.net/ diff --git a/math/octave-forge-base/pkg-plist b/math/octave-forge-base/pkg-plist index 327c41b4efc..ff9b91c283f 100644 --- a/math/octave-forge-base/pkg-plist +++ b/math/octave-forge-base/pkg-plist @@ -1,7 +1,9 @@ +libexec/octave/load-octave-pkg @exec mkdir -p %D/libexec/octave/packages @exec mkdir -p %D/share/octave/packages @exec mkdir -p %D/share/octave/tarballs -@unexec rm -rf %D/libexec/octave/packages 2>&1 >/dev/null || true -@unexec rm -f %D/share/octave/octave_packages 2>&1 >/dev/null || true -@unexec rm -rf %D/share/octave/packages 2>&1 >/dev/null || true -@unexec rm -rf %D/share/octave/tarballs 2>&1 >/dev/null || true +@exec %D/libexec/octave/load-octave-pkg +@unexec rm -rf %D/libexec/octave/packages >/dev/null 2>&1 || true +@unexec rm -f %D/share/octave/octave_packages >/dev/null 2>&1 || true +@unexec rm -rf %D/share/octave/packages >/dev/null 2>&1 || true +@dirrmtry share/octave/tarballs |