#!/bin/bash getBZ2=1 # Validate usage (minimally) if [ $# -ne 1 ]; then echo "mkcygwget: Usage $0 " >&2 exit 1 fi mirrorURL="$1" # Dissect the argument to separate the host and directory portions mirrorHost="${mirrorURL%*/}" mirrorDir="${mirrorURL##*/}" ueMirror="$(echo "$mirrorURL" |sed -e 's/:/%3a/g' -e 's|/|%2f|g')" mkdir "$ueMirror" # Retrieve the "setup.ini" file from the mirror # Get the BZip2-compressed form? if [ "$getBZ2" ]; then wget -O "$ueMirror/setup.bz2" "$mirrorHost/setup.bz2" if [ $? -ne 0 ]; then echo "mkwget: Error retrieving \"setup.bz2\" from \"$mirrorHost/setup.bz2\"" >&2 exit 1; fi bzcat "$ueMirror/setup.bz2" >"$ueMirror/setup.ini" rm "$ueMirror/setup.bz2" # Get the uncompressed "setup.ini" file else wget -O "$ueMirror/setup.ini" "$mirrorHost/setup.ini" if [ $? -ne 0 ]; then echo "mkwget: Error retrieving \"setup.ini\" from \"$mirrorHost/setup.ini\"" >&2 exit 1; fi fi # Use the "setup.ini" file to produce a download script ( echo -e '#!/bin/sh\n' echo -e "cd \"$ueMirror\"\n" echo "wget \\" echo -e "\t-x -nH --cut-dirs=1 \\" sed -n -e "/^install: / s|^install: \([^ ]*\) .*|\t\"$mirrorURL/\1\" \\\\|p" "$ueMirror/setup.ini" echo ) >|cygwget chmod +x cygwget