查看深入 Debian APT 包管理系统的源代码
←
深入 Debian APT 包管理系统
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== Example == I. 问题描述: 机器A 装有debian-sid,因为特殊的原因没有可用的源;机器B安装debian-sarge,可以获得可靠的deb包,为了稳定一直使用stable的源;现因业务需要对机器A进行升级。 II. 分析 默认情况下,系统安装的软件包状态由 /var/lib/dpkg/status 文件记录(实际上就是安装的软件包信息的汇总) 安装或升级时apt-get 首先会把要用到的包下载到 /var/cache/apt/archives/ 目录下,然后再执行相应的操作(-d 或 -o apt::get::download-only="true" 则仅仅下载) III. 求解 0. 在机器B的 /tmp下建立工作目录pool/ <pre> pool/ |-- archives/ | `-- partial/ |-- lists/ | `-- partial/ |-- sources.list ------------------------------>机器A所用的unstable源 `-- status ------------------------------>拷贝自机器A的/var/lib/dpkg/status </pre> 1. 获取APT所要用到的索引文件(如Packages,Release),并置于/tmp/pool/lists/下 <pre> root@A# apt-get -o dir::etc::sourcelist="/tmp/pool/sources.list" -------------->指定sources.list -o dir::state::lists="/tmp/pool/lists/" ------>指定Packages,Release文件的存放路径 update </pre> 2. 获取机器A升级所用软件包,存放于/tmp/pool/archives/ <pre> root@A#apt-get -d -o dir::cache="/tmp/pool/" --------->对应于/var/cache/apt/ -o dir::cache::archives="/tmp/pool/archives/" -------->下载之deb包存放目录 -o dir::state::status="/tmp/pool/status" --------->机器A升级前状态 -o dir::state::lists="/tmp/pool/lists/" -o dir::etc::sourcelist="/tmp/pool/sources.list" --->APT从该文件获取源类型(unstable,etc.) dist-upgrade </pre> 3. 把pool目录拷入机器A 之 /tmp 目录下 <pre> root@B#apt-get -o dir::cache="/tmp/pool/" -o dir::state="/tmp/pool/" -o dir::etc="/tmp/pool/" check [ APT generates a local copy of the cache files ] root@B#apt-get -o dir::cache="/tmp/pool/" -o dir::state="/tmp/pool/" -o dir::state::status="/var/lib/dpkg/status" -o dir::etc="/tmp/pool/" dist-upgrade </pre> 4.以上过程采用配置文件可简化为: 4.1 建立 apt.conf ,置于pool目录下 apt.conf must contain the necessary information to make APT use the pool: <pre> APT { /* This is not necessary if the two machines are the same arch, it tells the remote APT what architecture the Debian machine is */ Architecture "i386"; Get::Download-Only "true"; }; Dir { /* Use the disc for state information and redirect the status file from the /var/lib/dpkg default */ State "/tmp/pool/"; State::status "status"; // Binary caches will be stored locally Cache::archives "/tmp/pool/archives/"; Cache "/tmp/"; // Location of the source list. Etc "/tmp/pool/"; }; </pre> 4.2 <pre> root@A# export APT_CONFIG="/disc/apt.conf" root@A# apt-get update [ APT fetches the package files ] root@A# apt-get dist-upgrade [ APT fetches all the packages needed to upgrade your machine ] </pre> 4.3 <pre> root@B# export APT_CONFIG="/disc/apt.conf" root@B# apt-get check [ APT generates a local copy of the cache files ] root@B# apt-get --no-d -o dir::state::status=/var/lib/dpkg/status dist-upgrade [ Or any other APT command ] </pre> 5. 以下测试获取 libciao0.4.7 <pre> apt-get -d -o dir::cache="/tmp/pool/" -o dir::cache::archives="/tmp/pool/archives/" -o dir::state::status="/tmp/pool/status" -o dir::state::lists="/tmp/pool/lists/" -o dir::etc::sourcelist="/tmp/pool/sources.list" --->APT从该文件获取源类型(指定unstable) install libciao0.4.7 </pre> <br><br>
返回到
深入 Debian APT 包管理系统
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面