octave-maintainers
[Top][All Lists]
Advanced

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

Re: Issues with build Fedora RPMs of octave packages


From: David Bateman
Subject: Re: Issues with build Fedora RPMs of octave packages
Date: Sat, 22 Sep 2007 00:41:12 +0200
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Orion Poplawski wrote:
>
> I have made some hacks to split the .oct files into LOCALAPIOCTFILEDIR,
> but this bring up an issue with the recommended format of PKG_ADD:
> 
> autoload ("airy_Ai_deriv", fullfile (fileparts (mfilename ("fullpath")),
> "gsl_sf.oct"));
> 
> Which expects the PKG_ADD file to be in the same directory as the .oct
> files, which is not the case with the split.
>

What about the attached patch. This means that if we have the PKG_ADD
file in the same directory as gsl_sf.oct, and the PKG_ADD file contains
an autoload, then the autoload above might be simplified to

autoload ("airy_Ai_deriv", "gsl_sf.oct")

The patch does the following

* Modify Fautoload so that
1) If the path to the files is absolute, use it
2) If not, find the directory containing the currently run script,
concatenate with the file, and if this concatenation points to a file
that exists, use it, else
3) Assume the file name is relative, issue a warning and use it for the
autoload..
* Modify mk_pkg_add to use the simplier form above..

If this is accepted then all the equivalent code in octave-forge should
also be modified...

D.

*** ./src/mk-pkg-add.orig5      2007-09-21 14:51:24.982033355 +0200
--- ./src/mk-pkg-add    2007-09-21 14:51:00.272310418 +0200
***************
*** 16,22 ****
        if [ "$n" = "$base" ]; then
          true
        else
!           echo "autoload (\"$n\", fullfile (fileparts (mfilename 
(\"fullpath\")), \"$base.oct\"));"
        fi
        done
      fi
--- 16,22 ----
        if [ "$n" = "$base" ]; then
          true
        else
!           echo "autoload (\"$n\", \"$base.oct\");"
        fi
        done
      fi
*** ./src/parse.y.orig5 2007-09-21 14:51:32.522643637 +0200
--- ./src/parse.y       2007-09-21 19:18:40.762262499 +0200
***************
*** 3485,3512 ****
  @deftypefn {Built-in Function} {} autoload (@var{function}, @var{file})\n\
  Define @var{function} to autoload from @var{file}.\n\
  \n\
! The second argument, @var{file}, should be an absolute file name and\n\
! should not depend on the Octave load path.\n\
  \n\
  Normally, calls to @code{autoload} appear in PKG_ADD script files that\n\
  are evaluated when a directory is added to the Octave's load path.  To\n\
! avoid having to hardcode directory names in @var{file}, it is customary\n\
! to use\n\
  \n\
  @example\n\
! autoload (\"foo\",\n\
!           fullfile (fileparts (mfilename (\"fullpath\")),\n\
!                     \"bar.oct\"));\n\
  @end example\n\
  \n\
! Uses like\n\
  \n\
  @example\n\
  autoload (\"foo\", file_in_loadpath (\"bar.oct\"))\n\
  @end example\n\
  \n\
  @noindent\n\
! are strongly discouraged.\n\
  \n\
  With no arguments, return a structure containing the current autoload map.\n\
  @seealso{PKG_ADD}\n\
--- 3485,3513 ----
  @deftypefn {Built-in Function} {} autoload (@var{function}, @var{file})\n\
  Define @var{function} to autoload from @var{file}.\n\
  \n\
! The second argument, @var{file}, should be an absolute file name or\n\
! a file name in the same directory as the function or script from which\n\
! the autoload command was run. @var{file} should not depend on the\n\
! Octave load path.\n\
  \n\
  Normally, calls to @code{autoload} appear in PKG_ADD script files that\n\
  are evaluated when a directory is added to the Octave's load path.  To\n\
! avoid having to hardcode directory names in @var{file}, if @var{file}\n\
! is in the same directory as the PKG_ADD script then\n\
  \n\
  @example\n\
! autoload (\"foo\", \"bar.oct\");\n\
  @end example\n\
  \n\
! will load the function @code{foo} from the file @code{bar.oct}. The above\n\
! when @code{bar.oct} is not in the same directory or uses like\n\
  \n\
  @example\n\
  autoload (\"foo\", file_in_loadpath (\"bar.oct\"))\n\
  @end example\n\
  \n\
  @noindent\n\
! are strongly discouraged, as their behavior might be unpredictable.\n\
  \n\
  With no arguments, return a structure containing the current autoload map.\n\
  @seealso{PKG_ADD}\n\
***************
*** 3547,3556 ****
          std::string nm = argv[2];
  
          if (! octave_env::absolute_pathname (nm))
!           warning_with_id ("Octave:autoload-relative-file-name",
!                            "autoload: `%s' is not an absolute file name",
!                            nm.c_str ());
! 
          autoload_map[argv[1]] = nm;
        }
      }
--- 3548,3579 ----
          std::string nm = argv[2];
  
          if (! octave_env::absolute_pathname (nm))
!           {
!             octave_function *fcn = 
!               octave_call_stack::caller_user_script_or_function ();
!             bool found = false;
!             if (fcn)
!               {
!                 std::string fname = fcn->fcn_file_name ();
!                 if (! fname.empty ())
!                   {
!                     fname = octave_env::make_absolute (fname,
!                       octave_env::getcwd ());
!                     fname = fname.substr (0, 
!                       fname.find_last_of (file_ops::dir_sep_str) + 1);
!                     file_stat fs (fname + nm);
!                     if (fs.exists ())
!                       {
!                         nm = fname + nm;
!                         found = true;
!                       }
!                   }
!               }
!             if (! found)
!               warning_with_id ("Octave:autoload-relative-file-name",
!                                "autoload: `%s' is not an absolute file name",
!                                nm.c_str ());
!           }
          autoload_map[argv[1]] = nm;
        }
      }
2007-09-21  David Bateman  <address@hidden>

        * mk-pkg-add: Simplfy the autoload commands.
        * parse.y (Fautoload): Allow bare filename if file is in the same
        directory as the script from where the autoload command is run.

reply via email to

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