Mercurial > hg > octave-lyh
changeset 5987:f1375e3f3b97
[project @ 2006-09-12 21:25:27 by dbateman]
author | dbateman |
---|---|
date | Tue, 12 Sep 2006 21:25:27 +0000 |
parents | 14078139f941 |
children | d9ce802628e6 |
files | scripts/ChangeLog scripts/pkg/pkg.m |
diffstat | 2 files changed, 34 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,11 @@ +2006-08-30 David Bateman <dbateman@free.fr> + + * pkg/pkg.m (install): Disallow bundles of packages. More verbose + error message for archive name not matching package name. + (installed_packages): Size header of printed results to + arguments. Sort the list of installed packages before printing + them. + 2006-09-11 Paul Kienzle <pkienzle@users.sf.net> * signal/freqz.m: Update tests. @@ -22,7 +30,7 @@ 2006-08-30 David Bateman <dbateman@free.fr> - * pkg/pkg.m create_pkgadddel): Resolve variable name-clash from + * pkg/pkg.m (create_pkgadddel): Resolve variable name-clash from previous change. 2006-08-26 David Bateman <dbateman@free.fr>
--- a/scripts/pkg/pkg.m +++ b/scripts/pkg/pkg.m @@ -157,6 +157,10 @@ if (err) error("Couldn't read directory produced by tar: %s\n", msg); endif + + if (length(dirlist) > 3) + error("Bundles of packages are not allowed") + endif for k = 3:length(dirlist) # the two first entries of dirlist are "." and ".." packdir = [tmpdir "/" dirlist{k} "/"]; @@ -173,7 +177,8 @@ [dummy, nm] = fileparts(tgz); if ((length(nm) >= length(desc.name)) && ! strcmp(desc.name,nm(1:length(desc.name)))) - error("Package name doesn't correspond to its filename"); + error(["Package name '",desc.name,"' doesn't correspond", + "to its filename '",nm,"'"]); endif ## Set default installation directory @@ -992,32 +997,37 @@ return; endif - ## Print a header + ## Compute the maximal lengths of name, version, and dir h1 = "Package Name"; h2 = "Version"; h3 = "Installation directory"; + max_name_length = length(h1); + max_version_length = length(h2); + names = cell(num_packages,1); + for i = 1:num_packages + max_name_length = max(max_name_length, + length(installed_packages{i}.name)); + max_version_length = max(max_version_length, + length(installed_packages{i}.version)); + names{i} = installed_packages{i}.name; + endfor + h1 = postpad (h1, max_name_length,' '); + h2 = postpad (h2, max_version_length, ' ');; + + ## Print a header header = sprintf("%s | %s | %s\n", h1, h2, h3); printf(header); tmp = sprintf(repmat("-", 1, length(header)-1)); tmp(length(h1)+2) = "+"; tmp(length(h1)+length(h2)+5) = "+"; printf("%s\n", tmp); - ## Compute the maximal lengths of name, version, and dir - max_name_length = length(h1); - max_version_length = length(h2); - for i = 1:num_packages - max_name_length = max(max_name_length, - length(installed_packages{i}.name)); - max_version_length = max(max_version_length, - length(installed_packages{i}.version)); - endfor - ## Print the packages format = sprintf("%%%ds | %%%ds | %%s\n", max_name_length, max_version_length); + [dummy, idx] = sort(names); for i = 1:num_packages - cur_name = installed_packages{i}.name; - cur_version = installed_packages{i}.version; - cur_dir = installed_packages{i}.dir; + cur_name = installed_packages{idx(i)}.name; + cur_version = installed_packages{idx(i)}.version; + cur_dir = installed_packages{idx(i)}.dir; printf(format, cur_name, cur_version, cur_dir); endfor endfunction