-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathprep.sh
More file actions
executable file
·120 lines (98 loc) · 4.31 KB
/
Copy pathprep.sh
File metadata and controls
executable file
·120 lines (98 loc) · 4.31 KB
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
#!/bin/bash
# python-awips prep script
# author: mjames@ucar.edu
# author: tiffanym@ucar.edu
# This script scrapes the awips2 repos for dynamicserialize, thrift, and awips to package them for python-awips
# should be /awips2/repo/python-awips or ~/python-awips
dir="$( cd "$(dirname "$0")" ; pwd -P )"
echo $dir
rm -rf ${dir}/src
# Find plugin-contributed files and add them to the site packages.
mkdir -p ${dir}/src/dynamicserialize
find /awips2/repo/awips2-core/common/ -path '*/pythonPackages/dynamicserialize' \
-exec cp {} -rv ${dir}/src \;
find /awips2/repo/awips2-hazards/common/ -path '*/pythonPackages/dynamicserialize' \
-exec cp {} -rv ${dir}/src \;
find /awips2/repo/awips2/ -path '*/pythonPackages/dynamicserialize' \
-exec cp {} -rv ${dir}/src \;
#bash %{_baseline_workspace}/build.edex/opt/tools/update_dstypes.sh %{_build_root}/awips2/python/lib/python2.7/site-packages/dynamicserialize
# Update __init__.py files under dynamicserialize/dstypes/ to include
# all contributed python packages and modules within __all__ in the packages'
# __init__.py
echo "Updating dynamicserialize/dstypes"
# Update __all__ for every package under dstypes
# Update __all__ for every package under dstypes
while IFS= read -r -d '' package
do
pushd "$package" > /dev/null
# Read subpackages and modules into actual Bash arrays
mapfile -t subpackages < <(
find . -mindepth 1 -maxdepth 1 \
-type d ! -name ".*" \
-printf '%f\n' |
sort
)
mapfile -t modules < <(
find . -maxdepth 1 \
-type f \
-name "*.py" \
! -name "__init__.py" \
! -name ".*" \
-printf '%f\n' |
sed 's/\.py$//' |
sort
)
all=("${subpackages[@]}" "${modules[@]}")
if (( ${#all[@]} > 0 )); then
joined=$(printf " '%s',\n" "${all[@]}")
replacement=$'__all__ = [\n'"${joined}"$'\n]'
else
replacement='__all__ = []'
fi
REPLACEMENT="$replacement" perl -0777 -pi -e \
's/__all__ = \[[^\]]*\]/$ENV{REPLACEMENT}/g' \
__init__.py
popd > /dev/null
done < <(
find src/dynamicserialize/dstypes \
-name "__init__.py" \
-printf '%h\0'
)
echo "Done"
#################
# Updating ufpy
#################
mkdir -p ${dir}/src/awips
cp -r /awips2/repo/awips2/pythonPackages/ufpy/* ${dir}/src/awips/
# Replace all instances of ufpy with awips
rg -l -0 'ufpy' -- src/ | xargs -0 sed -i 's/ufpy/awips/g'
###################
# Updating thrift
###################
mkdir -p ${dir}/src/thrift
find /awips2/repo/awips2-core/ -path '*/bin/*/serialization/thrift' \
-exec cp {} -rv ${dir}/src \;
find /awips2/repo/awips2-rpm -name 'thrift*gz' \
-exec tar -xzf {} \
-C "${dir}/src/thrift/" \
--strip-components=4 \
thrift-0.18.1/lib/py/src/ \;
rm -rf ${dir}/src/thrift/ext
# These are files that are Unidata specific and need to be restored
git restore ${dir}/src/awips/RadarCommon.py
git restore ${dir}/src/awips/dataaccess/ModelSounding.py
git restore ${dir}/src/awips/tables.py
git restore ${dir}/src/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/records/AbstractDataRecord.py
# These are files that Unidata made changes to and most likely we will want to keep our changes - most likely none of these files have changed by NWS
git restore ${dir}/src/awips/dataaccess/DataAccessLayer.py
git restore ${dir}/src/awips/dataaccess/ThriftClientRouter.py
git restore ${dir}/src/awips/gfe/IFPClient.py
git restore ${dir}/src/dynamicserialize/dstypes/com/raytheon/uf/common/auth/user/UserId.py
git restore ${dir}/src/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/GFERecord.py
git restore ${dir}/src/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/ParmID.py
git restore ${dir}/src/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py
git restore ${dir}/src/dynamicserialize/dstypes/com/raytheon/uf/common/dataquery/requests/RequestConstraint.py
git restore ${dir}/src/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/MasterLevel.py
git restore ${dir}/src/dynamicserialize/dstypes/com/raytheon/uf/common/localization/LocalizationLevel.py
git restore ${dir}/src/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py
git restore ${dir}/src/dynamicserialize/dstypes/java/util/EnumSet.py