This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

modification to mkcygwget to overcome arg length limitation

Hi all,
I tried to use the mkcygwget script to download a cygwin mirror for offline installation. The mkcygwget script generates a script named cygwget to do the heavy lifting of retreiving files. However, I got a "argument list too long" exception from wget, since the generated script has all the files to be downloaded appended to a single wget command.

I've made a slight modification to the mkcygwget script so that the generated cygwget contains a separate wget command for each file to be downloaded. This solved the problem I was having....thought I'd post the modified script to this mailing list in case anyone else was interested.
Lance Nehring
New Particles Corp



# Validate usage (minimally)
if [ $# -ne 1 ]; then
	echo "mkcygwget: Usage $0 <mirrorURL>" >&2
	exit 1


# Dissect the argument to separate the host and directory portions

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;

	bzcat "$ueMirror/setup.bz2" >"$ueMirror/setup.ini"
	rm "$ueMirror/setup.bz2"

# Get the uncompressed "setup.ini" file
	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;


# Use the "setup.ini" file to produce a download script
wgetprefix="wget -x -nH --cut-dirs=1 $mirrorURL"
	echo -e '#!/bin/sh\n'

	echo -e "cd \"$ueMirror\"\n"

	sed -n -e "/^install: / s|^install: \([^ ]*\) .*|\t$wgetprefix/\1 |p" "$ueMirror/setup.ini"

) >|cygwget

chmod +x cygwget

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]