apt:在安装包版本的新版本时自动升级依赖于包

时间:2016-11-27 23:56:58

标签: apt

情况如下:

我们有包B和A(取决于B)。在存储库中,我们有下一张图片:

A
  version table
    0.0.1 (depends B=0.1.1) 
    0.0.2 (depends B=0.1.2)
    0.0.3 (depends B=0.1.3)
B 
  version table
    0.1.1
    0.1.2
    0.1.3
    0.1.4

在服务器上我们安装了A = 0.0.1。 下次当我们想要在服务器上升级包A时,我们不想手动升级包B(只需运行apt-get install A = 0.0.2)。目前的配置似乎不太可能。

我们尝试了下一个配置: 而不是创建B的下一个版本,我们开始为每个版本创建新的包,如B-1,B-2

A
  version table
    0.0.1 (depends B-1) 
    0.0.2 (depends B-2)
    0.0.3 (depends B-3)
B-1 
B-2 (provides B-1)
B-3 (provides B-2)

此配置不起作用。

有没有适合我们的配置?

由于

1 个答案:

答案 0 :(得分:1)

必要的包字段

  • ./ aa_0.0.1 / Debian的/控制

    • 包装:aa
    • 取决于:bb-1
  • ./ aa_0.0.2 / Debian的/控制

    • 包装:aa
    • 取决于:bb-2
  • ./ bb_0.1.1 / Debian的/控制

    • 包装:bb-1
  • ./ bb_0.1.2 / Debian的/控制

    • 包装:bb-2
    • 冲突:bb-1

使用本地存储库

构建和测试包的脚本
#!/bin/bash

# Rebuild packages
d=`pwd`
repo_name=mydebs
mydebs=${d}/${repo_name}
list=/etc/apt/sources.list.d/${repo_name}.list

rm -rf {aa,bb}*.{build,deb,changes,dsc,tar.gz} $mydebs
for i in ${d}/{aa_0.0.1,aa_0.0.2,bb_0.1.1,bb_0.1.2}
do
  cd $i
  debuild -us -uc
  rm -rf debian/{aa,bb-*,aa.*,bb.*} debian/files
done
cd $d

# Rebuild the repository
type dpkg-scanpackages >/dev/null 2>&1 || sudo apt-get install dpkg-dev

mkdir -p $mydebs
cp *.deb ${mydebs}/
cd $mydebs
dpkg-scanpackages --multiversion . /dev/null | gzip -9c > Packages.gz

echo "deb file:${mydebs} ./" | sudo tee $list
sudo apt-get update

# Return
cd $d

测试

~debian_packaging$ sudo apt-get install aa=0.0.1-1
The following extra packages will be installed:
  bb-1
The following NEW packages will be installed:
  aa bb-1
0 upgraded, 2 newly installed and 0 to remove.
Setting up bb-1 (0.1.1-1) ...
Setting up aa (0.0.1-1) ...
​
~debian_packaging$ sudo apt-get install aa=0.0.2-1
The following extra packages will be installed:
  bb-2
The following packages will be REMOVED:
  bb-1
The following NEW packages will be installed:
  bb-2
The following packages will be upgraded:
  aa
1 upgraded, 1 newly installed and 1 to remove.
Removing bb-1 (0.1.1-1) ...
Setting up bb-2 (0.1.2-1) ...
Setting up aa (0.0.2-1) ...