Caching apt-get install results

I need to use gcc-5 and g+±5 so I have the following circle.yml file which installs them and uses update-alternatives to make them the default version:

dependencies:
pre:
- sudo apt-get update; sudo apt-get install gcc-5; sudo apt-get install g+±5
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g+±5 100

test:
pre:
- gcc --version
- g++ --version
- make

post:
- ./helloworld

This works well, but it takes about 50 seconds to install gcc-5 and g++5.

Is there a way to cache them so they don’t have to be manually installed each build?

Hello!

Unfortunately there is no good way to currently cache anything installed with apt. If you would like to see this as a feature I would encourage you to make this a feature request.

I use “simple way” to achieve this.

Just find correspondent .deb packages, download, cache, and install them in post dependencies task with dpkg.

Below is simple circle.yml to demostrate

dependencies:
  override:
    - /bin/true
  cache_directories:
    - "~/.local"
  pre:
    - >-
      if [[ ! -d "$HOME/.local/debs" ]]; then \
        mkdir -p "$HOME/.local/debs"; cd "$HOME/.local/debs" \
        && curl -LOs http://launchpadlibrarian.net/198723929/libc6-dbg_2.19-0ubuntu6.6_amd64.deb \
      ; fi
  post:
    - sudo dpkg -i $HOME/.local/debs/libc6-dbg_2.19-0ubuntu6.6_amd64.deb

For anyone who’s doing this, you can use apt-get download <library> instead of hunting around for the urls.

Hello!

I’ve just published a guide which helps improve apt-get installs on CCI, please try it out and let me know how we can improve it!