[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Newbie Packaging Question
From: |
Tobias Geerinckx-Rice |
Subject: |
Re: Newbie Packaging Question |
Date: |
Sat, 11 May 2019 02:40:33 +0200 |
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
signature.asc
Description: PGP signature