5801
|
1 ## Copyright (C) 2005 S�ren Hauberg |
|
2 ## |
|
3 ## This program is free software; you can redistribute it and/or modify |
|
4 ## it under the terms of the GNU General Public License as published by |
|
5 ## the Free Software Foundation; either version 2 of the License, or |
|
6 ## (at your option) any later version. |
|
7 ## |
|
8 ## This program is distributed in the hope that it will be useful, |
|
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 ## GNU General Public License for more details. |
|
12 ## |
|
13 ## You should have received a copy of the GNU General Public License |
|
14 ## along with this program; if not, write to the Free Software |
|
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
16 |
|
17 ## -*- texinfo -*- |
6032
|
18 ## @deftypefn {Command} pkg @var{command} @var{pkg_name} |
|
19 ## @deftypefnx {Command} pkg @var{command} @var{option} @var{pkg_name} |
|
20 ## This command interacts with the package manager. Different actions will |
|
21 ## be taking depending on the value of @var{command}. |
|
22 ## |
|
23 ## @table @samp |
|
24 ## @item install |
6033
|
25 ## Install named packages. For example, |
6032
|
26 ## @example |
|
27 ## pkg install image-1.0.0.tar.gz |
|
28 ## @end example |
|
29 ## @noindent |
6033
|
30 ## installs the package found in the file @code{image-1.0.0.tar.gz}. |
6032
|
31 ## |
|
32 ## If @var{option} is @code{-nodeps} the package manager will disable the |
|
33 ## dependency checking. That way it is possible to install a package even |
|
34 ## if it depends on another package that's not installed on the system. |
|
35 ## @strong{Use this option with care.} |
|
36 ## @item uninstall |
6033
|
37 ## Uninstall named packages. For example, |
6032
|
38 ## @example |
|
39 ## pkg uninstall image |
|
40 ## @end example |
|
41 ## @noindent |
6033
|
42 ## removes the @code{image} package from the system. If another installed |
6032
|
43 ## package depends on the @code{image} package an error will be issued. |
|
44 ## The package can be uninstalled anyway by using the @code{-nodeps} option. |
|
45 ## @item load |
6033
|
46 ## Add named packages to the path. After loading a package it is |
|
47 ## possible to use the functions provided by the package. For example, |
6032
|
48 ## @example |
|
49 ## pkg load image |
|
50 ## @end example |
|
51 ## @noindent |
6033
|
52 ## adds the @code{image} package to the path. It is possible to load all |
|
53 ## installed packages at once with the command |
6032
|
54 ## @example |
|
55 ## pkg load all |
|
56 ## @end example |
|
57 ## @item list |
6033
|
58 ## Show a list of the currently installed packages. By requesting one or two |
6032
|
59 ## output argument it is possible to get a list of the currently installed |
6033
|
60 ## packages. For example, |
6032
|
61 ## @example |
|
62 ## installed_packages = pkg list; |
|
63 ## @end example |
|
64 ## @noindent |
6033
|
65 ## returns a cell array containing a structure for each installed package. |
6032
|
66 ## The command |
|
67 ## @example |
|
68 ## [@var{user_packages}, @var{system_packages}] = pkg list |
|
69 ## @end example |
|
70 ## @noindent |
6033
|
71 ## splits the list of installed packages into those who are installed by |
6032
|
72 ## the current user, and those installed by the system administrator. |
6034
|
73 ## @item prefix |
|
74 ## Set the installation prefix directory. For example, |
|
75 ## @example |
|
76 ## pkg prefix ~/my_octave_packages |
|
77 ## @end example |
|
78 ## @noindent |
|
79 ## sets the installation prefix to @code{~/my_octave_packages}. |
|
80 ## Packages will be installed in this directory. |
|
81 ## |
|
82 ## It is possible to get the current installation prefix by requesting an |
|
83 ## output argument. For example, |
|
84 ## @example |
|
85 ## p = pkg prefix |
|
86 ## @end example |
6032
|
87 ## @end table |
5801
|
88 ## @end deftypefn |
5947
|
89 |
|
90 ## PKG_ADD: mark_as_command pkg |
|
91 |
5801
|
92 function [local_packages, global_packages] = pkg(varargin) |
6034
|
93 ## Installation prefix |
|
94 persistent prefix = -1; |
|
95 if (prefix == -1) |
|
96 if (issuperuser()) |
6036
|
97 prefix = fullfile (OCTAVE_HOME (), "/share/octave/packages/"); |
6034
|
98 else |
|
99 prefix = "~/octave/"; |
|
100 endif |
|
101 endif |
|
102 prefix = tilde_expand(prefix); |
|
103 |
5801
|
104 ## Handle input |
|
105 if (length(varargin) == 0 || !iscellstr(varargin)) |
5928
|
106 print_usage(); |
5801
|
107 endif |
|
108 files = {}; |
|
109 deps = true; |
|
110 action = "none"; |
|
111 for i = 1:length(varargin) |
|
112 switch (varargin{i}) |
|
113 case "-nodeps" |
|
114 deps = false; |
6034
|
115 case {"list", "install", "uninstall", "load", "prefix"} |
5801
|
116 action = varargin{i}; |
|
117 otherwise |
|
118 files{end+1} = varargin{i}; |
|
119 endswitch |
|
120 endfor |
|
121 |
|
122 ## Take action |
|
123 switch (action) |
|
124 case "list" |
|
125 if (nargout == 0) |
|
126 installed_packages(); |
|
127 elseif (nargout == 1) |
|
128 local_packages = installed_packages(); |
|
129 elseif (nargout == 2) |
|
130 [local_packages, global_packages] = installed_packages(); |
|
131 else |
|
132 error("Too many output arguments requested.\n"); |
|
133 endif |
|
134 case "install" |
|
135 if (length(files) == 0) |
|
136 error("You must specify at least one filename when calling 'pkg install'\n"); |
|
137 endif |
6034
|
138 install(files, deps, prefix); |
5801
|
139 case "uninstall" |
|
140 if (length(files) == 0) |
|
141 error("You must specify at least one package when calling 'pkg uninstall'\n"); |
|
142 endif |
|
143 uninstall(files, deps); |
|
144 case "load" |
|
145 if (length(files) == 0) |
|
146 error("You must specify at least one package or 'all' when calling 'pkg load'\n"); |
|
147 endif |
|
148 load_packages(files, deps); |
6034
|
149 case "prefix" |
|
150 if (length(files) == 0 && nargout == 0) |
6035
|
151 disp(prefix); |
6034
|
152 elseif (length(files) == 0 && nargout == 1) |
|
153 local_packages = prefix; |
|
154 elseif (length(files) == 1 && nargout == 0 && ischar(files{1})) |
|
155 prefix = files{1}; |
|
156 if (!strcmp(prefix(end), "/")) prefix(end+1) = "/"; endif |
|
157 else |
|
158 error("You must specify a prefix directory, or request an output arguement"); |
|
159 endif |
5801
|
160 otherwise |
|
161 error("You must specify a valid action for 'pkg'. See 'help pkg' for details\n"); |
|
162 endswitch |
|
163 endfunction |
|
164 |
6034
|
165 function install(files, handle_deps, prefix) |
5801
|
166 ## Set parameters depending on wether or not the installation |
|
167 ## is system-wide (global) or local. |
|
168 local_list = tilde_expand("~/.octave_packages"); |
6036
|
169 global_list = fullfile (OCTAVE_HOME (), "/share/octave/octave_packages"); |
6034
|
170 |
|
171 global_install = issuperuser(); |
5801
|
172 |
|
173 # Check that the directory in prefix exist. If it doesn't: create it! |
|
174 if (!exist(prefix, "dir")) |
|
175 warning("Creating installation directory %s", prefix); |
|
176 [status, msg] = mkdir(prefix); |
|
177 if (status != 1) |
|
178 error("Could not create installation directory: %s\n", msg); |
|
179 endif |
|
180 endif |
|
181 |
|
182 ## Get the list of installed packages |
|
183 [local_packages, global_packages] = installed_packages(); |
|
184 installed_packages = {local_packages{:} global_packages{:}}; |
|
185 |
|
186 if (global_install) |
|
187 packages = global_packages; |
|
188 else |
|
189 packages = local_packages; |
|
190 endif |
|
191 |
|
192 ## Uncompress the packages and read the DESCRIPTION files |
5947
|
193 tmpdirs = packdirs = descriptions = {}; |
5801
|
194 try |
|
195 ## Unpack the package files and read the DESCRIPTION files |
|
196 packages_to_uninstall = []; |
|
197 for i = 1:length(files) |
|
198 tgz = files{i}; |
|
199 |
|
200 ## Create a temporary directory |
|
201 tmpdir = tmpnam(); |
5947
|
202 tmpdirs{end+1} = tmpdir; |
5801
|
203 [status, msg] = mkdir(tmpdir); |
|
204 if (status != 1) |
|
205 error("Couldn't create temporary directory: %s\n", msg); |
|
206 endif |
|
207 |
|
208 ## Uncompress the package |
|
209 untar(tgz, tmpdir); |
5928
|
210 |
5947
|
211 ## Get the name of the directories produced by tar |
5801
|
212 [dirlist, err, msg] = readdir(tmpdir); |
|
213 if (err) |
|
214 error("Couldn't read directory produced by tar: %s\n", msg); |
|
215 endif |
5987
|
216 |
|
217 if (length(dirlist) > 3) |
|
218 error("Bundles of packages are not allowed") |
|
219 endif |
5947
|
220 |
|
221 for k = 3:length(dirlist) # the two first entries of dirlist are "." and ".." |
|
222 packdir = [tmpdir "/" dirlist{k} "/"]; |
|
223 packdirs{end+1} = packdir; |
5801
|
224 |
5947
|
225 ## Make sure the package contains necessary files |
|
226 verify_directory(packdir); |
5928
|
227 |
5947
|
228 ## Read the DESCRIPTION file |
|
229 filename = [packdir "DESCRIPTION"]; |
|
230 desc = get_description(filename); |
5928
|
231 |
5971
|
232 ## Verify that package name corresponds with filename |
|
233 [dummy, nm] = fileparts(tgz); |
|
234 if ((length(nm) >= length(desc.name)) && |
|
235 ! strcmp(desc.name,nm(1:length(desc.name)))) |
5987
|
236 error(["Package name '",desc.name,"' doesn't correspond", |
|
237 "to its filename '",nm,"'"]); |
5971
|
238 endif |
|
239 |
5947
|
240 ## Set default installation directory |
|
241 desc.dir = [prefix "/" desc.name "-" desc.version]; |
5801
|
242 |
5947
|
243 ## Save desc |
|
244 descriptions{end+1} = desc; |
5801
|
245 |
5947
|
246 ## Are any of the new packages already installed? |
|
247 ## If so we'll remove the old version. |
|
248 for j = 1:length(packages) |
|
249 if (strcmp(packages{j}.name, desc.name)) |
|
250 packages_to_uninstall(end+1) = j; |
|
251 endif |
|
252 endfor |
|
253 endfor |
5801
|
254 endfor |
|
255 catch |
|
256 ## Something went wrong, delete tmpdirs |
|
257 for i = 1:length(tmpdirs) |
5928
|
258 rm_rf(tmpdirs{i}); |
5801
|
259 endfor |
|
260 error(lasterr()(8:end)); |
|
261 end_try_catch |
|
262 |
|
263 ## Check dependencies |
|
264 if (handle_deps) |
|
265 ok = true; |
|
266 error_text = ""; |
|
267 for i = 1:length(descriptions) |
|
268 desc = descriptions{i}; |
|
269 idx1 = complement(packages_to_uninstall, 1:length(installed_packages)); |
|
270 idx2 = complement(i, 1:length(descriptions)); |
|
271 pseudo_installed_packages = {installed_packages{idx1} descriptions{idx2}}; |
|
272 bad_deps = get_unsatisfied_deps(desc, pseudo_installed_packages); |
|
273 ## Are there any unsatisfied dependencies? |
|
274 if (!isempty(bad_deps)) |
|
275 ok = false; |
|
276 for i = 1:length(bad_deps) |
|
277 dep = bad_deps{i}; |
|
278 error_text = [error_text " " desc.name " needs " ... |
|
279 dep.package " " dep.operator " " ... |
|
280 dep.version "\n"]; |
|
281 endfor |
|
282 endif |
|
283 endfor |
|
284 |
|
285 ## Did we find any unsatisfied dependencies? |
|
286 if (!ok) |
|
287 error("The following dependencies where unsatisfied:\n %s", error_text); |
|
288 endif |
|
289 endif |
|
290 |
|
291 ## Prepare each package for installation |
|
292 try |
|
293 for i = 1:length(descriptions) |
|
294 desc = descriptions{i}; |
|
295 pdir = packdirs{i}; |
|
296 prepare_installation (desc, pdir); |
|
297 configure_make (desc, pdir); |
|
298 endfor |
|
299 catch |
|
300 ## Something went wrong, delete tmpdirs |
|
301 for i = 1:length(tmpdirs) |
5928
|
302 rm_rf(tmpdirs{i}); |
5801
|
303 endfor |
|
304 error(lasterr()(8:end)); |
|
305 end_try_catch |
|
306 |
|
307 ## Uninstall the packages that will be replaced |
|
308 try |
|
309 for i = packages_to_uninstall |
|
310 uninstall({installed_packages{i}.name}, false); |
|
311 endfor |
|
312 catch |
|
313 ## Something went wrong, delete tmpdirs |
|
314 for i = 1:length(tmpdirs) |
5928
|
315 rm_rf(tmpdirs{i}); |
5801
|
316 endfor |
|
317 error(lasterr()(8:end)); |
|
318 end_try_catch |
|
319 |
|
320 ## Install each package |
|
321 try |
|
322 for i = 1:length(descriptions) |
|
323 desc = descriptions{i}; |
|
324 pdir = packdirs{i}; |
5971
|
325 copy_files(desc, pdir); |
|
326 create_pkgadddel(desc, pdir, "PKG_ADD"); |
|
327 create_pkgadddel(desc, pdir, "PKG_DEL"); |
5801
|
328 finish_installation (desc, pdir) |
|
329 endfor |
|
330 catch |
|
331 ## Something went wrong, delete tmpdirs |
|
332 for i = 1:length(tmpdirs) |
5928
|
333 rm_rf(tmpdirs{i}); |
5801
|
334 endfor |
5971
|
335 for i = 1:length(descriptions) |
|
336 rm_rf(descriptions{i}.dir); |
|
337 endfor |
5801
|
338 error(lasterr()(8:end)); |
|
339 end_try_catch |
|
340 |
5971
|
341 ## Check if the installed directory is empty. If it is remove it |
|
342 ## from the list |
|
343 for i = length(descriptions):-1:1 |
|
344 if (dirempty(descriptions{i}.dir,{"packinfo","doc"})) |
|
345 rm_rf(descriptions{i}.dir); |
|
346 descriptions(i) = []; |
|
347 endif |
|
348 endfor |
|
349 |
|
350 ## Add the packages to the package list |
5801
|
351 try |
|
352 if (global_install) |
|
353 idx = complement(packages_to_uninstall, 1:length(global_packages)); |
|
354 global_packages = {global_packages{idx} descriptions{:}}; |
|
355 save(global_list, "global_packages"); |
|
356 else |
|
357 idx = complement(packages_to_uninstall, 1:length(local_packages)); |
|
358 local_packages = {local_packages{idx} descriptions{:}}; |
|
359 save(local_list, "local_packages"); |
|
360 endif |
|
361 catch |
|
362 ## Something went wrong, delete tmpdirs |
|
363 for i = 1:length(tmpdirs) |
5928
|
364 rm_rf(tmpdirs{i}); |
5801
|
365 endfor |
|
366 for i = 1:length(descriptions) |
5928
|
367 rm_rf(descriptions{i}.dir); |
5801
|
368 endfor |
|
369 if (global_install) |
|
370 error("Couldn't append to %s: %s\n", global_list, lasterr()(8:end)); |
|
371 else |
|
372 error("Couldn't append to %s: %s\n", local_list, lasterr()(8:end)); |
|
373 endif |
|
374 end_try_catch |
|
375 |
|
376 ## All is well, let's clean up |
|
377 for i = 1:length(tmpdirs) |
5928
|
378 [status, msg] = rm_rf(tmpdirs{i}); |
5801
|
379 if (status != 1) |
|
380 warning("Couldn't clean up after my self: %s\n", msg); |
|
381 endif |
|
382 endfor |
|
383 |
|
384 ## Add the newly installed packages to the path, so the user |
5971
|
385 ## can begin usings them. |
|
386 if (length(descriptions) > 0) |
|
387 dirs = cell(1, length(descriptions)); |
|
388 for i = 1:length(descriptions) |
5801
|
389 dirs{i} = descriptions{i}.dir; |
5971
|
390 endfor |
|
391 addpath(dirs{:}); |
|
392 endif |
5801
|
393 endfunction |
|
394 |
|
395 function uninstall(pkgnames, handle_deps) |
|
396 local_list = tilde_expand("~/.octave_packages"); |
6036
|
397 global_list = fullfile (OCTAVE_HOME (), "/share/octave/octave_packages"); |
5801
|
398 ## Get the list of installed packages |
|
399 [local_packages, global_packages] = installed_packages(); |
|
400 if (issuperuser()) |
|
401 installed_packages = global_packages; |
|
402 else |
|
403 installed_packages = local_packages; |
|
404 endif |
|
405 |
|
406 num_packages = length(installed_packages); |
|
407 delete_idx = []; |
|
408 for i = 1:num_packages |
|
409 cur_name = installed_packages{i}.name; |
|
410 if (any(strcmp(cur_name, pkgnames))) |
|
411 delete_idx(end+1) = i; |
|
412 endif |
|
413 endfor |
|
414 |
|
415 ## Are all the packages that should be uninstalled already installed? |
|
416 if (length(delete_idx) != length(pkgnames)) |
|
417 # XXX: We should have a better error message |
|
418 error("Some of the packages you want to uninstall are not installed.\n"); |
|
419 endif |
|
420 |
|
421 ## Compute the packages that will remain installed |
|
422 idx = complement(delete_idx, 1:num_packages); |
|
423 remaining_packages = {installed_packages{idx}}; |
|
424 |
|
425 ## Check dependencies |
|
426 if (handle_deps) |
|
427 ok = true; |
|
428 error_text = ""; |
|
429 for i = 1:length(remaining_packages) |
|
430 desc = remaining_packages{i}; |
|
431 bad_deps = get_unsatisfied_deps(desc, remaining_packages); |
|
432 |
|
433 ## Will the uninstallation break any dependencies? |
|
434 if (!isempty(bad_deps)) |
|
435 ok = false; |
|
436 for i = 1:length(bad_deps) |
|
437 dep = bad_deps{i}; |
|
438 error_text = [error_text " " desc.name " needs " ... |
|
439 dep.package " " dep.operator " " ... |
|
440 dep.version "\n"]; |
|
441 endfor |
|
442 endif |
|
443 endfor |
|
444 |
|
445 if (!ok) |
|
446 error("The following dependencies where unsatisfied:\n %s", error_text); |
|
447 endif |
|
448 endif |
|
449 |
|
450 ## Delete the directories containing the packages |
|
451 for i = delete_idx |
|
452 desc = installed_packages{i}; |
|
453 ## If an 'on_uninstall.m' exist, call it! |
|
454 if (exist([desc.dir "/packinfo/on_uninstall.m"], "file")) |
|
455 try |
|
456 wd = pwd(); |
|
457 cd([desc.dir "/packinfo"]); |
|
458 on_uninstall(desc); |
|
459 cd(wd); |
|
460 catch |
|
461 # XXX: Should this rather be an error? |
|
462 warning("The 'on_uninstall' script returned the following error: %s", lasterr); |
|
463 cd(wd); |
|
464 end_try_catch |
|
465 endif |
|
466 ## Do the actual deletion |
5928
|
467 rmpath(desc.dir); |
|
468 [status, msg] = rm_rf(desc.dir); |
5801
|
469 if (status != 1) |
|
470 error("Couldn't delete directory %s: %s\n", desc.dir, msg); |
|
471 endif |
|
472 endfor |
|
473 |
|
474 ## Write a new ~/.octave_packages |
|
475 if (issuperuser()) |
|
476 if (length(remaining_packages) == 0) |
|
477 unlink(global_list); |
|
478 else |
|
479 global_packages = remaining_packages; |
|
480 save(global_list, "global_packages"); |
|
481 endif |
|
482 else |
|
483 if (length(remaining_packages) == 0) |
|
484 unlink(local_list); |
|
485 else |
|
486 local_packages = remaining_packages; |
|
487 save(local_list, "local_packages"); |
|
488 endif |
|
489 endif |
|
490 |
|
491 endfunction |
|
492 |
|
493 ########################################################## |
|
494 ## A U X I L A R Y F U N C T I O N S ## |
|
495 ########################################################## |
|
496 |
|
497 function prepare_installation(desc, packdir) |
|
498 ## Is there a pre_install to call? |
|
499 if (exist([packdir "pre_install.m"], "file")) |
|
500 wd = pwd(); |
|
501 try |
|
502 cd(packdir); |
|
503 pre_install(desc); |
|
504 cd(wd); |
|
505 catch |
|
506 cd(wd); |
|
507 error("The pre-install function returned the following error: %s\n", lasterr); |
|
508 end_try_catch |
|
509 endif |
|
510 |
5993
|
511 ## If the directory "inst" doesn't exist, we create it |
|
512 if (!exist([packdir "inst"], "dir")) |
5801
|
513 [status, msg] = mkdir([packdir "inst"]); |
|
514 if (status != 1) |
5928
|
515 rm_rf(desc.dir); |
5801
|
516 error("The 'inst' directory did not exist and could not be created: %s\n", msg); |
|
517 endif |
|
518 endif |
|
519 endfunction |
|
520 |
|
521 function configure_make (desc, packdir) |
|
522 ## Perform ./configure, make, make install in "src" |
|
523 if (exist([packdir "src"], "dir")) |
|
524 src = [packdir "src/"]; |
|
525 ## configure |
|
526 if (exist([src "configure"], "file")) |
5928
|
527 [status, output] = system(["cd " src " ;./configure --prefix=" desc.dir]); |
5801
|
528 if (status != 0) |
5928
|
529 rm_rf(desc.dir); |
5801
|
530 error("The configure script returned the following error: %s\n", output); |
|
531 endif |
|
532 endif |
|
533 |
|
534 ## make |
|
535 if (exist([src "Makefile"], "file")) |
5928
|
536 [status, output] = system(["export INSTALLDIR=" desc.dir "; make -C " src]); |
5801
|
537 if (status != 0) |
5928
|
538 rm_rf(desc.dir); |
5801
|
539 error("'make' returned the following error: %s\n", output); |
|
540 endif |
|
541 %# make install |
5928
|
542 %[status, output] = system(["export INSTALLDIR=" desc.dir "; make install -C " src]); |
5801
|
543 %if (status != 0) |
5928
|
544 % rm_rf(desc.dir); |
5801
|
545 % error("'make install' returned the following error: %s\n", output); |
|
546 %endif |
|
547 endif |
|
548 |
|
549 ## Copy files to "inst" (this is instead of 'make install') |
|
550 files = [src "FILES"]; |
|
551 if (exist(files, "file")) |
|
552 [fid, msg] = fopen(files, "r"); |
|
553 if (fid < 0) |
|
554 error("Couldn't open %s: %s\n", files, msg); |
|
555 endif |
5928
|
556 filenames = char(fread(fid))'; |
5801
|
557 filenames = strrep(filenames, "\n", " "); |
5928
|
558 [status, output] = system(["cd " src "; cp " filenames " " packdir "inst/"]); |
5801
|
559 fclose(fid); |
|
560 else |
|
561 m = dir([src "*.m"]); |
|
562 oct = dir([src "*.oct"]); |
|
563 f = ""; |
|
564 if (length(m) > 0) |
5928
|
565 f = sprintf([src "%s "], m.name); |
5801
|
566 endif |
|
567 if (length(oct) > 0) |
5928
|
568 f = [f " " sprintf([src "%s "], oct.name)]; |
5801
|
569 endif |
5928
|
570 |
|
571 if (!all(isspace(f))) |
|
572 [status, output] = system(["cp -R " f " " packdir "inst/"]); |
|
573 endif |
5801
|
574 endif |
|
575 if (status != 0) |
5928
|
576 rm_rf(desc.dir); |
5801
|
577 error("Couldn't copy files from 'src' to 'inst': %s\n", output); |
|
578 endif |
|
579 endif |
|
580 endfunction |
|
581 |
5971
|
582 function pkg = extract_pkg (nm, pat) |
5955
|
583 fid = fopen (nm, "rt"); |
5971
|
584 pkg = ""; |
5955
|
585 if (fid >= 0) |
|
586 while (! feof(fid)) |
|
587 ln = fgetl (fid); |
|
588 if (ln > 0) |
|
589 t = regexp(ln, pat, "tokens","dotexceptnewline"); |
|
590 if (!isempty(t)) |
5971
|
591 pkg = [pkg, "\n", t{1}{1}]; |
5955
|
592 endif |
|
593 endif |
|
594 endwhile |
5971
|
595 if (!isempty(pkg)) |
|
596 pkg = [pkg, "\n"]; |
5955
|
597 endif |
|
598 fclose (fid); |
|
599 endif |
|
600 endfunction |
|
601 |
5971
|
602 function create_pkgadddel (desc, packdir, nm) |
|
603 pkg = [desc.dir "/" nm]; |
|
604 fid = fopen(pkg, "wt"); |
5976
|
605 |
5955
|
606 if (fid >= 0) |
5971
|
607 ## Search all dot-m files for PKG commands |
5955
|
608 lst = dir ([packdir "inst/*.m"]); |
|
609 for i=1:length(lst) |
5976
|
610 nam = [packdir "inst/" lst(i).name]; |
|
611 fwrite (fid, extract_pkg (nam, ['^[#%][#%]* *' nm ': *(.*)$'])); |
5955
|
612 endfor |
|
613 |
5971
|
614 ## Search all C++ source files for PKG commands |
5955
|
615 lst = dir ([packdir "src/*.cc"]); |
|
616 for i=1:length(lst) |
5976
|
617 nam = [packdir "src/" lst(i).name]; |
|
618 fwrite (fid, extract_pkg (nam, ['^//* *' nm ': *(.*)$'])); |
|
619 fwrite (fid, extract_pkg (nam, ['^/\** *' nm ': *(.*) *\*/$'])); |
5955
|
620 endfor |
|
621 |
5971
|
622 ## Add developer included PKG commands |
|
623 if (exist([packdir nm],"file")) |
|
624 fid2 = fopen([packdir nm],"rt"); |
5955
|
625 if (fid2 >= 0) |
|
626 while (! feof(fid2)) |
|
627 ln = fgets (fid2); |
|
628 if (ln > 0) |
|
629 fwrite(fid, ln); |
|
630 endif |
|
631 endwhile |
5971
|
632 fclose(fid2); |
5955
|
633 endif |
|
634 endif |
|
635 fclose(fid); |
5971
|
636 |
|
637 ## If the file is empty remove it |
|
638 t = dir (pkg); |
|
639 if (t.bytes <= 0) |
|
640 unlink (pkg); |
|
641 endif |
5955
|
642 endif |
|
643 endfunction |
|
644 |
5971
|
645 function copy_files (desc, packdir, bindir) |
6020
|
646 ## Create the installation directory |
|
647 if (! exist (desc.dir, "dir")) |
|
648 [status, output] = mkdir (desc.dir); |
|
649 if (status != 1) |
|
650 error("Couldn't create installation directory %s : %s\n", |
|
651 desc.dir, output); |
|
652 endif |
|
653 endif |
|
654 |
5801
|
655 ## Copy the files from "inst" to installdir |
5971
|
656 if (! dirempty([packdir "inst"])) |
|
657 [status, output] = system(["cp -R " packdir "inst/* " desc.dir]); |
|
658 if (status != 0) |
|
659 rm_rf(desc.dir); |
|
660 error("Couldn't copy files to the installation directory\n"); |
|
661 endif |
5801
|
662 endif |
|
663 |
|
664 ## Create the "packinfo" directory |
|
665 packinfo = [desc.dir "/packinfo/"]; |
|
666 [status, msg] = mkdir (packinfo); |
|
667 if (status != 1) |
5928
|
668 rm_rf(desc.dir); |
5801
|
669 error("Couldn't create packinfo directory: %s\n", msg); |
|
670 endif |
|
671 |
|
672 ## Copy DESCRIPTION |
5928
|
673 [status, output] = system(["cp " packdir "DESCRIPTION " packinfo]); |
5801
|
674 if (status != 0) |
5928
|
675 rm_rf(desc.dir); |
5801
|
676 error("Couldn't copy DESCRIPTION: %s\n", output); |
|
677 endif |
|
678 |
5993
|
679 ## Copy COPYING |
|
680 [status, output] = system(["cp " packdir "COPYING " packinfo]); |
|
681 if (status != 0) |
|
682 rm_rf(desc.dir); |
|
683 error("Couldn't copy COPYING: %s\n", output); |
|
684 endif |
|
685 |
5801
|
686 ## Is there an INDEX file to copy or should we generate one? |
|
687 if (exist([packdir "INDEX"], "file")) |
5928
|
688 [status, output] = system(["cp " packdir "INDEX " packinfo]); |
5801
|
689 if (status != 0) |
5928
|
690 rm_rf(desc.dir); |
5801
|
691 error("Couldn't copy INDEX file: %s\n", output); |
|
692 endif |
|
693 else |
|
694 try |
|
695 write_INDEX(desc, [packdir "inst"], [packinfo "INDEX"]); |
|
696 catch |
5928
|
697 rm_rf(desc.dir); |
5801
|
698 error(lasterr); |
|
699 end_try_catch |
|
700 endif |
|
701 |
|
702 ## Is there an 'on_uninstall.m' to install? |
|
703 if (exist([packdir "on_uninstall.m"], "file")) |
5928
|
704 [status, output] = system(["cp " packdir "on_uninstall.m " packinfo]); |
5801
|
705 if (status != 0) |
5928
|
706 rm_rf(desc.dir); |
5801
|
707 error("Couldn't copy on_uninstall.m: %s\n", output); |
|
708 endif |
|
709 endif |
5971
|
710 |
|
711 ## Is there a doc/ directory that needs to be installed |
|
712 if (exist([packdir "doc"], "dir") && !dirempty([packdir "doc"])) |
|
713 [status, output] = system(["cp -pR " packdir "doc " desc.dir]); |
|
714 endif |
|
715 |
|
716 ## Is there a bin/ directory that needs to be installed |
|
717 if (exist([packdir "bin"], "dir") && !dirempty([packdir "bin"])) |
|
718 [status, output] = system(["cp -pR " packdir "bin " desc.dir]); |
|
719 endif |
5801
|
720 endfunction |
|
721 |
|
722 function finish_installation (desc, packdir) |
|
723 ## Is there a post-install to call? |
|
724 if (exist([packdir "post_install.m"], "file")) |
|
725 wd = pwd(); |
|
726 try |
|
727 cd(packdir); |
|
728 post_install(desc); |
|
729 cd(wd); |
|
730 catch |
|
731 cd(wd); |
5928
|
732 rm_rf(desc.dir); |
5801
|
733 error("The post_install function returned the following error: %s\n", lasterr); |
|
734 end_try_catch |
|
735 endif |
|
736 endfunction |
|
737 |
|
738 function out = issuperuser() |
|
739 out = strcmp(getenv("USER"), "root"); |
|
740 endfunction |
|
741 |
|
742 ## This function makes sure the package contains the |
|
743 ## essential files. |
|
744 function verify_directory(dir) |
|
745 needed_files = {"COPYING", "DESCRIPTION"}; |
|
746 for f = needed_files |
|
747 if (!exist([dir "/" f{1}], "file")) |
|
748 error("Package is missing file: %s", f{1}); |
|
749 endif |
|
750 endfor |
|
751 endfunction |
|
752 |
|
753 ## This function parses the DESCRIPTION file |
|
754 function desc = get_description(filename) |
|
755 fid = fopen(filename, "r"); |
|
756 if (fid == -1) |
|
757 error("The DESCRIPTION file %s could not be read\n", filename); |
|
758 endif |
|
759 |
|
760 desc = struct(); |
|
761 |
|
762 line = fgetl(fid); |
|
763 while (line != -1) |
|
764 ## Comments |
|
765 if (line(1) == "#") |
|
766 # Do nothing |
|
767 ## Continuation lines |
|
768 elseif (isspace(line(1))) |
|
769 if (exist("keyword", "var") && isfield(desc, keyword)) |
|
770 desc.(keyword) = [desc.(keyword) " " rstrip(line)]; |
|
771 endif |
|
772 ## Keyword/value pair |
|
773 else |
|
774 colon = find(line == ":"); |
|
775 if (length(colon) == 0) |
|
776 disp("Skipping line."); |
|
777 else |
|
778 colon = colon(1); |
|
779 keyword = tolower(strip(line(1:colon-1))); |
|
780 value = strip(line(colon+1:end)); |
|
781 if (length(value) == 0) |
|
782 fclose(fid); |
|
783 error("The keyword %s have empty value\n", desc.keywords{end}); |
|
784 endif |
|
785 desc.(keyword) = value; |
|
786 endif |
|
787 endif |
|
788 line = fgetl(fid); |
|
789 endwhile |
|
790 fclose(fid); |
|
791 |
|
792 ## Make sure all is okay |
|
793 needed_fields = {"name", "version", "date", "title", ... |
|
794 "author", "maintainer", "description"}; |
|
795 for f = needed_fields |
|
796 if (!isfield(desc, f{1})) |
|
797 error("Description is missing needed field %s\n", f{1}); |
|
798 endif |
|
799 endfor |
|
800 desc.version = fix_version(desc.version); |
|
801 if (isfield(desc, "depends")) |
|
802 desc.depends = fix_depends(desc.depends); |
|
803 else |
|
804 desc.depends = ""; |
|
805 endif |
|
806 desc.name = tolower(desc.name); |
|
807 endfunction |
|
808 |
|
809 ## Makes sure the version string v is a valid x.y.z version string |
|
810 ## Examples: "0.1" => "0.1.0", "monkey" => error(...) |
|
811 function out = fix_version(v) |
|
812 dots = find(v == "."); |
|
813 if (length(dots) == 1) |
|
814 major = str2num(v(1:dots-1)); |
|
815 minor = str2num(v(dots+1:end)); |
|
816 if (length(major) != 0 && length(minor) != 0) |
|
817 out = sprintf("%d.%d.0", major, minor); |
|
818 return |
|
819 endif |
|
820 elseif (length(dots) == 2) |
|
821 major = str2num(v(1:dots(1)-1)); |
|
822 minor = str2num(v(dots(1)+1:dots(2)-1)); |
|
823 rev = str2num(v(dots(2)+1:end)); |
|
824 if (length(major) != 0 && length(minor) != 0 && length(rev) != 0) |
|
825 out = sprintf("%d.%d.%d", major, minor, rev); |
|
826 return |
|
827 endif |
|
828 endif |
|
829 error("Bad version string: %s\n", v); |
|
830 endfunction |
|
831 |
|
832 ## Makes sure the depends field is of the right format. |
|
833 ## This function returns a cell of structures with the following fields: |
|
834 ## package, version, operator |
|
835 function deps_cell = fix_depends(depends) |
|
836 deps = split_by(tolower(depends), ","); |
|
837 deps_cell = cell(1, length(deps)); |
|
838 |
|
839 ## For each dependency |
|
840 for i = 1:length(deps) |
|
841 dep = deps{i}; |
|
842 lpar = find(dep == "("); |
|
843 rpar = find(dep == ")"); |
|
844 ## Does the dependency specify a version |
|
845 ## Example: package(>= version) |
|
846 if (length(lpar) == 1 && length(rpar) == 1) |
|
847 package = tolower(strip(dep(1:lpar-1))); |
|
848 sub = dep( lpar(1)+1:rpar(1)-1 ); |
|
849 parts = split_by(sub, " "); |
|
850 idx = []; |
|
851 for r = 1:size(parts,1) |
|
852 if (length(parts{r}) > 0) |
|
853 idx(end+1) = r; |
|
854 endif |
|
855 endfor |
|
856 |
|
857 if (length(idx) != 2) |
|
858 error(["There's something wrong with the DESCRIPTION file. " ... |
|
859 "The dependency %s has the wrong syntax.\n"], dep); |
|
860 endif |
|
861 operator = parts{idx(1)}; |
|
862 if (!any(strcmp(operator, {">=", "<=", "=="}))) ## XXX: I belive we also support ">" and "<" |
|
863 error("Unsupported operator: %s\n", operator); |
|
864 endif |
|
865 version = fix_version(parts{idx(2)}); |
|
866 |
|
867 ## If no version is specified for the dependency |
|
868 ## we say that the version should be greater than |
|
869 ## or equal to 0.0.0 |
|
870 else |
|
871 package = tolower(strip(dep)); |
|
872 operator = ">="; |
|
873 version = "0.0.0"; |
|
874 endif |
|
875 deps_cell{i} = struct("package", package, "operator", operator, "version", version); |
|
876 endfor |
|
877 endfunction |
|
878 |
|
879 ## Strips the text of spaces from the right |
|
880 ## Example: " hello world " => " hello world" (XXX: is this the same as deblank?) |
|
881 function text = rstrip(text) |
|
882 chars = find(!isspace(text)); |
|
883 if (length(chars) > 0) |
|
884 text = text(chars(1):end); # XXX: shouldn't it be text = text(1:chars(end)); |
|
885 else |
|
886 text = ""; |
|
887 endif |
|
888 endfunction |
|
889 |
|
890 ## Strips the text of spaces from the left and the right |
|
891 ## Example: " hello world " => "hello world" |
|
892 function text = strip(text) |
|
893 chars = find(!isspace(text)); |
|
894 if (length(chars) > 0) |
|
895 text = text(chars(1):chars(end)); |
|
896 else |
|
897 text = ""; |
|
898 endif |
|
899 endfunction |
|
900 |
|
901 ## Splits the text into a cell array of strings by sep |
|
902 ## Example: "A, B" => {"A", "B"} (with sep = ",") |
|
903 function out = split_by(text, sep) |
|
904 text_matrix = split(text, sep); |
|
905 num_words = size(text_matrix,1); |
|
906 out = cell(num_words, 1); |
|
907 for i = 1:num_words |
|
908 out{i} = strip(text_matrix(i, :)); |
|
909 endfor |
|
910 endfunction |
|
911 |
|
912 ## Creates an INDEX file for a package that doesn't provide one. |
|
913 ## 'desc' describes the package. |
|
914 ## 'dir' is the 'inst' direcotyr in temporary directory. |
|
915 ## 'INDEX' is the name (including path) of resulting INDEX file. |
|
916 function write_INDEX(desc, dir, INDEX) |
|
917 ## Get names of functions in dir |
|
918 [files, err, msg] = readdir(dir); |
|
919 if (err) |
|
920 error("Couldn't read directory %s: %s\n", dir, msg); |
|
921 endif |
|
922 |
|
923 functions = {}; |
|
924 for i = 1:length(files) |
|
925 file = files{i}; |
|
926 lf = length(file); |
|
927 if (lf > 2 && strcmp( file(end-1:end), ".m" )) |
|
928 functions{end+1} = file(1:end-2); |
|
929 elseif (lf > 4 && strcmp( file(end-3:end), ".oct" )) |
|
930 functions{end+1} = file(1:end-4); |
|
931 endif |
|
932 endfor |
|
933 |
|
934 ## Does desc have a categories field? |
|
935 if (!isfield(desc, "categories")) |
|
936 error("The DESCRIPTION file must have a Categories field, when no INDEX file is given.\n"); |
|
937 endif |
|
938 categories = split_by(desc.categories, ","); |
|
939 if (length(categories) < 1) |
|
940 error("The Category field is empty.\n"); |
|
941 endif |
|
942 |
|
943 ## Write INDEX |
|
944 fid = fopen(INDEX, "w"); |
|
945 if (fid == -1) |
|
946 error("Couldn't open %s for writing.\n", INDEX); |
|
947 endif |
|
948 fprintf(fid, "%s >> %s\n", desc.name, desc.title); |
|
949 fprintf(fid, "%s\n", categories{1}); |
|
950 fprintf(fid, " %s\n", functions{:}); |
|
951 fclose(fid); |
|
952 endfunction |
|
953 |
|
954 function bad_deps = get_unsatisfied_deps(desc, installed_packages) |
|
955 bad_deps = {}; |
|
956 |
|
957 ## For each dependency |
|
958 for i = 1:length(desc.depends) |
|
959 dep = desc.depends{i}; |
|
960 |
|
961 ## Is the current dependency Octave? |
|
962 if (strcmp(dep.package, "octave")) |
|
963 if (!compare_versions(OCTAVE_VERSION, dep.version, dep.operator)) |
|
964 bad_deps{end+1} = dep; |
|
965 endif |
|
966 ## Is the current dependency not Octave? |
|
967 else |
|
968 ok = false; |
|
969 for i = 1:length(installed_packages) |
|
970 cur_name = installed_packages{i}.name; |
|
971 cur_version = installed_packages{i}.version; |
|
972 if (strcmp(dep.package, cur_name) && compare_versions(cur_version, dep.version, dep.operator)) |
|
973 ok = true; |
|
974 break; |
|
975 endif |
|
976 endfor |
|
977 if (!ok) |
|
978 bad_deps{end+1} = dep; |
|
979 endif |
|
980 endif |
|
981 endfor |
|
982 endfunction |
|
983 |
|
984 ## Compares to version string using the given operator |
|
985 ## Example: v1="0.1.0", v2="0.0.9", operator=">=" => true |
|
986 ## TODO: This function is very long and complex! Can't it be simplified? |
|
987 function out = compare_versions(v1, v2, operator) |
|
988 dot1 = find(v1 == "."); |
|
989 dot2 = find(v2 == "."); |
|
990 if (length(dot1) != 2 || length(dot2) != 2) |
|
991 error("Given version strings are not valid: %s %s", v1, v2); |
|
992 endif |
|
993 |
|
994 major1 = str2num( v1( 1:dot1(1)-1 ) ); |
|
995 minor1 = str2num( v1( dot1(1)+1:dot1(2)-1 ) ); |
|
996 rev1 = str2num( v1( dot1(2)+1:end ) ); |
|
997 major2 = str2num( v2( 1:dot2(1)-1 ) ); |
|
998 minor2 = str2num( v2( dot2(1)+1:dot2(2)-1 ) ); |
|
999 rev2 = str2num( v2( dot2(2)+1:end) ); |
|
1000 mmr = [sign(major1-major2), sign(minor1-minor2), sign(rev1-rev2)]; |
|
1001 |
|
1002 if (length(operator) > 1 && operator(2) == "=" && !any(mmr)) |
|
1003 out = 1; |
|
1004 return; |
|
1005 elseif (operator(1) == "<") |
|
1006 mmr = -mmr; |
|
1007 endif |
|
1008 |
|
1009 ## Now we ony need to decide if v1 > v2 |
|
1010 if (mmr(1) == 1) |
|
1011 out = 1; |
|
1012 elseif (mmr(1) == -1) |
|
1013 out = 0; |
|
1014 elseif (mmr(2) == 1) |
|
1015 out = 1; |
|
1016 elseif (mmr(2) == -1) |
|
1017 out = 0; |
|
1018 elseif (mmr(3) == 1) |
|
1019 out = 1; |
|
1020 else |
|
1021 out = 0; |
|
1022 endif |
|
1023 endfunction |
|
1024 |
|
1025 function [out1, out2] = installed_packages() |
|
1026 local_list = tilde_expand("~/.octave_packages"); |
6036
|
1027 global_list = fullfile (OCTAVE_HOME (), "/share/octave/octave_packages"); |
5801
|
1028 ## Get the list of installed packages |
|
1029 try |
|
1030 local_packages = load(local_list).local_packages; |
|
1031 catch |
|
1032 local_packages = {}; |
|
1033 end_try_catch |
|
1034 try |
|
1035 global_packages = load(global_list).global_packages; |
|
1036 catch |
|
1037 global_packages = {}; |
|
1038 end_try_catch |
|
1039 installed_packages = {local_packages{:} global_packages{:}}; |
|
1040 |
|
1041 ## Should we return something? |
|
1042 if (nargout == 2) |
|
1043 out1 = local_packages; |
|
1044 out2 = global_packages; |
|
1045 return; |
|
1046 elseif (nargout == 1) |
|
1047 out1 = installed_packages; |
|
1048 return; |
|
1049 endif |
|
1050 |
|
1051 ## We shouldn't return something, so we'll print something |
|
1052 num_packages = length(installed_packages); |
|
1053 if (num_packages == 0) |
|
1054 printf("No packages installed.\n"); |
|
1055 return; |
|
1056 endif |
|
1057 |
5987
|
1058 ## Compute the maximal lengths of name, version, and dir |
5801
|
1059 h1 = "Package Name"; |
|
1060 h2 = "Version"; |
|
1061 h3 = "Installation directory"; |
5987
|
1062 max_name_length = length(h1); |
|
1063 max_version_length = length(h2); |
|
1064 names = cell(num_packages,1); |
|
1065 for i = 1:num_packages |
|
1066 max_name_length = max(max_name_length, |
|
1067 length(installed_packages{i}.name)); |
|
1068 max_version_length = max(max_version_length, |
|
1069 length(installed_packages{i}.version)); |
|
1070 names{i} = installed_packages{i}.name; |
|
1071 endfor |
|
1072 h1 = postpad (h1, max_name_length,' '); |
|
1073 h2 = postpad (h2, max_version_length, ' ');; |
|
1074 |
|
1075 ## Print a header |
5801
|
1076 header = sprintf("%s | %s | %s\n", h1, h2, h3); |
|
1077 printf(header); |
|
1078 tmp = sprintf(repmat("-", 1, length(header)-1)); |
|
1079 tmp(length(h1)+2) = "+"; tmp(length(h1)+length(h2)+5) = "+"; |
|
1080 printf("%s\n", tmp); |
|
1081 |
|
1082 ## Print the packages |
|
1083 format = sprintf("%%%ds | %%%ds | %%s\n", max_name_length, max_version_length); |
5987
|
1084 [dummy, idx] = sort(names); |
5801
|
1085 for i = 1:num_packages |
5987
|
1086 cur_name = installed_packages{idx(i)}.name; |
|
1087 cur_version = installed_packages{idx(i)}.version; |
|
1088 cur_dir = installed_packages{idx(i)}.dir; |
5801
|
1089 printf(format, cur_name, cur_version, cur_dir); |
|
1090 endfor |
|
1091 endfunction |
|
1092 |
|
1093 function load_packages(files, handle_deps) |
|
1094 installed_packages = installed_packages(); |
|
1095 num_packages = length(installed_packages); |
|
1096 |
|
1097 if (length(files) == 1 && strcmp(files{1}, "all")) |
|
1098 dirs = cell(1, num_packages); |
|
1099 for i = 1:num_packages |
|
1100 dirs{i} = installed_packages{i}.dir; |
|
1101 endfor |
|
1102 elseif (handle_deps) |
|
1103 # XXX: implement this |
|
1104 error("Currently you need to call load_packages with 'all' or '-nodeps'. This is a bug!\n"); |
|
1105 else |
|
1106 dirs = cell(1, length(files)); |
|
1107 for j = 1:length(files) |
|
1108 for i = 1:num_packages |
|
1109 if (strcmp(installed_packages{i}.name, files{j})) |
|
1110 dirs{j} = installed_packages{i}.dir; |
5971
|
1111 break; |
5801
|
1112 endif |
|
1113 endfor |
5971
|
1114 if (isempty(dirs{j})) |
|
1115 error("Package %s is not installed\n", files{j}); |
|
1116 endif |
5801
|
1117 endfor |
|
1118 endif |
6025
|
1119 if (length(dirs) > 0) |
|
1120 addpath(dirs{:}); |
|
1121 endif |
5971
|
1122 |
|
1123 ## Add local binaries, if any, to the EXEC_PATH |
|
1124 for i = 1:length(dirs) |
|
1125 if (exist ([dirs{i} "/bin"],"dir")) |
|
1126 EXEC_PATH ([dirs{i} "/bin:" EXEC_PATH()]); |
|
1127 endif |
|
1128 endfor |
5801
|
1129 endfunction |
5928
|
1130 |
|
1131 function [status_out, msg_out] = rm_rf (dir) |
|
1132 crr = confirm_recursive_rmdir (); |
|
1133 unwind_protect |
|
1134 confirm_recursive_rmdir (false); |
|
1135 [status, msg] = rmdir (dir, "s"); |
|
1136 unwind_protect_cleanup |
|
1137 confirm_recursive_rmdir (crr); |
|
1138 end_unwind_protect |
|
1139 if (nargout > 0) |
|
1140 status_out = status; |
|
1141 endif |
|
1142 if (nargout > 1) |
|
1143 msg_out = msg; |
|
1144 endif |
|
1145 endfunction |
5971
|
1146 |
|
1147 function emp = dirempty (nm, ign) |
|
1148 if (nargin < 2) |
|
1149 ign = {".",".."}; |
|
1150 else |
|
1151 ign = [{".",".."},ign]; |
|
1152 endif |
|
1153 l = dir (nm); |
|
1154 for i=1:length(l) |
|
1155 found = false; |
|
1156 for j=1:length(ign) |
|
1157 if (strcmp(l(i).name,ign{j})) |
|
1158 found = true; |
|
1159 break; |
|
1160 endif |
|
1161 endfor |
|
1162 if (!found) |
|
1163 emp = false; |
|
1164 return |
|
1165 endif |
|
1166 endfor |
|
1167 emp = true; |
|
1168 return; |
|
1169 endfunction |