forked from usnistgov/oar-pdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makedist
executable file
·151 lines (144 loc) · 4.26 KB
/
makedist
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#! /bin/bash
#
# makedist: build the package's distributions
#
# This script is designed to run without any arguments: this will build
# all of the available distributions. Restricting the build to specific
# distributions can be done by listing the names of the desired distributions
# on the command line.
#
# There are currently two distributions: pdr-publish, pdr-lps
#
# SYNOPSIS
# makedist.angular [OPTIONS] [DISTNAME ...]
#
# OPTIONS
# -l, --list list the names of the supported distributions and
# exit without building.
# --dist-dir=DIR The output directory to write the distribution
# products into.
# -d DIR, --source-dir=DIR the directory containing the python source code
# (default: .)
# -c DIR, --cache-dir=DIR directory for holding intermediate or cache-able
# products; if provided, the node_modules cache will
# be located and used from here. This can be shared
# with other similar packages to avoid redundant
# re-building of nodejs dependency modules
# -v VER, --version=VER assign VER as the VERSION for this product
#
#
set -e
prog=`basename $0`
execdir=`dirname $0`
[ "$execdir" = "" -o "$execdir" = "." ] && execdir=$PWD
PACKAGE_DIR=`dirname $execdir`
VERSION=
# this is needed because realpath is not on macs
function realpath {
if [ -d "$1" ]; then
(cd $1 && pwd)
elif [ -f "$1" ]; then
file=`basename $1`
parent=`dirname $1`
realdir=`(cd $parent && pwd)`
echo "$realdir/$file"
elif [[ $1 = /* ]]; then
echo $1
else
echo "$PWD/${1#./}"
fi
}
# Update this list with the names of the individual component names
#
DISTNAMES="pdr-publish pdr-lps"
angular_dists=":pdr-lps:"
python_dists=":pdr-publish:"
# handle command line options
while [ "$1" != "" ]; do
case "$1" in
--list|-l)
echo "Available distributions: $DISTNAMES"
exit 0
;;
--dist-dir=*)
DIST_DIR=`echo $1 | sed -e 's/[^=]*=//'`
;;
--dist-dir)
shift
DIST_DIR=$1
;;
--source-dir=*|--dir=*)
SOURCE_DIR=`echo $1 | sed -e 's/[^=]*=//'`
;;
-d|--dir|--source-dir)
shift
SOURCE_DIR=$1
;;
--cache-dir=*)
CACHE_DIR=`echo $1 | sed -e 's/[^=]*=//'`
# NOTE: CACHE_DIR is ignored
;;
-c|--cache-dir)
shift
CACHE_DIR=$1
# NOTE: CACHE_DIR is ignored
;;
-*)
echo "$prog: unsupported option:" $1
false
;;
*)
(echo :${DISTNAMES}: | sed -e 's/ /:/g' | grep -qs :${1}:) || {
echo "${prog}: ${1}: unrecognized distribution name"
echo "${prog}: recognized names:" $DISTNAMES
false
}
build_dist="$build_dist $1"
;;
esac
shift
done
[ -n "$build_dist" ] || build_dist=$DISTNAMES
echo '#' Building $build_dist
# make sure the oar-metadata submodule has been initialized
#
[ -d "oar-metadata/scripts" ] || {
set -x
git submodule init
git submodule update
set +x
}
# set the current version. This will inject the version into the code, if
# needed.
#
set -x
(cd oar-metadata; scripts/setversion.sh)
scripts/setversion.sh $VERSION
set +x
[ -n "$PACKAGE_NAME" ] || PACKAGE_NAME=`cat VERSION | awk '{print $1}'`
version=`cat VERSION | awk '{print $2}'`
vers4fn=`echo $version | perl -pe 's#[/ ]+#_#g'`
build_py=
build_ang=
for dist in $build_dist; do
if (echo $angular_dists | grep -qs :${dist}:); then
build_ang="$build_ang $dist"
else
build_py="$build_py $dist"
fi
done
args=
[ -z "$CACHE_DIR" ] || args="$args --cache-dir=`realpath $CACHE_DIR`"
[ -z "$DIST_DIR" ] || args="$args --dist-dir=`realpath $DIST_DIR`"
[ -z "$build_ang" ] || {
sargs=
[ -z "$SOURCE_DIR" ] || sargs="--source-dir=$SOURCE_DIR/angular"
echo '+' makedist.angular $sargs $args $build_ang
$execdir/makedist.angular $sargs $args $build_ang
}
[ -z "$build_py" ] || {
sargs=
[ -z "$SOURCE_DIR" ] || sargs="--source-dir=$SOURCE_DIR/python"
echo '+' makedist.python $sargs $args $build_py
$execdir/makedist.python $sargs $args $build_py
}