Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Apr 2023 11:55:03 +0100
From:      Nuno Teixeira <eduardo@freebsd.org>
To:        Eugene Grosbein <eugen@grosbein.net>
Cc:        FreeBSD Mailing List <freebsd-ports@freebsd.org>
Subject:   Re: Get ${OSREL} at install time
Message-ID:  <CAFDf7U%2BwOWBnW=bT8qM96_%2BWzCvgZ2dO2TD2LiJ=Gyc36Ft80A@mail.gmail.com>
In-Reply-To: <bbeaf874-8d0d-88b3-29d6-fcb081fb26cd@grosbein.net>
References:  <CAFDf7UKJ%2BSy0f9xJZ8oc8fcaejhT1LFgjspVTHDt4E99z2sz3w@mail.gmail.com> <ff0dc458-76f6-0bc2-8560-0eea00744226@grosbein.net> <bbeaf874-8d0d-88b3-29d6-fcb081fb26cd@grosbein.net>

next in thread | previous in thread | raw e-mail | index | archive | help
--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 <eugen@grosbein.net> 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

<div dir=3D"ltr"><div><span class=3D"gmail-im">pkg-plist:<br></span></div><=
div><span class=3D"gmail-im">@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</span></div><div><span class=3D"gmai=
l-im"><br></span></div><div><span class=3D"gmail-im">Result:</span></div><d=
iv>/bin/sh: ${osrel\...}: Bad substitution<br>pkg-static: POST-INSTALL scri=
pt failed</div><div><br></div><div>Other aproach:<br></div><div><br></div><=
div>pkg-post-install</div><div>---</div><div>#!/bin/sh -<br><br>osrel=3D$(f=
reebsd-version -u)<br>releng=3D${osrel%%-*}<br>stable=3D${osrel%%.*}<br><br=
>echo &quot;Configuring gitup.conf for $osrel&quot;<br><br>sed -E -e &#39;s=
|stable\/12|stable\/${stable}|&#39; -e &#39;s|releng\/11.4|releng\/${releng=
}|&#39; /usr/local/etc/gitup.conf<br><br>echo debug:<br>echo osrel=3D${osre=
l}<br>echo releng=3D${releng}<br>echo stable=3D${stable}</div><div>---</div=
><div><br></div><div>Result:<br></div>---<br><div><div>debug:</div><div><di=
v>&quot;branch&quot; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 : &quot;releng/${re=
leng}&quot;,</div><div>&quot;branch&quot; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 : &quot;stable/${stable}&quot;,<br></div></div><div>osrel=3D13.2-RELEAS=
E<br>releng=3D13.2<br>stable=3D13</div><div>---</div><div><br></div><div>se=
d doesn&#39;t subtitute as it uses literal variables<br></div></div></div><=
br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">Eugene =
Grosbein &lt;<a href=3D"mailto:eugen@grosbein.net">eugen@grosbein.net</a>&g=
t; escreveu no dia ter=C3=A7a, 18/04/2023 =C3=A0(s) 10:40:<br></div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p=
x solid rgb(204,204,204);padding-left:1ex">18.04.2023 16:26, Eugene Grosbei=
n wrote:<br>
<br>
&gt; 18.04.2023 15:05, Nuno Teixeira wrote:<br>
&gt;&gt; Hello all,<br>
&gt;&gt;<br>
&gt;&gt; net/gitup uses a reinplace cmd to setup gitup.conf to the correspo=
ndent RELEASE/STABLE for command `gitup release` and `gitup stable`.<br>
&gt;&gt; So, if user is using 13.1-RELEASE, reinplace will configure gitup.=
conf to:<br>
&gt;&gt;<br>
&gt;&gt; &quot;release&quot; : {<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot=
;branch&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0: &quot;releng/13.1&q=
uot;,<br>
&gt;&gt; &quot;stable&quot; : {<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot=
;branch&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0: &quot;stable/13&quo=
t;,<br>
&gt;&gt;<br>
&gt;&gt; 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.<br>
&gt;&gt; So the result is wrong by setting releng/13.1 instead of releng/13=
.2.<br>
&gt;&gt;<br>
&gt;&gt; the reinplace cmd is:<br>
&gt;&gt; ---<br>
&gt;&gt; ${REINPLACE_CMD} -e &#39;s|stable\/12|stable\/${OSREL:R}| ; \<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s|rel=
eng\/11.4|releng\/${OSREL}|&#39; \<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0${WRK=
SRC}/gitup.conf<br>
&gt;&gt; ---<br>
&gt;&gt;<br>
&gt;&gt; Any sugestion or example that permits to get OSREL at install time=
?<br>
&gt; <br>
&gt; # osrel=3D$(sysctl -n kern.osrelease)<br>
&gt; # echo $osrel ${osrel%%-*} ${osrel%%.*}<br>
&gt; 13.2-STABLE 13.2 13<br>
&gt; <br>
&gt; And use @postexec command in pkg-plist to run sed instead of REINPLACE=
_CMD in the Makefile.<br>
&gt; Something like this (untested):<br>
&gt; <br>
&gt; @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<br>
<br>
Jail-friendly replacement is $(freebsd-version -u) instead of (sysctl -n ke=
rn.osrelease).<br>
<br>
&quot;freebsd-version -u&quot; reports version of userland and in case of f=
ull jail it may be older than kernel version.<br>
<br>
</blockquote></div><br clear=3D"all"><br><span class=3D"gmail_signature_pre=
fix">-- </span><br><div dir=3D"ltr" class=3D"gmail_signature"><div dir=3D"l=
tr"><span style=3D"color:rgb(102,102,102)">Nuno Teixeira<br>FreeBSD Committ=
er (ports)</span></div></div>

--0000000000006d647905f99a2419--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFDf7U%2BwOWBnW=bT8qM96_%2BWzCvgZ2dO2TD2LiJ=Gyc36Ft80A>