From owner-freebsd-ports@freebsd.org Tue Dec 29 08:23:20 2020 Return-Path: Delivered-To: freebsd-ports@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BB6B74D4DCF for ; Tue, 29 Dec 2020 08:23:20 +0000 (UTC) (envelope-from portmaster@bsdforge.com) Received: from udns.ultimatedns.net (static-24-113-41-81.wavecable.com [24.113.41.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "ultimatedns.net", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D4nVc2J06z3hsN for ; Tue, 29 Dec 2020 08:23:19 +0000 (UTC) (envelope-from portmaster@bsdforge.com) Received: from ultimatedns.net (localhost [127.0.0.1]) by udns.ultimatedns.net (8.16.1/8.16.1) with ESMTP id 0BT8Nole044013 for ; Tue, 29 Dec 2020 00:23:57 -0800 (PST) (envelope-from portmaster@bsdforge.com) MIME-Version: 1.0 Date: Tue, 29 Dec 2020 00:23:50 -0800 From: Chris To: freebsd-ports@freebsd.org Subject: Re: How to fix/patch hardcoded values In-Reply-To: <20201229080734.ibew4kwiejxihvob@aching.in.mat.cc> References: <20201229080734.ibew4kwiejxihvob@aching.in.mat.cc> User-Agent: UDNSMS/17.0 Message-ID: X-Sender: portmaster@bsdforge.com Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4D4nVc2J06z3hsN X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; ASN(0.00)[asn:11404, ipnet:24.113.0.0/16, country:US]; local_wl_ip(0.00)[24.113.41.81] X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Dec 2020 08:23:20 -0000 On 2020-12-29 00:07, Mathieu Arnold wrote: > On Sun, Dec 27, 2020 at 09:58:13PM +0000, Nuno Teixeira wrote: >> Hello I've just submited a new port net/gitup >> and I used a >> simple workaround to help program find its config in /usr/local/etc instead >> of (hardcoded) ./ >> >> --- gitup.c.orig 2020-12-27 21:16:22 UTC >> +++ gitup.c >> @@ -2030,7 +2030,7 @@ main(int argc, char **argv) >> ... >> - const char *configuration_file = "./gitup.conf"; >> + const char *configuration_file = "/usr/local/etc/gitup.conf"; >> >> Now I'm thinking that this might not be the best fix in case PREFIX is a >> different one. >> >> Could I have an opinion on this? > > You need to change the patch to use %%PREFIX%% or %%LOCALBASE%% > depending on whether this is a reference to a path/file installed by the > software or by one of its dependency. Then, in a post-patch target, you > need to use REINPLACE_CMD to replace those to by they variables > equivalent, something like: > > post-patch: > ${REINPLACE_CMD} -e 's,%%PREFIX%%,${PREFIX}' ${WRKSRC}/githup.c It seems to me that you might also want to allow the user to reference a/their config from within their home dir (~/). But of course that's purely optional. Just thought I might mention it in case it mattered.