delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/08/12/10:10:40

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.7 required=5.0 tests=AWL,BAYES_00,DONT_USE_RAW_EMAIL_IN_BODY,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Message-ID: <4C6400CF.9050800@gmx.de>
Date: Thu, 12 Aug 2010 16:10:23 +0200
From: Matthias Andree <matthias DOT andree AT gmx DOT de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
CC: Jeremy Ramer <jdramer AT gmail DOT com>
Subject: Re: Postinstall script errors
References: <AANLkTinNXnksnBKU7EKC4mFsqR9P5uAFsgTn0WyJ1Z=j AT mail DOT gmail DOT com> <20100812095930 DOT GX14202 AT calimero DOT vinschen DOT de> <AANLkTim0EAbuHF81OC0RX_qz2jMf_Sqhj0tNOCyQNV8c AT mail DOT gmail DOT com>
In-Reply-To: <AANLkTim0EAbuHF81OC0RX_qz2jMf_Sqhj0tNOCyQNV8c@mail.gmail.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Am 12.08.2010 15:37, schrieb Jeremy Ramer:
> On Thu, Aug 12, 2010 at 3:59 AM, Corinna Vinschen
> <corinna-cygwin AT cygwin DOT com> wrote:
>> On Aug 11 09:18, Jeremy Ramer wrote:
>>> I recently upgraded from cygwin 1.5 to 1.7. At the end of the install
>>> there were errors with some of the postinstall scripts.  From the
>>> setup.full.log:
>>>
>>> 2010/08/11 08:39:53 running: C:\cygwin\bin\bash.exe --norc --noprofile
>>> /etc/postinstall/bash.sh
>>> ln: creating symbolic link `/dev/stdin': File exists
>>> 2010/08/11 08:39:54 abnormal exit: exit code=1
>>> 2010/08/11 08:39:54 running: C:\cygwin\bin\bash.exe --norc --noprofile
>>> /etc/postinstall/passwd-grp.sh
>>> 2010/08/11 08:39:55 abnormal exit: exit code=1
>>>
>>>
>>> I tried manually running the scripts with mixed results
>>>
>>> $ bash --norc --noprofile /etc/postinstall/bash.sh ; echo $?
>>> 0
>>>
>>> $ bash --norc --noprofile /etc/postinstall/passwd-grp.sh ; echo $?
>>> 1
>>>
>>> I tired manually running the commands inside passwd-grp.sh and they
>>> all return 0. So I'm not sure what exactly is failing.  Is there
>>> anything I should do to investigate?
>>
>> That's probably a fault in the postinstall scripts.  It would be nice if
>> you could provide more details about what fails exactly in the script,
>> or better, what in the script has a non-0 exit code.  That would help us
>> lazy maintainers to fix the scripts faster.
> 
> The issue with the passwd-grp.sh script seems to be the last two lines.
> 
> [ "$created_passwd" = "yes" ] && /bin/chgrp --silent root /etc/passwd
> [ "$created_group" = "yes"  ] && /bin/chgrp --silent root /etc/group
> 
> I verified that $created_passwd and $created_group were both no so
> both conditionals will fail. But because the last conditional is the
> last thing run, the script returns 1.  Adding an exit 0 to the script
> fixes it, but I'm not sure if that accomplishes what you want from the
> script.

PLEASE DON'T.

Adding an "exit 0" will mask the error and just reinstate the former state of
silently failing postinstall scripts more rigidly. This is not desirable. The
proper way to fix this is:

set -e  # this is providing that the whole script is written properly.
        # it causes immediate exit after one command (outside if, and
        # outside || or && lists) fails - usually desirable, but takes more
        # work because you can't write the scripts as sloppily as the
        # snippet you've just shown from passwd-grp.sh.
#
# ...other work...
#
if [ "$created_passwd" = "yes" ] ; then
	/bin/chgrp --silent root /etc/passwd
fi

if [ "$created_group" = "yes"  ] ; then
	/bin/chgrp --silent root /etc/group
fi

-- 
Matthias Andree

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019