Fetch now wants full name (13.2-RELEASE), limit pkg to download/extract
This commit is contained in:
parent
6a8b022165
commit
26b8973c6c
32
cmd/fetch.go
32
cmd/fetch.go
@ -23,7 +23,9 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
FetchFiles = []string{"base.txz", "lib32.txz", "src.txz"}
|
// TODO : Make this a config/cmd line setting
|
||||||
|
//FetchFiles = []string{"base.txz", "lib32.txz", "src.txz"}
|
||||||
|
FetchFiles = []string{"base.txz"}
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Check if files already exist
|
// TODO: Check if files already exist
|
||||||
@ -66,9 +68,9 @@ func fetchRelease(release string, proto string, arch string, datastore string, f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create download/XX.X-RELEASE dataset if necessary
|
// Create download/XX.X dataset if necessary
|
||||||
thisDownloadDsName := fmt.Sprintf("%s/%s-RELEASE", downloadDsName, release)
|
thisDownloadDsName := fmt.Sprintf("%s/%s", downloadDsName, release)
|
||||||
thisDownloadDsMountPoint := fmt.Sprintf("%s/%s-RELEASE", downloadDsMountPoint, release)
|
thisDownloadDsMountPoint := fmt.Sprintf("%s/%s", downloadDsMountPoint, release)
|
||||||
exist, err = doZfsDatasetExist(thisDownloadDsName)
|
exist, err = doZfsDatasetExist(thisDownloadDsName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error accessing dataset %s: %v\n", thisDownloadDsName, err)
|
return fmt.Errorf("Error accessing dataset %s: %v\n", thisDownloadDsName, err)
|
||||||
@ -82,9 +84,9 @@ func fetchRelease(release string, proto string, arch string, datastore string, f
|
|||||||
|
|
||||||
var fetchUrl string
|
var fetchUrl string
|
||||||
if len(fetchFrom) > 0 {
|
if len(fetchFrom) > 0 {
|
||||||
fetchUrl = fmt.Sprintf("%s/%s-RELEASE", fetchFrom, release)
|
fetchUrl = fmt.Sprintf("%s/%s", fetchFrom, release)
|
||||||
} else {
|
} else {
|
||||||
fetchUrl = fmt.Sprintf("%s://%s/%s/%s/%s-RELEASE", proto, ReleaseServer, ReleaseRootDir, arch, release)
|
fetchUrl = fmt.Sprintf("%s://%s/%s/%s/%s", proto, ReleaseServer, ReleaseRootDir, arch, release)
|
||||||
}
|
}
|
||||||
log.Debugf("FetchURL = %s", fetchUrl)
|
log.Debugf("FetchURL = %s", fetchUrl)
|
||||||
|
|
||||||
@ -153,9 +155,9 @@ func extractRelease(release string, datastore string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create releases/XX.X-RELEASE dataset if necessary
|
// Create releases/XX.X dataset if necessary
|
||||||
thisReleaseDsName := fmt.Sprintf("%s/%s-RELEASE", releaseDsName, release)
|
thisReleaseDsName := fmt.Sprintf("%s/%s", releaseDsName, release)
|
||||||
thisReleaseDsMountPoint := fmt.Sprintf("%s/%s-RELEASE", releaseDsMountPoint, release)
|
thisReleaseDsMountPoint := fmt.Sprintf("%s/%s", releaseDsMountPoint, release)
|
||||||
exist, err = doZfsDatasetExist(thisReleaseDsName)
|
exist, err = doZfsDatasetExist(thisReleaseDsName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error accessing dataset %s: %v\n", thisReleaseDsName, err)
|
fmt.Printf("Error accessing dataset %s: %v\n", thisReleaseDsName, err)
|
||||||
@ -169,7 +171,7 @@ func extractRelease(release string, datastore string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create releases/XX.X-RELEASE/root dataset if necessary
|
// Create releases/XX.X/root dataset if necessary
|
||||||
thisReleaseRootDsName := fmt.Sprintf("%s/root", thisReleaseDsName)
|
thisReleaseRootDsName := fmt.Sprintf("%s/root", thisReleaseDsName)
|
||||||
thisReleaseRootDsMountPoint := fmt.Sprintf("%s/root", thisReleaseDsMountPoint)
|
thisReleaseRootDsMountPoint := fmt.Sprintf("%s/root", thisReleaseDsMountPoint)
|
||||||
exist, err = doZfsDatasetExist(thisReleaseRootDsName)
|
exist, err = doZfsDatasetExist(thisReleaseRootDsName)
|
||||||
@ -185,9 +187,9 @@ func extractRelease(release string, datastore string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now extract download/$RELEASE/*.txz to releases/XX.X-RELEASE/root
|
// Now extract download/$RELEASE/*.txz to releases/XX.X/root
|
||||||
downloadDsMountPoint := fmt.Sprintf("%s/download", ds.Mountpoint)
|
downloadDsMountPoint := fmt.Sprintf("%s/download", ds.Mountpoint)
|
||||||
downloadDir := fmt.Sprintf("%s/%s-RELEASE", downloadDsMountPoint, release)
|
downloadDir := fmt.Sprintf("%s/%s", downloadDsMountPoint, release)
|
||||||
|
|
||||||
d, err := os.Open(downloadDir)
|
d, err := os.Open(downloadDir)
|
||||||
defer d.Close()
|
defer d.Close()
|
||||||
@ -201,12 +203,13 @@ func extractRelease(release string, datastore string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract every .txz files
|
// Extract every .txz files in FetchFiles
|
||||||
for _, fi := range files {
|
for _, fi := range files {
|
||||||
if false == fi.IsDir() {
|
if false == fi.IsDir() {
|
||||||
if strings.HasSuffix(fi.Name(), ".txz") {
|
if strings.HasSuffix(fi.Name(), ".txz") {
|
||||||
|
if isStringInArray(FetchFiles, fi.Name()) {
|
||||||
ar := fmt.Sprintf("%s/%s", downloadDir, fi.Name())
|
ar := fmt.Sprintf("%s/%s", downloadDir, fi.Name())
|
||||||
fmt.Printf("Extracting file %s... ", ar)
|
fmt.Printf("Extracting file %s to %s... ", ar, thisReleaseRootDsMountPoint)
|
||||||
// pure Go method, sorry this is so slow. Also I did not handle permissions in this
|
// pure Go method, sorry this is so slow. Also I did not handle permissions in this
|
||||||
/* f, err := os.Open(ar)
|
/* f, err := os.Open(ar)
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
@ -267,6 +270,7 @@ func extractRelease(release string, datastore string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func fetchFile(proto, baseUrl, fileName, storeDir string, checksum []byte) error {
|
func fetchFile(proto, baseUrl, fileName, storeDir string, checksum []byte) error {
|
||||||
// Check storeDir exist
|
// Check storeDir exist
|
||||||
|
Loading…
x
Reference in New Issue
Block a user