Skip to content

Commit

Permalink
tweaks and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Pickett committed Jul 25, 2024
1 parent 0b736a3 commit 2fbeac3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/packagekit/wix/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func NewService(matchString string, opts ...ServiceOpt) *Service {

s := &Service{
matchString: matchString,
// one count for arm64 and ond for amd64
// one count for arm64, one for amd64
expectedCount: 2,
count: 0,
serviceInstall: si,
Expand Down
10 changes: 7 additions & 3 deletions pkg/packagekit/wix/wix.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,19 @@ func (wo *wixTool) addServices(ctx context.Context) error {
continue
}

if strings.Contains(line, "Directory") {
// the directory tag will like like "<Directory Id="xxxx"...>"
// so we just check for the first part of the string
if strings.Contains(line, "<Directory") {
if strings.Contains(line, string(amd64)) {
// were in a arch specific bin dir that we want to remove so when we hit closing tag, we'll skip it
// were in a arch specific bin dir that we want to remove, skip opening tag
// and set current arch specific bin dir so we'll skip closing tag as well
currentArchSpecificBinDir = amd64
continue
}

if strings.Contains(line, string(arm64)) {
// were in a arch specific bin dir that we want to remove so when we hit closing tag, we'll skip it
// were in a arch specific bin dir that we want to remove, skip opening tag
// and set current arch specific bin dir so we'll skip closing tag as well
currentArchSpecificBinDir = arm64
continue
}
Expand Down
12 changes: 4 additions & 8 deletions pkg/packaging/detectLauncherVersion.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ func (p *PackageOptions) detectLauncherVersion(ctx context.Context) error {
logger := log.With(ctxlog.FromContext(ctx), "library", "detectLauncherVersion")
level.Debug(logger).Log("msg", "Attempting launcher autodetection")

binDir := filepath.Join(p.packageRoot, p.binDir)
if p.target.Platform != Darwin {
binDir = filepath.Join(binDir, string(p.target.Arch))
}

launcherPath := p.launcherLocation(binDir)
launcherPath := p.launcherLocation(filepath.Join(p.packageRoot, p.binDir, string(p.target.Arch)))

stdout, err := p.execOut(ctx, launcherPath, "-version")
if err != nil {
Expand Down Expand Up @@ -56,8 +51,9 @@ func (p *PackageOptions) detectLauncherVersion(ctx context.Context) error {
// fall back to the common location if it doesn't.
func (p *PackageOptions) launcherLocation(binDir string) string {
if p.target.Platform == Darwin {
// We want /usr/local/Kolide.app, not /usr/local/bin/Kolide.app, so we use Dir to strip out `bin`
appBundleBinaryPath := filepath.Join(filepath.Dir(binDir), "Kolide.app", "Contents", "MacOS", "launcher")
// We want /usr/local/Kolide.app, not /usr/local/bin/universal/Kolide.app, so we use Dir to strip out `bin`
// and universal
appBundleBinaryPath := filepath.Join(filepath.Dir(filepath.Dir(binDir)), "Kolide.app", "Contents", "MacOS", "launcher")
if info, err := os.Stat(appBundleBinaryPath); err == nil && !info.IsDir() {
return appBundleBinaryPath
}
Expand Down

0 comments on commit 2fbeac3

Please sign in to comment.