我正在使用travis-ci
测试我的github存储库,发现在3
到10
分钟的时间里下载了deb
软件包。它们只有127 MB
大。
我检查了travis-ci/Caching Dependencies and Directories
,但不支持apt-get
。
该怎么做?
答案 0 :(得分:0)
可以通过将内容缓存在非root用户可以访问的另一个文件夹中并将其下的所有mv
deb
缓存到/var/cache/apt/archives/
中来实现。安装后,cp
将它们返回到该文件夹。
注意:
我建议您将YOUR_DIR_FOR_DEB_PACKAGES
放在~
下的某个地方。
# .travis.yml
sudo: required
cache:
- directories:
- $YOUR_DIR_FOR_DEB_PACKAGES # This must be accessible for non-root users
addons:
apt:
sources:
# Whatever source you need
# Download the dependencies if it is not cached
# All the "echo" and "ls" in "before_script" can be remove since they are only used for debugging.
before_script:
- echo "Print content of $YOUR_DIR_FOR_DEB_PACKAGES"
- ls $YOUR_DIR_FOR_DEB_PACKAGES
- echo "Check whether apt-get has no cache"
- ls /var/cache/apt/archives
-
- echo "Start loading cache"
- |
exist() {
[ -e "$1" ]
}
- |
if exist ~/$YOUR_DIR_FOR_DEB_PACKAGES/*.deb
then
sudo mv ~/$YOUR_DIR_FOR_DEB_PACKAGES/*.deb /var/cache/apt/archives/
ls /var/cache/apt/archives
fi
-
- echo "Start to install software"
- sudo apt-get update
- sudo apt-get install -y --no-install-recommends --no-install-suggests $THE_PACKAGES_REQUIRED
-
- echo "Start updating the cache"
- cp /var/cache/apt/archives/*deb ~/$YOUR_DIR_FOR_DEB_PACKAGES/
script:
- # Do whatever you want here.
答案 1 :(得分:0)
在我看来,这不是推荐的做法。 根据{{3}}
快速安装但下载缓慢的大文件不会 从缓存中受益,因为它们需要很长时间才能从缓存中下载 来源:
- Debian软件包