|
|
@ -3,9 +3,13 @@ package Package |
|
|
|
import ( |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"io/ioutil" |
|
|
|
"os" |
|
|
|
"path/filepath" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"PackageManager/Archive" |
|
|
|
"PackageManager/Client/Filesystem" |
|
|
|
"PackageManager/Color" |
|
|
|
"PackageManager/Helper" |
|
|
@ -13,17 +17,19 @@ import ( |
|
|
|
|
|
|
|
func CreatePackage() error { |
|
|
|
var ( |
|
|
|
dirtyFiles map[int]string |
|
|
|
newFiles map[int]string |
|
|
|
pkgFiles map[int]string = make(map[int]string) |
|
|
|
choices string |
|
|
|
choicesSplit []string |
|
|
|
filePath string |
|
|
|
pkgName string |
|
|
|
pkgVersion string |
|
|
|
index int |
|
|
|
ok bool |
|
|
|
e error |
|
|
|
dirtyFiles map[int]string |
|
|
|
newFiles map[int]string |
|
|
|
pkgFiles map[int]string = make(map[int]string) |
|
|
|
choices string |
|
|
|
choicesSplit []string |
|
|
|
filePath string |
|
|
|
pkgName string |
|
|
|
pkgVersion string |
|
|
|
pkgNameVersion string |
|
|
|
tmpDir string |
|
|
|
index int |
|
|
|
ok bool |
|
|
|
e error |
|
|
|
) |
|
|
|
|
|
|
|
fmt.Println("Initialising package creation...") |
|
|
@ -111,5 +117,27 @@ func CreatePackage() error { |
|
|
|
return errors.New("User aborted") |
|
|
|
} |
|
|
|
|
|
|
|
pkgNameVersion = fmt.Sprintf("%s-%s", pkgName, pkgVersion) |
|
|
|
|
|
|
|
tmpDir, e = ioutil.TempDir("/tmp", pkgNameVersion) |
|
|
|
if e != nil { |
|
|
|
return e |
|
|
|
} |
|
|
|
defer os.RemoveAll(tmpDir) |
|
|
|
|
|
|
|
for _, file := range pkgFiles { |
|
|
|
Filesystem.CopyFile(file, filepath.Join(tmpDir, file)) |
|
|
|
} |
|
|
|
|
|
|
|
e = Archive.TarGzip(tmpDir, pkgNameVersion+".tar.gz") |
|
|
|
if e != nil { |
|
|
|
return e |
|
|
|
} |
|
|
|
|
|
|
|
fmt.Printf( |
|
|
|
Color.Green("\nSuccessfully created package %s\n"), |
|
|
|
pkgNameVersion, |
|
|
|
) |
|
|
|
|
|
|
|
return nil |
|
|
|
} |