From 48c6a56ee0422e0cf623cc2ce958436c4d44beaf Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 26 Oct 2021 09:39:02 +0900 Subject: [PATCH] Add go.mod and go.sum for upgrade (#978) * Add go.mod and go.sum for upgrade * Fix upgrade tools to have to run on upgrade directory --- upgrade/go.mod | 5 +++++ upgrade/go.sum | 12 ++++++++++++ upgrade/upgrade.go | 31 ++++++++++++++++++++----------- 3 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 upgrade/go.mod create mode 100644 upgrade/go.sum diff --git a/upgrade/go.mod b/upgrade/go.mod new file mode 100644 index 0000000..caf97ff --- /dev/null +++ b/upgrade/go.mod @@ -0,0 +1,5 @@ +module github.com/mattn/go-sqlite3/upgrade + +go 1.16 + +require github.com/PuerkitoBio/goquery v1.7.1 // indirect diff --git a/upgrade/go.sum b/upgrade/go.sum new file mode 100644 index 0000000..986201f --- /dev/null +++ b/upgrade/go.sum @@ -0,0 +1,12 @@ +github.com/PuerkitoBio/goquery v1.7.1 h1:oE+T06D+1T7LNrn91B4aERsRIeCLJ/oPSa6xB9FPnz4= +github.com/PuerkitoBio/goquery v1.7.1/go.mod h1:XY0pP4kfraEmmV1O7Uf6XyjoslwsneBbgeDjLYuN8xY= +github.com/andybalholm/cascadia v1.2.0 h1:vuRCkM5Ozh/BfmsaTm26kbjm0mIOM3yS5Ek/F5h18aE= +github.com/andybalholm/cascadia v1.2.0/go.mod h1:YCyR8vOZT9aZ1CHEd8ap0gMVm2aFgxBp0T0eFw1RUQY= +golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/upgrade/upgrade.go b/upgrade/upgrade.go index 50d7d9c..9652c67 100644 --- a/upgrade/upgrade.go +++ b/upgrade/upgrade.go @@ -1,5 +1,5 @@ -// +build !cgo -// +build upgrade,ignore +//go:build !cgo && upgrade && ignore +// +build !cgo,upgrade,ignore package main @@ -98,16 +98,25 @@ func mergeFile(src string, dst string) error { func main() { fmt.Println("Go-SQLite3 Upgrade Tool") + wd, err := os.Getwd() + if err != nil { + log.Fatal(err) + } + if filepath.Base(wd) != "upgrade" { + log.Printf("Current directory is %q but should run in upgrade directory", wd) + os.Exit(1) + } + // Download Amalgamation _, amalgamation, err := download("sqlite-amalgamation-") if err != nil { - fmt.Println("Failed to download: sqlite-amalgamation; %s", err) + log.Fatalf("Failed to download: sqlite-amalgamation; %s", err) } // Download Source _, source, err := download("sqlite-src-") if err != nil { - fmt.Println("Failed to download: sqlite-src; %s", err) + log.Fatalf("Failed to download: sqlite-src; %s", err) } // Create Amalgamation Zip Reader @@ -127,11 +136,11 @@ func main() { var f *os.File switch path.Base(zf.Name) { case "sqlite3.c": - f, err = os.Create("sqlite3-binding.c") + f, err = os.Create("../sqlite3-binding.c") case "sqlite3.h": - f, err = os.Create("sqlite3-binding.h") + f, err = os.Create("../sqlite3-binding.h") case "sqlite3ext.h": - f, err = os.Create("sqlite3ext.h") + f, err = os.Create("../sqlite3ext.h") default: continue } @@ -186,9 +195,9 @@ func main() { var f *os.File switch path.Base(zf.Name) { case "userauth.c": - f, err = os.Create("userauth.c") + f, err = os.Create("../userauth.c") case "sqlite3userauth.h": - f, err = os.Create("userauth.h") + f, err = os.Create("../userauth.h") default: continue } @@ -211,10 +220,10 @@ func main() { } // Merge SQLite User Authentication into amalgamation - if err := mergeFile("userauth.c", "sqlite3-binding.c"); err != nil { + if err := mergeFile("../userauth.c", "../sqlite3-binding.c"); err != nil { log.Fatal(err) } - if err := mergeFile("userauth.h", "sqlite3-binding.h"); err != nil { + if err := mergeFile("../userauth.h", "../sqlite3-binding.h"); err != nil { log.Fatal(err) }