-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathmaven-index-repo
49 lines (38 loc) · 1.42 KB
/
maven-index-repo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Usage:
# maven-index-repo releases/clojars-web-current.jar indexer/indexer-core-4.1.2-cli.jar indexer/index-4.1.2 repo
set -e
clojars_jar=$1
indexer_jar=$2
index_dir=$3
repo=$4
CLOJARS_ENVIRONMENT=production
S3_REPO_BUCKET=clojars-repo-production
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "$dir/set_default_java_opts.bash"
# synchronize the repo bucket locally
# we only need the existing index, the poms, and maven-metadata.xml files
aws s3 sync "s3://$S3_REPO_BUCKET/" "$repo" \
--exclude "*" \
--include "*.pom" \
--include "*.xml" \
--include ".index/*"
# generate the index shards
java "${JAVA_OPTS[@]}" -jar $indexer_jar -n clojars -i $index_dir -d $repo/.index -r $repo -s -q -t min -l -c -k 50
# remove old sums locally (the indexer removes old shards itself, but doesn't remove the sums for those shards)
shopt -s extglob
pushd $repo/.index
for sum in @(*.gz.md5|*.gz.sha1); do
shard=$(ls "$sum" | sed -e 's/\.md5//' -e 's/\.sha1//')
if [ ! -f "$shard" ]; then
rm "$sum"
fi
done
popd
# upload new shards and sums to s3
java "${JAVA_OPTS[@]}" -cp $clojars_jar clojure.main -m clojars.tools.upload-repo-s3 $repo \
$S3_REPO_BUCKET .index :gen-index 2> /dev/null
# remove old shards and sums from s3
java "${JAVA_OPTS[@]}" -cp $clojars_jar clojure.main -m clojars.tools.remove-deletions-s3 $repo \
$S3_REPO_BUCKET \
.index 2> /dev/null