From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id bJ/sFbiTGmD/RgAA0tVLHw (envelope-from ) for ; Wed, 03 Feb 2021 12:14:48 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WNI3EbiTGmDlLgAAB5/wlQ (envelope-from ) for ; Wed, 03 Feb 2021 12:14:48 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B549D9405D1 for ; Wed, 3 Feb 2021 12:14:47 +0000 (UTC) Received: from localhost ([::1]:52882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7H3W-0006tL-KL for larch@yhetil.org; Wed, 03 Feb 2021 07:14:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7H3L-0006sz-SD for guix-devel@gnu.org; Wed, 03 Feb 2021 07:14:35 -0500 Received: from michel.telenet-ops.be ([2a02:1800:110:4::f00:18]:48196) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7H3J-0007n9-6Q for guix-devel@gnu.org; Wed, 03 Feb 2021 07:14:35 -0500 Received: from ptr-bvsjgyjmffd7q9timvx.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by michel.telenet-ops.be with bizsmtp id QcEU2400h0mfAB406cEUX5; Wed, 03 Feb 2021 13:14:29 +0100 Message-ID: Subject: Re: Installing a wrapper guile script in /bin From: Maxime Devos To: elaexuotee@wilsonb.com Date: Wed, 03 Feb 2021 13:12:25 +0100 In-Reply-To: <3TT5JRKHCZ2E4.2VYCP49OAJARA@wilsonb.com> References: <3EA9135IVLYXR.223U6JDXT4SSS@wilsonb.com> <874kivlqol.fsf@gnu.org> <2VMUHEHLO03FL.3AF0SWRKGMFZ3@wilsonb.com> <6d41cb49f87561620e46f5e8a25946f2fbb927ab.camel@telenet.be> <3TT5JRKHCZ2E4.2VYCP49OAJARA@wilsonb.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-ktfO9f3VLEcNnnUvaa3y" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1612354469; bh=NZNomXyMGR4t6DLpUDiYe1bG8M3UgnAzvnUnpQohG98=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=InL8F5VJCnd1l7yo7uwoBbLp5Gyi+EgI+5O6LoiMD05ZEjeBedXj7t6iKUEfAiRTN ZzzEblATxdx5nZOkTKtd2MjIYmgAIFSVlp06bHpWz4im0YU7/aEQsWyungUeG06ALE qXTVLvCHxekLqh03KT7eM6Y3/N+FNiheF4blCVb6nova6w5DGGJ68pl1PNRXbnmCxp rc6fT4ay2Xc19X2AzZfM9QXsBtyIS+BUPGsHWi+7e4Gfu/Kt59Qg01q9vLsGCenTfJ 9lcKMB9BGa38/zHpgic1LjU9G5hJqlSC7YmVO1/izAJAOlqnx3ClZJjkQ+lQO1/Bns mnkAvPR3tvE7A== Received-SPF: pass client-ip=2a02:1800:110:4::f00:18; envelope-from=maximedevos@telenet.be; helo=michel.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel@gnu.org, Ludovic =?ISO-8859-1?Q?Court=E8s?= Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.36 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=InL8F5VJ; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: B549D9405D1 X-Spam-Score: -3.36 X-Migadu-Scanner: scn1.migadu.com X-TUID: xW6tl6KwMhs+ --=-ktfO9f3VLEcNnnUvaa3y Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > The script contents are not what I'm confused about. I don't know how to = turn > my gexp script into a file under /bin/. This is conceptually what I = want: >=20 > (package > (name "foo") > ... > (arguments > `(... > #:phases > (modify-phases %standard-phases > ... > (replace 'install > (lambda* (#:key outputs #:allow-other-keys) > (let ((out (assoc-ref outputs "out")) > (wrapper-script #~(...))) > ... ; Do normal install stuff > (copy-file wrapper-script (string-append out "/bin/foo")) > ... ; Finish install stuff > ))))))) >=20 > Of course `copy-file` doesn't work here because `wrapper-script` is a gex= p not > a file. What code do I replace this with? Three options I have in mind: * forego representing `wrapper-script` as a gexp (using #~), instead repres= ent `wrapper-script` as something quasiquoted. Then write this expression to a file (with 'write', and include an appropriate shebang line) Something like this: (let ((wrapper-script-contents `(exec* ,(string-append out "/bin/.foo-rea= l") "--extra-library-stuff" other-arguments))) rename-upstream-binary write-wrapper-binary ) * The procedure =E2=80=98program-file=E2=80=99 turns a gexp into a represen= tation of a store item. Write your script to accept arguments like this: YOUR-SCRIPT REAL-BINARY ARGUMENTS =20 And write a small wrapper shell script to /bin/foo. Maybe with somet= hing like this (format PORT "#!~a~%exec ~a ~a #$@" bin-sh-something #$THE-SCRIPT-GEXP /bin/.foo-real) (Warning: the above shell script might be incorrect. I'm not very famili= ar with using the shell as a programming language.) * Define a wrapper package. See wrap-python3 in packages/python.scm for an example. (This option probably has to be combined with one of the first two options.)=20 Greetings, Maxime --=-ktfO9f3VLEcNnnUvaa3y Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYIADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYBqTLhccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7lbYAQDca5CLvZ8JVCx6N6YvtIfeBwVM dg4/BqLy+ZnWZof9MAEA8BPcrCS+H82xaRMHQbnT6EdibBka+Vj8BGD3sNeQSgk= =xzZT -----END PGP SIGNATURE----- --=-ktfO9f3VLEcNnnUvaa3y--