* Newbie Packaging Question
@ 2019-05-10 23:04 Brian Woodcox
2019-05-11 0:40 ` Tobias Geerinckx-Rice
0 siblings, 1 reply; 3+ messages in thread
From: Brian Woodcox @ 2019-05-10 23:04 UTC (permalink / raw)
To: help-guix
I have a question regarding packaging.
Say I have the following in my sample.scm file:
(define commit "a1ee2ebf087768b5fbffa07f50a294ad9c8ee600")
(define version-date “201903271913”)
and then
(define-public test-me
(package
(name “test-me”)
(version commit)
(source …
.
.
. etc...
In my modify-phases %standard-phases, I am trying to use substitute* to patch some files with the version-date define outside my package.
Is this not possible, I always get an unbound variable error.
I have no problem accessing the commit variable which is defined outside of the package.
Any help would be greatly appreciated.
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Newbie Packaging Question
2019-05-10 23:04 Newbie Packaging Question Brian Woodcox
@ 2019-05-11 0:40 ` Tobias Geerinckx-Rice
0 siblings, 0 replies; 3+ messages in thread
From: Tobias Geerinckx-Rice @ 2019-05-11 0:40 UTC (permalink / raw)
To: help-guix, Brian Woodcox
[-- Attachment #1: Type: text/plain, Size: 2391 bytes --]
Brian,
Brian Woodcox wrote:
> I have a question regarding packaging.
>
> Say I have the following in my sample.scm file:
>
> (define commit "a1ee2ebf087768b5fbffa07f50a294ad9c8ee600")
>
> (define version-date “201903271913”)
>
> and then
>
> (define-public test-me
> (package
> (name “test-me”)
> (version commit)
> (source …
> .
> .
> . etc...
>
>
> In my modify-phases %standard-phases, I am trying to use
> substitute* to patch some files with the version-date define
> outside my package.
>
> Is this not possible, I always get an unbound variable error.
You've omitted one of the interesting parts (the one where the
error happens), but I suspect it's something roughly like this:
(arguments
'(#:phases
(modify-phases %standard-phases
(add-after 'unpack 'uh-oh
(lambda _
(substitute* "foo.bar"
(("198309270000") version-date))
#t))))) ; ^^^^^^^^^^^^
(If not: forgive & ignore the basic Scheme lecture below and
please paste your full package expression :-)
What's happening here is that the value of ARGUMENTS is being
*quoted* (by the ‘'’ just after ARGUMENTS), meaning that is is not
immediately evaluated, but passed to the ‘build stage’ as-is. And
since VERSION-DATE isn't bound (defined) in the build stage's
environment, the builder will return the error you're seeing.
Luckily, this is easily fixed:
(arguments
`(#:phases
(modify-phases %standard-phases
(add-after 'unpack 'uh-oh
(lambda _
(substitute* "foo.bar"
(("198309270000") ,version-date))
#t))))) ; ^
Two subtle changes here:
- The ‘'’ (quote) has been changed into a ‘`’ *quasiquote*, which
is identical to quote except that it allows *unquoting* inside
the quoted expression.
- This unquoting is done by adding ‘,’ to VERSION-DATE. Any book
on Scheme will explain it much better than I can, but here it
basically says that you want to send the currently bound *value*
of VERSION-DATE to the builder, not the variable name.
(If you've written your package by copying an existing one, you
might already be using quasiquote without realising it, and all
that's missing is an unquote.)
Kind regards,
T G-R
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Newbie Packaging Question
@ 2019-05-11 3:06 Brian Woodcox
0 siblings, 0 replies; 3+ messages in thread
From: Brian Woodcox @ 2019-05-11 3:06 UTC (permalink / raw)
To: help-guix
Hi Tobias,
You totally nailed it.
Your example solved my problem.
I spent a few hours trying to resolve this problem. I did try the comma because I saw that in another package definition.
Ultimately, i completely missed the quasiquote.
Thanks again
Brian.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-11 3:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-10 23:04 Newbie Packaging Question Brian Woodcox
2019-05-11 0:40 ` Tobias Geerinckx-Rice
-- strict thread matches above, loose matches on Subject: below --
2019-05-11 3:06 Brian Woodcox
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.