#!/usr/bin/env zsh # Generate a cygwin setup kit in the directory cygwin-yyyy-mm-dd. # Every package belonging to the Base category and all the packages # listed in the extra_packages file will be included in the setup kit. # All of the packages will be installed by default when setup.exe is run. # # Assumptions: # 1. Cygwin is already installed on the machine. At least coreutils, # gawk, grep, perl, rsync, tar and zsh must be installed. # 2. A local repository of cygwin packages has been set up in the # directory identified by the cygwin_repo environment variable # (defaults to the directory cygwin_repo). The -s option # to this script can be used to create or sync up the repository. # 3. The file extra_packages contains the list of packages to add # to the default list of cygwin packages. Alternatively, if the # environment variable extra_packages is set, it must be a list # of packages to add to the cygwin base install; e.g. # extra_packages="bison flex" ./MakeCygwinKit # will add bison and flex to the setup kit. # # Once you have run this script, burn the contents of the # cygwin-yyyy-mm-dd directory onto a CD, and that CD can be # used to install all the specified cygwin packages, without # requiring network access. emulate zsh setopt extended_glob progname=${0:t} function usage { print -u2 "\ usage: $progname -hsv Create a cygwin setup kit in the subdirectory cygwin_disk-yyyy-mm-dd. The contents of cygwin_disk-yyyy-mm-dd can then be burned onto a CD. All cygwin base packages are included in the generated kit. The contents of the file \"extra_packages\" (or the environment variable \$extra_packages) can be used to specify additional packages to add to the generated kit. All of the specified packages will be installed by default when setup.exe is run. In order for this script to work, the directory identified by the environment variable \$cygwin_repo (which has a default value of \"cygwin_repo\") must contain a mirror image of the cygwin package repository. You can use the -s option to bootstrap this directory. Options: -h Print this help message. -s Sync the packages with a cygwin mirror before running the script. The environment variable \$cygwin_site specifies which cygwin mirror to use. -v Print progress messages." } # Parse the options zparseopts -D h=help s=sync_packages v=verbose if [[ -n $help ]]; then usage exit 0 fi : ${cygwin_repo:=$PWD/cygwin_repo} # Add current directory to $PATH. path=($PWD $path) # Sync up to the latest packages. if [[ -n $sync_packages ]]; then cd $cygwin_repo # This command will display a list of mirror sites that support rsync: # wget -q -O - http://cygwin.com/mirrors.txt | grep rsync | cut -d';' -f1 | sed -e 's;\(rsync://[0-9a-z.-]*\).*;\1;' cygwin_site=${cygwin_site:-rsync://mirrors.xmission.com/cygwin/} [[ -n $verbose ]] && print -u2 "Syncing packages from cygwin mirror: $cygwin_site" rsync -az --exclude mail-archives $cygwin_site . cd - fi # Define the list of packages to be added to the base kit. if [[ -n $extra_packages ]]; then extra=( ${=extra_packages} ) else [[ -r extra_packages ]] && extra=( $(