-
Notifications
You must be signed in to change notification settings - Fork 3
/
promote.sh
59 lines (48 loc) · 1.93 KB
/
promote.sh
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
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
set -euf
usage() {
echo "promote.sh CENTRAL_OPAM_REPO DKML_OPAM_VERSION" >&2
echo "Ex. promote.sh /z/source/opam-repository 2.0.0" >&2
exit 1
}
if [ $# -lt 2 ]; then usage; fi
CENTRAL_OPAM_REPO=$1
shift
DKML_OPAM_VERSION=$1
shift
HERE=$(dirname "$0")
HERE=$(cd "$HERE" && pwd)
copypkgver() {
# .../packages/dkml-exe/dkml-exe.2.0.0
copypkgver_PKGVERDIR=$1
shift
# .../packages/dkml-exe/dkml-exe.2.0.0 -> dkml-exe
copypkgver_PKG=$(dirname "$copypkgver_PKGVERDIR")
copypkgver_PKG=$(basename "$copypkgver_PKG")
copypkgver_PKGVER=$(basename "$copypkgver_PKGVERDIR")
echo "$copypkgver_PKGVER"
install -d "$CENTRAL_OPAM_REPO/packages/$copypkgver_PKG/"
rsync -a --delete "$copypkgver_PKGVERDIR" "$CENTRAL_OPAM_REPO/packages/$copypkgver_PKG/"
}
# ex. /z/source/dkml/build/_deps/diskuv-opam-repository-src/packages/dkml-exe/dkml-exe.2.0.0
PKGVERDIRS=$(find "$HERE/packages" -mindepth 2 -maxdepth 2 -name "*.$DKML_OPAM_VERSION")
for PKGVERDIR in $PKGVERDIRS; do
copypkgver "$PKGVERDIR"
done
# ex. /z/source/dkml/build/_deps/diskuv-opam-repository-src/packages/dkml-base-compiler/dkml-base-compiler.4.14.0~v2.0.0
PKGVERDIRS=$(find "$HERE/packages" -mindepth 2 -maxdepth 2 -name "*.*~v$DKML_OPAM_VERSION")
for PKGVERDIR in $PKGVERDIRS; do
copypkgver "$PKGVERDIR"
done
# The latest version of conf-withdkml
# ex. /z/source/dkml/build/_deps/diskuv-opam-repository-src/packages/conf-withdkml/conf-withdkml.2
PKGVERDIRS=$(find "$HERE/packages" -mindepth 2 -maxdepth 2 -name "conf-withdkml.*" | sort -nr | head -n1)
for PKGVERDIR in $PKGVERDIRS; do
copypkgver "$PKGVERDIR"
done
# The latest version of conf-dkml-sys-opam
# ex. /z/source/dkml/build/_deps/diskuv-opam-repository-src/packages/conf-dkml-sys-opam/conf-dkml-sys-opam.1
PKGVERDIRS=$(find "$HERE/packages" -mindepth 2 -maxdepth 2 -name "conf-dkml-sys-opam.*" | sort -nr | head -n1)
for PKGVERDIR in $PKGVERDIRS; do
copypkgver "$PKGVERDIR"
done