File: genproto.sh

package info (click to toggle)
golang-github-dnstap-golang-dnstap 0.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 256 kB
  • sloc: sh: 17; makefile: 17
file content (25 lines) | stat: -rwxr-xr-x 533 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

go_package() {
	local file pkg line script
	file=$1; shift
	pkg=$1; shift

	line="option go_package = \"$pkg\";"
	grep "^$line\$" $file > /dev/null && return

	script="/^package dnstap/|a|$line|.|w|q|"
	if grep "^option go_package" $file > /dev/null; then
		script="/^option go_package/d|1|${script}"
	fi

	echo "$script" | tr '|' '\n' | ed $file || exit
}

dir=$(dirname $0)
[ -n "$dir" ] && cd $dir

cd dnstap.pb

go_package dnstap.proto "github.com/dnstap/golang-dnstap;dnstap"
protoc --go_out=../../../.. dnstap.proto