# HG changeset patch # User Rik # Date 1301630257 25200 # Node ID 0ade5992e3744e08c4f133ac30d0f2f94d1ff12a # Parent d6ad4ed57dda75604b46efd868ba39516d385b96 Add documentation for '-forge' option (bug #32464). diff -r d6ad4ed57dda -r 0ade5992e374 scripts/ChangeLog --- a/scripts/ChangeLog Thu Mar 31 20:24:06 2011 -0700 +++ b/scripts/ChangeLog Thu Mar 31 20:57:37 2011 -0700 @@ -1,3 +1,9 @@ +2011-03-31 Rik + + * pkg/module.mk, pkg/pkg.m, pkg/private/get_forge_pkg.m: Add + documentation for '-forge' option (bug #32464). Make get_forge_pkg + a private function. + 2011-03-31 Marco Caliari * sparse/spdiags.m: Treat empty vector (1x0 or 0x1) the same as diag(). diff -r d6ad4ed57dda -r 0ade5992e374 scripts/pkg/get_forge_pkg.m --- a/scripts/pkg/get_forge_pkg.m Thu Mar 31 20:24:06 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -## Copyright (C) 2010-2011 VZLU Prague, a.s. -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {[@var{ver}, @var{url}] =} get_forge_pkg (@var{name}) -## Tries to discover the current version of an OctaveForge package from the web, -## using a working internet connection and the urlread function. -## If two output arguments are requested, returns also an address to download -## the file. -## @end deftypefn - -function [ver, url] = get_forge_pkg (name) - if (nargin != 1) - print_usage (); - endif - ## Verify that name is valid. - if (! (ischar (name) && rows (name) == 1 && ndims (name) == 2)) - error ("get_forge_pkg: package NAME must be a string"); - elseif (! all (isalnum (name) | name == "-" | name == "." | name == "_")) - error ("get_forge_pkg: invalid package name: %s", name); - endif - - name = tolower (name); - - ## Try to download package's index page. - [html, succ] = urlread (sprintf ("http://octave.sourceforge.net/%s/index.html", name)); - if (succ) - ## Remove blanks for simpler matching. - html(isspace(html)) = []; - ## Good. Let's grep for the version. - pat = "PackageVersion:([\\d.]*)"; - t = regexp (html, pat, "tokens"); - if (isempty (t) || isempty(t{1})) - error ("get_forge_pkg: could not read version number from package's page"); - else - ver = t{1}{1}; - if (nargout > 1) - # Build download string. - urlbase = "http://downloads.sourceforge.net/octave/%s-%s.tar.gz?download"; - url = sprintf (urlbase, name, ver); - ## Verify that the string exists on the page. - if (isempty (strfind (html, url))) - warning ("get_forge_pkg: download URL not verified"); - endif - endif - endif - else - ## Try get the list of all packages. - [html, succ] = urlread ("http://octave.sourceforge.net/packages.php"); - if (succ) - t = regexp (html, "
", "tokens"); - t = horzcat (t{:}); - if (any (strcmp (t, name))) - error ("get_forge_pkg: package NAME exists, but index page not available"); - else - ## Try a simplistic method to determine close names. - dist = cellfun (@(n) length (setdiff (name, n)), t); - [~, i] = min (dist); - error ("get_forge_pkg: package not found: ""%s"". Maybe you meant ""%s?""", name, t{i}); - endif - else - error ("get_forge_pkg: could not read URL, please verify internet connection"); - endif - endif - -endfunction diff -r d6ad4ed57dda -r 0ade5992e374 scripts/pkg/module.mk --- a/scripts/pkg/module.mk Thu Mar 31 20:24:06 2011 -0700 +++ b/scripts/pkg/module.mk Thu Mar 31 20:57:37 2011 -0700 @@ -1,8 +1,11 @@ FCN_FILE_DIRS += pkg +pkg_PRIVATE_FCN_FILES = \ + pkg/private/get_forge_pkg.m + pkg_FCN_FILES = \ pkg/pkg.m \ - pkg/get_forge_pkg.m + $(pkg_PRIVATE_FCN_FILES) FCN_FILES += $(pkg_FCN_FILES) diff -r d6ad4ed57dda -r 0ade5992e374 scripts/pkg/pkg.m --- a/scripts/pkg/pkg.m Thu Mar 31 20:24:06 2011 -0700 +++ b/scripts/pkg/pkg.m Thu Mar 31 20:57:37 2011 -0700 @@ -58,6 +58,10 @@ ## @item -global ## A global installation is forced, even if the user doesn't normally have ## system privileges +## +## @item -forge +## Install a package directly from the Octave-Forge repository. This +## requires an internet connection and the cURL library. ## ## @item -verbose ## The package manager will print the output of all of the commands that are @@ -118,6 +122,9 @@ ## splits the list of installed packages into those who are installed by ## the current user, and those installed by the system administrator. ## +## The option '-forge' lists packages available at the Octave-Forge repository. +## This requires an internet connection and the cURL library. +## ## @item describe ## Show a short description of the named installed packages, with the option ## '-verbose' also list functions provided by the package, e.g.: diff -r d6ad4ed57dda -r 0ade5992e374 scripts/pkg/private/get_forge_pkg.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/pkg/private/get_forge_pkg.m Thu Mar 31 20:57:37 2011 -0700 @@ -0,0 +1,81 @@ +## Copyright (C) 2010-2011 VZLU Prague, a.s. +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{ver}, @var{url}] =} get_forge_pkg (@var{name}) +## Tries to discover the current version of an OctaveForge package from the web, +## using a working internet connection and the urlread function. +## If two output arguments are requested, returns also an address to download +## the file. +## @end deftypefn + +function [ver, url] = get_forge_pkg (name) + if (nargin != 1) + print_usage (); + endif + ## Verify that name is valid. + if (! (ischar (name) && rows (name) == 1 && ndims (name) == 2)) + error ("get_forge_pkg: package NAME must be a string"); + elseif (! all (isalnum (name) | name == "-" | name == "." | name == "_")) + error ("get_forge_pkg: invalid package name: %s", name); + endif + + name = tolower (name); + + ## Try to download package's index page. + [html, succ] = urlread (sprintf ("http://octave.sourceforge.net/%s/index.html", name)); + if (succ) + ## Remove blanks for simpler matching. + html(isspace(html)) = []; + ## Good. Let's grep for the version. + pat = "PackageVersion:([\\d.]*)"; + t = regexp (html, pat, "tokens"); + if (isempty (t) || isempty(t{1})) + error ("get_forge_pkg: could not read version number from package's page"); + else + ver = t{1}{1}; + if (nargout > 1) + # Build download string. + urlbase = "http://downloads.sourceforge.net/octave/%s-%s.tar.gz?download"; + url = sprintf (urlbase, name, ver); + ## Verify that the string exists on the page. + if (isempty (strfind (html, url))) + warning ("get_forge_pkg: download URL not verified"); + endif + endif + endif + else + ## Try get the list of all packages. + [html, succ] = urlread ("http://octave.sourceforge.net/packages.php"); + if (succ) + t = regexp (html, "
", "tokens"); + t = horzcat (t{:}); + if (any (strcmp (t, name))) + error ("get_forge_pkg: package NAME exists, but index page not available"); + else + ## Try a simplistic method to determine close names. + dist = cellfun (@(n) length (setdiff (name, n)), t); + [~, i] = min (dist); + error ("get_forge_pkg: package not found: ""%s"". Maybe you meant ""%s?""", name, t{i}); + endif + else + error ("get_forge_pkg: could not read URL, please verify internet connection"); + endif + endif + +endfunction