Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com From: Christopher Cobb Subject: Re: non-interactive cygwin setup Date: Fri, 15 Oct 2004 17:17:53 +0000 (UTC) Lines: 156 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet AT sea DOT gmane DOT org X-Gmane-NNTP-Posting-Host: main.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 162.70.244.40 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.8) X-IsSubscribed: yes Rainer Hochreiter hochreiter.at> writes: > > is there a chance to install cygwin without gui dialog? > > my plan is to download all needed packages into a local directory > and then install the packages from that local directory by starting > setup from a command line without further user interaction. > Here is a script that I use over ssh. It has not been exhaustively tested but seems to work for the light duty I have put it through so far. Every now and then setup.exe seems to hang. Since I'm logged in over ssh, I can't tell if maybe setup.exe has put up a dialog and is waiting for user input. My normal response is to make sure the desired application has been installed, and then give setup.exe a "generous" amount of time to finish up. If it still hasn't returned, I kill it. The other caveat is that when you run this script, in addition to installing the requested packages, it upgrades all of your packages to their latest versions. This may or may not be good for you. --- begin installCygwinPackages.sh --- #!/bin/sh # # This script allows you to install a cygwin package from the command line. # # Usage: installCygwinPackages.sh ... # # It assumes that packages are at /packages and that setup.exe is somewhere # in the path (like /usr/local/bin). # # It works by inserting fake package entries with a zeroed out versions # into installed.db, then running setup.exe. # # Unfortunately, setup.exe insists on popping up a progress window # on the local system. # # WARNING: any currently installed packages will also be updated. (How can # these be pinned?) # # Thanks to Max Bowsher for the idea. # # Author: -c-c-o-b-b-a-t-e-m-a-i-l-d-o-t-c-o-m- # PACKAGES_DIR=/packages # adjust this for your installation scriptName=`basename $0` [ "$#" = "0" ] && { echo>&2 "$scriptName: No packages specified." echo>&2 "Usage: $scriptName ... " exit 1 } # most recently used install site dir INSTALL_SITE_DIR=$PACKAGES_DIR/`cd $PACKAGES_DIR && cat /etc/setup/last-mirror | sed -e 's@:@%3a AT g' -e 's@/@%2f AT g' | xargs ls -td | head -1` # argument for setup, is this necessary? INSTALL_SITE=`echo $INSTALL_SITE_DIR | sed -e 's@%3a@:@g' -e 's@%2f@/@g' | sed -e 's|\([^/]\)/[^/].*|\1|'` SETUP_INI=$INSTALL_SITE_DIR/setup.ini INSTALLED_DB=/etc/setup/installed.db # backup installed.db INSTALLED_DB_BACKUP=$INSTALLED_DB.`date +%F_%H_%M_%S` cp $INSTALLED_DB $INSTALLED_DB_BACKUP # check dependencies and normalize list of packages to install _packagesToInstall() { for pkgName do # make sure package exists grep -q "^@ $pkgName$" $SETUP_INI || { echo>&2 $scriptName: NOT FOUND: package: $pkgName continue } grep -q "^$pkgName " $INSTALLED_DB && continue echo $newPackages | tr " " "\n" | grep -q "^$pkgName$" && continue newPackages="$newPackages $pkgName" echo $pkgName # check dependencies requiredPkgs=`awk < $SETUP_INI ' /@ / { pkgName=$2 } pkg == pkgName && /requires: / { num=split($0,arrPkgs," ") for (i=2; i<=num; ++i) printf arrPkgs[i] " " } ' pkg=$pkgName ` _packagesToInstall $requiredPkgs done } packagesToInstall() { newPackages="" _packagesToInstall $* } packages=`packagesToInstall "$@"` [ "$packages" ] && { # add zero-version packages to $INSTALLED_DB for pkgName in $packages do pkgFileName=` awk < $SETUP_INI ' /@ / { pkgName=$2 } pkg == pkgName && /install: / { num=split($2,arrFile,"/") pkgFile=arrFile[num] hyphenOffset=index(pkgFile,"-") verLength=index(pkgFile,".tar.") - hyphenOffset pkgSuffix=substr(pkgFile, hyphenOffset + verLength) if (hyphenOffset != 0) { pkgPrefix=substr(pkgFile, 0, hyphenOffset) print pkgPrefix "0" pkgSuffix } else { pkgPrefix=substr(pkgFile, 0, verLength-1) print pkgPrefix "-0" pkgSuffix } pkgPrinted="true" exit } END{ if (pkgPrinted != "true") print pkgFile } ' pkg=$pkgName ` echo $pkgName $pkgFileName 0 | cat $INSTALLED_DB - | sort -uf > $INSTALLED_DB.tmp && mv $INSTALLED_DB.tmp $INSTALLED_DB done echo>&2 $scriptName: installing: $packages setup -D -L -s $INSTALL_SITE -R `cygpath -m /` -q -n } --- end installCygwinPackages.sh --- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/