add sqlite default tip

Sat, 20 Dec 2025 23:10:56 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 20 Dec 2025 23:10:56 +0100
changeset 10
a4537989ed09
parent 9
eef1439666f7

add sqlite

.hgignore file | annotate | diff | comparison | revisions
src/go.mod file | annotate | diff | comparison | revisions
src/go.sum file | annotate | diff | comparison | revisions
src/main.go file | annotate | diff | comparison | revisions
--- a/.hgignore	Fri Dec 19 23:02:38 2025 +0100
+++ b/.hgignore	Sat Dec 20 23:10:56 2025 +0100
@@ -2,3 +2,4 @@
 ^tmp/
 ^out/
 ^testrepo/
+^uwbuild.db$
--- a/src/go.mod	Fri Dec 19 23:02:38 2025 +0100
+++ b/src/go.mod	Sat Dec 20 23:10:56 2025 +0100
@@ -1,3 +1,17 @@
 module uwbuild
 
 go 1.25
+
+require (
+	github.com/dustin/go-humanize v1.0.1 // indirect
+	github.com/google/uuid v1.6.0 // indirect
+	github.com/mattn/go-isatty v0.0.20 // indirect
+	github.com/ncruces/go-strftime v0.1.9 // indirect
+	github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
+	golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
+	golang.org/x/sys v0.36.0 // indirect
+	modernc.org/libc v1.66.10 // indirect
+	modernc.org/mathutil v1.7.1 // indirect
+	modernc.org/memory v1.11.0 // indirect
+	modernc.org/sqlite v1.41.0 // indirect
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/go.sum	Sat Dec 20 23:10:56 2025 +0100
@@ -0,0 +1,23 @@
+github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
+github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
+github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
+github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
+github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
+github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
+golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
+golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
+golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
+modernc.org/libc v1.66.10 h1:yZkb3YeLx4oynyR+iUsXsybsX4Ubx7MQlSYEw4yj59A=
+modernc.org/libc v1.66.10/go.mod h1:8vGSEwvoUoltr4dlywvHqjtAqHBaw0j1jI7iFBTAr2I=
+modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
+modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
+modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
+modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
+modernc.org/sqlite v1.41.0 h1:bJXddp4ZpsqMsNN1vS0jWo4IJTZzb8nWpcgvyCFG9Ck=
+modernc.org/sqlite v1.41.0/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE=
--- a/src/main.go	Fri Dec 19 23:02:38 2025 +0100
+++ b/src/main.go	Sat Dec 20 23:10:56 2025 +0100
@@ -2,6 +2,7 @@
 
 import (
 	"bytes"
+	"database/sql"
 	"encoding/json"
 	"encoding/xml"
 	"errors"
@@ -13,6 +14,8 @@
 	"strconv"
 	"strings"
 	"text/template"
+
+	_ "modernc.org/sqlite"
 )
 
 type Config struct {
@@ -85,6 +88,17 @@
 		log.Fatal(err)
 	}
 
+	db, err := sql.Open("sqlite", "uwbuild.db")
+	if err != nil {
+		log.Fatal(err)
+	}
+	defer db.Close()
+
+	err = prepare_db(db)
+	if err != nil {
+		log.Fatal(err)
+	}
+
 	config := &Config{}
 	if err := xml.Unmarshal(data, &config); err != nil {
 		log.Fatal(err)
@@ -164,6 +178,25 @@
 	}
 }
 
+func prepare_db(db *sql.DB) error {
+	_, err := db.Exec(`
+	create table Repository (
+		id integer primary key autoincrement,
+		path text not null,
+		name text not null
+	);
+	create table RepoCommit (
+	    id integer primary key autoincrement,
+	    repository_id integer not null,
+	    node text,
+	    node_short text,
+	    author text,
+	    description text,
+	    date text
+	);`)
+	return err
+}
+
 func create_repo_archive(repo *Repository, tpl *template.Template, tpl2 *template.Template, tmp_dir string) error {
 	// create a build directory, that contains the repository source
 	// and build scripts

mercurial