mirror of
https://github.com/beego/bee.git
synced 2024-11-25 15:00:55 +00:00
bee pack support zip Symlink
This commit is contained in:
parent
244f27afdf
commit
6695161de2
18
pack.go
18
pack.go
@ -46,7 +46,7 @@ compress an beego project
|
|||||||
-ba additional args of go build
|
-ba additional args of go build
|
||||||
-be=[] additional ENV Variables of go build. eg: GOARCH=arm
|
-be=[] additional ENV Variables of go build. eg: GOARCH=arm
|
||||||
-o compressed file output dir. default use current path
|
-o compressed file output dir. default use current path
|
||||||
-f="" format. [ tar.gz / zip ]. default tar.gz. note: zip doesn't support embed symlink, skip it
|
-f="" format. [ tar.gz / zip ]. default tar.gz
|
||||||
-exp="" relpath exclude prefix. default: .
|
-exp="" relpath exclude prefix. default: .
|
||||||
-exs="" relpath exclude suffix. default: .go:.DS_Store:.tmp
|
-exs="" relpath exclude suffix. default: .go:.DS_Store:.tmp
|
||||||
all path use : as separator
|
all path use : as separator
|
||||||
@ -91,7 +91,7 @@ func init() {
|
|||||||
fs.StringVar(&buildArgs, "ba", "", "additional args of go build")
|
fs.StringVar(&buildArgs, "ba", "", "additional args of go build")
|
||||||
fs.Var(&buildEnvs, "be", "additional ENV Variables of go build. eg: GOARCH=arm")
|
fs.Var(&buildEnvs, "be", "additional ENV Variables of go build. eg: GOARCH=arm")
|
||||||
fs.StringVar(&outputP, "o", "", "compressed file output dir. default use current path")
|
fs.StringVar(&outputP, "o", "", "compressed file output dir. default use current path")
|
||||||
fs.StringVar(&format, "f", "tar.gz", "format. [ tar.gz / zip ] note: zip doesn't support embed symlink, skip it")
|
fs.StringVar(&format, "f", "tar.gz", "format. [ tar.gz / zip ]")
|
||||||
fs.StringVar(&excludeP, "exp", ".", "path exclude prefix. use : as separator")
|
fs.StringVar(&excludeP, "exp", ".", "path exclude prefix. use : as separator")
|
||||||
fs.StringVar(&excludeS, "exs", ".go:.DS_Store:.tmp", "path exclude suffix. use : as separator")
|
fs.StringVar(&excludeS, "exs", ".go:.DS_Store:.tmp", "path exclude suffix. use : as separator")
|
||||||
fs.Var(&excludeR, "exr", "filename exclude by Regexp")
|
fs.Var(&excludeR, "exr", "filename exclude by Regexp")
|
||||||
@ -355,11 +355,6 @@ type zipWalk struct {
|
|||||||
|
|
||||||
func (wft *zipWalk) compress(name, fpath string, fi os.FileInfo) (bool, error) {
|
func (wft *zipWalk) compress(name, fpath string, fi os.FileInfo) (bool, error) {
|
||||||
isSym := fi.Mode()&os.ModeSymlink > 0
|
isSym := fi.Mode()&os.ModeSymlink > 0
|
||||||
if isSym {
|
|
||||||
// golang1.2 still not support embed symlink
|
|
||||||
// what i miss something?
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
hdr, err := zip.FileInfoHeader(fi)
|
hdr, err := zip.FileInfoHeader(fi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -383,6 +378,15 @@ func (wft *zipWalk) compress(name, fpath string, fi os.FileInfo) (bool, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
var link string
|
||||||
|
if link, err = os.Readlink(fpath); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
_, err = w.Write([]byte(link))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user