Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cpackget] add command shall download the pack and extract the license files to .Download #196 #198

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion cmd/installer/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,20 @@ func (p *PackType) extractEula(packPath string) error {

eulaFileName := packPath + "." + path.Base(p.Pdsc.License)

log.Infof("Extracting embedded license to %v", eulaFileName)
if utils.GetEncodedProgress() {
log.Infof("[L:F\"%s\"]", eulaFileName)
} else {
log.Infof("Extracting embedded license to %v", eulaFileName)
}

if utils.FileExists(eulaFileName) {
soumeh01 marked this conversation as resolved.
Show resolved Hide resolved
utils.UnsetReadOnly(eulaFileName)
os.Remove(eulaFileName)
}
if utils.FileExists(eulaFileName) {
log.Errorf("Cannot remove previous copy of license file: \"%s\"", eulaFileName)
return errs.ErrFailedCreatingFile
}

return os.WriteFile(eulaFileName, eulaContents, utils.FileModeRO)
}
Expand Down
11 changes: 10 additions & 1 deletion cmd/installer/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ func DownloadPDSCFiles(skipInstalledPdscFiles bool, concurrency int, timeout int
return nil
}

log.Infof("[J%d:F\"%s\"]", numPdsc, Installation.PublicIndex)
if utils.GetEncodedProgress() {
log.Infof("[J%d:F\"%s\"]", numPdsc, Installation.PublicIndex)
}

queue := concurrency
for _, pdscTag := range pdscTags {
Expand Down Expand Up @@ -1087,8 +1089,10 @@ func (p *PacksInstallationType) downloadPdscFile(pdscTag xml.PdscTag, skipInstal

if skipInstalledPdscFiles {
if utils.FileExists(pdscFilePath) {
log.Debugf("File already exists: \"%s\"", pdscFilePath)
return nil
}
log.Debugf("File does not exist and will be copied: \"%s\"", pdscFilePath)
}

pdscURL := pdscTag.URL
Expand Down Expand Up @@ -1119,6 +1123,11 @@ func (p *PacksInstallationType) downloadPdscFile(pdscTag xml.PdscTag, skipInstal
utils.UnsetReadOnly(pdscFilePath)
err = utils.MoveFile(localFileName, pdscFilePath)
utils.SetReadOnly(pdscFilePath)

if !utils.FileExists(pdscFilePath) {
log.Errorf("File was not copied: \"%s\"", pdscFilePath)
}

return err
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/ui/eula.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ type LicenseWindowType struct {
// DisplayAndWaitForEULA prints out the license to the user through a UI
// and waits for user confirmation.
func DisplayAndWaitForEULA(licenseTitle, licenseContents string) (bool, error) {
if Extract {
return false, errs.ErrExtractEula
}

promptText := "License Agreement: [A]ccept [D]ecline [E]xtract"

if !utils.IsTerminalInteractive() {
Expand Down
1 change: 1 addition & 0 deletions cmd/utils/encodedProgress.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func (p *EncodedProgress) Write(bs []byte) (int, error) {
* P: Currently processed percentage
* C: Currently processed bytes or numbers of files
* J: Total number of files beeing processed
* L: License file follows
*/
func (p *EncodedProgress) Print() {
newPercent := int(float64(p.current) / float64(p.total) * 100)
Expand Down