mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
cmd/gio: handle subdirectories in apk files
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+19
-11
@@ -10,7 +10,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -332,18 +331,24 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo) (err error) {
|
|||||||
}()
|
}()
|
||||||
apkw := newZipWriter(ap_)
|
apkw := newZipWriter(ap_)
|
||||||
defer apkw.Close()
|
defer apkw.Close()
|
||||||
apkFiles, err := filepath.Glob(filepath.Join(apkDir, "*"))
|
err = filepath.Walk(apkDir, func(path string, f os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if f.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
zpath := path[len(apkDir)+1:]
|
||||||
|
if filepath.Base(path) == "resources.arsc" {
|
||||||
|
apkw.Store(zpath, path)
|
||||||
|
} else {
|
||||||
|
apkw.Add(zpath, path)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, f := range apkFiles {
|
|
||||||
name := filepath.Base(f)
|
|
||||||
if name == "resources.arsc" {
|
|
||||||
apkw.Store(name, f)
|
|
||||||
} else {
|
|
||||||
apkw.Add(name, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, a := range bi.archs {
|
for _, a := range bi.archs {
|
||||||
arch := allArchs[a]
|
arch := allArchs[a]
|
||||||
libFile := filepath.Join(arch.jniArch, "libgio.so")
|
libFile := filepath.Join(arch.jniArch, "libgio.so")
|
||||||
@@ -395,7 +400,10 @@ func unzip(dir, zipfile string) (err error) {
|
|||||||
}
|
}
|
||||||
defer zipr.Close()
|
defer zipr.Close()
|
||||||
for _, f := range zipr.File {
|
for _, f := range zipr.File {
|
||||||
path := filepath.Join(dir, path.Base(f.Name))
|
path := filepath.Join(dir, f.Name)
|
||||||
|
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
out, err := os.Create(path)
|
out, err := os.Create(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user