Re: [Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2023-01-03 Thread Panu Matilainen
It's possible in Lua of course, the above was to point out a way to do it 
*without*, because not everybody is content with Lua.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155#issuecomment-1369490067
You are receiving this because you are subscribed to this thread.

Message ID: ___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2023-01-02 Thread Demi Marie Obenour
What about rewriting the macro in Lua and stashing the result in a Lua global 
variable?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155#issuecomment-1369167626
You are receiving this because you are subscribed to this thread.

Message ID: ___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2023-01-02 Thread Panu Matilainen
FWIW, a simple and generic way to implement this on macro level is to redefine 
the macro as a global on first evaluation, eg:

> %python3_sitearch %{global python3_sitearch %(RPM_BUILD_ROOT= %{__python3} 
> -Esc "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': 
> '%{_prefix}', 'base': '%{_prefix}'}))")}%{python3_sitearch}

Optimally what would use %literal (or the equivalent) instead of %global but we 
don't have that yet...

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155#issuecomment-1368771083
You are receiving this because you are subscribed to this thread.

Message ID: ___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2020-04-16 Thread Panu Matilainen
Yeah, %define with options is what I'd really like (I think I even mentioned 
somewhere surrounding the pending %literal). 

In macro files the name limitation could be abused for similar effect by adding 
special characters in the front of the name. AIUI rpm5 used "." to denote a 
read-only macro, for our purposes eg "=" could mean "literal" and so on. It's 
pretty ugly of course.

I suppose we could place the macro flags after the name, using a separator such 
as ':'
That would fit in the macro file syntax easily, eg:
```
%_pyver:o %(python3 --version)
```

Not sure its any prettier than special characters in front, though :joy: For a 
moment I thought about putting the flags inside [] after the name, but I think 
we want to reserve that syntax for arrays if we ever get around to implement 
them. 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155#issuecomment-614460893___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2020-04-15 Thread Michael Schroeder
Well, we don't need to allow %global.

Anyway, let's move a step back and talk about this issue. This is about one 
shot macros. Implementation wise this is not hard, it's more a question of 
syntax.

It would be nice to have the following options:
- literal: do not expand the macro when using it
- global: put macro in global namespace
- expand: expand macro right away
- once: cache expanded macro (this issue)

So %global is %define plus the global + expand flags.

Macro names can't start with a `-`, so we could make use normal options:
```
%global foo bar
%define -g -x foo bar
```

As next step can can discuss how we support this in the macro files ;)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155#issuecomment-614169509___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2020-04-15 Thread Panu Matilainen
There are other downsides too, such as arbitrary side-effects and code 
execution on load (as opposed to time of use).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155#issuecomment-614024891___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2020-04-15 Thread Michael Schroeder
Crazy thought: we could allow to use %define/%global in the macro file, as 
those are illegal macro names. I.e. we could allow this:
```
%foo hello
%define bar world
```
(rpm internally somewhat rewrites the %foo to %define foo anyway)

Then we could also allow
```
%undefine foo
```
which is something I wanted to have since quite some time.

The downside is of course that people will start to try to use %if statements, 
because the macro file looks too much like a spec file.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155#issuecomment-614012836___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2020-04-02 Thread Panu Matilainen
Well yes, people occasionally get confused about that. The difference is a big 
one though, its like comparing a shell script with an ini file. Both have their 
places.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155#issuecomment-607681367___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2020-04-01 Thread Vít Ondruch
First seeing spec file and then trying to move some macros into macros file, it 
was very confusing, I can tell you. From packager POV, the macro file is the 
same as spec file, but you don't write `%global` everywhere for some unknown 
reason. Also the difference between `%import` and `%load` (where the later was 
introduced on my request) is not really obvious.

Obviously, you know the internals, but honestly, that is just implementation 
detail to me.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155#issuecomment-607326391___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2020-04-01 Thread Panu Matilainen
Um. And use what instead? The spec file format? Whose parser is the one of the 
most compilicated and loathed piece of code in rpm and would be difficult to 
lift out of librpmbuild to put it mildly, and slow every rpm startup in the 
process?

In contrast, the macro file format is a nice, declarative format that can be 
always safely read without side-effects. It could be extended without 
sacrificing that.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155#issuecomment-607128768___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2020-04-01 Thread Vít Ondruch
Is there any benefit in having macro files? Wouldn't be better to deprecate 
them instead?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155#issuecomment-607124518___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


[Rpm-maint] [rpm-software-management/rpm] RFE: optional one-shot/cached macro expansion (#1155)

2020-04-01 Thread Panu Matilainen
Some macros are really expensive to expand, notorious examples include 
python/perl/etc related macros that invoke the interpreter to fish out a 
configuration path or such. When these are expanded repeatedly, it really adds 
up.

In a spec one can use %global to achieve this, but that's not possible from a 
macro file which is how most such macros are distributed.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1155___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint