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 "Configuring gitup.conf for $osrel"<br><br>sed -E -e 's= |stable\/12|stable\/${stable}|' -e 's|releng\/11.4|releng\/${releng= }|' /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>"branch" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 : "releng/${re= leng}",</div><div>"branch" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 : "stable/${stable}",<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'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 <<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> > 18.04.2023 15:05, Nuno Teixeira wrote:<br> >> Hello all,<br> >><br> >> net/gitup uses a reinplace cmd to setup gitup.conf to the correspo= ndent RELEASE/STABLE for command `gitup release` and `gitup stable`.<br> >> So, if user is using 13.1-RELEASE, reinplace will configure gitup.= conf to:<br> >><br> >> "release" : {<br> >>=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;,<br> >> "stable" : {<br> >>=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;,<br> >><br> >> 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> >> So the result is wrong by setting releng/13.1 instead of releng/13= .2.<br> >><br> >> the reinplace cmd is:<br> >> ---<br> >> ${REINPLACE_CMD} -e 's|stable\/12|stable\/${OSREL:R}| ; \<br> >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s|rel= eng\/11.4|releng\/${OSREL}|' \<br> >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0${WRK= SRC}/gitup.conf<br> >> ---<br> >><br> >> Any sugestion or example that permits to get OSREL at install time= ?<br> > <br> > # osrel=3D$(sysctl -n kern.osrelease)<br> > # echo $osrel ${osrel%%-*} ${osrel%%.*}<br> > 13.2-STABLE 13.2 13<br> > <br> > And use @postexec command in pkg-plist to run sed instead of REINPLACE= _CMD in the Makefile.<br> > Something like this (untested):<br> > <br> > @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> "freebsd-version -u" 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>