-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathsnapshot.sh
More file actions
executable file
·79 lines (72 loc) · 3.09 KB
/
snapshot.sh
File metadata and controls
executable file
·79 lines (72 loc) · 3.09 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
#!/bin/sh
if [ -z ${GOPATH} ]; then
echo "$GOPATH must be set"
exit 1
fi
LOC=$(pwd)
COCKROACHDB_LOC=$GOPATH/src/github.com/cockroachdb/cockroach
echo "Generating files in-line using dev build short"
cd $COCKROACHDB_LOC
./dev gen
./dev gen parser
./dev gen protobuf
echo "Copying required dependencies over"
rm -rf $LOC/pkg
bazel query 'deps(//pkg/sql/parser)' | \
# only care about dependencies in the CockroachDB repo
grep '^//pkg' | \
# remove the // prefix
sed -e 's_^//__' | \
# remove the :build_target directive
sed -e 's/:.*$//' | \
# remove testutils
grep -v 'pkg/testutils' | grep -v 'pkg/cmd/protoc-gen-gogoroach' | \
# ensure everything is unique
sort | uniq | \
# copy over each dependency
xargs -I from_dir $LOC/copy_files.sh from_dir $COCKROACHDB_LOC $LOC
echo $(git rev-parse HEAD) > $LOC/version
echo "removing excess files, fixing up file paths"
cd $LOC
# replace compiler function to avoid conflicts.
sed -i.bak -e 's/compilerVersion/compilerVersionParser/g' pkg/build/*.go
# copy all geo subdirectories with embedded data and required functionality
cp -R $COCKROACHDB_LOC/pkg/geo/geoprojbase/data $LOC/pkg/geo/geoprojbase/data
cp -R $COCKROACHDB_LOC/pkg/geo/geoprojbase/embeddedproj $LOC/pkg/geo/geoprojbase/embeddedproj
# ensure all geo subdirectories needed for geometry parsing/creation are included
echo "Ensuring all geo dependencies are copied..."
for geo_subdir in geodist geogen geogfn geographiclib geoindex geomfn geoproj geos geosegmentize geotest geotransform twkb; do
if [ -d "$COCKROACHDB_LOC/pkg/geo/$geo_subdir" ] && [ ! -d "$LOC/pkg/geo/$geo_subdir" ]; then
echo "Copying additional geo dependency: $geo_subdir"
cp -R "$COCKROACHDB_LOC/pkg/geo/$geo_subdir" "$LOC/pkg/geo/$geo_subdir"
fi
done
# copy the proj_api.h file
cp $COCKROACHDB_LOC/c-deps/proj/src/proj_api.h $LOC/pkg/geo/geoproj/proj_api.h
# delete gitignores
rm pkg/sql/lexbase/.gitignore pkg/sql/parser/.gitignore
rm pkg/sql/plpgsql/parser/.gitignore pkg/sql/plpgsql/parser/lexbase/.gitignore
# delete tests and testfiles
find pkg -type f -name '*_test.go' | xargs rm
# sed replace any instances of cockroachdb
find pkg -type f -name '*.go' | xargs sed -i.bak -e 's_github\.com/cockroachdb/cockroach/_github.com/cockroachdb/cockroachdb-parser/_g'
# fix protobuf enum and type registration to avoid conficts.
find pkg -type f -name '*.pb.go' | xargs sed -i.bak -e 's/\"cockroach\./\"cockroach\.parser\./g'
goimports -w pkg/sql/sem/tree/function_name.go
# delete any BUILD.bazel files. These files are invalid after being extracted
# from the main repository and will break any bazel builds that attempt to
# import this repository.
find pkg -type f -name 'BUILD.bazel' | xargs rm
# delete any .bak files generated by sed, the use of -i.bak makes these sed
# command works on both linux and macos.
find pkg -type f -name '*.bak' | xargs rm
# embed stopwords
cp -R $COCKROACHDB_LOC/pkg/util/tsearch/stopwords $LOC/pkg/util/tsearch/stopwords
for f in patches/*; do
echo "applying patch $f"
git apply $f
done
echo "Cleaning up go and testing everything works"
go mod tidy
echo "v1.2.3" > pkg/build/version.txt
go test .