Mercurial > hg > octave-lyh
comparison scripts/pkg/pkg.m @ 6655:8dda89ca38f6
[project @ 2007-05-22 19:25:29 by jwe]
author | jwe |
---|---|
date | Tue, 22 May 2007 19:25:29 +0000 |
parents | 81eb28d50cee |
children | f4938870a0a7 |
comparison
equal
deleted
inserted
replaced
6654:3390577e4e70 | 6655:8dda89ca38f6 |
---|---|
490 catch | 490 catch |
491 ## Something went wrong, delete tmpdirs | 491 ## Something went wrong, delete tmpdirs |
492 for i = 1:length (tmpdirs) | 492 for i = 1:length (tmpdirs) |
493 rm_rf (tmpdirs{i}); | 493 rm_rf (tmpdirs{i}); |
494 endfor | 494 endfor |
495 error (lasterr()(8:end)); | 495 rethrow (lasterror ()); |
496 end_try_catch | 496 end_try_catch |
497 | 497 |
498 ## Check dependencies | 498 ## Check dependencies |
499 if (handle_deps) | 499 if (handle_deps) |
500 ok = true; | 500 ok = true; |
534 catch | 534 catch |
535 ## Something went wrong, delete tmpdirs | 535 ## Something went wrong, delete tmpdirs |
536 for i = 1:length (tmpdirs) | 536 for i = 1:length (tmpdirs) |
537 rm_rf (tmpdirs{i}); | 537 rm_rf (tmpdirs{i}); |
538 endfor | 538 endfor |
539 error (lasterr()(8:end)); | 539 rethrow (lasterror ()); |
540 end_try_catch | 540 end_try_catch |
541 | 541 |
542 ## Uninstall the packages that will be replaced | 542 ## Uninstall the packages that will be replaced |
543 try | 543 try |
544 for i = packages_to_uninstall | 544 for i = packages_to_uninstall |
548 catch | 548 catch |
549 ## Something went wrong, delete tmpdirs | 549 ## Something went wrong, delete tmpdirs |
550 for i = 1:length (tmpdirs) | 550 for i = 1:length (tmpdirs) |
551 rm_rf (tmpdirs{i}); | 551 rm_rf (tmpdirs{i}); |
552 endfor | 552 endfor |
553 error (lasterr()(8:end)); | 553 rethrow (lasterror ()); |
554 end_try_catch | 554 end_try_catch |
555 | 555 |
556 ## Install each package | 556 ## Install each package |
557 try | 557 try |
558 for i = 1:length (descriptions) | 558 for i = 1:length (descriptions) |
569 rm_rf (tmpdirs{i}); | 569 rm_rf (tmpdirs{i}); |
570 endfor | 570 endfor |
571 for i = 1:length (descriptions) | 571 for i = 1:length (descriptions) |
572 rm_rf (descriptions{i}.dir); | 572 rm_rf (descriptions{i}.dir); |
573 endfor | 573 endfor |
574 error (lasterr()(8:end)); | 574 rethrow (lasterror ()); |
575 end_try_catch | 575 end_try_catch |
576 | 576 |
577 ## Check if the installed directory is empty. If it is remove it | 577 ## Check if the installed directory is empty. If it is remove it |
578 ## from the list | 578 ## from the list |
579 for i = length (descriptions):-1:1 | 579 for i = length (descriptions):-1:1 |
580 if (dirempty (descriptions{i}.dir, {"packinfo", "doc"})) | 580 if (dirempty (descriptions{i}.dir, {"packinfo", "doc"})) |
581 warning ("package %s is empty\n", descriptions{i}.name); | |
581 rm_rf (descriptions{i}.dir); | 582 rm_rf (descriptions{i}.dir); |
582 descriptions(i) = []; | 583 descriptions(i) = []; |
583 endif | 584 endif |
584 endfor | 585 endfor |
585 | 586 |
663 | 664 |
664 ## Are all the packages that should be uninstalled already installed? | 665 ## Are all the packages that should be uninstalled already installed? |
665 if (length (delete_idx) != length (pkgnames)) | 666 if (length (delete_idx) != length (pkgnames)) |
666 if (global_install) | 667 if (global_install) |
667 ## Try again for a locally installed package | 668 ## Try again for a locally installed package |
668 installed_packages = local_packages | 669 installed_packages = local_packages; |
669 | 670 |
670 num_packages = length (installed_packages); | 671 num_packages = length (installed_packages); |
671 delete_idx = []; | 672 delete_idx = []; |
672 for i = 1:num_packages | 673 for i = 1:num_packages |
673 cur_name = installed_packages{i}.name; | 674 cur_name = installed_packages{i}.name; |
675 delete_idx(end+1) = i; | 676 delete_idx(end+1) = i; |
676 endif | 677 endif |
677 endfor | 678 endfor |
678 if (length (delete_idx) != length (pkgnames)) | 679 if (length (delete_idx) != length (pkgnames)) |
679 ## XXX: We should have a better error message | 680 ## XXX: We should have a better error message |
680 error ("some of the packages you want to uninstall are not installed"); | 681 warning ("some of the packages you want to uninstall are not installed"); |
681 endif | 682 endif |
682 else | 683 else |
683 ## XXX: We should have a better error message | 684 ## XXX: We should have a better error message |
684 error ("some of the packages you want to uninstall are not installed."); | 685 warning ("some of the packages you want to uninstall are not installed."); |
685 endif | 686 endif |
686 endif | 687 endif |
687 | 688 |
688 ## Compute the packages that will remain installed | 689 ## Compute the packages that will remain installed |
689 idx = complement (delete_idx, 1:num_packages); | 690 idx = complement (delete_idx, 1:num_packages); |
832 | 833 |
833 ## Copy files to "inst" and "inst/arch" (this is instead of 'make install') | 834 ## Copy files to "inst" and "inst/arch" (this is instead of 'make install') |
834 files = fullfile (src, "FILES"); | 835 files = fullfile (src, "FILES"); |
835 instdir = fullfile (packdir, "inst"); | 836 instdir = fullfile (packdir, "inst"); |
836 archdir = fullfile (packdir, "inst", getarch ()); | 837 archdir = fullfile (packdir, "inst", getarch ()); |
838 ## Get file names | |
837 if (exist (files, "file")) | 839 if (exist (files, "file")) |
838 ## Get file names | |
839 [fid, msg] = fopen (files, "r"); | 840 [fid, msg] = fopen (files, "r"); |
840 if (fid < 0) | 841 if (fid < 0) |
841 error ("couldn't open %s: %s", files, msg); | 842 error ("couldn't open %s: %s", files, msg); |
842 endif | 843 endif |
843 filenames = char (fread (fid))'; | 844 filenames = char (fread (fid))'; |
844 fclose (fid); | 845 fclose (fid); |
845 if (filenames(end) == "\n") | 846 if (filenames(end) == "\n") |
846 filenames(end) = []; | 847 filenames(end) = []; |
847 endif | 848 endif |
848 ## Copy the files | 849 filenames = split_by (filenames, "\n"); |
849 fn = split_by (filenames, "\n"); | |
850 delete_idx = []; | 850 delete_idx = []; |
851 for i = 1:length (fn) | 851 for i = 1:length (filenames) |
852 if (! all (isspace (fn{i}))) | 852 if (! all (isspace (filenames{i}))) |
853 fn{i} = fullfile (src, fn{i}); | 853 filenames{i} = fullfile (src, filenames{i}); |
854 else | 854 else |
855 delete_idx(end+1) = i; | 855 delete_idx(end+1) = i; |
856 endif | 856 endif |
857 endfor | 857 endfor |
858 fn(delete_idx) = []; | 858 filenames(delete_idx) = []; |
859 filenames = sprintf ("%s ", fn{:}); | 859 idx1 = cellfun ("isempty", regexp (filenames, '^.*\.mex')); |
860 | 860 idx2 = cellfun ("isempty", regexp (filenames, '^.*\.oct')); |
861 filenames = split_by (filenames, " "); | 861 mex = filenames; |
862 mex(idx1 != 0) = []; | |
863 oct = filenames; | |
864 oct(idx2 != 0) = []; | |
862 archindependent = filenames; | 865 archindependent = filenames; |
863 mex = regexp (filenames, '^.*\.mex'); | 866 archindependent(idx1 == 0 | idx2 == 0) = []; |
864 archindependent(cellfun ("isempty", mex) == 0) = []; | |
865 mex (cellfun ("isempty", mex)) = []; | |
866 mex = cellfun (@(x) x(1), mex); | |
867 oct = regexp (filenames, '^.*\.oct'); | |
868 archindependent(cellfun ("isempty", oct) == 0) = []; | |
869 oct (cellfun ("isempty", oct)) = []; | |
870 oct = cellfun (@(x) x(1), oct); | |
871 archdependent = [oct, mex]; | 867 archdependent = [oct, mex]; |
872 else | 868 else |
873 m = dir (fullfile (src, "*.m")); | 869 m = dir (fullfile (src, "*.m")); |
874 oct = dir (fullfile (src, "*.oct")); | 870 oct = dir (fullfile (src, "*.oct")); |
875 mex = dir (fullfile (src, "*.mex")); | 871 mex = dir (fullfile (src, "*.mex")); |
893 filenames = split_by (filenames, " "); | 889 filenames = split_by (filenames, " "); |
894 archdependent = split_by (archdependent, " "); | 890 archdependent = split_by (archdependent, " "); |
895 archindependent = split_by (archindependent, " "); | 891 archindependent = split_by (archindependent, " "); |
896 endif | 892 endif |
897 | 893 |
894 ## Copy the files | |
898 if (! all (isspace (filenames))) | 895 if (! all (isspace (filenames))) |
899 mkdir (instdir); | 896 if (! exist (instdir, "dir")) |
897 mkdir (instdir); | |
898 endif | |
900 if (! all (isspace (archindependent))) | 899 if (! all (isspace (archindependent))) |
901 if (verbose) | 900 if (verbose) |
902 printf ("copyfile"); | 901 printf ("copyfile"); |
903 printf (" %s", archindependent{:}); | 902 printf (" %s", archindependent{:}); |
904 printf ("%s\n", instdir); | 903 printf ("%s\n", instdir); |
913 if (verbose) | 912 if (verbose) |
914 printf ("copyfile"); | 913 printf ("copyfile"); |
915 printf (" %s", archdependent{:}); | 914 printf (" %s", archdependent{:}); |
916 printf (" %s\n", archdir); | 915 printf (" %s\n", archdir); |
917 endif | 916 endif |
918 mkdir (archdir); | 917 if (! exist (archdir, "dir")) |
918 mkdir (archdir); | |
919 endif | |
919 [status, output] = copyfile (archdependent, archdir); | 920 [status, output] = copyfile (archdependent, archdir); |
920 if (status != 1) | 921 if (status != 1) |
921 rm_rf (desc.dir); | 922 rm_rf (desc.dir); |
922 error ("Couldn't copy files from 'src' to 'inst': %s", output); | 923 error ("Couldn't copy files from 'src' to 'inst': %s", output); |
923 endif | 924 endif |