comparison scripts/pkg/pkg.m @ 6683:a2f697dca2a4

[project @ 2007-06-01 23:10:24 by dbateman]
author dbateman
date Fri, 01 Jun 2007 23:10:56 +0000
parents f938c7018d28
children 44ebfc8c4ff0
comparison
equal deleted inserted replaced
6682:1e440ccda1ca 6683:a2f697dca2a4
176 persistent local_list = tilde_expand (fullfile("~", ".octave_packages")); 176 persistent local_list = tilde_expand (fullfile("~", ".octave_packages"));
177 persistent global_list = fullfile (OCTAVE_HOME (), "share", "octave", 177 persistent global_list = fullfile (OCTAVE_HOME (), "share", "octave",
178 "octave_packages"); 178 "octave_packages");
179 mlock (); 179 mlock ();
180 180
181 global_install = issuperuser (); 181 if (ispc () && ! isunix ())
182 global_install = 1;
183 else
184 global_install = (geteuid() == 0);
185 endif
186
182 if (prefix == -1) 187 if (prefix == -1)
183 if (global_install) 188 if (global_install)
184 prefix = fullfile (OCTAVE_HOME (), "share", "octave", "packages"); 189 prefix = fullfile (OCTAVE_HOME (), "share", "octave", "packages");
185 else 190 else
186 prefix = fullfile ("~", "octave"); 191 prefix = fullfile ("~", "octave");
462 endif 467 endif
463 468
464 ## Uncompress the packages and read the DESCRIPTION files 469 ## Uncompress the packages and read the DESCRIPTION files
465 tmpdirs = packdirs = descriptions = {}; 470 tmpdirs = packdirs = descriptions = {};
466 try 471 try
472
473 ## Warn about non existent files
474 for i = 1:length (files)
475 if (isempty (glob(files{i})))
476 warning ("file %s does not exist", files{i});
477 endif
478 endfor
479
467 ## Unpack the package files and read the DESCRIPTION files 480 ## Unpack the package files and read the DESCRIPTION files
468 files = glob (files); 481 files = glob (files);
469 packages_to_uninstall = []; 482 packages_to_uninstall = [];
470 for i = 1:length (files) 483 for i = 1:length (files)
471 tgz = files{i}; 484 tgz = files{i};
529 if (strcmp (packages{j}.name, desc.name)) 542 if (strcmp (packages{j}.name, desc.name))
530 packages_to_uninstall(end+1) = j; 543 packages_to_uninstall(end+1) = j;
531 endif 544 endif
532 endfor 545 endfor
533 endfor 546 endfor
534 else
535 warning ("file %s does not exist", tgz);
536 endif 547 endif
537 endfor 548 endfor
538 catch 549 catch
539 ## Something went wrong, delete tmpdirs 550 ## Something went wrong, delete tmpdirs
540 for i = 1:length (tmpdirs) 551 for i = 1:length (tmpdirs)
1240 lasterr ()); 1251 lasterr ());
1241 end_try_catch 1252 end_try_catch
1242 endif 1253 endif
1243 endfunction 1254 endfunction
1244 1255
1245 function out = issuperuser ()
1246 if (ispc () && ! isunix ())
1247 out = 1;
1248 else
1249 ## Need to be a bit presistent in probing superuser
1250 out = (geteuid() == 0);
1251 endif
1252 endfunction
1253
1254 ## This function makes sure the package contains the 1256 ## This function makes sure the package contains the
1255 ## essential files. 1257 ## essential files.
1256 function verify_directory (dir) 1258 function verify_directory (dir)
1257 needed_files = {"COPYING", "DESCRIPTION"}; 1259 needed_files = {"COPYING", "DESCRIPTION"};
1258 for f = needed_files 1260 for f = needed_files