From 015db73c99ad1aae1291c505620bebd0a2d75a3f Mon Sep 17 00:00:00 2001 From: Chad Gilbert Date: Thu, 4 Mar 2021 11:30:07 -0500 Subject: [PATCH 1/3] Add git lfs to lambda layer Resolves lambci/git-lambda-layer#22 This adds the appropriate `git-lfs` RPM repo and validates its signature, then installs it with the `yum install` command. We have to manually move the `git-lfs` binary (which is [the only file required for git-lfs](https://github.com/git-lfs/git-lfs/wiki/Installation#other)) into the `/opt/bin/` folder of the output so that it will be available in the `$PATH` in the lambda layer. This manual handling of the RPM repo is done because the [standard git-lfs install script](https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh) has hardcoded `/etc/` all over the place, whereas we need it to respect the `/lambda/` root. --- lambda2/build.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lambda2/build.sh b/lambda2/build.sh index 36f13bd..83c4928 100755 --- a/lambda2/build.sh +++ b/lambda2/build.sh @@ -5,7 +5,10 @@ rm layer.zip docker run --rm -v "$PWD":/tmp/layer lambci/yumda:2 bash -c " - yum install -y git-${GIT_VERSION} && \ + curl -sSf 'https://packagecloud.io/install/repositories/github/git-lfs/config_file.repo?os=amzn&dist=2&source=script' > /lambda/etc/yum.repos.d/github_git-lfs.repo && \ + yum -q makecache -y --disablerepo='*' --enablerepo='github_git-lfs' --enablerepo='github_git-lfs-source' && \ + yum install -y git-${GIT_VERSION} git-lfs && \ + mv /lambda/usr/bin/git-lfs /lambda/opt/bin/git-lfs && \ cd /lambda/opt && \ zip -yr /tmp/layer/layer.zip . " From d3a834b808f195cc05bd0eb8e84603d247d63e32 Mon Sep 17 00:00:00 2001 From: Chad Gilbert Date: Sat, 6 Mar 2021 08:36:39 -0500 Subject: [PATCH 2/3] Install specific version of git lfs At present, 2.12.1 is the latest version available from this RPM repo, even though there is a 2.13.2 on the git-lfs release page. --- lambda2/build.sh | 2 +- lambda2/config.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lambda2/build.sh b/lambda2/build.sh index 83c4928..e96b43c 100755 --- a/lambda2/build.sh +++ b/lambda2/build.sh @@ -7,7 +7,7 @@ rm layer.zip docker run --rm -v "$PWD":/tmp/layer lambci/yumda:2 bash -c " curl -sSf 'https://packagecloud.io/install/repositories/github/git-lfs/config_file.repo?os=amzn&dist=2&source=script' > /lambda/etc/yum.repos.d/github_git-lfs.repo && \ yum -q makecache -y --disablerepo='*' --enablerepo='github_git-lfs' --enablerepo='github_git-lfs-source' && \ - yum install -y git-${GIT_VERSION} git-lfs && \ + yum install -y git-${GIT_VERSION} git-lfs-${GIT_LFS_VERSION} && \ mv /lambda/usr/bin/git-lfs /lambda/opt/bin/git-lfs && \ cd /lambda/opt && \ zip -yr /tmp/layer/layer.zip . diff --git a/lambda2/config.sh b/lambda2/config.sh index f7d01b6..7a37c4b 100644 --- a/lambda2/config.sh +++ b/lambda2/config.sh @@ -1,2 +1,3 @@ export LAYER_NAME=git-lambda2 export GIT_VERSION=2.29.0 +export GIT_LFS_VERSION=2.12.1 From 8c4dc5da9e5c75c421eedbb7542e219981b3a1ba Mon Sep 17 00:00:00 2001 From: Chad Gilbert Date: Sat, 6 Mar 2021 08:55:36 -0500 Subject: [PATCH 3/3] Add test to show git-lfs output in lambda --- lambda2/test/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lambda2/test/index.js b/lambda2/test/index.js index 8fc41ee..9fd35cb 100644 --- a/lambda2/test/index.js +++ b/lambda2/test/index.js @@ -12,4 +12,6 @@ exports.handler = async(event) => { execSync('ldd /opt/bin/ssh', { encoding: 'utf8', stdio: 'inherit' }) execSync('ssh -V', { encoding: 'utf8', stdio: 'inherit' }) + + execSync('git lfs', { encoding: 'utf8', stdio: 'inherit' }) }