Either backend or blockbook config sections are optional

pull/29/head
Jakub Matys 2018-07-31 16:28:00 +02:00
parent 53f8c042cf
commit dbe71185bb
2 changed files with 35 additions and 16 deletions

View File

@ -17,12 +17,12 @@ cp -r /src/configs .
go run build/templates/generate.go $coin
# backend
if [ $package = "backend" ] || [ $package = "all" ]; then
if ([ $package = "backend" ] || [ $package = "all" ]) && [ -d build/pkg-defs/backend ]; then
(cd build/pkg-defs/backend && dpkg-buildpackage -us -uc $@)
fi
# blockbook
if [ $package = "blockbook" ] || [ $package = "all" ]; then
if ([ $package = "blockbook" ] || [ $package = "all" ]) && [ -d build/pkg-defs/blockbook ]; then
export VERSION=$(cd build/pkg-defs/blockbook && dpkg-parsechangelog | sed -rne 's/^Version: ([0-9.]+)([-+~].+)?$/\1/p')
cp Makefile ldb sst_dump build/pkg-defs/blockbook

View File

@ -166,31 +166,48 @@ func loadConfig(coin string) *Config {
config.Meta.BuildDatetime = time.Now().Format("Mon, 02 Jan 2006 15:04:05 -0700")
switch config.Backend.ServiceType {
case "forking":
case "simple":
default:
panic("Invalid service type: " + config.Backend.ServiceType)
}
if !isEmpty(config, "backend") {
switch config.Backend.ServiceType {
case "forking":
case "simple":
default:
panic("Invalid service type: " + config.Backend.ServiceType)
}
switch config.Backend.VerificationType {
case "":
case "gpg":
case "sha256":
case "gpg-sha256":
default:
panic("Invalid verification type: " + config.Backend.VerificationType)
switch config.Backend.VerificationType {
case "":
case "gpg":
case "sha256":
case "gpg-sha256":
default:
panic("Invalid verification type: " + config.Backend.VerificationType)
}
}
return config
}
func isEmpty(config *Config, target string) bool {
switch target {
case "backend":
return config.Backend.PackageName == ""
case "blockbook":
return config.Blockbook.PackageName == ""
default:
panic("Invalid target name: " + target)
}
}
func generatePackageDefinitions(config *Config) {
templ := config.ParseTemplate()
makeOutputDir(outputDir)
for _, subdir := range []string{"backend", "blockbook"} {
if isEmpty(config, subdir) {
continue
}
root := filepath.Join(inputDir, subdir)
err := os.Mkdir(filepath.Join(outputDir, subdir), 0755)
@ -235,7 +252,9 @@ func generatePackageDefinitions(config *Config) {
}
}
writeBackendConfigFile(config)
if !isEmpty(config, "backend") {
writeBackendConfigFile(config)
}
}
func makeOutputDir(path string) {