Admin/lib/Tools/makedist_cygwin
author wenzelm
Tue, 02 Aug 2016 11:49:30 +0200
changeset 63578 e8990d0e3965
parent 63490 9416333a17c2
child 64344 c1695143de35
permissions -rwxr-xr-x
tuned;

#!/usr/bin/env bash
#
# DESCRIPTION: produce pre-canned Cygwin distribution for Isabelle

## global parameters

CYGWIN_MIRROR="http://isabelle.in.tum.de/cygwin_2016"


## diagnostics

PRG=$(basename "$0")

function usage()
{
  echo
  echo "Usage: isabelle $PRG"
  echo
  echo "  Produce pre-canned Cygwin distribution for Isabelle."
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}


## arguments

[ "$#" -ne 0 ] && usage


## main

TARGET="$PWD/cygwin"


# download

[ ! -e "$TARGET" ] || fail "Target already exists: \"$TARGET\""
mkdir -p "$TARGET/isabelle" || fail "Failed to create target directory: \"$TARGET\""

type -p curl > /dev/null || fail "Cannot download files: missing curl"
curl --fail --silent "$CYGWIN_MIRROR/setup-x86.exe" > "$TARGET/isabelle/cygwin.exe" || \
  fail "Failed to download \"$CYGWIN_MIRROR/setup-x86.exe\""
chmod +x "$TARGET/isabelle/cygwin.exe"

"$TARGET/isabelle/cygwin.exe" -h </dev/null >/dev/null || exit 2


# install

"$TARGET/isabelle/cygwin.exe" \
  --site "$CYGWIN_MIRROR" --no-verify \
  --local-package-dir 'C:\temp' \
  --root "$(cygpath -w "$TARGET")" \
  --packages curl,nano,perl,perl-libwww-perl,rlwrap,unzip \
  --no-shortcuts --no-startmenu --no-desktop --quiet-mode

[ "$?" = 0 -a -e "$TARGET/etc" ] || exit 2


# patches

for NAME in hosts protocols services networks passwd group
do
  rm -f "$TARGET/etc/$NAME"
done

rm "$TARGET/Cygwin.bat"


# archive

DATE=$(date +%Y%m%d)
tar -C "$TARGET/.." -cz -f "cygwin-${DATE}.tar.gz" cygwin