-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsnapshot.sh
executable file
·67 lines (60 loc) · 2.36 KB
/
snapshot.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
60
61
62
63
64
65
66
67
#!/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 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
# temporarily copy embedded data over
cp -R $COCKROACHDB_LOC/pkg/geo/geoprojbase/data $LOC/pkg/geo/geoprojbase/data
# 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 "v0.0.0" > pkg/build/version.txt
go test .