From a9b5e6b1dbb93dcbc5dceb4896a9a3d1caf029e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 7 Jan 2018 11:26:15 +0000 Subject: [PATCH] all: move to mvdan.cc/fdroidcl, merge basedir I have been moving all github.com/mvdan/... packages to mvdan.cc/... recently - do this one too. basedir was only really used by these packages, so merge it in to simplify building and packaging the tool. --- .travis.yml | 2 ++ README.md | 4 ++-- basedir/basedir.go | 41 ++++++++++++++++++++++++++++++++++++++ basedir/basedir_darwin.go | 17 ++++++++++++++++ basedir/basedir_unix.go | 19 ++++++++++++++++++ basedir/basedir_windows.go | 17 ++++++++++++++++ cmd/fdroidcl/devices.go | 2 +- cmd/fdroidcl/download.go | 2 +- cmd/fdroidcl/install.go | 4 ++-- cmd/fdroidcl/main.go | 2 +- cmd/fdroidcl/search.go | 4 ++-- cmd/fdroidcl/show.go | 2 +- cmd/fdroidcl/update.go | 2 +- cmd/fdroidcl/upgrade.go | 4 ++-- index.go | 2 +- 15 files changed, 110 insertions(+), 14 deletions(-) create mode 100644 basedir/basedir.go create mode 100644 basedir/basedir_darwin.go create mode 100644 basedir/basedir_unix.go create mode 100644 basedir/basedir_windows.go diff --git a/.travis.yml b/.travis.yml index f1d4ebc..bdb33b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,5 @@ language: go go: - 1.7.x - 1.8.x + +go_import_path: mvdan.cc/fdroidcl diff --git a/README.md b/README.md index a6ca926..5ba00a8 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # fdroidcl -[![GoDoc](https://godoc.org/github.com/mvdan/fdroidcl?status.svg)](https://godoc.org/github.com/mvdan/fdroidcl) +[![GoDoc](https://godoc.org/github.com/mvdan/fdroidcl?status.svg)](https://godoc.org/mvdan.cc/fdroidcl) [![Build Status](https://travis-ci.org/mvdan/fdroidcl.svg?branch=master)](https://travis-ci.org/mvdan/fdroidcl) [F-Droid](https://f-droid.org/) desktop client. - go get -u github.com/mvdan/fdroidcl/cmd/fdroidcl + go get -u mvdan.cc/fdroidcl/cmd/fdroidcl This is **not** a replacement for the [Android client](https://gitlab.com/fdroid/fdroidclient). diff --git a/basedir/basedir.go b/basedir/basedir.go new file mode 100644 index 0000000..0b0b359 --- /dev/null +++ b/basedir/basedir.go @@ -0,0 +1,41 @@ +// Copyright (c) 2015, Daniel Martí +// See LICENSE for licensing information + +package basedir + +import ( + "os" + "os/user" + "path/filepath" +) + +// Cache returns the base cache directory. +func Cache() string { + return cache() +} + +// Data returns the base data directory. +func Data() string { + return data() +} + +func firstGetenv(def string, evs ...string) string { + for _, ev := range evs { + if v := os.Getenv(ev); v != "" { + return v + } + } + home, err := homeDir() + if err != nil { + return "" + } + return filepath.Join(home, def) +} + +func homeDir() (string, error) { + curUser, err := user.Current() + if err != nil { + return "", err + } + return curUser.HomeDir, nil +} diff --git a/basedir/basedir_darwin.go b/basedir/basedir_darwin.go new file mode 100644 index 0000000..97a708a --- /dev/null +++ b/basedir/basedir_darwin.go @@ -0,0 +1,17 @@ +// Copyright (c) 2015, Daniel Martí +// See LICENSE for licensing information + +package basedir + +var ( + cacheDir = firstGetenv("Library/Caches") + dataDir = firstGetenv("Library/Application Support") +) + +func cache() string { + return cacheDir +} + +func data() string { + return dataDir +} diff --git a/basedir/basedir_unix.go b/basedir/basedir_unix.go new file mode 100644 index 0000000..2916f37 --- /dev/null +++ b/basedir/basedir_unix.go @@ -0,0 +1,19 @@ +// Copyright (c) 2015, Daniel Martí +// See LICENSE for licensing information + +// +build dragonfly freebsd linux netbsd openbsd + +package basedir + +var ( + cacheDir = firstGetenv(".cache", "XDG_CACHE_HOME") + dataDir = firstGetenv(".config", "XDG_CONFIG_HOME") +) + +func cache() string { + return cacheDir +} + +func data() string { + return dataDir +} diff --git a/basedir/basedir_windows.go b/basedir/basedir_windows.go new file mode 100644 index 0000000..6e0b5ef --- /dev/null +++ b/basedir/basedir_windows.go @@ -0,0 +1,17 @@ +// Copyright (c) 2015, Daniel Martí +// See LICENSE for licensing information + +package basedir + +var ( + cacheDir = firstGetenv("", "TEMP", "TMP") + dataDir = firstGetenv("", "APPDATA") +) + +func cache() string { + return cacheDir +} + +func data() string { + return dataDir +} diff --git a/cmd/fdroidcl/devices.go b/cmd/fdroidcl/devices.go index cff8e20..d226174 100644 --- a/cmd/fdroidcl/devices.go +++ b/cmd/fdroidcl/devices.go @@ -6,7 +6,7 @@ package main import ( "fmt" - "github.com/mvdan/fdroidcl/adb" + "mvdan.cc/fdroidcl/adb" ) var cmdDevices = &Command{ diff --git a/cmd/fdroidcl/download.go b/cmd/fdroidcl/download.go index 443aa5d..c06b8b2 100644 --- a/cmd/fdroidcl/download.go +++ b/cmd/fdroidcl/download.go @@ -7,7 +7,7 @@ import ( "fmt" "path/filepath" - "github.com/mvdan/fdroidcl" + "mvdan.cc/fdroidcl" ) var cmdDownload = &Command{ diff --git a/cmd/fdroidcl/install.go b/cmd/fdroidcl/install.go index efb6dd3..d1f54dc 100644 --- a/cmd/fdroidcl/install.go +++ b/cmd/fdroidcl/install.go @@ -6,8 +6,8 @@ package main import ( "fmt" - "github.com/mvdan/fdroidcl" - "github.com/mvdan/fdroidcl/adb" + "mvdan.cc/fdroidcl" + "mvdan.cc/fdroidcl/adb" ) var cmdInstall = &Command{ diff --git a/cmd/fdroidcl/main.go b/cmd/fdroidcl/main.go index 35a05fb..5974834 100644 --- a/cmd/fdroidcl/main.go +++ b/cmd/fdroidcl/main.go @@ -11,7 +11,7 @@ import ( "path/filepath" "strings" - "github.com/mvdan/basedir" + "mvdan.cc/fdroidcl/basedir" ) const cmdName = "fdroidcl" diff --git a/cmd/fdroidcl/search.go b/cmd/fdroidcl/search.go index 6086249..9be7b26 100644 --- a/cmd/fdroidcl/search.go +++ b/cmd/fdroidcl/search.go @@ -10,8 +10,8 @@ import ( "strings" "time" - "github.com/mvdan/fdroidcl" - "github.com/mvdan/fdroidcl/adb" + "mvdan.cc/fdroidcl" + "mvdan.cc/fdroidcl/adb" ) var cmdSearch = &Command{ diff --git a/cmd/fdroidcl/show.go b/cmd/fdroidcl/show.go index d552d58..60c82a0 100644 --- a/cmd/fdroidcl/show.go +++ b/cmd/fdroidcl/show.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/mvdan/fdroidcl" + "mvdan.cc/fdroidcl" ) var cmdShow = &Command{ diff --git a/cmd/fdroidcl/update.go b/cmd/fdroidcl/update.go index f45df78..6ff46c8 100644 --- a/cmd/fdroidcl/update.go +++ b/cmd/fdroidcl/update.go @@ -15,7 +15,7 @@ import ( "path/filepath" "sort" - "github.com/mvdan/fdroidcl" + "mvdan.cc/fdroidcl" ) var cmdUpdate = &Command{ diff --git a/cmd/fdroidcl/upgrade.go b/cmd/fdroidcl/upgrade.go index 2249976..5f6168a 100644 --- a/cmd/fdroidcl/upgrade.go +++ b/cmd/fdroidcl/upgrade.go @@ -6,8 +6,8 @@ package main import ( "fmt" - "github.com/mvdan/fdroidcl" - "github.com/mvdan/fdroidcl/adb" + "mvdan.cc/fdroidcl" + "mvdan.cc/fdroidcl/adb" ) var cmdUpgrade = &Command{ diff --git a/index.go b/index.go index b569af3..61f416d 100644 --- a/index.go +++ b/index.go @@ -10,7 +10,7 @@ import ( "sort" "strings" - "github.com/mvdan/fdroidcl/adb" + "mvdan.cc/fdroidcl/adb" ) type Index struct {