From nobody Tue Apr 18 10:55:03 2023 X-Original-To: freebsd-ports@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q116D078Nz44vw3 for ; Tue, 18 Apr 2023 10:55:16 +0000 (UTC) (envelope-from eduardo@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q116C4W4jz46Mv for ; Tue, 18 Apr 2023 10:55:15 +0000 (UTC) (envelope-from eduardo@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681815315; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HBluX0jam0MBLacci3pKVWAi+4AVUS2beSwk3fcUVjE=; b=ec8y5t/3IxD3qLEk2ed/uJ85IMO2YCMnnvFhyHAfcV9E1YPU+t9lW6OC/3t7URzmW97ahP 8TiwTz1J8acg7aSfPu8fi3dfUS+G5BNO4/SaqSYJ09Cy6wc4Eyk7/2//eZSS/TGoqfhCVy QeQt+FjuzUXUjQQ/ilPlRSqHUCRccx/9bu5gIHRPfkWZKfiH1te1D7hsKHi93pA2wnUyHg eURdqSnL8Fc80LgtREvzQttO+fG68xLJInpPNjwaE8kWUJsyPDa6/gpUd5uzu7T9kYobfZ tNMYdtU63EG113Tw9zPALxmrgUtyJ2K8JtwLboL9pE8+n2gXefdW1V/fSv3R3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681815315; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HBluX0jam0MBLacci3pKVWAi+4AVUS2beSwk3fcUVjE=; b=SOtfWB1GEwWe5A5/Ax1yp8jFQweLF8GvRJm3drM7a0Ugslef2PP+7oPtMIsvcxczWfi1po Sqi2QLUSmQhwG3DqaFACNstRg8k2xmmIQSx2p+kHa0U1rMQX/Bs17vfgS9RO3eJrZEvAay 1FQ32njsT1EcA5MOZLmcCWgdytl07zPP5DR5Mri5sfyr1D8ykbaIb9XJLX3UIDh5imX7p6 N8lNROgwpWZJIlM4c3cn0o1l7nFehNUsVOe0E2608bL9w2IIRyjNabddCi+cvKRKADOXJu tsVuIH52+YEuAEFUNpR9EBbDEqQ+kp2rXtOammZF8F9Dr6fJkOp6f1tpFXNctg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681815315; a=rsa-sha256; cv=none; b=A9mclFfkuFn5oFrfNvKx1fKGIsFiWRKm2lkSCfHL+jB/TPCO8KC1R9B3NWT/LDoFa5GKd8 +mgtGDkRTr9jJ7fEZU/WlDi4CxswYiKvjRhu3cqz1ZbgVSF1bRSmkil1+qq5UFNuU4bisf WaqBwiuKWyMvaxkIXSRtNA3ojsWg0e5uxjDApJlL/AuLAhDQVOPNmrvjiIHq9GmmvrtbQm TlXV0nbhcMkfEPGaVWWReRZr5zsiAptWnWQKKOjdl5LGnDinNubJKfagJjR6exBidnyY2y M7F/mW6o/pXlbGdpQFlFgKeKkc8wo3G2Wp/CHgXBTPFLganiSkjGOxSp6BdGFQ== Received: from mail-ua1-f51.google.com (mail-ua1-f51.google.com [209.85.222.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) (Authenticated sender: eduardo) by smtp.freebsd.org (Postfix) with ESMTPSA id 4Q116C3Mfzz12KY for ; Tue, 18 Apr 2023 10:55:15 +0000 (UTC) (envelope-from eduardo@freebsd.org) Received: by mail-ua1-f51.google.com with SMTP id az21so5349838uab.12 for ; Tue, 18 Apr 2023 03:55:15 -0700 (PDT) X-Gm-Message-State: AAQBX9eR1H8dxLPM/jnfFEDh6qy4yYv3wWLNT4gH6pkOxyPm/UzueJ5I lh3jUSAntiXCq1X3UWGu2JlYS77V/L2DyqGYM08= X-Google-Smtp-Source: AKy350Yi/gjXNzFt0FCvx2R4Wp7T1DnF049eDwjUr01tg8p2Jnrv0GGQB53I7jiAeJIqJjOryQLbk9XQohFChndzDyY= X-Received: by 2002:a1f:2a47:0:b0:43f:c93f:4eb8 with SMTP id q68-20020a1f2a47000000b0043fc93f4eb8mr10396402vkq.3.1681815314979; Tue, 18 Apr 2023 03:55:14 -0700 (PDT) List-Id: Porting software to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-ports List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-ports@freebsd.org X-BeenThere: freebsd-ports@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Nuno Teixeira Date: Tue, 18 Apr 2023 11:55:03 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Get ${OSREL} at install time To: Eugene Grosbein Cc: FreeBSD Mailing List Content-Type: multipart/alternative; boundary="0000000000006d647905f99a2419" X-ThisMailContainsUnwantedMimeParts: N --0000000000006d647905f99a2419 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable pkg-plist: @postexec env osrel=3D$(freebsd-update -u) sed -E -e s,stable/[0-9]+,stable/${osrel\%\%.*}, -e s,releng/[0-9]+,releng/${osrel\%\%-*}, %%PREFIX%%/etc/gitup.conf Result: /bin/sh: ${osrel\...}: Bad substitution pkg-static: POST-INSTALL script failed Other aproach: pkg-post-install --- #!/bin/sh - osrel=3D$(freebsd-version -u) releng=3D${osrel%%-*} stable=3D${osrel%%.*} echo "Configuring gitup.conf for $osrel" sed -E -e 's|stable\/12|stable\/${stable}|' -e 's|releng\/11.4|releng\/${releng}|' /usr/local/etc/gitup.conf echo debug: echo osrel=3D${osrel} echo releng=3D${releng} echo stable=3D${stable} --- Result: --- debug: "branch" : "releng/${releng}", "branch" : "stable/${stable}", osrel=3D13.2-RELEASE releng=3D13.2 stable=3D13 --- sed doesn't subtitute as it uses literal variables Eugene Grosbein escreveu no dia ter=C3=A7a, 18/04/2023= =C3=A0(s) 10:40: > 18.04.2023 16:26, Eugene Grosbein wrote: > > > 18.04.2023 15:05, Nuno Teixeira wrote: > >> Hello all, > >> > >> net/gitup uses a reinplace cmd to setup gitup.conf to the corresponden= t > RELEASE/STABLE for command `gitup release` and `gitup stable`. > >> So, if user is using 13.1-RELEASE, reinplace will configure gitup.conf > to: > >> > >> "release" : { > >> "branch" : "releng/13.1", > >> "stable" : { > >> "branch" : "stable/13", > >> > >> The problem is that OSREL is taken from build time and at this moment > 13.2 pkgs are being built on a 13.1 machine. > >> So the result is wrong by setting releng/13.1 instead of releng/13.2. > >> > >> the reinplace cmd is: > >> --- > >> ${REINPLACE_CMD} -e 's|stable\/12|stable\/${OSREL:R}| ; \ > >> s|releng\/11.4|releng\/${OSREL}|' \ > >> ${WRKSRC}/gitup.conf > >> --- > >> > >> Any sugestion or example that permits to get OSREL at install time? > > > > # osrel=3D$(sysctl -n kern.osrelease) > > # echo $osrel ${osrel%%-*} ${osrel%%.*} > > 13.2-STABLE 13.2 13 > > > > And use @postexec command in pkg-plist to run sed instead of > REINPLACE_CMD in the Makefile. > > Something like this (untested): > > > > @postexec env osrel=3D$(sysctl -n kern.osrelease) sed -E -e > s,stable/[0-9]+,stable/${osrel\%\%.*}, -e > s,releng/[0-9]+,releng/${osrel\%\%-*}, %%PREFIX%%/etc/gitup.conf > > Jail-friendly replacement is $(freebsd-version -u) instead of (sysctl -n > kern.osrelease). > > "freebsd-version -u" reports version of userland and in case of full jail > it may be older than kernel version. > > --=20 Nuno Teixeira FreeBSD Committer (ports) --0000000000006d647905f99a2419 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
pkg-plist:
<= div>@postexec env osrel=3D$(freebsd-update -u) sed= -E -e s,stable/[0-9]+,stable/${osrel\%\%.*}, -e s,releng/[0-9]+,releng/${o= srel\%\%-*}, %%PREFIX%%/etc/gitup.conf

Result:
/bin/sh: ${osrel\...}: Bad substitution
pkg-static: POST-INSTALL scri= pt failed

Other aproach:

<= div>pkg-post-install
---
#!/bin/sh -

osrel=3D$(f= reebsd-version -u)
releng=3D${osrel%%-*}
stable=3D${osrel%%.*}
echo "Configuring gitup.conf for $osrel"

sed -E -e 's= |stable\/12|stable\/${stable}|' -e 's|releng\/11.4|releng\/${releng= }|' /usr/local/etc/gitup.conf

echo debug:
echo osrel=3D${osre= l}
echo releng=3D${releng}
echo stable=3D${stable}
---

Result:
---
debug:
"branch" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 : "releng/${re= leng}",
"branch" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 : "stable/${stable}",
osrel=3D13.2-RELEAS= E
releng=3D13.2
stable=3D13
---

se= d doesn't subtitute as it uses literal variables
<= br>
Eugene = Grosbein <eugen@grosbein.net&g= t; escreveu no dia ter=C3=A7a, 18/04/2023 =C3=A0(s) 10:40:
18.04.2023 16:26, Eugene Grosbei= n wrote:

> 18.04.2023 15:05, Nuno Teixeira wrote:
>> Hello all,
>>
>> net/gitup uses a reinplace cmd to setup gitup.conf to the correspo= ndent RELEASE/STABLE for command `gitup release` and `gitup stable`.
>> So, if user is using 13.1-RELEASE, reinplace will configure gitup.= conf to:
>>
>> "release" : {
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"= ;branch"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0: "releng/13.1&q= uot;,
>> "stable" : {
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"= ;branch"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0: "stable/13&quo= t;,
>>
>> The problem is that OSREL is taken from build time and at this mom= ent 13.2 pkgs are being built on a 13.1 machine.
>> So the result is wrong by setting releng/13.1 instead of releng/13= .2.
>>
>> the reinplace cmd is:
>> ---
>> ${REINPLACE_CMD} -e 's|stable\/12|stable\/${OSREL:R}| ; \
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s|rel= eng\/11.4|releng\/${OSREL}|' \
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0${WRK= SRC}/gitup.conf
>> ---
>>
>> Any sugestion or example that permits to get OSREL at install time= ?
>
> # osrel=3D$(sysctl -n kern.osrelease)
> # echo $osrel ${osrel%%-*} ${osrel%%.*}
> 13.2-STABLE 13.2 13
>
> And use @postexec command in pkg-plist to run sed instead of REINPLACE= _CMD in the Makefile.
> Something like this (untested):
>
> @postexec env osrel=3D$(sysctl -n kern.osrelease) sed -E -e s,stable/[= 0-9]+,stable/${osrel\%\%.*}, -e s,releng/[0-9]+,releng/${osrel\%\%-*}, %%PR= EFIX%%/etc/gitup.conf

Jail-friendly replacement is $(freebsd-version -u) instead of (sysctl -n ke= rn.osrelease).

"freebsd-version -u" reports version of userland and in case of f= ull jail it may be older than kernel version.



--
Nuno Teixeira
FreeBSD Committ= er (ports)
--0000000000006d647905f99a2419--