Re: Optional Patches

2011-05-22 Thread Ion-Mihai Tetcu
On Wed, 18 May 2011 19:01:31 -0400
Matthew Pounsett  wrote:

> 
> Based on the responses here it sounds like I've been doing nothing
> wrong so I played around a bit more.  I guess in my testing there
> must've been some combination of things I didn't get right... I did a
> bunch more testing and eventually I made it work doing exactly what
> I've been doing, except for the location of the ifdef.
> 
> It turns out that in order to make this work, the .if define must
> appear below where bsd.port.pre.mk is included.  If it occurs above
> that, I guess the definition of .if doesn't exist yet and so the
> block doesn't get run at all.

Yes, or you need to use bsd.options.mk.

> I don't recall seeing this restriction mentioned in the porters'
> handbook, but perhaps I missed it.

It is documented in PH "5.11.2.2 Syntax"

-- 
IOnut - Un^d^dregistered ;) FreeBSD "user"
  "Intellectual Property" is   nowhere near as valuable   as "Intellect"
FreeBSD committer -> ite...@freebsd.org, PGP Key ID 057E9F8B493A297B


signature.asc
Description: PGP signature


Re: Optional Patches

2011-05-18 Thread Matthew Pounsett

Based on the responses here it sounds like I've been doing nothing wrong so I 
played around a bit more.  I guess in my testing there must've been some 
combination of things I didn't get right... I did a bunch more testing and 
eventually I made it work doing exactly what I've been doing, except for the 
location of the ifdef.

It turns out that in order to make this work, the .if define must appear below 
where bsd.port.pre.mk is included.  If it occurs above that, I guess the 
definition of .if doesn't exist yet and so the block doesn't get run at all.

I don't recall seeing this restriction mentioned in the porters' handbook, but 
perhaps I missed it.

Thanks for the feedback.. sometimes just knowing it *should* work is enough to 
help lead one to the right bit of troubleshooting.

Cheers,
   Matt


___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: Optional Patches

2011-05-18 Thread Matthew Seaman
On 18/05/2011 23:17, Doug Barton wrote:
> On 05/18/2011 15:10, Matthew Seaman wrote:
>> # Testing both WITH_ and WITHOUT_ is a good idea...
> 
> I'm not sure why you would need to test both, unless it's to catch wacky
> stuff coming in from the environment?

That's one reason.  Another is that it makes the layout of the .if block
handling that option independent of whether the option defaults to on or
off, which might just help avoid some logic errors.

Neither of which reasons is sufficiently compelling to make that style
preferable to just testing only one of WITH_ or WITHOUT_ in general.

> The usual way is to test the opposite of the default. So for default on
> you would test that WITHOUT_FOO is not defined.

There are plenty of examples of both styles in the ports.  Personal
preferences of the port maintainer is probably the biggest deciding factor.

Cheers,

Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.   7 Priory Courtyard
  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
JID: matt...@infracaninophile.co.uk   Kent, CT11 9PW



signature.asc
Description: OpenPGP digital signature


Re: Optional Patches

2011-05-18 Thread Doug Barton

On 05/18/2011 15:10, Matthew Seaman wrote:

# Testing both WITH_ and WITHOUT_ is a good idea...


I'm not sure why you would need to test both, unless it's to catch wacky 
stuff coming in from the environment?


The usual way is to test the opposite of the default. So for default on 
you would test that WITHOUT_FOO is not defined.



Doug

--

Nothin' ever doesn't change, but nothin' changes much.
-- OK Go

Breadth of IT experience, and depth of knowledge in the DNS.
Yours for the right price.  :)  http://SupersetSolutions.com/

___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: Optional Patches

2011-05-18 Thread Matthew Seaman
On 18/05/2011 22:29, Matthew Pounsett wrote:
> I've added a new option (call it 'FOO') to the OPTIONS definition,
> and I'm attempting to add something like this directly below MASTER_SITES
> near the top of the Makefile:
> 
> .if defined(FOO)
> PATCH_SITES=  http://location.site.com/path/
> PATCHFILES=   port-${PORTVERSION}.patch
> PATCH_DIST_STRIP= -p1
> .endif
> 
> The option shows up when the config target is run, but ports doesn't
> do anything with the patch info.  If I remove or comment-out the .if
> and .endif surrounding the above block, then ports finds and applies
> the patch perfectly, so I know the patching info itself is correct.

For an option FOO you want to test 'WITH_FOO' and/or 'WITHOUT_FOO' in
your Makefile.

Basically the structure is like this:

OPTIONS=FOO "Frob the foo-ness"  no \
BAR "Enable order round" yes

.include 

# Testing both WITH_ and WITHOUT_ is a good idea...
.if defined(WITH_FOO) && !defined(WITHOUT_FOO)
{ do foo related stuff }
.else
{ do non-foo stuff }
.endif

# ... but just testing WITH_ is very common too.
.if defined(WITH_BAR)
ORDER+= "Two pints of lager and a packet of crisps"
.endif

The important thing is to only test OPTION settings *after* including
 (or  which is an older style of
doing options stuff.)

Cheers,

Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.   7 Priory Courtyard
  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
JID: matt...@infracaninophile.co.uk   Kent, CT11 9PW



signature.asc
Description: OpenPGP digital signature


Re: Optional Patches

2011-05-18 Thread Matthew Pounsett

Following up my own post.  Bleargh.


On 2011/05/18, at 17:29, Matthew Pounsett wrote:

> .if defined(FOO)
> PATCH_SITES=  http://location.site.com/path/
> PATCHFILES=   port-${PORTVERSION}.patch
> PATCH_DIST_STRIP= -p1
> .endif

I should note that I have actually been doing this using '.if 
defined(WITH_FOO)', as one would expect for an option named FOO.  I've tried 
defined(FOO) just in case, but didn't really expect that to work.



___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Optional Patches

2011-05-18 Thread Matthew Pounsett
I posted the other day about an issue I was having working around a 
distribution CGI when adding a patch to a port.  Thanks to a suggestion from 
Matthew Seaman that problem is solved, but I seem to have bumped up against 
another.  It seems that I can't find a way to make applying the patch optional, 
which was the original intent.

I've added a new option (call it 'FOO') to the OPTIONS definition, and I'm 
attempting to add something like this directly below MASTER_SITES near the top 
of the Makefile:

.if defined(FOO)
PATCH_SITES=  http://location.site.com/path/
PATCHFILES=   port-${PORTVERSION}.patch
PATCH_DIST_STRIP= -p1
.endif

The option shows up when the config target is run, but ports doesn't do 
anything with the patch info.  If I remove or comment-out the .if and .endif 
surrounding the above block, then ports finds and applies the patch perfectly, 
so I know the patching info itself is correct.

I've tried placing the block in various places around the Makefile, on the off 
chance that there's an issue with ordering, but that hasn't solved the problem 
either.

I've done a quick grep through the ports tree looking for instances of 
PATCH_SITES appearing shortly after an .if defined but nothing has cropped up 
that I can crib from.

Does anyone know what the problem is?  Is what I'm attempting just not possible?

Thanks,
  Matt


___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"