Subject: Re: review wanted: su/cvs return code checking (resend)
To: Hubert Feyrer <hubert.feyrer@informatik.fh-regensburg.de>
From: Alistair Crooks <agc@pkgsrc.org>
List: tech-pkg
Date: 11/27/2003 11:13:58
On Mon, Nov 24, 2003 at 08:47:59PM +0100, Hubert Feyrer wrote:
> 
> Seems either my mail didn't make it through or any replies got lost... can
> someone please comment on the diff below?
> 
> 
>  - Hubert
> 
> -- 
>   ___ _ _  _   _        * Harddisk Image Cloning *
>  / __| | || | | |           www.feyrer.de/g4u/
> | (_ |_  _| |_| |
>  \___| |_| \___/          v1.12 out now, including partition support!
> 
> ---------- Forwarded message ----------
> Date: Sat, 22 Nov 2003 12:57:27 +0100 (CET)
> From: Hubert Feyrer <hubert.feyrer@informatik.fh-regensburg.de>
> To: tech-pkg@netbsd.org
> Subject: review wanted: su/cvs return code checking
> 
> 
> I'd like to catch if the user given to "su" is bogus/non-existing, but if
> the "cvs" command inside the su returns an error, that should be ignored.
> (Aparently cvs returns "1" even if it's done a successful update but if
> there were some files removed on purpose).
> 
> Can anyone please let me know if the following patch makes sense, or if
> there's a better way:
> 
> --- pre-build	20 Nov 2003 00:02:59 -0000	1.31
> +++ pre-build	22 Nov 2003 11:46:39 -0000
> @@ -148,7 +148,7 @@
>  		( cd ${USR_PKGSRC}/security/ssh ; ${BMAKE} bulk-install )
>  	fi
>  	echo Performing CVS update - this will take some time
> -	su - ${CVS_USER} -c 'stty sane ; setenv CVS_RSH ssh ; cd '${USR_PKGSRC}' ; cvs -q update -Pd '"${CVS_FLAGS}"
> +	su - ${CVS_USER} -c 'stty sane ; setenv CVS_RSH ssh ; cd '${USR_PKGSRC}' ; cvs -q update -Pd '"${CVS_FLAGS}"' || exit 0'
>          if [ $? != 0 ]
>          then
>                  echo CVS update not successful, aborting.

How about (not tried):

	if ${ID} ${CVS_USER} > /dev/null 2>&1; then			\
		su - ${CVS_USER} -c 'stty sane ; setenv CVS_RSH ssh ; cd '${USR_PKGSRC}' ; cvs -q update -Pd '"${CVS_FLAGS}"' || exit 0'; \
		if [ $? != 0 ]; then					\
			...						\
		fi;							\
	else								\
		echo "*** $${CVS_USER} (${CVS_USER}) does not exist ***" 2>&1; \
		exit 1;							\
	fi

Regards,
Alistair
--
Alistair Crooks <agc@pkgsrc.org>