Web lists-archives.com

Re: Unattended upgrade does not report errors via the exit code




On 7/3/2018 1:55 PM, R. Diez via cygwin wrote:
First of all, many thanks for Cygwin.

I have been trying to find out how to do an unattended update/upgrade of all packages, in order to save some mouse clicks. To do that, you start
setup-x86_64.exe with --quiet-mode. During experimentation, I found out the following:

1) Apparently, it will close all running Cygwin software automatically as needed, in order to upgrade it. That may be a nasty surprise for the unwary.

One of the features of --quiet-mode is that setup doesn't bother the user with a lot of popup dialogs. For the most part it simply proceeds with the defaults, corresponding to what would happen if the user pressed ENTER when running interactively. In particular, this applies to the dialog that pops up when running processes need to be stopped.

2) If you start it from a Cygwin console, or from an unprivileged Windows console, you will not see the console messages like this:


Starting cygwin install, version 2.891
User has backup/restore rights

Current Directory: C:\CygwinInstall
Could not open service McShield for query, start and stop. McAfee may not be installed, or we don't have access.
root: C:\cygwin64 system
Selected local directory: C:\CygwinInstall
net: Direct
connection error: 12007
site: http://linux.rz.ruhr-uni-bochum.de/download/cygwin/
connection error: 12007
connection error: 12007
...

If you run it from a unprivileged console, you will not see the message either that tells you about the log file where to look for errors.


I would suggest documenting those things. I could not find mention of that anywhere in the web pages.

The documentation could certainly use improvement. Patches would be welcome. AFAICT, the main documentation is at

  https://cygwin.com/cygwin-ug-net/setup-net.html,

the source for which is in winsup/doc/setup-net.xml in the Cygwin source repository. See also winsup/doc/faq-setup.xml. And see https://cygwin.com/git.html for information about getting access to the source repository.

More seriously, the setup program does not indicate any failure (it always yields an exit code of 0). In the above example, where I disabled the network card, you get the following lines at the end:

connection error: 12007
connection error: 12007
mbox note: Unable to get setup from <http://linux.rz.ruhr-uni-bochum.de/download/cygwin/>
unattended_mode is set at mbox: returning default value
download/verify error in unattended_mode: out of retries
note: Installation incomplete.  Check C:\cygwin64\var\log\setup.log.full for details
Ending cygwin install



I tried printing $? from a Cygwin shell afterwards, and %ERRORLEVEL% in a Windows console, and it always showed an exit status of 0.

setup is a Windows program, not a Cygwin application, so I don't think you can expect $? to contain its exit status. I don't know enough about Windows programming to know what would have to be changed in the setup sources to support %ERRORLEVEL%.

On the other hand, if you're running setup from a script, you could probably achieve what you want by grepping /var/log/setup.log.full.

There's been a proposal on the cygwin-apps list to have a Cygwin "setup" package, possibly including a wrapper script for setup.exe. Maybe that script could be tweaked to provide a useful exit code. See

  https://sourceware.org/ml/cygwin-apps/2018-04/msg00016.html

Ken


--
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