Dependency Enumeration Scripts for Cygwin Packages

Japanese TeX Environment for Cygwin (ptetexwin) > Dependency Enumeration Scripts / Japanese Version

We will show how to semi-automatically enumarate Cygwin packages that binary files in Cygwin system are dependent on. The main targets of this page are Cygwin package distributors, but not limit to them.

Programs and How to Use

Main Script

You can use the following script (say main.sh) with the name of an installed package (excluding the version number) as a parameter. For example, you can use it as follows:

$ ./main.sh ghostscript-bin

The output of the script will be redundant (like a multiset, with some repetition/multiplicity).

#!/bin/sh

### already installed package
PACKAGE=$1
BINFILES=`gzip -dc /etc/setup/${PACKAGE}.lst.gz`
ROOT=/

### before a new release
# PACKAGE=glpk
# BINFILES=`tar tjf glpk-4.19-1.tar.bz2`
# ROOT=`pwd`/.inst/

### direct access
# PACKAGE=glpk
# BINFILES=`(cd .inst && find usr/bin)`
# ROOT=`pwd`/.inst/

for f in ${BINFILES}; do
    ff=`echo ${ROOT}${f} | sed -e 's/\/\//\//g'`
    if [ -f ${ff} ]; then
        if `file ${ff} | grep -q 'MS-DOS executable'`; then
        # if ! `head -q -n 1 ${ff} | grep -q \#!`; then
            echo "#--- $ff ---"
            for prog in `cygcheck ${ff}`; do
                progunix=`cygpath -u "${prog}" | tr -d "\r"`
                if ! `echo ${progunix} | grep -q cygdrive`; then
                    progshort=`cygcheck -f ${progunix} | sed -e 's/\-[^\-]*\-[^\-]*$//'`;
                    if [ x${progshort} != x${PACKAGE} ]; then echo ${progshort}; fi
                fi
            done;
        fi;
    fi;
done

Excluding Duplication and Sorting

You may use the UNIX commands as follows:

$ ./main.sh ghostscript-bin > ghostscript-bin.log
$ sort -u ghostscript-bin.log | grep -e ^[^#]

Japanese TeX Environment for Cygwin (ptetexwin) > Dependency Enumeration Scripts / Japanese Version