Skip to content

Commit 13ec6a8

Browse files
authored
Feature/fix find prov profile by uuid (#51)
* go deps update * if prov profile not found by filename, search by content (fallback) fixes #50 / #50
1 parent 80f5be7 commit 13ec6a8

File tree

86 files changed

+10353
-3911
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+10353
-3911
lines changed

Godeps/Godeps.json

Lines changed: 32 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/common.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cmd
22

33
import (
4-
"errors"
54
"fmt"
65
"os"
76
"path/filepath"
@@ -18,6 +17,7 @@ import (
1817
"github.com/bitrise-tools/codesigndoc/osxkeychain"
1918
"github.com/bitrise-tools/codesigndoc/provprofile"
2019
"github.com/bitrise-tools/codesigndoc/utils"
20+
"github.com/pkg/errors"
2121
)
2222

2323
const (
@@ -137,7 +137,7 @@ func exportCodeSigningFiles(toolName, absExportOutputDirPath string, codeSigning
137137

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

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

provprofile/provprofile.go

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package provprofile
22

33
import (
4-
"errors"
54
"fmt"
65
"path/filepath"
76
"strings"
@@ -13,6 +12,7 @@ import (
1312
"github.com/bitrise-io/go-utils/command"
1413
"github.com/bitrise-io/go-utils/maputil"
1514
"github.com/bitrise-io/go-utils/pathutil"
15+
"github.com/pkg/errors"
1616
"github.com/ryanuber/go-glob"
1717
)
1818

@@ -106,6 +106,40 @@ func CreateProvisioningProfileModelFromFile(filePth string) (ProvisioningProfile
106106
return provProfileData, nil
107107
}
108108

109+
func walkProvProfiles(ppWalkFn func(provProfile ProvisioningProfileFileInfoModel) error) error {
110+
absProvProfileDirPath, err := pathutil.AbsPath(provProfileSystemDirPath)
111+
if err != nil {
112+
return errors.Wrap(err, "Failed to get Absolute path of Provisioning Profiles dir")
113+
}
114+
115+
pths, err := filepath.Glob(absProvProfileDirPath + "/*.mobileprovision")
116+
if err != nil {
117+
return errors.Wrap(err, "Failed to perform *.mobileprovision search")
118+
}
119+
120+
for _, aPth := range pths {
121+
provProfileData, err := CreateProvisioningProfileModelFromFile(aPth)
122+
if err != nil {
123+
return errors.Wrapf(err, "Failed to read Provisioning Profile infos from file (path: %s)",
124+
aPth)
125+
}
126+
127+
if time.Now().After(provProfileData.ExpirationDate) {
128+
log.Warnf(colorstring.Yellow(" (!) ")+"Provisioning Profile %s "+colorstring.Yellow("expired")+" at %s. Skipping.",
129+
colorstring.Blue(provProfileData.UUID), colorstring.Blue(provProfileData.ExpirationDate))
130+
log.Warnf(" If you want to delete this Provisioning Profile you can find it at: %s",
131+
colorstring.Yellow(aPth))
132+
continue
133+
}
134+
135+
if err := ppWalkFn(ProvisioningProfileFileInfoModel{Path: aPth, ProvisioningProfileInfo: provProfileData}); err != nil {
136+
return errors.WithStack(err)
137+
}
138+
}
139+
140+
return nil
141+
}
142+
109143
// FindProvProfilesByAppID ...
110144
// `appID`` supports "glob", e.g.: *.bundle.id will match any Prov Profile with ".bundle.id"
111145
// app ID suffix
@@ -156,11 +190,32 @@ func FindProvProfileByUUID(provProfileUUID string) (ProvisioningProfileFileInfoM
156190

157191
// iOS / .mobileprovision
158192
{
193+
isFound := false
159194
mobileProvPth := filepath.Join(absProvProfileDirPath, provProfileUUID+".mobileprovision")
160195
exist, err := pathutil.IsPathExists(mobileProvPth)
161-
if !exist || err != nil {
196+
if err != nil {
162197
log.Debugf("No mobileprovision file found at: %s | err: %s", mobileProvPth, err)
198+
} else if !exist {
199+
log.Debugf("Not found at path (%s), doing a full search by content ...", mobileProvPth)
200+
// try by content
201+
err := walkProvProfiles(func(ppf ProvisioningProfileFileInfoModel) error {
202+
if ppf.ProvisioningProfileInfo.UUID == provProfileUUID {
203+
isFound = true
204+
mobileProvPth = ppf.Path
205+
}
206+
return nil
207+
})
208+
if err != nil {
209+
log.Debugf("Error during Prov Profile walk: %+v", errors.WithStack(err))
210+
}
211+
if !isFound {
212+
log.Debugf("Prov Profile not found by UUID (walk)")
213+
}
163214
} else {
215+
isFound = true
216+
}
217+
218+
if isFound {
164219
provProfileData, err := CreateProvisioningProfileModelFromFile(mobileProvPth)
165220
if err != nil {
166221
return ProvisioningProfileFileInfoModel{},

vendor/github.com/Sirupsen/logrus/terminal_appengine.go

Lines changed: 0 additions & 10 deletions
This file was deleted.

vendor/github.com/Sirupsen/logrus/terminal_notwindows.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

vendor/github.com/Sirupsen/logrus/terminal_solaris.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)