Since a few days, downloading ppa packages during the build is really slow.
wget http://ppa.launchpad.net/openjdk-r/ppa/ubuntu/pool/main/o/openjdk-11/openjdk-11-dbg_11~24-1~14.04.2_amd64.deb --2018-11-16 02:02:30-- http://ppa.launchpad.net/openjdk-r/ppa/ubuntu/pool/main/o/openjdk-11/openjdk-11-dbg_11~24-1~14.04.2_amd64.deb Resolving ppa.launchpad.net (ppa.launchpad.net)... 18.104.22.168 Connecting to ppa.launchpad.net (ppa.launchpad.net)|22.214.171.124|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 211820884 (202M) [application/x-debian-package] Saving to: ‘openjdk-11-dbg_11~24-1~14.04.2_amd64.deb’ 0% [ ] 2,115,923 239KB/s eta 11m 52s^C
This is what I’ve done to keep a cache of all the required apt packages (rsync is required since restore_cache on root-owned folders won’t work with machine executor), so that only the first build will be slow fetching package. Cache key needs to be manually incremented when new deb versions will be released. Sed command is just an optimization for switching from the main ubuntu mirror that is kinda slow everytime, so it’s better to switch to another mirror anyway.
commands: install_java_11: description: "Install openjdk 11 from ppa" steps: - run: mkdir /tmp/archives - restore_cache: keys: - apt-v2 - run: sudo rsync -av /tmp/archives/ /var/cache/apt/archives/ - run: sudo sed -i 's/archive.ubuntu.com/us.archive.ubuntu.com/g' /etc/apt/sources.list - run: name: Install java 11 command: | sudo add-apt-repository ppa:openjdk-r/ppa sudo apt update -q sudo apt install -qy openjdk-11-jdk - run: rsync -av /var/cache/apt/archives/*.deb /tmp/archives/ - save_cache: key: apt-v2 paths: - /tmp/archives