Fix some path determination stuff

This commit is contained in:
idk
2022-02-03 02:06:39 -05:00
parent edb4ce1670
commit 1bac06a43b
4 changed files with 23 additions and 12 deletions

View File

@ -60,7 +60,7 @@ bsd:
# GOOS=openbsd GOARCH=amd64 make build su3 # GOOS=openbsd GOARCH=amd64 make build su3
dep: dep:
cp "$(HOME)/Workspace/GIT_WORK/i2p.i2p/build/shellservice.jar" tor-browser/lib/shellservice.jar -v cp "$(HOME)/build/shellservice.jar" tor-browser/lib/shellservice.jar -v
su3: su3:
i2p.plugin.native -name=$(BINARY) \ i2p.plugin.native -name=$(BINARY) \

View File

@ -36,16 +36,20 @@ func DefaultDir() string {
if !FileExists(WORKING_DIR) { if !FileExists(WORKING_DIR) {
os.MkdirAll(WORKING_DIR, 0755) os.MkdirAll(WORKING_DIR, 0755)
} }
return WORKING_DIR wd, err := filepath.Abs(WORKING_DIR)
if err != nil {
log.Fatal(err)
}
return wd
} }
func UNPACK_PATH() string { func UNPACK_PATH() string {
var UNPACK_PATH = path.Join(DefaultDir(), "unpack") var UNPACK_PATH = filepath.Join(DefaultDir(), "unpack")
return UNPACK_PATH return UNPACK_PATH
} }
func DOWNLOAD_PATH() string { func DOWNLOAD_PATH() string {
var DOWNLOAD_PATH = path.Join(DefaultDir(), "tor-browser") var DOWNLOAD_PATH = filepath.Join(DefaultDir(), "tor-browser")
return DOWNLOAD_PATH return DOWNLOAD_PATH
} }
@ -164,15 +168,16 @@ func (t *TBDownloader) Log(function, message string) {
func (t *TBDownloader) MakeTBDirectory() { func (t *TBDownloader) MakeTBDirectory() {
os.MkdirAll(t.DownloadPath, 0755) os.MkdirAll(t.DownloadPath, 0755)
path := path.Join("tor-browser", "TPO-signing-key.pub") empath := path.Join("tor-browser", "TPO-signing-key.pub")
path := filepath.Join(t.DownloadPath, "TPO-signing-key.pub")
if !FileExists(path) { if !FileExists(path) {
t.Log("MakeTBDirectory()", "Initial TPO signing key not found, using the one embedded in the executable") t.Log("MakeTBDirectory()", "Initial TPO signing key not found, using the one embedded in the executable")
bytes, err := t.Profile.ReadFile(path) bytes, err := t.Profile.ReadFile(empath)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
t.Log("MakeTBDirectory()", "Writing TPO signing key to disk") t.Log("MakeTBDirectory()", "Writing TPO signing key to disk")
ioutil.WriteFile(filepath.Join(t.DownloadPath, "TPO-signing-key.pub"), bytes, 0644) ioutil.WriteFile(path, bytes, 0644)
t.Log("MakeTBDirectory()", "Writing TPO signing key to disk complete") t.Log("MakeTBDirectory()", "Writing TPO signing key to disk complete")
} }
} }
@ -336,17 +341,17 @@ func (t *TBDownloader) UnpackUpdater(binpath string) (string, error) {
os.MkdirAll(t.UnpackPath, 0755) os.MkdirAll(t.UnpackPath, 0755)
UNPACK_DIRECTORY, err := os.Open(t.UnpackPath) UNPACK_DIRECTORY, err := os.Open(t.UnpackPath)
if err != nil { if err != nil {
return "", fmt.Errorf("UnpackUpdater: %s", err) return "", fmt.Errorf("UnpackUpdater: directory error %s", err)
} }
defer UNPACK_DIRECTORY.Close() defer UNPACK_DIRECTORY.Close()
xzfile, err := os.Open(binpath) xzfile, err := os.Open(binpath)
if err != nil { if err != nil {
return "", fmt.Errorf("UnpackUpdater: %s", err) return "", fmt.Errorf("UnpackUpdater: XZFile error %s", err)
} }
defer xzfile.Close() defer xzfile.Close()
xzReader, err := xz.NewReader(xzfile) xzReader, err := xz.NewReader(xzfile)
if err != nil { if err != nil {
return "", fmt.Errorf("UnpackUpdater: %s", err) return "", fmt.Errorf("UnpackUpdater: XZReader error %s", err)
} }
tarReader := tar.NewReader(xzReader) tarReader := tar.NewReader(xzReader)
for { for {
@ -355,7 +360,7 @@ func (t *TBDownloader) UnpackUpdater(binpath string) (string, error) {
break break
} }
if err != nil { if err != nil {
return "", fmt.Errorf("UnpackUpdater: %s", err) return "", fmt.Errorf("UnpackUpdater: Tar looper Error %s", err)
} }
if header.Typeflag == tar.TypeDir { if header.Typeflag == tar.TypeDir {
os.MkdirAll(filepath.Join(UNPACK_DIRECTORY.Name(), header.Name), 0755) os.MkdirAll(filepath.Join(UNPACK_DIRECTORY.Name(), header.Name), 0755)
@ -364,7 +369,7 @@ func (t *TBDownloader) UnpackUpdater(binpath string) (string, error) {
filename := filepath.Join(UNPACK_DIRECTORY.Name(), header.Name) filename := filepath.Join(UNPACK_DIRECTORY.Name(), header.Name)
file, err := os.Create(filename) file, err := os.Create(filename)
if err != nil { if err != nil {
return "", fmt.Errorf("UnpackUpdater: %s", err) return "", fmt.Errorf("UnpackUpdater: Tar unpacker error %s", err)
} }
defer file.Close() defer file.Close()
io.Copy(file, tarReader) io.Copy(file, tarReader)

View File

@ -1,12 +1,18 @@
package main package main
import ( import (
"log"
"github.com/go-ole/go-ole" "github.com/go-ole/go-ole"
"github.com/go-ole/go-ole/oleutil" "github.com/go-ole/go-ole/oleutil"
"os/user" "os/user"
"path/filepath" "path/filepath"
) )
func GenerateAppArmor() error {
return nil
}
func DesktopDirectory() (string, error) { func DesktopDirectory() (string, error) {
myself, error := user.Current() myself, error := user.Current()
if error != nil { if error != nil {

Binary file not shown.