delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/08/19/17:04:33

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
To: cygwin AT cygwin DOT com
From: Christopher Cobb <ccobb AT email DOT com>
Subject: Re: installing packages using setup.exe from the command line (e.g., remotely)
Date: Thu, 19 Aug 2004 21:04:22 +0000 (UTC)
Lines: 120
Message-ID: <loom.20040819T224628-719@post.gmane.org>
References: <loom DOT 20040819T173137-946 AT post DOT gmane DOT org> <00c801c4860a$adcd62d0$78d96f83 AT robinson DOT cam DOT ac DOT uk>
Mime-Version: 1.0
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

Max Bowsher <maxb <at> ukf.net> writes:

> 
> Christopher Cobb wrote:
> > I've found snipets of information, such as this:
> >
> >    http://sources.redhat.com/ml/cygwin-apps/2003-03/msg00526.html
> >
> > What I would like is an example of how to use setup.exe from the command 
> > line
> > (e.g., via ssh) to install a package remotely.
> >
> > I've tried this:
> >
> >    setup -D -s ftp://mirrors.kernel.org -R $CYGWIN_HOME -q -n wget
> >
> > which does not produce any errors, but it also doesn't seem to download or
> > install the package.
> 
> setup isn't really designed for use from the command line. It doesn't take 
> package names as arguments, for example. You could, I suppose, munge 
> /etc/setup/installed.db to fool setup into thinking that a really old (e.g. 
> version 0) version of a package is installed, so that it would updated - 
> it's a messy way to do it, but there is no better way.
> 
> Max.

Thanks Max for the idea.  Here is a quick hack/shell script which worked on the
(small handful) of packages that I tried with it.  

--- begin installCygwinPackage.sh ---
#!/bin/sh
#
# This script/hack allows you to install a cygwin package from the command line.
#
# Usage: installCygwinPackage.sh <package1> ... <packageN>
#
# 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.
#
# Thanks to Max Bowsher for the idea.
#

scriptName=`basename $0`

[ "$#" = "0" ] && {
   echo>&2 "$scriptName: No packages specified."
   echo>&2 "Usage: $scriptName <packageName> ... "
   exit 1
}

PACKAGES_DIR=/packages # adjust this for your installation

INSTALL_SITE_DIR=$PACKAGES_DIR/`(cd $PACKAGES_DIR && ls -1t | head -1)` # most
recently modified install dir
INSTALL_SITE=`echo $INSTALL_SITE_DIR | 
              sed -e 's@%3a@:@g' \
                  -e 's@%2f@/@g' \
                  -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

# add zero-version packages to $INSTALLED_DB
for pkgName
do
    grep -q "^$pkgName " $INSTALLED_DB && {
       echo>&2 $scriptName: $pkgName is already installed
       continue;
    }

    pkgFileName=`
awk < $SETUP_INI '
/@ / {
    pkgName=$2
}
/version: / && pkg == pkgName {
    pkgVer=$2
}
/install: / && pkg == pkgName {
    num=split($2,arrFile,"/")
    pkgFile=arrFile[num]
    hyphenOffset=index(pkgFile,"-")
    if (hyphenOffset != 0)
    {
        pkgPrefix=substr(pkgFile, 0, hyphenOffset)
        verLength=index(pkgFile,".tar.bz2") - hyphenOffset
        ver=substr(pkgFile, hyphenOffset+1, verLength - 1)
        pkgSuffix=substr(pkgFile, hyphenOffset + verLength)
        pkgFile=pkgPrefix "" gensub(/[0-9]/,"0","g",ver) "" pkgSuffix
        print pkgFile
        pkgPrinted="true"
        exit
    }
}
END{
    if (pkgPrinted != "true") print pkgFile
}
' pkg=$pkgName
`
    echo $pkgName $pkgFileName 0 |
        cat $INSTALLED_DB - | sort -f > $INSTALLED_DB.tmp
    mv $INSTALLED_DB.tmp $INSTALLED_DB

done

diff -q $INSTALLED_DB $INSTALLED_DB_BACKUP > /dev/null ||
setup -D -L -s $INSTALL_SITE -R `cygpath -m /` -q -n
--- end installCygwinPackage.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/

- Raw text -


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