2006年11月17日星期五

写了个小脚本下载cygwin ports

为了给朋友提供一份cygwin,我从下面这个地方下载了一份ISO(自己用cygwin的安装工具下载实在是很受不了的):

http://inst.eecs.berkeley.edu/~instcd/iso/

然后就想着再把cygwin ports也下载一份,但其服务器慢得要命,而且常常断链,镜像网站也没有。最后只好祭出wget大法,用了个小脚本来搞。

(外一则)今天Nick Hodges的blog说到:

You know what I hate? I hate it when Windows tells me that it has installed new updates, and then it keeps insisting I have to reboot. If I say reboot later, it gives me like a five minute grace period and 'reminds' me again. I should be able to reboot when I want to reboot, not when Windows insists that I reboot. Very irritating.

有人在留言中说:

What I hate - you leave a long download going overnigt, and you get up the next morning and your computer has been rebooted by Windows Update.

嘿,跟我在下载cygwin ports中碰到的问题一样: 开始Windows Update每隔5分钟问我一次要不要重启,烦死我了;后来配好了下载脚本,本来放心地去睡了,第二天早上一看,就下载了3%, 机器被Windows Update自作聪明地重启了 :-(。只是没想到这些高手也会被这个问题所困扰。


首先:

  wget ftp://sunsite.dk/projects/cygwinports/setup.bz2

bunzip2 -dc setup.bz2 > setup.ini

然后就可以不断使用这个脚本了:

#!/bin/sh

OFFICIAL_DIR="../official"
# find packages not downloaded
echo "analysing setup.ini and finding packages not downloaded..."
awk 'BEGIN{current=0;}
/^@/ { current=1; }
/^[prev/ {current=0; }
/^[test/ {current-0; }
/^install:/ { if (1==current) print $2,$3; }' setup.ini | while read file size; do
[ ! -f "$file" ] && echo "$file $size"
done > .missing.tmp

# download them, from the smallest one to bigger ones
#sort -n -k2 .missing.tmp | while read file size; do
cat .missing.tmp | while read file size; do
d=`dirname $file`
# if "../$d" exists, official port already exists
# thus this package is an update, ignore it
if [ ! -f "$file" -a ! -d "${OFFICIAL_DIR}/$d" ]; then
[ ! -d $d ] && mkdir -p $d

d=`dirname $file`
[ ! -d $d ] && mkdir -p $d
wget --timestamping --no-host-directories --force-directories
--cut-dirs=2 "ftp://sunsite.dk/projects/cygwinports/$file"
# wget --timestamping --no-host-directories --force-directories
# --cut-dirs=2 "ftp://sunsite.dk/projects/cygwinports/$d/setup.hint"
sleep 10
fi
done

User Comments
关不掉windows update的重启提示 [Reply]
bamanzi | 17 十一月, 2006 21:40
在网上收了一阵,说是运行gpedit.msc,然后设置某个选项即可关掉。但我这里没有gpedit.msc,说是XP Home版本没有这个东西。唉!
(no subject) [Reply]
netawater | 18 十一月, 2006 13:48
请问cygwin ports和以前的cygwin.com有什么关系?
Re: [Reply]
bamanzi | 19 十一月, 2006 11:29
cygwin ports提供一些额外的包,是 cygwin官方包的补充,甚至KDE,GNOME和mono都有
(no subject) [Reply]
netawater | 19 十一月, 2006 22:23
哦,谢谢!
(no subject) [Reply]
anony | 21 十一月, 2006 15:51
我用的cygwin是这个版本:cygwin-cd-release-20060906.iso.全部安装,在下载好cygwin ports,全部安装.安装的时候看到cygwin自动把旧的gnome/xorg什么的卸载掉了,装好后,运行gnome/kde都不成功 (startgnome,startkde),老是提示: _X11TransOpen: transport open failed for local _X11TransOpen: transport open failed for tcp ,并且xterm都不能打开,can't open display 127.0.0.1:0,但是明明X是起来的,telnet能直接联上127.0.0.1:6000.是因为cygwin版本太低了么?
(no subject) [Reply]
anony | 22 十一月, 2006 16:33
又使用了最新的cygwin(20061108).还是不行,估计是cygwin ports的问题.唉

没有评论: