今天想把fedora8升级到fedora9,结果先把fedora-release*的包升级以后,发现系统fedora源已经全部变成fedora9的了,但是因几个基本包有问题,我用yum安装什么包都装不了了。 只好回退,结果遇上这样一个问题: Cannot retrieve repository metadata (repomd.xml) for repository:/var/cache/yum/fedora/mirrorlist.txt 到处查,都搞不懂为什么。最后只好自己查查yum的源代码,再加上我天才般的瞎猜,终于整出来了: 记下过程: 手工建立/var/cache/yum/fedora/和/var/cache/yum/updates两个目录。 编辑/var/cache/yum/fedora/mirrorlist.txt为 # repo = fedora-8 arch = x86_64 country = CN country = RU country = JP country = HK country = KR country = TW country = TH country = IN http://fedora.candishosting.com.cn/pub/fedora/linux/releases/8/Everything/x86\_64/os http://opensource.nchc.org.tw/fedora/linux/releases/8/Everything/x86\_64/os http://ftp.twaren.net/Linux/Fedora/linux/releases/8/Everything/x86\_64/os http://linux.ntcu.net/ftp/dists/fedora/releases/8/Everything/x86\_64/os http://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora/linux/releases/8/Everything/x86\_64/os http://ftp.hostrino.com/pub/fedora/linux/releases/8/Everything/x86\_64/os ftp://ftp.rhd.ru/pub/fedora/linux/releases/8/Everything/x86\_64/os http://ftp.cse.yzu.edu.tw/pub/Linux/Fedora/releases/8/Everything/x86\_64/os http://ftp.chg.ru/pub/Linux/fedora/linux/releases/8/Everything/x86\_64/os http://ftp.jaist.ac.jp/pub/Linux/Fedora/releases/8/Everything/x86\_64/os http://ftp.ncnu.edu.tw/Linux/Fedora/linux/releases/8/Everything/x86\_64/os http://allotter.yandex.net/fedora/linux/releases/8/Everything/x86\_64/os http://ftp.kddilabs.jp/Linux/packages/fedora/releases/8/Everything/x86\_64/os http://ftp.kaist.ac.kr/pub/fedora/linux/releases/8/Everything/x86\_64/os ftp://ftp.sfc.wide.ad.jp/pub/Linux/Fedora/releases/8/Everything/x86\_64/os http://ftp.riken.jp/Linux/fedora/releases/8/Everything/x86\_64/os http://spreader.yandex.net/fedora/linux/releases/8/Everything/x86\_64/os 编辑/var/cache/yum/updates/mirrorlist.txt为: # repo = updates-released-f8 arch = x86_64 country = RU country = JP country = HK country = CY country = SG country = TW country = TH country = IN http://spreader.yandex.net/fedora/linux/updates/8/x86\_64 http://ftp.kddilabs.jp/Linux/packages/fedora/updates/8/x86\_64 http://allotter.yandex.net/fedora/linux/updates/8/x86\_64 http://ftp.hostrino.com/pub/fedora/linux/updates/8/x86\_64 http://ftp.riken.jp/Linux/fedora/updates/8/x86\_64 ftp://ftp.oss.eznetsols.org/linux/fedora/updates/8/x86\_64 ftp://ftp.sfc.wide.ad.jp/pub/Linux/Fedora/updates/8/x86\_64 http://opensource.nchc.org.tw/fedora/linux/updates/8/x86\_64 http://ftp.jaist.ac.jp/pub/Linux/Fedora/updates/8/x86\_64 http://mirrors.cytanet.com.cy/linux/fedora/linux/updates/8/x86\_64 大功告成。 再运行yum install mplayer,一切正常。 原因(个人瞎猜版): /var/cache/yum/下是yum的缓存目录。当我运行yum clean all时,把这两个目录下的一些文件清空了。但是可能yum存在一个bug, /var/cache/yum/fedora/repomd.xml能重新下载生成,/var/cache/yum/fedora/mirrotlist.txt却不能正常生成。因此需要我们手工构造这个文件。 那我是怎么构造这个文件的内容的呢? 注意看/etc/yum.repos.d/fedora.repod文件,中有 mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch $releasever应该是8(我用的是fedora 8),$basearch是架构的意思,我的是x86_64,替换上,访问之,得到: # repo = fedora-8 arch = x86_64 country = CN country = RU country = JP country = HK country = KR country = TW country = TH country = IN http://fedora.candishosting.com.cn/pub/fedora/linux/releases/8/Everything/x86\_64/os http://opensource.nchc.org.tw/fedora/linux/releases/8/Everything/x86\_64/os http://ftp.twaren.net/Linux/Fedora/linux/releases/8/Everything/x86\_64/os http://linux.ntcu.net/ftp/dists/fedora/releases/8/Everything/x86\_64/os http://ftp.yz.yamagata-u.ac.jp/pub/linux/fedora/linux/releases/8/Everything/x86\_64/os http://ftp.hostrino.com/pub/fedora/linux/releases/8/Everything/x86\_64/os ftp://ftp.rhd.ru/pub/fedora/linux/releases/8/Everything/x86\_64/os http://ftp.cse.yzu.edu.tw/pub/Linux/Fedora/releases/8/Everything/x86\_64/os http://ftp.chg.ru/pub/Linux/fedora/linux/releases/8/Everything/x86\_64/os http://ftp.jaist.ac.jp/pub/Linux/Fedora/releases/8/Everything/x86\_64/os http://ftp.ncnu.edu.tw/Linux/Fedora/linux/releases/8/Everything/x86\_64/os http://allotter.yandex.net/fedora/linux/releases/8/Everything/x86\_64/os http://ftp.kddilabs.jp/Linux/packages/fedora/releases/8/Everything/x86\_64/os http://ftp.kaist.ac.kr/pub/fedora/linux/releases/8/Everything/x86\_64/os ftp://ftp.sfc.wide.ad.jp/pub/Linux/Fedora/releases/8/Everything/x86\_64/os http://ftp.riken.jp/Linux/fedora/releases/8/Everything/x86\_64/os http://spreader.yandex.net/fedora/linux/releases/8/Everything/x86\_64/os 这就是/var/cache/yum/fedora/mirrorlist.txt的内容了。 对应地,查看/etc/yum.repos.d/fedora-updates.repo,去访问对应的地址,取得内容写入到/var/cache/yum/updates/mirrorlist.txt.