-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild
executable file
·77 lines (65 loc) · 1.45 KB
/
build
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
command -v realpath &> /dev/null || realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
while [[ $# -gt 2 ]]; do
case "$1" in
-k|--key)
KEY="$2"
shift
;;
-s|--src)
SRCDIR="$2"
shift
;;
-p|--pkg)
PKGDIR="$2"
shift
;;
*)
;;
esac
shift
done
if [[ -z "$1" || -z "$2" ]]; then
echo "Usage: `basename $0` [options] <branch> <package-name>"
echo "Use package-name 'debug' to enter with bash"
echo
echo "Options:"
echo " --key <private-key.rsa>"
echo " --src <parent-dir-of-apks>"
echo " --pkg <output-dir-for-packages>"
exit 1
fi
BRANCH=$1
PACKAGE=$2
IMAGE="nbgallery/apkbuilder:$BRANCH"
if [ -z "$KEY" ]; then
if [ "$BRANCH" == "edge" ]; then
KEY=*jupyter.gallery*.rsa
else
KEY=*nb.gallery*.rsa
fi
fi
if [ -z "$SRCDIR" ]; then
SRCDIR=$PWD
fi
if [ -z "$PKGDIR" ]; then
PKGDIR=$PWD/packages-$BRANCH
fi
KEYFILE=`basename $KEY`
PUBKEYFILE=$KEYFILE.pub
KEYDIR=`dirname $KEY`
KEYDIR=`realpath $KEYDIR`
echo "keyfile: $KEYFILE"
echo "keydir: $KEYDIR"
echo "srcdir: $SRCDIR"
echo "pkgdir: $PKGDIR"
ARGS="--rm -v $KEYDIR:/home/nbgallery/keys -v $PKGDIR:/home/nbgallery/packages -v $SRCDIR:/home/nbgallery/apks -e PACKAGER_PRIVKEY=/home/nbgallery/keys/$KEYFILE -e PACKAGER_PUBKEY=/home/nbgallery/keys/$PUBKEYFILE"
if [ "$PACKAGE" == "debug" ]; then
ARGS="$ARGS -ti --entrypoint bash $IMAGE"
else
ARGS="$ARGS $IMAGE $PACKAGE"
fi
echo docker run $ARGS
docker run $ARGS