fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
3.11k stars 431 forks source link

Cannot build pkg and msi packages on Ubuntu #19370

Closed diegmonti closed 5 months ago

diegmonti commented 5 months ago

Fleet version: 4.50.0

Web browser and operating system: Ubuntu 22.04.4 LTS


💥  Actual behavior

Using fleetctl on Ubuntu I'm not able to build the packages for Windows and macOS. I suspect this issue started with Fleet 4.50.0 as two weeks ago I was able to create the packages without errors.

🧑‍💻  Steps to reproduce

$ fleetctl package --type=msi --fleet-desktop --fleet-url=https://fleet.company.com --enroll-secret=secret
Generating your fleetd agent...
Windows Installer XML Toolset Toolset Harvester version 
Copyright (c) .NET Foundation and contributors. All rights reserved.

heat.exe : error HEAT5052 : The directory 'Z:\wix\root' could not be found.
Error: package root files: heat failed: exit status 188
$ fleetctl package --type=pkg --fleet-desktop --fleet-url=https://fleet.company.com --enroll-secret=secret
Generating your fleetd agent...
Unable to find path: /root/root
Error: build pkg: mkbom: exit status 1

🕯️ More info (optional)

This works as expected:

$ fleetctl package --type=deb --fleet-desktop --fleet-url=https://fleet.company.com --enroll-secret=secret
Generating your fleetd agent...

Success! You generated fleetd at /home/diego/fleet-osquery_1.25.0_amd64.deb

To add this device to Fleet, double-click to install fleetd.

To add other devices to Fleet, distribute fleetd using Chef, Ansible, Jamf, or Puppet. Learn how: https://fleetdm.com/learn-more-about/enrolling-hosts
georgekarrv commented 5 months ago

We do have some internal documentation on how to achieve this via docker since ubuntu native is missing a lot of required tooling natively. Let us know if these docs are helpful and if you have any other questions.

diegmonti commented 5 months ago

Thanks, the Docker approach works fine.

lucasmrod commented 5 months ago

I'm curious as to why it doesn't work because we have CI actions that test generating msi and pkg from ubuntu-latest (fleetctl package on Linux uses Docker to generate msis/pkgs).

diegmonti commented 5 months ago

Maybe this is helpful:

$ fleetctl package --type=msi --fleet-desktop --fleet-url=https://fleet.company.com --enroll-secret=secret --verbose
Generating your fleetd agent...
{"level":"debug","path":"/tmp/orbit-package1817156352","time":"2024-05-31T10:35:04+02:00","message":"created temp directory"}
{"level":"debug","error":"stat /tmp/orbit-package1817156352/root/bin/osqueryd/windows/stable/osqueryd.exe: no such file or directory","time":"2024-05-31T10:35:04+02:00","message":"stat file"}
{"level":"debug","error":"stat /tmp/orbit-package1817156352/root/bin/orbit/windows/stable/orbit.exe: no such file or directory","time":"2024-05-31T10:35:05+02:00","message":"stat file"}
{"level":"debug","error":"stat /tmp/orbit-package1817156352/root/bin/desktop/windows/stable/fleet-desktop.exe: no such file or directory","time":"2024-05-31T10:35:07+02:00","message":"stat file"}
{"level":"debug","data":"orbit={/tmp/orbit-package1817156352/root/bin/orbit/windows/stable/orbit.exe,1.25.0}, osqueryd={/tmp/orbit-package1817156352/root/bin/osqueryd/windows/stable/osqueryd.exe,5.12.1}","time":"2024-05-31T10:35:09+02:00","message":"updates initialized"}
Windows Installer XML Toolset Toolset Harvester version 
Copyright (c) .NET Foundation and contributors. All rights reserved.

heat.exe : error HEAT5052 : The directory 'Z:\wix\root' could not be found.
Error: package root files: heat failed: exit status 188
sharon-fdm commented 5 months ago

Timebox to 2 points to build the env and reproduce.

lucasmrod commented 5 months ago

Hi @diegmonti!

I was not able to reproduce. See my setup and test below. Anything special/different about your environment? (My guess is docker)

Setup

Ubuntu version

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:  Ubuntu 22.04.3 LTS
Release:  22.04
Codename: jammy

fleetctl version

From https://github.com/fleetdm/fleet/releases/download/fleet-v4.50.0/fleetctl_v4.50.0_linux.tar.gz.

fleetctl --version
fleetctl - version 4.50.0
  branch:   HEAD
  revision:     a540e0e38b1c0cb3d406c2ff8df3e2be4e94d962
  build date:   2024-05-23
  build user:   runner
  go version:   go1.21.7

docker version

$ sudo docker version
Client: Docker Engine - Community
 Version:           26.1.3
 API version:       1.45
 Go version:        go1.21.10
 Git commit:        b72abbb
 Built:             Thu May 16 08:33:29 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          26.1.3
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.10
  Git commit:       8e96db1
  Built:            Thu May 16 08:33:29 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.32
  GitCommit:        8b3b7ca2e5ce38e8f31a34f35b2b68ceb8470d89
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

fleetctl package

$ fleetctl package --type=pkg --enable-scripts --fleet-desktop --fleet-url=<...> --enroll-secret=<...>
Generating your fleetd agent...
Unable to find image 'fleetdm/bomutils:latest' locally
latest: Pulling from fleetdm/bomutils
adce49e07b06: Pull complete 
f85c043cc640: Pull complete 
50e729d01de1: Pull complete 
9f9a382b26b2: Pull complete 
57fa2c8c5e60: Pull complete 
Digest: sha256:a559967d8f9ed9776713789813947fa2c96c7de24c28a59f7d4dde4b4a9734d5
Status: Downloaded newer image for fleetdm/bomutils:latest

Success! You generated fleetd at /home/luk/Downloads/fleet-osquery.pkg

To add this device to Fleet, double-click to install fleetd.

To add other devices to Fleet, distribute fleetd using Chef, Ansible, Jamf, or Puppet. Learn how: https://fleetdm.com/learn-more-about/enrolling-hosts

$ fleetctl package --type=msi --enable-scripts --fleet-desktop --fleet-url=<...> --enroll-secret=<...>
Generating your fleetd agent...
Unable to find image 'fleetdm/wix:latest' locally
latest: Pulling from fleetdm/wix
7d63c13d9b9b: Pull complete 
d6b3bca85310: Pull complete 
26a41d401cc6: Pull complete 
1a28001a7315: Pull complete 
86ad66875459: Pull complete 
4f4fb700ef54: Pull complete 
Digest: sha256:3183e1a702efe74cef600b73c193605bed5aeff53f09cf858b86fe66efdd8e3e
Status: Downloaded newer image for fleetdm/wix:latest
Windows Installer XML Toolset Toolset Harvester version 
Copyright (c) .NET Foundation and contributors. All rights reserved.

Windows Installer XML Toolset Compiler version 
Copyright (c) .NET Foundation and contributors. All rights reserved.

heat.wxs
main.wxs
Windows Installer XML Toolset Linker version 
Copyright (c) .NET Foundation and contributors. All rights reserved.

Success! You generated fleetd at /home/luk/Downloads/fleet-osquery.msi

To add this device to Fleet, double-click to install fleetd.

To add other devices to Fleet, distribute fleetd using Chef, Ansible, Jamf, or Puppet. Learn how: https://fleetdm.com/learn-more-about/enrolling-hosts
diegmonti commented 5 months ago

Hi @lucasmrod! You are right, the issue was related to Docker. The client and server versions were mismatched because, for unknown reasons, the client was installed via snap. After removing the snap package, fleetctl works fine. Thanks for your help.

lucasmrod commented 5 months ago

Happy to hear that!

fleet-release commented 5 months ago

Ubuntu, like a cloud, Pkg, msi, cannot sprout. Fixed, they rain down.