satyaortiz-gagne commited on
Commit
f5ea7f6
·
1 Parent(s): a2c8dfc

Add git-lfs download/extract script

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. scripts/download_extract_git-lfs.sh +49 -0
.gitignore CHANGED
@@ -2,3 +2,4 @@
2
  *.jugdata/
3
  /.tmp/
4
  /logs/
 
 
2
  *.jugdata/
3
  /.tmp/
4
  /logs/
5
+ /bin/git-lfs-linux-amd64-v*/
scripts/download_extract_git-lfs.sh ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ source scripts/utils.sh echo -n
3
+
4
+ # Saner programming env: these switches turn some bugs into errors
5
+ set -o errexit -o pipefail
6
+
7
+ # this script is meant to be used with 'datalad run'
8
+
9
+ # Download git-lfs
10
+ _VERSION=v2.13.3
11
+
12
+ mkdir -p bin/git-lfs-linux-amd64-${_VERSION}
13
+ rm -f bin/sha256sums
14
+ echo "03197488f7be54cfc7b693f0ed6c75ac155f5aaa835508c64d68ec8f308b04c1 git-lfs-linux-amd64-${_VERSION}.tar.gz" > bin/sha256sums
15
+
16
+ files_url=(
17
+ "https://github.com/git-lfs/git-lfs/releases/download/${_VERSION}/git-lfs-linux-amd64-${_VERSION}.tar.gz bin/git-lfs-linux-amd64-${_VERSION}.tar.gz")
18
+
19
+ git-annex addurl --fast -c annex.largefiles=anything --raw --batch --with-files <<EOF
20
+ $(for file_url in "${files_url[@]}" ; do echo "${file_url}" ; done)
21
+ EOF
22
+ # Downloads should complete correctly but in multiprocesses the last git-annex
23
+ # step most likely fails on a BGFS with the error "rename: resource busy
24
+ # (Device or resource busy)"
25
+ ! git-annex get --fast -J8
26
+ # Remove the last byte from each files to prevent the "download failed:
27
+ # ResponseBodyTooShort" error
28
+ ls -l $(list) | grep -oE "\.git/[^']*" | \
29
+ cut -d'/' -f7 | xargs -n1 -- find .git/annex/tmp/ -name | \
30
+ while read f
31
+ do
32
+ newfsize=$(($(stat -c '%s' "${f}") - 1))
33
+ chmod +w "${f}"
34
+ truncate -s $newfsize "${f}"
35
+ done
36
+ # Retry incomplete downloads
37
+ git-annex get --fast --incomplete
38
+ git-annex migrate --fast -c annex.largefiles=anything *
39
+ (cd bin/
40
+ sha256sum -c sha256sums) || \
41
+ exit_on_error_code "Failed to download git-lfs"
42
+
43
+ # Install git-lfs
44
+ tar -C bin/git-lfs-linux-amd64-${_VERSION} -xf bin/git-lfs-linux-amd64-${_VERSION}.tar.gz || \
45
+ exit_on_error_code "Failed to extract git-lfs"
46
+
47
+ pushd bin/ >/dev/null
48
+ ln -sf git-lfs-linux-amd64-${_VERSION}/git-lfs .
49
+ popd >/dev/null