gnu: Add dicedb.

* gnu/packages/databases.scm (dicedb): New variable.
* gnu/packages/patches/dicedb-remove-init-from-config-subpkg.patch:
New file.
* gnu/local.mk (dist_patch_DATA): Register patch.

Change-Id: Id5c97d254c35301181593b42c96a83a1ef843131
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Ashvith Shetty 2025-04-16 01:19:54 +05:30 committed by Ludovic Courtès
parent a3e0a45b5d
commit bff04df003
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
3 changed files with 144 additions and 0 deletions

View file

@ -0,0 +1,50 @@
If built locally, dicedb works for as long as the build cache in the tmp
directory exists - it looks for a file called VERSION in the project root.
Once cleared, or in the case of downloading from substitute server, the
location of the VERSION file is invalid. Removing this code and instead
providing them through the flag resolves this issue.
diff --git a/config/config.go b/config/config.go
index b358813..c408096 100644
--- a/config/config.go
+++ b/config/config.go
@@ -9,8 +9,6 @@ import (
"os"
"path/filepath"
"reflect"
- "runtime"
- "strings"
"github.com/spf13/pflag"
"github.com/spf13/viper"
@@ -20,30 +18,6 @@ var (
DiceDBVersion = "-"
)
-// init initializes the DiceDBVersion variable by reading the
-// VERSION file from the project root.
-// This function runs automatically when the package is imported.
-func init() {
- // Get the absolute path of the current file (config.go)
- // using runtime reflection
- _, currentFile, _, _ := runtime.Caller(0) //nolint:dogsled
-
- // Navigate up two directories from config.go to reach the project root
- // (config.go is in the config/ directory, so we need to go up twice)
- projectRoot := filepath.Dir(filepath.Dir(currentFile))
-
- // Read the VERSION file from the project root
- // This approach works regardless of where the program is executed from
- version, err := os.ReadFile(filepath.Join(projectRoot, "VERSION"))
- if err != nil {
- slog.Error("could not read the version file", slog.String("error", err.Error()))
- os.Exit(1)
- }
-
- // Store the version string in the package-level DiceDBVersion variable
- DiceDBVersion = strings.TrimSpace(string(version))
-}
-
var Config *DiceDBConfig
type DiceDBConfig struct {