From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tobias Geerinckx-Rice Subject: Re: Newbie Packaging Question Date: Sat, 11 May 2019 02:40:33 +0200 Message-ID: <874l61zuv2.fsf@nckx> References: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:46639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPG4F-0007PD-I5 for help-guix@gnu.org; Fri, 10 May 2019 20:40:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPG4D-0001ao-N5 for help-guix@gnu.org; Fri, 10 May 2019 20:40:47 -0400 Received: from tobias.gr ([2001:470:7405::1]:32892) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hPG4D-0001WR-08 for help-guix@gnu.org; Fri, 10 May 2019 20:40:45 -0400 In-reply-to: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: help-guix@gnu.org, Brian Woodcox --=-=-= Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable 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 =E2=80=9C201903271913=E2=80=9D) > > and then > > (define-public test-me > (package > (name =E2=80=9Ctest-me=E2=80=9D) > (version commit) > (source =E2=80=A6 > . > . > . etc... > > > In my modify-phases %standard-phases, I am trying to use=20 > substitute* to patch some files with the version-date define=20 > 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=20 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=20 please paste your full package expression :-) What's happening here is that the value of ARGUMENTS is being=20 *quoted* (by the =E2=80=98'=E2=80=99 just after ARGUMENTS), meaning that is= is not=20 immediately evaluated, but passed to the =E2=80=98build stage=E2=80=99 as-i= s. And=20 since VERSION-DATE isn't bound (defined) in the build stage's=20 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: =2D The =E2=80=98'=E2=80=99 (quote) has been changed into a =E2=80=98`=E2= =80=99 *quasiquote*, which=20 is identical to quote except that it allows *unquoting* inside=20 the quoted expression. =2D This unquoting is done by adding =E2=80=98,=E2=80=99 to VERSION-DATE. = Any book=20 on Scheme will explain it much better than I can, but here it=20 basically says that you want to send the currently bound *value*=20 of VERSION-DATE to the builder, not the variable name. (If you've written your package by copying an existing one, you=20 might already be using quasiquote without realising it, and all=20 that's missing is an unquote.) Kind regards, T G-R --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQT12iAyS4c9C3o4dnINsP+IT1VteQUCXNYaAgAKCRANsP+IT1Vt efw1AQCCfr8Qr2sCAMkaKnVOr3pDqIUwFqwY2Kd5rkjgjSIKFgD8DGVFRlIvAhBz UpiCW2uiDQlhJf1GK5uQ4TnYMGlWIwE= =lmwg -----END PGP SIGNATURE----- --=-=-=--