Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
58 changes: 32 additions & 26 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions cmd/common.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand All @@ -18,6 +17,7 @@ import (
"github.com/bitrise-tools/codesigndoc/osxkeychain"
"github.com/bitrise-tools/codesigndoc/provprofile"
"github.com/bitrise-tools/codesigndoc/utils"
"github.com/pkg/errors"
)

const (
Expand Down Expand Up @@ -137,7 +137,7 @@ func exportCodeSigningFiles(toolName, absExportOutputDirPath string, codeSigning

exportedProvProfiles, err := collectAndExportProvisioningProfiles(codeSigningSettings, absExportOutputDirPath)
if err != nil {
return printFinishedWithError(toolName, "Failed to export Provisioning Profiles, error: %s", err)
return printFinishedWithError(toolName, "Failed to export Provisioning Profiles, error: %+v", err)
}

provProfileTeamIDs, err := exportedProvProfiles.CollectTeamIDs()
Expand Down Expand Up @@ -175,7 +175,7 @@ func collectAndExportProvisioningProfiles(codeSigningSettings common.CodeSigning
log.Infof(" * "+colorstring.Blue("Searching for required Provisioning Profile")+": %s (UUID: %s)", aProvProfile.Title, aProvProfile.UUID)
provProfileFileInfo, err := provprofile.FindProvProfileByUUID(aProvProfile.UUID)
if err != nil {
return provProfileFileInfos, fmt.Errorf("Failed to find Provisioning Profile: %s", err)
return provProfileFileInfos, errors.Wrap(err, "Failed to find Provisioning Profile")
}
log.Infof(" File found at: %s", provProfileFileInfo.Path)

Expand Down
59 changes: 57 additions & 2 deletions provprofile/provprofile.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package provprofile

import (
"errors"
"fmt"
"path/filepath"
"strings"
Expand All @@ -13,6 +12,7 @@ import (
"github.com/bitrise-io/go-utils/command"
"github.com/bitrise-io/go-utils/maputil"
"github.com/bitrise-io/go-utils/pathutil"
"github.com/pkg/errors"
"github.com/ryanuber/go-glob"
)

Expand Down Expand Up @@ -106,6 +106,40 @@ func CreateProvisioningProfileModelFromFile(filePth string) (ProvisioningProfile
return provProfileData, nil
}

func walkProvProfiles(ppWalkFn func(provProfile ProvisioningProfileFileInfoModel) error) error {
absProvProfileDirPath, err := pathutil.AbsPath(provProfileSystemDirPath)
if err != nil {
return errors.Wrap(err, "Failed to get Absolute path of Provisioning Profiles dir")
}

pths, err := filepath.Glob(absProvProfileDirPath + "/*.mobileprovision")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would recommand: filepath.Join(absProvProfileDirPath, "*.mobileprovision") instead of: absProvProfileDirPath + "/*.mobileprovision"

if err != nil {
return errors.Wrap(err, "Failed to perform *.mobileprovision search")
}

for _, aPth := range pths {
provProfileData, err := CreateProvisioningProfileModelFromFile(aPth)
if err != nil {
return errors.Wrapf(err, "Failed to read Provisioning Profile infos from file (path: %s)",
aPth)
}

if time.Now().After(provProfileData.ExpirationDate) {
log.Warnf(colorstring.Yellow(" (!) ")+"Provisioning Profile %s "+colorstring.Yellow("expired")+" at %s. Skipping.",
colorstring.Blue(provProfileData.UUID), colorstring.Blue(provProfileData.ExpirationDate))
log.Warnf(" If you want to delete this Provisioning Profile you can find it at: %s",
colorstring.Yellow(aPth))
continue
}

if err := ppWalkFn(ProvisioningProfileFileInfoModel{Path: aPth, ProvisioningProfileInfo: provProfileData}); err != nil {
return errors.WithStack(err)
}
}

return nil
}

// FindProvProfilesByAppID ...
// `appID`` supports "glob", e.g.: *.bundle.id will match any Prov Profile with ".bundle.id"
// app ID suffix
Expand Down Expand Up @@ -156,11 +190,32 @@ func FindProvProfileByUUID(provProfileUUID string) (ProvisioningProfileFileInfoM

// iOS / .mobileprovision
{
isFound := false
mobileProvPth := filepath.Join(absProvProfileDirPath, provProfileUUID+".mobileprovision")
exist, err := pathutil.IsPathExists(mobileProvPth)
if !exist || err != nil {
if err != nil {
log.Debugf("No mobileprovision file found at: %s | err: %s", mobileProvPth, err)
} else if !exist {
log.Debugf("Not found at path (%s), doing a full search by content ...", mobileProvPth)
// try by content
err := walkProvProfiles(func(ppf ProvisioningProfileFileInfoModel) error {
if ppf.ProvisioningProfileInfo.UUID == provProfileUUID {
isFound = true
mobileProvPth = ppf.Path
}
return nil
})
if err != nil {
log.Debugf("Error during Prov Profile walk: %+v", errors.WithStack(err))
}
if !isFound {
log.Debugf("Prov Profile not found by UUID (walk)")
}
} else {
isFound = true
}

if isFound {
provProfileData, err := CreateProvisioningProfileModelFromFile(mobileProvPth)
if err != nil {
return ProvisioningProfileFileInfoModel{},
Expand Down
10 changes: 0 additions & 10 deletions vendor/github.com/Sirupsen/logrus/terminal_appengine.go

This file was deleted.

29 changes: 0 additions & 29 deletions vendor/github.com/Sirupsen/logrus/terminal_notwindows.go

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/github.com/Sirupsen/logrus/terminal_solaris.go

This file was deleted.

Loading