要从安装 DVD 创建本地存储库,只需将 isos 安装到 mnt 并在 mnt 中调用

要从安装 DVD 创建本地存储库,只需将 isos 安装到 mnt 并在 mnt 中调用

我正在尝试从我的 CentOS 5 主机构建一个新的 CentOS 6 VM,但似乎这些版本之间的一些基本内容发生了变化:

$ rpm -ivh --nodeps --nodigest --ignorearch --ignoreos --force --root=/mnt centos-release-6-0.el6.centos.5.i686.rpm
warning: centos-release-6-0.el6.centos.5.i686.rpm: Header V3 RSA/SHA256 signature: NOKEY, key ID c105b9de
Preparing...                ########################################### [100%]
   1:centos-release         ########################################### [100%]
error: unpacking of archive failed: cpio: Bad magic

$ rpm --version
RPM version 4.4.2.3

这些版本之间的 RPM 神奇数字是否发生了变化?我该如何解决这个问题?

编辑(澄清):

我是不是尝试升级现有机器。我正在尝试使用 yum --installroot=/mnt groupinstall core 创建新安装。为了获得工作配置,第一步是安装包含 yum repo 配置的发布 rpm。

答案1

据我所知,不能这样做:RPM 中的坏魔法是最不重要的问题。

简而言之:没有推荐的 RHEL5->RHEL6 升级路径,因此没有 Centos5->6。我尝试了一点小伎俩(我自己有大量的 C5 服务器),但决定不这样做。

考虑到 5->6 的过渡相当于 fedora core 6->12 的过渡,但没有 yum 中的预升级支持。因此,您可以打开 FC7 DVD,使用

selinux=0 upgradeany

冲洗,然后重复 FC8...FC11,最后是 CentOS6。祝你好运 - 说到我自己的机器,我会很惊讶最终能得到比 bash 更复杂的东西 - 这是在花了几天时间尝试这个古怪的壮举之后。

我估计我可能会在更短的时间内重建一台(正常工作的)机器。这也很好,因为 RHEL5 仍然有几年的支持。

答案2

问题

问题如下:

  1. RHEL6 中的 rpm 文件使用不同的魔法数字
  2. RHEL5 python2.4 无法识别用于在 CentOS 6 中校验下载的 sha256
  3. yum 在 RHEL6 中使用不同的数据库格式,因此 RHEL5 yum 构建的 chroot 环境无法被 RHEL6 中的 yum 理解

解决方案

警告:以下针对问题 1 的解决方案很危险。如果 RPM 升级中断,您的系统很可能会崩溃。针对问题 2 的解决方案可能会导致安装损坏的软件包!

问题 1 可以通过从源 RPM 反向移植 RPM 4.6 来规避。请参阅http://orcorc.blogspot.com/2009/03/oh-my-goodness.html

为源 RPM 构建依赖项:

$ yum install redhat-rpm-config elfutils-devel elfutils-libelf-devel readline-devel zlib-devel nss-devel gettext-devel libselinux-devel ncurses-devel bzip2-devel python-devel lua-devel xz-devel xz

我的 CentOS 发行版中没有合适的 lua。从 rpmsearch 获取:

$ rpm -i lua-5.1.2-1.el5.x86_64.rpm lua-devel-5.1.2-1.el5.x86_64.rpm

安装并构建源 RPM。当然可能需要其他软件包,例如 gcc:

$ rpm -i rpm-4.6.0-4.0.notting.1.el5.src.rpm
$ rpmbuild -ba /usr/src/redhat/SPECS/rpm.spec

在实际安装替换 RPM 之前进行测试:

$ rpm -U --test /usr/src/redhat/RPMS/i386/rpm-4.6.0-4.0.notting.1.i386.rpm /usr/src/redhat/RPMS/i386/rpm-libs-4.6.0-4.0.notting.1.i386.rpm /usr/src/redhat/RPMS/i386/rpm-python-4.6.0-4.0.notting.1.i386.rpm /usr/src/redhat/RPMS/i386/rpm-build-4.6.0-4.0.notting.1.i386.rpm

我们现在可以安装基线:

$ rpm -i --root=/mnt centos-release-6-0.el6.centos.5.i686.rpm

问题 2 可以通过手动编辑 /usr/lib/python2.4/site-packages/yum 文件来解决(可以使用 PYTHONPATH magic 来减少这种黑客行为)。差异如下:

--- yum-python/__init__.py      2011-10-05 11:03:00.000000000 +0200
+++ /usr/lib/python2.4/site-packages/yum/__init__.py    2011-10-05 11:14:24.000000000 +0200
@@ -1215,7 +1215,7 @@
             if ylp.pkgtup != po.pkgtup:
                 failed = True

-
+        failed = False
         if failed:            
             # if the file is wrong AND it is >= what we expected then it
             # can't be redeemed. If we can, kill it and start over fresh
diff -ru yum-python/yumRepo.py /usr/lib/python2.4/site-packages/yum/yumRepo.py
--- yum-python/yumRepo.py       2011-10-05 11:03:00.000000000 +0200
+++ /usr/lib/python2.4/site-packages/yum/yumRepo.py     2011-10-05 11:12:51.000000000 +0200
@@ -1461,6 +1461,7 @@
         else:
             file = fn

+        return 1
         try:
             l_csum = self._checksum(r_ctype, file) # get the local checksum
         except Errors.RepoError, e:

我们现在准备执行 yum groupinstall:

$ yum groupinstall --nogpgcheck --installroot=/mnt core

请注意,由于我们已禁用大多数软件包验证,因此软件包在此步骤可能会安装失败。请密切注意输出:

Failed:
  python.i686 0:2.6.5-3.el6_0.2         redhat-logos.noarch 0:60.0.14-10.el6        

$ yum install --nogpgcheck --installroot=/mnt python redhat-logos

冲洗并重复。

由于核心不会进行任何系统设置,您可能需要在下一步之前做许多事情。我需要提供 /mnt/etc/resolv.conf。

我们现在有了一个可以针对问题 3 进行 chroot 的环境:

$ SHELL=/bin/bash chroot /mnt
$ yum install zsh
error: cannot open Packages index using db3 - No such file or directory (2)
error: cannot open Packages database in /var/lib/rpm

幸运的是,这个问题很容易解决:只需重建 /var/lib/rpm:

$ mv /var/lib/rpm/ /var/lib/old.rpm
$ rpm --initdb

此时我遇到了经典的 $releasever 问题,因此我不得不编辑 /etc/yum.repos.d/* 以将 $releasever 替换为 6。例如:

sed -re 's/\$releasever/6/g' -i /etc/yum.repos.d/CentOS-Base.repo

可能有更好的方法可以做到这一点,但我还没有找到。

$ yum install zsh
Loaded plugins: fastestmirror
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. $releasever is not a valid release or hasnt been released yet/
removing mirrorlist with no valid mirrors: /var/cache/yum/i386/$releasever/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

经过这次编辑,yum 可以按预期工作,并且我有一个由 CentOS 5 构建的 CentOS 6。任何针对 CentOS 6 的 chroot 环境/VM 客户机设置说明都应该能够让您获得一个功能齐全的系统。

答案3

伟大的,

在这种情况下,我的系统崩溃了,需要对系统做一些更疯狂的事情。

许多事情都取决于系统的实际状态,因此差异是可以接受的 最重要的事情是解决“RPM:坏魔法”

开始前检查其他方式!!!


是不是哪里出错了?那么你可以使用 rpm2cpio 或 mc 来提取 cpio,然后使用 cpio 提取 rpm 文件并手动复制到文件夹,之后别忘了运行 ldconfig

可能你必须获取新版本的 cpio 才能提取 cpio 内容

所以我要使用 el6 版本来解决这个问题。

意思是,必须让 RPM 再次工作,然后我才能重新安装其他软件包。

因为系统崩溃了并且没有更多可供安装的 el6 库,所以必须从源代码编译所有依赖的内容。

1)使用 yum 从 el5 存储库安装尽可能多的依赖项,其中包含 devel 包,其中的头文件包括 nss3 + devel lzma + devel nspr4 + devel ncurses + devel readline db-4.5.20 + devel rpm-libs + devel

在其他情况下必须下载源代码并编译

2) 继续 cpio,lzma 获取 SRPM 和补丁的内容 从主页下载 cpio 2.10+ better = 编译并安装 下载 rpm 4.6.0+ 更好=从主页编译并安装 从主页下载 rpm-libs 4.6.0+ 更好=编译并安装 从主页下载 db-4.5.20 更好=编译并安装

rpm* el6 有 4.8.* 但为了兼容性 4.6+ 也可以

如果 rpmbuild --rebuild 工作正常,中间几行会显示出来,这意味着上帝保佑你,你已经安装了正确版本的头文件和库

或者对于其他依赖项,下载 src.rpm 文件解压 rpm、cpio、主存档将补丁应用到一个文件夹

http://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/

总是应用补丁,必须指定正确的文件名或在同一文件夹中创建符号链接

ls *.patch.bz2|while read a;do bzcat $a > $a.patch;done
ls *.patch.gz|while read a;do zcat $a > $a.patch;done
ls cpio*.patch|while read p;do patch -p0 < "$p";done

毕竟,你必须构建 lzma 和其他库

ldconfig

用于配置 RPM

CFLAGS="-lncurses -lnss3 -I/usr/include/nss3 -I/usr/include/nspr4 -lnspr4"
./configure --prefix=/usr --with-lua --with-lzma --with-nss3 --with-nspr4 --with-external-db
make

其他配置,如 cpio

CFLAGS="-lncurses -lnss3 -I/usr/include/nss3 -I/usr/include/nspr4 -lnspr4"
# or specify bin folder
./configure --prefix=/ 
make
# test, !!! make backup of rpm binaries and libs in case rollback /usr/lib/rpm /usr/bin /bin and rpm-db
make install
# then move man and other to /usr/share from / where are now

如果要回滚,您必须手动重新安装 rpm 或用备份版本替换文件并运行 ldconfig

命令

全部都正确嗎?

% 安装

并继续“我们现在可以安装基线:”或者如果你愿意,只需更新从 /etc/yum.repos.d 中删除其他存储库,只保留 el6 包

如果你不确定是否会删除某些文件,请小心并拒绝,其他依赖项则必须使用 rpm 手动安装

yum clean all
yum update --skip-broken
package-clean --problems
package-clean --dups
yum update

要从安装 DVD 创建本地存储库,只需将 isos 安装到 mnt 并在 mnt 中调用

yum install yum-utils
cd /mnt
createrepo .

一些存储库 修复 $releasever 版本为 el5

    cat << _EOF_ > /etc/yum.repos.d/all-in-one-`date +%s`.repo     
    [base]
    name=CentOS-6.4-colacl-dvd mount
    baseurl=file:///mnt
    gpgcheck=0
    ### Name: RPMforge RPM Repository for RHEL 5 - dag
    ### URL: http://rpmforge.net/
    [rpmforge]
    name = RHEL $releasever - RPMforge.net - dag
    baseurl = http://apt.sw.be/redhat/el5/en/5.7/rpmforge
    mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
    gpgcheck = 1

    [rpmforge-extras]
    name = RHEL $releasever - RPMforge.net - extras
    baseurl = http://apt.sw.be/redhat/el5/en/$basearch/extras
    mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge-extras
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
    gpgcheck = 1

    [rpmforge]
    name = RHEL $releasever - RPMforge.net - dag
    baseurl = http://apt.sw.be/redhat/el6/en/$basearch/rpmforge
    mirrorlist = http://apt.sw.be/redhat/el6/en/mirrors-rpmforge
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
    gpgcheck = 1

    [rpmforge-extras]
    name = RHEL $releasever - RPMforge.net - extras
    baseurl = http://apt.sw.be/redhat/el6/en/$basearch/extras
    mirrorlist = http://apt.sw.be/redhat/el6/en/mirrors-rpmforge-extras
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
    gpgcheck = 1


    #---- Packages previously released as 5.7, and its updates
    [C5.7-base]
    name=CentOS-5.7 - Base
    baseurl=http://vault.centos.org/5.7/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.7-updates]
    name=CentOS-5.7 - Updates
    baseurl=http://vault.centos.org/5.7/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.7-extras]
    name=CentOS-5.7 - Extras
    baseurl=http://vault.centos.org/5.7/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.7-centosplus]
    name=CentOS-5.7 - Plus
    baseurl=http://vault.centos.org/5.7/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.6, and its updates
    [C5.6-base]
    name=CentOS-5.6 - Base
    baseurl=http://vault.centos.org/5.6/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.6-updates]
    name=CentOS-5.6 - Updates
    baseurl=http://vault.centos.org/5.6/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.6-extras]
    name=CentOS-5.6 - Extras
    baseurl=http://vault.centos.org/5.6/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.6-centosplus]
    name=CentOS-5.6 - Plus
    baseurl=http://vault.centos.org/5.6/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.5, and its updates
    [C5.5-base]
    name=CentOS-5.5 - Base
    baseurl=http://vault.centos.org/5.5/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.5-updates]
    name=CentOS-5.5 - Updates
    baseurl=http://vault.centos.org/5.5/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.5-extras]
    name=CentOS-5.5 - Extras
    baseurl=http://vault.centos.org/5.5/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.5-centosplus]
    name=CentOS-5.5 - Plus
    baseurl=http://vault.centos.org/5.5/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.4 and its updates
    [C5.4-base]
    name=CentOS-5.4 - Base
    baseurl=http://vault.centos.org/5.4/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.4-updates]
    name=CentOS-5.4 - Updates
    baseurl=http://vault.centos.org/5.4/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.4-extras]
    name=CentOS-5.4 - Extras
    baseurl=http://vault.centos.org/5.4/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.4-centosplus]
    name=CentOS-5.4 - Plus
    baseurl=http://vault.centos.org/5.4/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


    #---- Packages previously released as 5.3 and its updates
    [C5.3-base]
    name=CentOS-5.3 - Base
    baseurl=http://vault.centos.org/5.3/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.3-updates]
    name=CentOS-5.3 - Updates
    baseurl=http://vault.centos.org/5.3/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.3-extras]
    name=CentOS-5.3 - Extras
    baseurl=http://vault.centos.org/5.3/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.3-centosplus]
    name=CentOS-5.3 - Plus
    baseurl=http://vault.centos.org/5.3/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.2 and its updates
    [C5.2-base]
    name=CentOS-5.2 - Base
    baseurl=http://vault.centos.org/5.2/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.2-updates]
    name=CentOS-5.2 - Updates
    baseurl=http://vault.centos.org/5.2/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.2-extras]
    name=CentOS-5.2 - Extras
    baseurl=http://vault.centos.org/5.2/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.2-centosplus]
    name=CentOS-5.2 - Plus
    baseurl=http://vault.centos.org/5.2/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.1 and its updates
    [C5.1-base]
    name=CentOS-5.1 - Base
    baseurl=http://vault.centos.org/5.1/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.1-updates]
    name=CentOS-5.1 - Updates
    baseurl=http://vault.centos.org/5.1/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.1-extras]
    name=CentOS-5.1 - Extras
    baseurl=http://vault.centos.org/5.1/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.1-centosplus]
    name=CentOS-5.1 - Plus
    baseurl=http://vault.centos.org/5.1/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


    #---- Packages previously released as 5.0 and its updates
    [C5.0-base]
    name=CentOS-5.0 - Base
    baseurl=http://vault.centos.org/5.0/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.0-updates]
    name=CentOS-5.0 - Updates
    baseurl=http://vault.centos.org/5.0/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.0-extras]
    name=CentOS-5.0 - Extras
    baseurl=http://vault.centos.org/5.0/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.0-centosplus]
    name=CentOS-5.0 - Plus
    baseurl=http://vault.centos.org/5.0/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


    [basee]
    name=CentOS-$releasever - Base
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
    baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #released updates
    [updatese]
    name=CentOS-$releasever - Updates
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
    baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #additional packages that may be useful
    [extrase]
    name=CentOS-$releasever - Extras
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
    baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #additional packages that extend functionality of existing packages
    [centospluse]
    name=CentOS-$releasever - Plus
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
    baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #contrib - packages by Centos Users
    [contribe]
    name=CentOS-$releasever - Contrib
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
    baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    #---- Packages previously released as 5.8, and its updates
    [C5.8-base]
    name=CentOS-5.8 - Base
    baseurl=http://vault.centos.org/5.8/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.8-updates]
    name=CentOS-5.8 - Updates
    baseurl=http://vault.centos.org/5.8/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.8-extras]
    name=CentOS-5.8 - Extras
    baseurl=http://vault.centos.org/5.8/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

    [C5.8-centosplus]
    name=CentOS-5.8 - Plus
    baseurl=http://vault.centos.org/5.8/centosplus/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
_EOF_

敬请邀请您访问我的页面,喜欢的人就点赞吧。

Facebook 页面

相关内容