Re: sed trouble when UNAME_* is set in jail (fwd)

From: Sysadmin Lists <sysadmin.lists_at_mailfence.com>
Date: Mon, 24 Jan 2022 23:49:48 UTC
> ----------------------------------------
> From: Dmitry Morozovsky <woozle@woozle.net>
> Sent: Mon Jan 24 20:45:11 CET 2022
> To: <freebsd-ports@FreeBSD.org>
> Subject: sed trouble when UNAME_* is set in jail (fwd)
>
> I have a jail on my build system, nested-built on a previous major; on the 
> case, it's stable/10; for a poudriere, it is defined as null-mounted from the 
> build jail:
> 
> 10-amd64 stable/10        amd64 null   2022-01-20 13:10:41 /X/j10a
> 
> for some other reasons, there're definition in login.conf like
> 
> :setenv=MAIL=/var/mail/$,BLOCKSIZE=K,UNAME_r=10.4-STABLE,UNAME_v=FreeBSD 10.4-STABLE #0:\
> 
> however, bulk.sh/common.sh are unhappy with this breaking with
> 
> sed: 1: "s/,UNAME_r.*:/:/ ; s/:\ ...": bad flag in substitute command: ','
> 
> I tracked this down to update_version_env() in common.sh, but then stuck
> did I miss something trivial?

`sed' is complaining about a bad substitution flag. Here's the expected behavior:

$ awk '/sed/ && /UNAME/ {print NR ": " $0}' /usr/local/share/poudriere/common.sh
2860:   sed -i "" -e "s/,UNAME_r.*:/:/ ; s/:\(setenv.*\):/:\1${login_env}:/" \

$ cat testfile 
:setenv=MAIL=/var/mail/$,BLOCKSIZE=K,UNAME_r=10.4-STABLE,UNAME_v=FreeBSD 10.4-STABLE #0:\

$ sed -e "s/,UNAME_r.*:/:/ ; s/:\(setenv.*\):/:\1${login_env}:/" testfile 
:setenv=MAIL=/var/mail/$,BLOCKSIZE=K:\

Try running the sed command by hand one piece at a time to troubleshoot what's breaking.

$ sed "s//,UNAME_r.*:/:/" ${mnt}/etc/login.conf
$ sed "s/:\(setenv.*\):/:\1${login_env}:/" ${mnt}/etc/login.conf
$ echo $login_env

-- 
Sent with https://mailfence.com  
Secure and private email