octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OctavePackaging


From: David Bateman
Subject: Re: OctavePackaging
Date: Fri, 11 May 2007 18:31:31 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Thomas,

What about something like the attached patch to pkg.m. If adds the
features discussed in the previous e-mail.. I hope this is sufficient to
address your needs..

Regards
David


-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

*** ./scripts/pkg/pkg.m.orig31  2007-04-11 10:39:45.000000000 +0200
--- ./scripts/pkg/pkg.m 2007-05-11 17:38:58.411811605 +0200
***************
*** 573,592 ****
      desc = installed_packages{i};
      ## If an 'on_uninstall.m' exist, call it!
      if (exist (fullfile (desc.dir, "packinfo", "on_uninstall.m"), "file"))
!       try
!       wd = pwd ();
!       cd (fullfile(desc.dir, "packinfo"));
!       on_uninstall (desc);
!       cd (wd);
!       catch
!       ## XXX: Should this rather be an error?
!       warning ("the 'on_uninstall' script retsurned the following error: %s",
!                lasterr ());
!       cd (wd);
!       end_try_catch
      endif
      ## Do the actual deletion
      rmpath (desc.dir);
      if (exist (desc.dir, "dir"))
        [status, msg] = rm_rf (desc.dir);
        if (status != 1)
--- 573,588 ----
      desc = installed_packages{i};
      ## If an 'on_uninstall.m' exist, call it!
      if (exist (fullfile (desc.dir, "packinfo", "on_uninstall.m"), "file"))
!       wd = pwd ();
!       cd (fullfile(desc.dir, "packinfo"));
!       on_uninstall (desc);
!       cd (wd);
      endif
      ## Do the actual deletion
      rmpath (desc.dir);
+     if (exist (fullfile (desc.dir, getarch()), "dir"))
+       rmpath (fullfile (desc.dir, getarch ()));
+     endif
      if (exist (desc.dir, "dir"))
        [status, msg] = rm_rf (desc.dir);
        if (status != 1)
***************
*** 677,685 ****
        %endif
      endif
  
!     ## Copy files to "inst" (this is instead of 'make install')
      files = fullfile (src, "FILES");
      instdir = fullfile (packdir, "inst");
      if (exist (files, "file"))
        ## Get file names
        [fid, msg] = fopen (files, "r");
--- 673,682 ----
        %endif
      endif
  
!     ## Copy files to "inst" and "inst/arch" (this is instead of 'make 
install')
      files = fullfile (src, "FILES");
      instdir = fullfile (packdir, "inst");
+     archdir = fullfile (packdir, "inst", getarch ());
      if (exist (files, "file"))
        ## Get file names
        [fid, msg] = fopen (files, "r");
***************
*** 703,732 ****
        endfor
        fn(delete_idx) = [];
        filenames = sprintf ("%s ", fn{:});
      else
        m = dir (fullfile (src, "*.m"));
        oct = dir (fullfile (src, "*.oct"));
        mex = dir (fullfile (src, "*.mex"));
        filenames = "";
        if (length (m) > 0)
        filenames = sprintf (fullfile (src, "%s "), m.name);
        endif
        if (length (oct) > 0)
        filenames = [filenames, " ", sprintf(fullfile(src, "%s "), oct.name)];
        endif
        if (length (mex) > 0)
        filenames = [filenames, " ", sprintf(fullfile(src, "%s "), mex.name)];
        endif
      endif
-     filenames = split_by (filenames, " ");
  
      if (! all (isspace (filenames)))
        mkdir (instdir);
!       [status, output] = copyfile (filenames, instdir);
!       if (status != 1)
            rm_rf (desc.dir);
            error ("Couldn't copy files from 'src' to 'inst': %s", output);
!       endif
      endif
    endif
  endfunction
--- 700,760 ----
        endfor
        fn(delete_idx) = [];
        filenames = sprintf ("%s ", fn{:});
+ 
+       filenames = split_by (filenames, " ");
+       archindependent = filenames;
+       mex = regexp (filenames, '^.*\.mex');
+       archindependent(cellfun ("isempty", mex) == 0) = [];
+       mex (cellfun ("isempty", mex)) = [];
+       mex = cellfun (@(x) x(1), mex);
+       oct = regexp (filenames, '^.*\.oct');
+       archindependent(cellfun ("isempty", oct) == 0) = [];
+       oct (cellfun ("isempty", oct)) = [];
+       oct = cellfun (@(x) x(1), oct);
+       archdependent = [oct, mex];
      else
        m = dir (fullfile (src, "*.m"));
        oct = dir (fullfile (src, "*.oct"));
        mex = dir (fullfile (src, "*.mex"));
+       archdependent = "";
+       archindependent = "";
        filenames = "";
        if (length (m) > 0)
        filenames = sprintf (fullfile (src, "%s "), m.name);
+       archindependent = sprintf (fullfile (src, "%s "), m.name);
        endif
        if (length (oct) > 0)
        filenames = [filenames, " ", sprintf(fullfile(src, "%s "), oct.name)];
+       archdependent = [archdependent, " ", ...
+                        sprintf(fullfile(src, "%s "), oct.name)];
        endif
        if (length (mex) > 0)
        filenames = [filenames, " ", sprintf(fullfile(src, "%s "), mex.name)];
+       archdependent = [archdependent, " ", ...
+                        sprintf(fullfile(src, "%s "), mex.name)];
        endif
+       filenames = split_by (filenames, " ");
+       archdependent = split_by (archdependent, " ");
+       archindependent = split_by (archindependent, " ");
      endif
  
      if (! all (isspace (filenames)))
        mkdir (instdir);
!       if (! all (isspace (archindependent)))
!         [status, output] = copyfile (archindependent, instdir);
!         if (status != 1)
            rm_rf (desc.dir);
            error ("Couldn't copy files from 'src' to 'inst': %s", output);
!         endif
!         endif
!       if (! all (isspace (archdependent)))
!         mkdir (archdir);
!         [status, output] = copyfile (archdependent, archdir);
!         if (status != 1)
!           rm_rf (desc.dir);
!           error ("Couldn't copy files from 'src' to 'inst': %s", output);
!         endif
!         endif
      endif
    endif
  endfunction
***************
*** 1296,1301 ****
--- 1324,1343 ----
      dirs = unique(dirs);
    endif
  
+   ## Check for architecture dependent directories
+   arch = getarch();
+   archdirs = {};
+   for i = 1:length (dirs)
+     tmpdir = fullfile (dirs{i}, arch);
+     if (exist (tmpdir, "dir"))
+       archdirs{end + 1} = dirs{i};
+       archdirs{end + 1} = tmpdir;
+     endif
+   endfor
+   if (length (archdirs) > 0)
+     dirs = archdirs;
+   endif
+ 
    ## Load the packages
    if (length (dirs) > 0)
      addpath (dirs{:});
***************
*** 1339,1344 ****
--- 1381,1400 ----
        endfor
    endif
  
+   ## Check for architecture dependent directories
+   arch = getarch();
+   archdirs = {};
+   for i = 1:length (dirs)
+     tmpdir = fullfile (dirs{i}, arch);
+     if (exist (tmpdir, "dir"))
+       archdirs{end + 1} = dirs{i};
+       archdirs{end + 1} = tmpdir;
+     endif
+   endfor
+   if (length (archdirs) > 0)
+     dirs = archdirs;
+   endif
+ 
    ## Unload the packages
    for i = 1:length (dirs)
      d = dirs{i};
***************
*** 1388,1390 ****
--- 1444,1451 ----
    endfor
    emp = true;
  endfunction
+ 
+ function arch = getarch ()
+  unm = uname ();
+  arch = [unm.sysname, "-", unm.machine];
+ endfunction

reply via email to

[Prev in Thread] Current Thread [Next in Thread]