Code Monkey home page Code Monkey logo

Comments (8)

gregneagle avatar gregneagle commented on September 27, 2024

If given a relative path, we really should be searching only in these directories, and in this order:

  1. The current recipe's directory ("RECIPE_DIR")
  2. The directory of the ParentRecipe (if any)
  3. The directory of the ParentRecipe's ParentRecipe (if any)
  4. and so on until there are no more ParentRecipes.

We should only be searching cwd if the recipe or one of its parents lives in the cwd.

from autopkg.

gregneagle avatar gregneagle commented on September 27, 2024

After looking at your change I think I see the problem.

if os.path.exists(relpath)

would return an item in the cwd, which was not the intention; I think the intention was "if this is actually a full path pointing to a file/directory, use it"

from autopkg.

gregneagle avatar gregneagle commented on September 27, 2024

# Convert relative paths to absolute.
for key, value in request.items():
if key in ("pkgroot", "pkgdir", "infofile", "resources", "scripts"):
if value and not value.startswith("/"):
# search for it
request[key] = self.find_path_for_relpath(value)

Since we don't call self.find_path_for_relpath(value) if the path starts with "/", I think the problem is then avoided.

I think you should merge the change and do a new release.

from autopkg.

timsutton avatar timsutton commented on September 27, 2024

Yep. I also hadn't thought about whether RECIPE_CACHE_DIR should or shouldn't be there, but now that you mention it, I'd say it makes sense for it to be removed as well.

The cache dir doesn't have anything to do with a recipe unless there's some special logic going on in staging files, in which case %RECIPE_CACHE_DIR% should be explicitly given.

from autopkg.

gregneagle avatar gregneagle commented on September 27, 2024

Not 100% sure either way (whether RECIPE_CACHE_DIR should be searched or not).

I think it might be useful to eliminate a lot of boiler-plate things in recipes; I think a common pattern is to start with a template item in the RECIPE_DIR, copy it to RECIPE_CACHE_DIR and modify it, then pass it to a processor like PkgCreator.

from autopkg.

timsutton avatar timsutton commented on September 27, 2024

That's true, but then that behavior seems too ambiguous to me - whether it will use the cache dir or the recipe dir is just implied and not obvious just from looking at the path in pkg_request. Having multiple lines all with %RECIPE_CACHE_DIR% is a bit noisy, but then it's very clear what the input path is.

Maybe you have a modified Resources folder in the cache and a stock unmodified Scripts folder in the recipe, for example..

from autopkg.

gregneagle avatar gregneagle commented on September 27, 2024

"Maybe you have a modified Resources folder in the cache and a stock unmodified Scripts folder in the recipe, for example.."

And a search order of

RECIPE_CACHE_DIR
RECIPE_DIR
(ParentRecipe dirs)

would do the right thing in this case.

I don't feel particularly strongly about this; since we do have access to a RECIPE_CACHE_DIR variable we can use it; it's harder to usefully subclass recipes if all resources must live in the RECIPE_DIR and not in any parent recipe's dir.

from autopkg.

timsutton avatar timsutton commented on September 27, 2024

Ok, sounds good. We can always revisit this later if it becomes an issue.

Merged the changes and made a new release of 0.2.1.

from autopkg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.