Mercurial > hg > octave-lyh
comparison scripts/pkg/pkg.m @ 6616:66e30383481b
[project @ 2007-05-14 13:56:34 by dbateman]
author | dbateman |
---|---|
date | Mon, 14 May 2007 13:56:34 +0000 |
parents | 3a53d0f3e0e4 |
children | 8c2fff7b50b0 |
comparison
equal
deleted
inserted
replaced
6615:687ae48b2253 | 6616:66e30383481b |
---|---|
43 ## | 43 ## |
44 ## If @var{option} is @code{-auto} the package manager will | 44 ## If @var{option} is @code{-auto} the package manager will |
45 ## automatically load the installed package when starting Octave, | 45 ## automatically load the installed package when starting Octave, |
46 ## even if the package requests that it isn't. | 46 ## even if the package requests that it isn't. |
47 ## | 47 ## |
48 ## Final if @var{option} is @code{-verbose} the package manager will | 48 ## Finally, if @var{option} is @code{-verbose} the package manager will |
49 ## print the output of all of the commands that are performed | 49 ## print the output of all of the commands that are performed |
50 ## @item uninstall | 50 ## @item uninstall |
51 ## Uninstall named packages. For example, | 51 ## Uninstall named packages. For example, |
52 ## @example | 52 ## @example |
53 ## pkg uninstall image | 53 ## pkg uninstall image |
1236 endfor | 1236 endfor |
1237 if (! isempty(dup)) | 1237 if (! isempty(dup)) |
1238 installed_packages(dup) = []; | 1238 installed_packages(dup) = []; |
1239 endif | 1239 endif |
1240 | 1240 |
1241 ## Now check if the package is loaded | |
1242 tmppath = path(); | |
1243 for i = 1:length (installed_packages) | |
1244 if (regexp (tmppath, installed_packages{i}.dir)) | |
1245 installed_packages{i}.loaded = true; | |
1246 else | |
1247 installed_packages{i}.loaded = false; | |
1248 endif | |
1249 endfor | |
1250 | |
1241 ## Should we return something? | 1251 ## Should we return something? |
1242 if (nargout == 2) | 1252 if (nargout == 2) |
1243 out1 = local_packages; | 1253 out1 = local_packages; |
1244 out2 = global_packages; | 1254 out2 = global_packages; |
1245 return; | 1255 return; |
1267 length (installed_packages{i}.name)); | 1277 length (installed_packages{i}.name)); |
1268 max_version_length = max (max_version_length, | 1278 max_version_length = max (max_version_length, |
1269 length (installed_packages{i}.version)); | 1279 length (installed_packages{i}.version)); |
1270 names{i} = installed_packages{i}.name; | 1280 names{i} = installed_packages{i}.name; |
1271 endfor | 1281 endfor |
1272 h1 = postpad (h1, max_name_length, " "); | 1282 h1 = postpad (h1, max_name_length + 1, " "); |
1273 h2 = postpad (h2, max_version_length, " ");; | 1283 h2 = postpad (h2, max_version_length, " ");; |
1274 | 1284 |
1275 ## Print a header | 1285 ## Print a header |
1276 header = sprintf("%s | %s | %s\n", h1, h2, h3); | 1286 header = sprintf("%s | %s | %s\n", h1, h2, h3); |
1277 printf (header); | 1287 printf (header); |
1279 tmp(length(h1)+2) = "+"; | 1289 tmp(length(h1)+2) = "+"; |
1280 tmp(length(h1)+length(h2)+5) = "+"; | 1290 tmp(length(h1)+length(h2)+5) = "+"; |
1281 printf ("%s\n", tmp); | 1291 printf ("%s\n", tmp); |
1282 | 1292 |
1283 ## Print the packages | 1293 ## Print the packages |
1284 format = sprintf ("%%%ds | %%%ds | %%s\n", max_name_length, | 1294 format = sprintf ("%%%ds %%1s| %%%ds | %%s\n", max_name_length, |
1285 max_version_length); | 1295 max_version_length); |
1286 [dummy, idx] = sort (names); | 1296 [dummy, idx] = sort (names); |
1287 for i = 1:num_packages | 1297 for i = 1:num_packages |
1288 cur_name = installed_packages{idx(i)}.name; | 1298 cur_name = installed_packages{idx(i)}.name; |
1289 cur_version = installed_packages{idx(i)}.version; | 1299 cur_version = installed_packages{idx(i)}.version; |
1290 cur_dir = installed_packages{idx(i)}.dir; | 1300 cur_dir = installed_packages{idx(i)}.dir; |
1291 printf (format, cur_name, cur_version, cur_dir); | 1301 if (installed_packages{idx(i)}.loaded) |
1302 cur_loaded = "*"; | |
1303 else | |
1304 cur_loaded = " "; | |
1305 endif | |
1306 printf (format, cur_name, cur_loaded, cur_version, cur_dir); | |
1292 endfor | 1307 endfor |
1293 endfunction | 1308 endfunction |
1294 | 1309 |
1295 function load_packages (files, handle_deps, local_list, global_list) | 1310 function load_packages (files, handle_deps, local_list, global_list) |
1296 installed_packages = installed_packages (local_list, global_list); | 1311 installed_packages = installed_packages (local_list, global_list); |