Skip to content

Commit 2b05ad3

Browse files
authored
Merge pull request #20 from wdconinc/use-cache-for-apt-downloads
Use action/cache for apt downloads
2 parents 16e6f1e + 2c7a859 commit 2b05ad3

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ branding:
44
icon: 'folder'
55
color: 'orange'
66
inputs:
7+
apt_cache:
8+
description: 'Location (directory) of the user-space apt cache.'
9+
required: false
10+
default: 'apt_cache'
711
cvmfs_alien_cache:
812
description: 'If set, use an alien cache at the given location.'
913
required: false
@@ -331,11 +335,26 @@ inputs:
331335
runs:
332336
using: "composite"
333337
steps:
338+
- id: lsb-release
339+
run: |
340+
source /etc/lsb-release
341+
echo "::set-output name=id::${DISTRIB_ID}"
342+
echo "::set-output name=release::${DISTRIB_RELEASE}"
343+
echo "::set-output name=codename::${DISTRIB_CODENAME}"
344+
echo "::set-output name=description::${DISTRIB_DESCRIPTION}"
345+
echo "::set-output name=id-release::${DISTRIB_ID}-${DISTRIB_DESCRIPTION}"
346+
shell: bash
347+
- uses: actions/cache@v3
348+
with:
349+
key: cvmfs-apt-cache-${{ steps.lsb-release.outputs.id-release }}-${{ hashFiles('action.yml') }}
350+
path: |
351+
${{ inputs.apt_cache }}
334352
- run: |
335353
${{ github.action_path }}/setup-cvmfs.sh
336354
shell: bash
337355
env:
338356
ACTION_PATH: ${{ github.action_path }}
357+
APT_CACHE: ${{ inputs.apt_cache }}
339358
CVMFS_ALIEN_CACHE: ${{ inputs.cvmfs_alien_cache }}
340359
CVMFS_ALT_ROOT_PATH: ${{ inputs.cvmfs_alt_root_path }}
341360
CVMFS_AUTHZ_HELPER: ${{ inputs.cvmfs_authz_helper }}

setup-cvmfs.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
#!/usr/bin/env bash
22

3-
#Platform specific install
3+
# Platform specific install
44
if [ "$(uname)" == "Linux" ]; then
5-
curl -L -o cvmfs-release-latest_all.deb ${CVMFS_UBUNTU_DEB_LOCATION}
6-
sudo dpkg -i cvmfs-release-latest_all.deb
5+
# download from cache
6+
if [ -n "${APT_CACHE}" ]; then
7+
echo "Copying cache from ${APT_CACHE} to system locations..."
8+
mkdir -p ${APT_CACHE}/archives/ ${APT_CACHE}/lists/
9+
sudo cp -r ${APT_CACHE}/archives /var/cache/apt
10+
sudo cp -r ${APT_CACHE}/lists /var/lib/apt
11+
fi
12+
# install cvmfs release package
13+
APT_ARCHIVES=/var/cache/apt/archives/
14+
if [ ! -f ${APT_ARCHIVES}/cvmfs-release-latest_all.deb ] ; then
15+
sudo curl -L -o ${APT_ARCHIVES}/cvmfs-release-latest_all.deb ${CVMFS_UBUNTU_DEB_LOCATION}
16+
fi
17+
sudo dpkg -i ${APT_ARCHIVES}/cvmfs-release-latest_all.deb
18+
# install cvmfs package
719
sudo apt-get -q update
820
sudo apt-get -q -y install cvmfs
9-
rm -f cvmfs-release-latest_all.deb
21+
# install cvmfs config package
1022
if [ "${CVMFS_CONFIG_PACKAGE}" == "cvmfs-config-default" ]; then
1123
sudo apt-get -q -y install cvmfs-config-default
1224
else
13-
curl -L -o cvmfs-config.deb ${CVMFS_CONFIG_PACKAGE}
14-
sudo dpkg -i cvmfs-config.deb
15-
rm -f cvmfs-config.deb
25+
sudo curl -L -o ${APT_ARCHIVES}/cvmfs-config.deb ${CVMFS_CONFIG_PACKAGE}
26+
sudo dpkg -i ${APT_ARCHIVES}/cvmfs-config.deb
27+
fi
28+
# update cache (avoid restricted partial directories)
29+
if [ -n "${APT_CACHE}" ]; then
30+
echo "Copying cache from system locations to ${APT_CACHE}..."
31+
mkdir -p ${APT_CACHE}/archives/ ${APT_CACHE}/lists/
32+
cp /var/cache/apt/archives/*.deb ${APT_CACHE}/archives/
33+
cp /var/lib/apt/lists/*_dists_* ${APT_CACHE}/lists/
1634
fi
1735
elif [ "$(uname)" == "Darwin" ]; then
1836
# Warn about the phasing out of MacOS support for this action

0 commit comments

Comments
 (0)