Index: Makefile
===================================================================
--- Makefile (nonexistent)
+++ Makefile (revision 5)
@@ -0,0 +1,67 @@
+ifndef BUILDDIR
+BUILDDIR=build
+endif
+
+ifndef CONFFILE
+ifeq ($(OS),Windows_NT)
+CONFFILE=%SystemDrive%\ProgramData\MaxMind\GeoIPUpdate\GeoIP.conf
+else
+CONFFILE=/etc/GeoIP.conf
+endif
+endif
+
+ifndef DATADIR
+ifeq ($(OS),Windows_NT)
+DATADIR=%SystemDrive%\ProgramData\MaxMind\GeoIPUpdate\GeoIP
+else
+DATADIR=/usr/share/GeoIP
+endif
+endif
+
+ifeq ($(OS),Windows_NT)
+MAYBE_CR=\r
+endif
+
+ifndef VERSION
+VERSION=4.8.0
+endif
+
+all: \
+ $(BUILDDIR)/geoipupdate \
+ data
+
+data: \
+ $(BUILDDIR)/GeoIP.conf \
+ $(BUILDDIR)/GeoIP.conf.md \
+ $(BUILDDIR)/geoipupdate.md \
+ $(BUILDDIR)/GeoIP.conf.5 \
+ $(BUILDDIR)/geoipupdate.1
+
+$(BUILDDIR):
+ mkdir -p $(BUILDDIR)
+
+$(BUILDDIR)/geoipupdate: $(BUILDDIR)
+ (cd cmd/geoipupdate && go build -compiler gccgo -gccgoflags '$(GCCGOFLAGS)')
+ cp cmd/geoipupdate/geoipupdate $(BUILDDIR)
+
+$(BUILDDIR)/GeoIP.conf: $(BUILDDIR) conf/GeoIP.conf.default
+ sed -e 's|CONFFILE|$(CONFFILE)|g' -e 's|DATADIR|$(DATADIR)|g' -e 's|$$|$(MAYBE_CR)|g' conf/GeoIP.conf.default > $(BUILDDIR)/GeoIP.conf
+
+$(BUILDDIR)/GeoIP.conf.md: $(BUILDDIR) doc/GeoIP.conf.md
+ sed -e 's|CONFFILE|$(CONFFILE)|g' -e 's|DATADIR|$(DATADIR)|g' -e 's|$$|$(MAYBE_CR)|g' doc/GeoIP.conf.md > $(BUILDDIR)/GeoIP.conf.md
+
+$(BUILDDIR)/geoipupdate.md: $(BUILDDIR) doc/geoipupdate.md
+ sed -e 's|CONFFILE|$(CONFFILE)|g' -e 's|DATADIR|$(DATADIR)|g' -e 's|$$|$(MAYBE_CR)|g' doc/geoipupdate.md > $(BUILDDIR)/geoipupdate.md
+
+$(BUILDDIR)/GeoIP.conf.5: $(BUILDDIR)/GeoIP.conf.md $(BUILDDIR)/geoipupdate.md
+ dev-bin/make-man-pages.pl "$(BUILDDIR)"
+
+$(BUILDDIR)/geoipupdate.1: $(BUILDDIR)/GeoIP.conf.5
+
+clean:
+ rm -rf $(BUILDDIR)/GeoIP.conf \
+ $(BUILDDIR)/GeoIP.conf.md \
+ $(BUILDDIR)/geoipupdate \
+ $(BUILDDIR)/geoipupdate.md \
+ $(BUILDDIR)/GeoIP.conf.5 \
+ $(BUILDDIR)/geoipupdate.1
Index: cmd/geoipupdate/main.go
===================================================================
--- cmd/geoipupdate/main.go (nonexistent)
+++ cmd/geoipupdate/main.go (revision 5)
@@ -0,0 +1,78 @@
+package main
+
+import (
+ "fmt"
+ "log"
+ "net/http"
+ "os"
+ "path/filepath"
+
+ "github.com/maxmind/geoipupdate/v4/pkg/geoipupdate"
+ "github.com/maxmind/geoipupdate/v4/pkg/geoipupdate/database"
+ "github.com/pkg/errors"
+)
+
+var (
+ version = "4.8.0"
+ defaultConfigFile = "/etc/GeoIP.conf"
+ defaultDatabaseDirectory = "/usr/share/GeoIP"
+)
+
+func main() {
+ log.SetFlags(0)
+
+ if defaultConfigFile == "" {
+ defaultConfigFile = geoipupdate.DefaultConfigFile
+ }
+ if defaultDatabaseDirectory == "" {
+ defaultDatabaseDirectory = geoipupdate.DefaultDatabaseDirectory
+ }
+
+ args := getArgs()
+ fatalLogger := func(message string, err error) {
+ if args.StackTrace {
+ log.Print(fmt.Sprintf("%s: %+v", message, err))
+ } else {
+ log.Print(fmt.Sprintf("%s: %s", message, err))
+ }
+ os.Exit(1)
+ }
+
+ config, err := geoipupdate.NewConfig(
+ args.ConfigFile, defaultDatabaseDirectory, args.DatabaseDirectory, args.Verbose)
+ if err != nil {
+ fatalLogger(fmt.Sprintf("error loading configuration file %s", args.ConfigFile), err)
+ }
+
+ if config.Verbose {
+ log.Printf("geoipupdate version %s", version)
+ log.Printf("Using config file %s", args.ConfigFile)
+ log.Printf("Using database directory %s", config.DatabaseDirectory)
+ }
+
+ client := geoipupdate.NewClient(config)
+
+ if err = run(client, config); err != nil {
+ fatalLogger("error retrieving updates", err)
+ }
+}
+
+func run(client *http.Client, config *geoipupdate.Config) error {
+ dbReader := database.NewHTTPDatabaseReader(client, config)
+
+ for _, editionID := range config.EditionIDs {
+ filename, err := geoipupdate.GetFilename(config, editionID, client)
+ if err != nil {
+ return errors.Wrapf(err, "error retrieving filename for %s", editionID)
+ }
+ filePath := filepath.Join(config.DatabaseDirectory, filename)
+ dbWriter, err := database.NewLocalFileDatabaseWriter(filePath, config.LockFile, config.Verbose)
+ if err != nil {
+ return errors.Wrapf(err, "error creating database writer for %s", editionID)
+ }
+ if err := dbReader.Get(dbWriter, editionID); err != nil {
+ return errors.WithMessagef(err, "error while getting database for %s", editionID)
+ }
+ }
+ return nil
+}
Index: cmd/geoipupdate
===================================================================
--- cmd/geoipupdate (nonexistent)
+++ cmd/geoipupdate (revision 5)
Property changes on: cmd/geoipupdate
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: cmd
===================================================================
--- cmd (nonexistent)
+++ cmd (revision 5)
Property changes on: cmd
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: .
===================================================================
--- . (nonexistent)
+++ . (revision 5)
Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~