Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Updating Cygwin

Aug
1,914
68
I like to keep my Cygwin up-to-date, which I usually do once a week.

I have been using the following .BTM for the past few months, which works well for me, in keeping Cygwin up-to-date;
Code:
@setlocal
@echo off
cdd C:\Users\jlc\Downloads\cygwin
copy https://www.cygwin.com/setup-x86.exe
setup-x86.exe -q -g
endlocal

Note that this is for the 32-bit version of Cygwin.

Thought that others might find this useful.

Joe
 
I also use Cygwin (64 bit), but I only update once a month or so. I made some minor changes to your script, and it works well for me. It does need to be run in Admin mode, which is funny because when I run it manually it doesn't need to start as Admin. I suppose when run manually it elevates by itself.


@setlocal
@echo off
cdd C:\cygwin64
copy https://www.cygwin.com/setup-x86_64.exe
setup-x86_64.exe -q -g
endlocal
::
:: use sudo to run as admin
 
Except the call to "ssh-pageant.sh" wrapper, it all could be used literal.

Code:
@ECHO OFF
SETLOCAL

IF "%[_ELEVATED]" == "1" GOTO :RUN
ECHO Restarting elevated.
START "" /MIN /ELEVATED "%~0" %*
EXIT /B

:RUN

"ssh-pageant.sh" -k
gpgconf --kill gpg-agent dirmngr scdaemon
UNSET STOP_SVC
UNSET START_SVC
DO svc IN /P cygrunsrv --list
  IFF "%[svc]" == "cygserver" THEN
    SET "START_SVC=%[svc] %[START_SVC]"
    SET "STOP_SVC=%[svc]"
    ITERATE
  ENDIFF
  SET "START_SVC=%[START_SVC] %[svc]"
  net stop "%[svc]"
ENDDO
IF NOT "%[STOP_SVC]" == "" net stop "%[STOP_SVC]"

:SAFETY
REM Crude test for other Cygwin processes running.
IFF "%~1" != "--force" THEN
  IF %@EXECSTR[ ( ( ps -al | grep -vE "\<%@INSTR[5,,%@EXECSTR[tty]]\>" ) | TEE CON: ) | wc -l ] GT 1 (
    ECHO There's likely other processes running from Cygwin environment.
    ECHO Please stop them or use --force to suppress this test.
    GOTO :RESTART
  )
ELSE
  SHIFT
ENDIFF

REM Cygwin upgrade helper script.
REM Usage:
REM
REM   install-cygwin.btm [--force] [-ns]
REM
REM If you intend to use it for new installs, you will need minimal bootstrap
REM including POSIX shell interpreter and wget utility.
REM
REM You will have to edit the script to provide mirror URL of your choice
REM or set CYGWIN_MIRROR environment variable to the mirror URL.
REM
REM The script assumes existing installation of the same architecture as
REM the host operating system.
REM If you want to install 32-bit Cygwin on 64-bit host, override
REM $ARCH with value other than "x86_64".
REM F.e.
REM
REM   SET ARCH=x86 && install-cygwin.btm

IF "%[CYGWIN_MIRROR]" != "" SET "MIRROR=%[CYGWIN_MIRROR]"
IF "%[MIRROR]" != "" GOTO :ARCH
REM Mirror URL - don't include trailing slash!
SET "MIRROR=https://mirrors.kernel.org/sourceware/cygwin"

:ARCH
REM System architecture.
IF "%[ARCH]" != "" GOTO :LOCALE
SET "ARCH=%@EXECSTR[ uname -m ]"

:LOCALE
REM Localization is fine... as long as you don't show it to other people.
SET LANG=C.UTF-8

IF "%[ARCH]" != "x86_64" SET ARCH=x86

wget -N "https://cygwin.com/setup-%[ARCH].exe"

REM Skip running setup on "NoSetup" switch
IF "%~1" == "-ns" GOTO :RESTART

".\setup-%[ARCH].exe" -O -s "%@RTRIM[/,%[MIRROR]]/" %[KEYS] %$

:RESTART
DO svc IN /Q %[START_SVC]
  net start "%[svc]"
ENDDO
"ssh-pageant.sh"
ENDLOCAL
 
Along the same vein, here's a script I use to get the latest nightly build off FFMpeg. This will run under CMD or TCC, if you're using TCC you won't need aria2c.

This will download the latest nightly build of FFMpeg and extract only the 3 exe files (FFMPEG, FFPROBE, FFPLAY) to C:\BIN.

@echo off set "get_from=https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/" set "get_file=ffmpeg-master-latest-win64-gpl.zip" set "dest_path=c:\bin" pushd %TEMP% aria2c %get_from%%get_file% if NOT exist ffmpeg-master-latest-win64-gpl.zip goto :NOT_THERE 7z.exe e -y %get_file% -o%dest_path% -r ff*.exe if NOT exist c:\bin\ffmpeg.exe (goto :FAILED_EXTRACTION) if NOT exist c:\bin\ffprobe.exe (goto :FAILED_EXTRACTION) if NOT exist c:\bin\ffplay.exe (goto :FAILED_EXTRACTION) dir c:\bin\ff*.exe del %TEMP%\ff*.exe del %TEMP%\ffmpeg*.zip popd goto :EOF :NOT_THERE echo %get_file% is NOT found in %TEMP% goto :EOF :FAILED_EXTRACTION echo ff*.exe not found in c:\bin dir c:\bin\ff*.exe goto :EOF
 
Amazingly, this totally broke my sed, such that it would no longer work with emoji, despite having the same version.

I had to revert my cygwin\bin folder as the error message erroneously made it look like a problem with quoting delimiters, causing 100% of human beings to go out of their mind insisting it was a quotes-vs-apostrophe thing.

[But you could demonstrate that it wasn't by issuing identical commands with both delimiters with and without emoji. Only 4 possibilities. And 3 cygwin\bins to prove it with.]

Moral of the story... Be careful if you don't have some form of regression tests (i sure don't, lol).
 
I find sed quite handy on occasion, but I don't really use it very often. After seeing your post, I tried it and saw similar failures. I ran the Cygwin setup program, which did not update SED itself, but did update several libraries. After the update, sed works again.
 
I find sed quite handy on occasion, but I don't really use it very often. After seeing your post, I tried it and saw similar failures. I ran the Cygwin setup program, which did not update SED itself, but did update several libraries. After the update, sed works again.

Interesting! I kidna went the "burn it down" route and just recopied the cygwin\bin folder from one of my other 2 machines. I kept the borked one around for experimentation, but when i put it back, my error message was different.

Madness! :)

I'm glad it was an easy fix!

I actually have a script that uses sed to decorate any mention of the machinenames in my lan with a machine-specific emoji that is defined by an environment variable. So i noticed right away because I use it to decorate my mapped drives list (drives get the emoji of the machine next to them) and it was failing haha. Talk about a tangent...
 
Back
Top