Mercurial > octave
comparison scripts/pkg/pkg.m @ 6675:f938c7018d28
[project @ 2007-05-31 19:31:14 by dbateman]
author | dbateman |
---|---|
date | Thu, 31 May 2007 19:31:14 +0000 |
parents | f4938870a0a7 |
children | a2f697dca2a4 |
comparison
equal
deleted
inserted
replaced
6674:e236f1b0a221 | 6675:f938c7018d28 |
---|---|
147 ## @example | 147 ## @example |
148 ## pkg rebuild -noauto image | 148 ## pkg rebuild -noauto image |
149 ## @end example | 149 ## @end example |
150 ## | 150 ## |
151 ## will remove the autoloading status of the image package. | 151 ## will remove the autoloading status of the image package. |
152 ## @item build | |
153 ## Builds a binary form of a package or packages. The binary file produced | |
154 ## will itself be an Octave package that can be installed normally with | |
155 ## @code{pkg}. The form of the command to build a binary package is | |
156 ## | |
157 ## @example | |
158 ## pkg build builddir image-1.0.0.tar.gz @dots{} | |
159 ## @end example | |
160 ## | |
161 ## @noindent | |
162 ## where @code{buiddir} is the name of a directory where the temporary | |
163 ## installation will be produced and the binary packages will be found. | |
164 ## The options @code{-verbose} and @code{-nodeps} are respected, while | |
165 ## the other options are ignored. | |
152 ## @end table | 166 ## @end table |
153 ## @end deftypefn | 167 ## @end deftypefn |
154 | 168 |
155 ## PKG_ADD: mark_as_command pkg | 169 ## PKG_ADD: mark_as_command pkg |
156 ## PKG_ADD: pkg ("load", "auto"); | 170 ## PKG_ADD: pkg ("load", "auto"); |
202 global_install = true; | 216 global_install = true; |
203 if (! user_prefix) | 217 if (! user_prefix) |
204 prefix = fullfile (OCTAVE_HOME (), "share", "octave", "packages"); | 218 prefix = fullfile (OCTAVE_HOME (), "share", "octave", "packages"); |
205 endif | 219 endif |
206 case {"list", "install", "uninstall", "load", "unload", ... | 220 case {"list", "install", "uninstall", "load", "unload", ... |
207 "prefix", "local_list", "global_list", "rebuild"} | 221 "prefix", "local_list", "global_list", "rebuild", "build"} |
208 action = varargin{i}; | 222 action = varargin{i}; |
209 otherwise | 223 otherwise |
210 files{end+1} = varargin{i}; | 224 files{end+1} = varargin{i}; |
211 endswitch | 225 endswitch |
212 endfor | 226 endfor |
254 case "prefix" | 268 case "prefix" |
255 if (length (files) == 0 && nargout == 0) | 269 if (length (files) == 0 && nargout == 0) |
256 disp (prefix); | 270 disp (prefix); |
257 elseif (length (files) == 0 && nargout == 1) | 271 elseif (length (files) == 0 && nargout == 1) |
258 local_packages = prefix; | 272 local_packages = prefix; |
259 elseif (length (files) == 1 && nargout == 0 && ischar (files{1})) | 273 elseif (length (files) == 1 && nargout <= 1 && ischar (files{1})) |
260 prefix = files{1}; | 274 prefix = files{1}; |
261 ## if (!strcmp(prefix(end), filesep)) | 275 ## if (!strcmp(prefix(end), filesep)) |
262 ## prefix(end+1) = filesep; | 276 ## prefix(end+1) = filesep; |
263 ## endif | 277 ## endif |
264 prefix = tilde_expand (prefix); | 278 prefix = absolute_pathname (prefix); |
279 local_packages = prefix; | |
265 user_prefix = true; | 280 user_prefix = true; |
266 else | 281 else |
267 error ("you must specify a prefix directory, or request an output argument"); | 282 error ("you must specify a prefix directory, or request an output argument"); |
268 endif | 283 endif |
269 | 284 |
271 if (length (files) == 0 && nargout == 0) | 286 if (length (files) == 0 && nargout == 0) |
272 disp (local_list); | 287 disp (local_list); |
273 elseif (length (files) == 0 && nargout == 1) | 288 elseif (length (files) == 0 && nargout == 1) |
274 local_packages = local_list; | 289 local_packages = local_list; |
275 elseif (length (files) == 1 && nargout == 0 && ischar (files{1})) | 290 elseif (length (files) == 1 && nargout == 0 && ischar (files{1})) |
276 local_list = files{1}; | 291 local_list = absolute_pathname (files{1}); |
277 else | 292 else |
278 error ("you must specify a local_list file, or request an output argument"); | 293 error ("you must specify a local_list file, or request an output argument"); |
279 endif | 294 endif |
280 | 295 |
281 case "global_list" | 296 case "global_list" |
282 if (length (files) == 0 && nargout == 0) | 297 if (length (files) == 0 && nargout == 0) |
283 disp(global_list); | 298 disp(global_list); |
284 elseif (length (files) == 0 && nargout == 1) | 299 elseif (length (files) == 0 && nargout == 1) |
285 local_packages = global_list; | 300 local_packages = global_list; |
286 elseif (length (files) == 1 && nargout == 0 && ischar (files{1})) | 301 elseif (length (files) == 1 && nargout == 0 && ischar (files{1})) |
287 global_list = files{1}; | 302 global_list = absolute_pathname (files{1}); |
288 else | 303 else |
289 error ("you must specify a global_list file, or request an output argument"); | 304 error ("you must specify a global_list file, or request an output argument"); |
290 endif | 305 endif |
291 | 306 |
292 case "rebuild" | 307 case "rebuild" |
293 if (global_install) | 308 if (global_install) |
294 global_packages = rebuild (prefix, global_list, files, auto, verbose); | 309 global_packages = rebuild (prefix, global_list, files, auto, verbose); |
295 save (global_list, "global_packages"); | 310 save (global_list, "global_packages"); |
296 local_packages = global_packages; | 311 local_packages = global_packages; |
297 else | 312 else |
298 local_packages = rebuild (prefix, local_list, files, auto, verbose); | 313 local_packages = rebuild (prefix, local_list, files, auto, verbose); |
299 save (local_list, "local_packages"); | 314 save (local_list, "local_packages"); |
300 endif | 315 endif |
316 | |
317 case "build" | |
318 if (length (files) < 2) | |
319 error ("you must specify at least the build directory and one filename\nwhen calling 'pkg build'"); | |
320 endif | |
321 build (files, deps, auto, verbose); | |
301 | 322 |
302 otherwise | 323 otherwise |
303 error ("you must specify a valid action for 'pkg'. See 'help pkg' for details"); | 324 error ("you must specify a valid action for 'pkg'. See 'help pkg' for details"); |
304 endswitch | 325 endswitch |
305 endfunction | 326 endfunction |
315 else | 336 else |
316 old_descriptions = installed_packages (list, list); | 337 old_descriptions = installed_packages (list, list); |
317 wd = pwd (); | 338 wd = pwd (); |
318 unwind_protect | 339 unwind_protect |
319 cd (prefix); | 340 cd (prefix); |
320 dirlist = glob (cellfun(@(x) [x, '-*'], files, 'UniformOutput', 0)) | 341 dirlist = glob (cellfun(@(x) strcat(x, '-*'), files, 'UniformOutput', 0)) |
321 unwind_protect_cleanup | 342 unwind_protect_cleanup |
322 cd (wd); | 343 cd (wd); |
323 end_unwind_protect | 344 end_unwind_protect |
324 endif | 345 endif |
325 descriptions = {}; | 346 descriptions = {}; |
377 descriptions (dup) = []; | 398 descriptions (dup) = []; |
378 endif | 399 endif |
379 endif | 400 endif |
380 endfunction | 401 endfunction |
381 | 402 |
382 function auto = isautoload (desc) | 403 function build (files, handle_deps, autoload, verbose) |
383 auto = false; | 404 if (length (files) < 1) |
384 if (isfield (desc{1}, "autoload")) | 405 error ("insufficient number of files"); |
385 a = desc{1}.autoload; | 406 endif |
386 if ((isnumeric (a) && a > 0) | 407 builddir = files{1}; |
387 || (ischar (a) && (strcmpi (a, "true") | 408 if (! exist (builddir, "dir")) |
388 || strcmpi (a, "on") | 409 warning ("creating build directory %s", builddir); |
389 || strcmpi (a, "yes") | 410 [status, msg] = mkdir (builddir); |
390 || strcmpi (a, "1")))) | 411 if (status != 1) |
391 auto = true; | 412 error ("could not create installation directory: %s", msg); |
392 endif | 413 endif |
393 endif | 414 endif |
415 builddir = absolute_pathname (builddir); | |
416 installdir = fullfile (builddir, "install"); | |
417 if (! exist (installdir, "dir")) | |
418 [status, msg] = mkdir (installdir); | |
419 if (status != 1) | |
420 error ("could not create installation directory: %s", msg); | |
421 endif | |
422 endif | |
423 files(1) = []; | |
424 buildlist = fullfile (builddir, "octave_packages"); | |
425 install (files, handle_deps, autoload, installdir, verbose, | |
426 buildlist, "", false); | |
427 unwind_protect | |
428 repackage (builddir, buildlist); | |
429 unwind_protect_cleanup | |
430 unload_packages ({"all"}, handle_deps, buildlist, ""); | |
431 if (exist (installdir, "dir")) | |
432 rm_rf (installdir); | |
433 endif | |
434 if (exist (buildlist, "file")) | |
435 unlink (buildlist); | |
436 endif | |
437 end_unwind_protect | |
394 endfunction | 438 endfunction |
395 | 439 |
396 function install (files, handle_deps, autoload, prefix, verbose, local_list, global_list, global_install) | 440 function install (files, handle_deps, autoload, prefix, verbose, local_list, global_list, global_install) |
441 | |
397 | 442 |
398 # Check that the directory in prefix exist. If it doesn't: create it! | 443 # Check that the directory in prefix exist. If it doesn't: create it! |
399 if (! exist (prefix, "dir")) | 444 if (! exist (prefix, "dir")) |
400 warning ("creating installation directory %s", prefix); | 445 warning ("creating installation directory %s", prefix); |
401 [status, msg] = mkdir (prefix); | 446 [status, msg] = mkdir (prefix); |
725 cd (fullfile(desc.dir, "packinfo")); | 770 cd (fullfile(desc.dir, "packinfo")); |
726 on_uninstall (desc); | 771 on_uninstall (desc); |
727 cd (wd); | 772 cd (wd); |
728 endif | 773 endif |
729 ## Do the actual deletion | 774 ## Do the actual deletion |
730 rmpath (desc.dir); | 775 if (desc.loaded) |
731 if (exist (fullfile (desc.dir, getarch()), "dir")) | 776 rmpath (desc.dir); |
732 rmpath (fullfile (desc.dir, getarch ())); | 777 if (exist (fullfile (desc.dir, getarch()), "dir")) |
778 rmpath (fullfile (desc.dir, getarch ())); | |
779 endif | |
733 endif | 780 endif |
734 if (exist (desc.dir, "dir")) | 781 if (exist (desc.dir, "dir")) |
735 [status, msg] = rm_rf (desc.dir); | 782 [status, msg] = rm_rf (desc.dir); |
736 if (status != 1) | 783 if (status != 1) |
737 error ("couldn't delete directory %s: %s", desc.dir, msg); | 784 error ("couldn't delete directory %s: %s", desc.dir, msg); |
761 endfunction | 808 endfunction |
762 | 809 |
763 ########################################################## | 810 ########################################################## |
764 ## A U X I L I A R Y F U N C T I O N S ## | 811 ## A U X I L I A R Y F U N C T I O N S ## |
765 ########################################################## | 812 ########################################################## |
813 | |
814 function pth = absolute_pathname (pth) | |
815 [status, msg, msgid] = fileattrib(pth); | |
816 pth = msg.Name; | |
817 endfunction | |
818 | |
819 function repackage (builddir, buildlist) | |
820 packages = installed_packages (buildlist, buildlist); | |
821 | |
822 wd = pwd(); | |
823 for i = 1 : length(packages) | |
824 pack = packages{i}; | |
825 unwind_protect | |
826 cd (builddir); | |
827 mkdir (pack.name); | |
828 mkdir (fullfile (pack.name, "inst")); | |
829 copyfile (fullfile (pack.dir, "*"), fullfile (pack.name, "inst")); | |
830 movefile (fullfile (pack.name, "inst","packinfo", "*"), pack.name); | |
831 if (exist (fullfile (pack.name, "inst","packinfo", ".autoload"), "file")) | |
832 unlink (fullfile (pack.name, "inst","packinfo", ".autoload")); | |
833 endif | |
834 rmdir (fullfile (pack.name, "inst", "packinfo")); | |
835 if (exist (fullfile (pack.name, "inst", "doc"), "dir")) | |
836 movefile (fullfile (pack.name, "inst", "doc"), pack.name); | |
837 endif | |
838 if (exist (fullfile (pack.name, "inst", "bin"), "dir")) | |
839 movefile (fullfile (pack.name, "inst", "bin"), pack.name); | |
840 endif | |
841 archdir = fullfile (pack.name, "inst", getarch ()); | |
842 if (exist (archdir, "dir")) | |
843 if (exist (fullfile (pack.name, "inst", "PKG_ADD"), "file")) | |
844 unlink (fullfile (pack.name, "inst", "PKG_ADD")); | |
845 endif | |
846 if (exist (fullfile (pack.name, "inst", "PKG_DEL"), "file")) | |
847 unlink (fullfile (pack.name, "inst", "PKG_DEL")); | |
848 endif | |
849 if (exist (fullfile (archdir, "PKG_ADD"), "file")) | |
850 movefile (fullfile (archdir, "PKG_ADD"), | |
851 fullfile (pack.name, "PKG_ADD")); | |
852 endif | |
853 if (exist (fullfile (archdir, "PKG_DEL"), "file")) | |
854 movefile (fullfile (archdir, "PKG_DEL"), | |
855 fullfile (pack.name, "PKG_DEL")); | |
856 endif | |
857 else | |
858 if (exist (fullfile (pack.name, "inst", "PKG_ADD"), "file")) | |
859 movefile (fullfile (pack.name, "inst", "PKG_ADD"), | |
860 fullfile (pack.name, "PKG_ADD")); | |
861 endif | |
862 if (exist (fullfile (pack.name, "inst", "PKG_DEL"), "file")) | |
863 movefile (fullfile (pack.name, "inst", "PKG_DEL"), | |
864 fullfile (pack.name, "PKG_DEL")); | |
865 endif | |
866 endif | |
867 tfile = strcat (pack.name, "-", pack.version, ".tar"); | |
868 tar (tfile, pack.name); | |
869 | |
870 | |
871 unwind_protect_cleanup | |
872 if (exist (pack.name, "dir")) | |
873 rm_rf (pack.name); | |
874 endif | |
875 cd (wd); | |
876 end_unwind_protect | |
877 endfor | |
878 endfunction | |
879 | |
880 function auto = isautoload (desc) | |
881 auto = false; | |
882 if (isfield (desc{1}, "autoload")) | |
883 a = desc{1}.autoload; | |
884 if ((isnumeric (a) && a > 0) | |
885 || (ischar (a) && (strcmpi (a, "true") | |
886 || strcmpi (a, "on") | |
887 || strcmpi (a, "yes") | |
888 || strcmpi (a, "1")))) | |
889 auto = true; | |
890 endif | |
891 endif | |
892 endfunction | |
766 | 893 |
767 function prepare_installation (desc, packdir) | 894 function prepare_installation (desc, packdir) |
768 ## Is there a pre_install to call? | 895 ## Is there a pre_install to call? |
769 if (exist (fullfile (packdir, "pre_install.m"), "file")) | 896 if (exist (fullfile (packdir, "pre_install.m"), "file")) |
770 wd = pwd (); | 897 wd = pwd (); |
801 desc.dir, "\"", | 928 desc.dir, "\"", |
802 " CC=", octave_config_info ("CC"), | 929 " CC=", octave_config_info ("CC"), |
803 " CXX=", octave_config_info ("CXX"), | 930 " CXX=", octave_config_info ("CXX"), |
804 " AR=", octave_config_info ("AR"), | 931 " AR=", octave_config_info ("AR"), |
805 " RANLIB=", octave_config_info ("RANLIB"))); | 932 " RANLIB=", octave_config_info ("RANLIB"))); |
806 if (verbose) | |
807 printf("%s", output); | |
808 endif | |
809 if (status != 0) | 933 if (status != 0) |
810 rm_rf (desc.dir); | 934 rm_rf (desc.dir); |
811 error ("the configure script returned the following error: %s", output); | 935 error ("the configure script returned the following error: %s", output); |
812 endif | 936 elseif (verbose) |
937 printf("%s", output); | |
938 endif | |
939 | |
813 endif | 940 endif |
814 | 941 |
815 ## make | 942 ## make |
816 if (exist (fullfile (src, "Makefile"), "file")) | 943 if (exist (fullfile (src, "Makefile"), "file")) |
817 [status, output] = shell (strcat ("export INSTALLDIR=\"", desc.dir, | 944 [status, output] = shell (strcat ("export INSTALLDIR=\"", desc.dir, |
818 "\"; make -C ", src)); | 945 "\"; make -C ", src)); |
819 if (verbose) | |
820 printf("%s", output); | |
821 endif | |
822 if (status != 0) | 946 if (status != 0) |
823 rm_rf (desc.dir); | 947 rm_rf (desc.dir); |
824 error ("'make' returned the following error: %s", output); | 948 error ("'make' returned the following error: %s", output); |
825 endif | 949 elseif (verbose) |
826 %# make install | 950 printf("%s", output); |
827 %[status, output] = system(["export INSTALLDIR=" desc.dir "; make install -C " src]); | 951 endif |
828 %if (verbose) | |
829 % printf("%s", output); | |
830 %endif | |
831 %if (status != 0) | |
832 % rm_rf(desc.dir); | |
833 % error("'make install' returned the following error: %s", output); | |
834 %endif | |
835 endif | 952 endif |
836 | 953 |
837 ## Copy files to "inst" and "inst/arch" (this is instead of 'make install') | 954 ## Copy files to "inst" and "inst/arch" (this is instead of 'make install') |
838 files = fullfile (src, "FILES"); | 955 files = fullfile (src, "FILES"); |
839 instdir = fullfile (packdir, "inst"); | 956 instdir = fullfile (packdir, "inst"); |
878 if (length (m) > 0) | 995 if (length (m) > 0) |
879 filenames = sprintf (fullfile (src, "%s "), m.name); | 996 filenames = sprintf (fullfile (src, "%s "), m.name); |
880 archindependent = sprintf (fullfile (src, "%s "), m.name); | 997 archindependent = sprintf (fullfile (src, "%s "), m.name); |
881 endif | 998 endif |
882 if (length (oct) > 0) | 999 if (length (oct) > 0) |
883 filenames = [filenames, " ", sprintf(fullfile(src, "%s "), oct.name)]; | 1000 filenames = strcat (filenames, " ", sprintf(fullfile(src, "%s "), ... |
884 archdependent = [archdependent, " ", ... | 1001 oct.name)); |
885 sprintf(fullfile(src, "%s "), oct.name)]; | 1002 archdependent = strcat (archdependent, " ", ... |
1003 sprintf(fullfile(src, "%s "), oct.name)); | |
886 endif | 1004 endif |
887 if (length (mex) > 0) | 1005 if (length (mex) > 0) |
888 filenames = [filenames, " ", sprintf(fullfile(src, "%s "), mex.name)]; | 1006 filenames = strcat (filenames, " ", sprintf(fullfile(src, "%s "), ... |
889 archdependent = [archdependent, " ", ... | 1007 mex.name)); |
890 sprintf(fullfile(src, "%s "), mex.name)]; | 1008 archdependent = strcat (archdependent, " ", ... |
1009 sprintf(fullfile(src, "%s "), mex.name)); | |
891 endif | 1010 endif |
892 filenames = split_by (filenames, " "); | 1011 filenames = split_by (filenames, " "); |
893 archdependent = split_by (archdependent, " "); | 1012 archdependent = split_by (archdependent, " "); |
894 archindependent = split_by (archindependent, " "); | 1013 archindependent = split_by (archindependent, " "); |
895 endif | 1014 endif |
949 fclose (fid); | 1068 fclose (fid); |
950 endif | 1069 endif |
951 endfunction | 1070 endfunction |
952 | 1071 |
953 function create_pkgadddel (desc, packdir, nm) | 1072 function create_pkgadddel (desc, packdir, nm) |
954 archdir = fullfile (desc.dir, getarch ()); | 1073 instpkg = fullfile (desc.dir, nm); |
955 | 1074 instfid = fopen (instpkg, "wt"); |
956 ## If it is exists, the PKG_* files should go into the architecture | 1075 ## If it is exists, most of the PKG_* file should go into the |
957 ## dependent directory so that the autoload/mfilename commands work | 1076 ## architecture dependent directory so that the autoload/mfilename |
958 ## as expected... | 1077 ## commands work as expected. The only part that doesn't is the |
959 if (exist (archdir, "dir")) | 1078 ## part in the main directory. |
960 pkg = fullfile (desc.dir, getarch(), nm); | 1079 if (exist (fullfile (desc.dir, getarch ()), "dir")) |
1080 archpkg = fullfile (desc.dir, getarch (), nm); | |
1081 archfid = fopen (archpkg, "wt"); | |
961 else | 1082 else |
962 pkg = fullfile (desc.dir, nm); | 1083 archpkg = instpkg; |
963 endif | 1084 archfid = instfid; |
964 fid = fopen (pkg, "wt"); | 1085 endif |
965 | 1086 |
966 if (fid >= 0) | 1087 if (archfid >= 0 && instfid >= 0) |
967 ## Search all dot-m files for PKG commands | 1088 ## Search all dot-m files for PKG commands |
968 lst = dir (fullfile(packdir, "inst", "*.m")); | 1089 lst = dir (fullfile(packdir, "inst", "*.m")); |
969 for i = 1:length (lst) | 1090 for i = 1:length (lst) |
970 nam = fullfile(packdir, "inst", lst(i).name); | 1091 nam = fullfile(packdir, "inst", lst(i).name); |
971 fwrite (fid, extract_pkg (nam, ['^[#%][#%]* *' nm ': *(.*)$'])); | 1092 fwrite (instfid, extract_pkg (nam, ['^[#%][#%]* *' nm ': *(.*)$'])); |
972 endfor | 1093 endfor |
973 | 1094 |
974 ## Search all C++ source files for PKG commands | 1095 ## Search all C++ source files for PKG commands |
975 lst = dir (fullfile(packdir, "src", "*.cc")); | 1096 lst = dir (fullfile(packdir, "src", "*.cc")); |
976 for i = 1:length (lst) | 1097 for i = 1:length (lst) |
977 nam = fullfile(packdir, "src", lst(i).name); | 1098 nam = fullfile(packdir, "src", lst(i).name); |
978 fwrite (fid, extract_pkg (nam, ['^//* *' nm ': *(.*)$'])); | 1099 fwrite (archfid, extract_pkg (nam, ['^//* *' nm ': *(.*)$'])); |
979 fwrite (fid, extract_pkg (nam, ['^/\** *' nm ': *(.*) *\*/$'])); | 1100 fwrite (archfid, extract_pkg (nam, ['^/\** *' nm ': *(.*) *\*/$'])); |
980 endfor | 1101 endfor |
981 | 1102 |
982 ## Add developer included PKG commands | 1103 ## Add developer included PKG commands |
983 packdirnm = fullfile (packdir, nm); | 1104 packdirnm = fullfile (packdir, nm); |
984 if (exist (packdirnm, "file")) | 1105 if (exist (packdirnm, "file")) |
985 fid2 = fopen (packdirnm, "rt"); | 1106 fid = fopen (packdirnm, "rt"); |
986 if (fid2 >= 0) | 1107 if (fid >= 0) |
987 while (! feof (fid2)) | 1108 while (! feof (fid)) |
988 ln = fgets (fid2); | 1109 ln = fgets (fid); |
989 if (ln > 0) | 1110 if (ln > 0) |
990 fwrite (fid, ln); | 1111 fwrite (archfid, ln); |
991 endif | 1112 endif |
992 endwhile | 1113 endwhile |
993 fclose (fid2); | 1114 fclose (fid); |
994 endif | 1115 endif |
995 endif | 1116 endif |
996 fclose (fid); | 1117 |
997 | 1118 ## If the files is empty remove it |
998 ## If the file is empty remove it | 1119 fclose (instfid); |
999 t = dir (pkg); | 1120 t = dir (instpkg); |
1000 if (t.bytes <= 0) | 1121 if (t.bytes <= 0) |
1001 unlink (pkg); | 1122 unlink (instpkg); |
1123 endif | |
1124 | |
1125 if (instfid != archfid) | |
1126 fclose (archfid); | |
1127 t = dir (archpkg); | |
1128 if (t.bytes <= 0) | |
1129 unlink (archpkg); | |
1130 endif | |
1002 endif | 1131 endif |
1003 endif | 1132 endif |
1004 endfunction | 1133 endfunction |
1005 | 1134 |
1006 function copy_files (desc, packdir, bindir) | 1135 function copy_files (desc, packdir, bindir) |
1383 local_packages = load (local_list).local_packages; | 1512 local_packages = load (local_list).local_packages; |
1384 catch | 1513 catch |
1385 local_packages = {}; | 1514 local_packages = {}; |
1386 end_try_catch | 1515 end_try_catch |
1387 try | 1516 try |
1388 if (strcmp(local_list, global_list)) | 1517 global_packages = load (global_list).global_packages; |
1389 global_packages = {}; | |
1390 else | |
1391 global_packages = load (global_list).global_packages; | |
1392 endif | |
1393 catch | 1518 catch |
1394 global_packages = {}; | 1519 global_packages = {}; |
1395 end_try_catch | 1520 end_try_catch |
1396 installed_packages = {local_packages{:}, global_packages{:}}; | 1521 installed_packages = {local_packages{:}, global_packages{:}}; |
1397 | 1522 |
1420 for i = 1:length (installed_packages) | 1545 for i = 1:length (installed_packages) |
1421 if (regexp (tmppath, strrep (installed_packages{i}.dir, "\\", "/"))) | 1546 if (regexp (tmppath, strrep (installed_packages{i}.dir, "\\", "/"))) |
1422 installed_packages{i}.loaded = true; | 1547 installed_packages{i}.loaded = true; |
1423 else | 1548 else |
1424 installed_packages{i}.loaded = false; | 1549 installed_packages{i}.loaded = false; |
1550 endif | |
1551 endfor | |
1552 for i = 1:length (local_packages) | |
1553 if (regexp (tmppath, strrep (local_packages{i}.dir, "\\", "/"))) | |
1554 local_packages{i}.loaded = true; | |
1555 else | |
1556 local_packages{i}.loaded = false; | |
1557 endif | |
1558 endfor | |
1559 for i = 1:length (global_packages) | |
1560 if (regexp (tmppath, strrep (global_packages{i}.dir, "\\", "/"))) | |
1561 global_packages{i}.loaded = true; | |
1562 else | |
1563 global_packages{i}.loaded = false; | |
1425 endif | 1564 endif |
1426 endfor | 1565 endfor |
1427 | 1566 |
1428 ## Should we return something? | 1567 ## Should we return something? |
1429 if (nargout == 2) | 1568 if (nargout == 2) |
1495 pdirs{i} = installed_packages{i}.dir; | 1634 pdirs{i} = installed_packages{i}.dir; |
1496 pdeps{i} = installed_packages{i}.depends; | 1635 pdeps{i} = installed_packages{i}.depends; |
1497 endfor | 1636 endfor |
1498 | 1637 |
1499 ## load all | 1638 ## load all |
1639 dirs = {}; | |
1500 if (length (files) == 1 && strcmp (files{1}, "all")) | 1640 if (length (files) == 1 && strcmp (files{1}, "all")) |
1501 dirs = pdirs; | 1641 dirs = pdirs; |
1502 ## load auto | 1642 ## load auto |
1503 elseif (length (files) == 1 && strcmp (files{1}, "auto")) | 1643 elseif (length (files) == 1 && strcmp (files{1}, "auto")) |
1504 dirs = {}; | |
1505 for i = 1:length (installed_packages) | 1644 for i = 1:length (installed_packages) |
1506 if (exist (fullfile (pdirs{i}, "packinfo", ".autoload"), "file")) | 1645 if (exist (fullfile (pdirs{i}, "packinfo", ".autoload"), "file")) |
1507 dirs{end+1} = pdirs{i}; | 1646 dirs{end+1} = pdirs{i}; |
1508 endif | 1647 endif |
1509 endfor | 1648 endfor |
1510 ## load package_name1 ... | 1649 ## load package_name1 ... |
1511 else | 1650 else |
1512 dirs = {}; | |
1513 for i = 1:length (files) | 1651 for i = 1:length (files) |
1514 idx = strcmp (pnames, files{i}); | 1652 idx = strcmp (pnames, files{i}); |
1515 if (! any (idx)) | 1653 if (! any (idx)) |
1516 error ("package %s is not installed", files{i}); | 1654 error ("package %s is not installed", files{i}); |
1517 endif | 1655 endif |
1538 ## Check for architecture dependent directories | 1676 ## Check for architecture dependent directories |
1539 arch = getarch(); | 1677 arch = getarch(); |
1540 archdirs = {}; | 1678 archdirs = {}; |
1541 for i = 1:length (dirs) | 1679 for i = 1:length (dirs) |
1542 tmpdir = fullfile (dirs{i}, arch); | 1680 tmpdir = fullfile (dirs{i}, arch); |
1681 archdirs{end + 1} = dirs{i}; | |
1543 if (exist (tmpdir, "dir")) | 1682 if (exist (tmpdir, "dir")) |
1544 archdirs{end + 1} = dirs{i}; | |
1545 archdirs{end + 1} = tmpdir; | 1683 archdirs{end + 1} = tmpdir; |
1546 endif | 1684 endif |
1547 endfor | 1685 endfor |
1548 if (length (archdirs) > 0) | 1686 if (length (archdirs) > 0) |
1549 dirs = archdirs; | 1687 dirs = archdirs; |
1655 endfor | 1793 endfor |
1656 emp = true; | 1794 emp = true; |
1657 endfunction | 1795 endfunction |
1658 | 1796 |
1659 function arch = getarch () | 1797 function arch = getarch () |
1660 persistent _arch = [octave_config_info("canonical_host_type"), "-", ... | 1798 persistent _arch = strcat (octave_config_info("canonical_host_type"), ... |
1661 octave_config_info("api_version")]; | 1799 "-", octave_config_info("api_version")); |
1662 arch = _arch; | 1800 arch = _arch; |
1663 endfunction | 1801 endfunction |
1664 | 1802 |
1665 function [status, output] = shell (cmd) | 1803 function [status, output] = shell (cmd) |
1666 | |
1667 persistent have_sh; | 1804 persistent have_sh; |
1668 | 1805 |
1669 cmd = strrep (cmd, "\\", "/"); | 1806 cmd = strrep (cmd, "\\", "/"); |
1670 disp (cmd); | |
1671 if (ispc () && ! isunix ()) | 1807 if (ispc () && ! isunix ()) |
1672 if (isempty(have_sh)) | 1808 if (isempty(have_sh)) |
1673 if (system("sh.exe -c \"exit\"")) | 1809 if (system("sh.exe -c \"exit\"")) |
1674 have_sh = false; | 1810 have_sh = false; |
1675 else | 1811 else |
1676 have_sh = true; | 1812 have_sh = true; |
1677 endif | 1813 endif |
1678 endif | 1814 endif |
1679 if (have_sh) | 1815 if (have_sh) |
1680 [status, output] = system (["sh.exe -c \"", cmd, "\""]); | 1816 [status, output] = system (strcat ("sh.exe -c \"", cmd, "\"")); |
1681 else | 1817 else |
1682 error ("Can not find the command shell") | 1818 error ("Can not find the command shell") |
1683 endif | 1819 endif |
1684 else | 1820 else |
1685 [status, output] = system (cmd); | 1821 [status, output] = system (cmd); |
1686 endif | 1822 endif |
1687 disp(output); | 1823 endfunction |
1688 | |
1689 endfunction |