Skip to content

Commit

Permalink
pkg: build single pkg installer using fat binaries
Browse files Browse the repository at this point in the history
instead of building two pkg installers for arm and x86
this create one universal pkg installer using macos universal
binaries for tray, admin-helper and vfkit

this also renames the helper binaries to drop the arch part, since
we now have only one binary for both the architectures
 - tray is called crc-tray-macos.tar.gz
 - output pkg is called crc-macos-installer.pkg
 - vfkit is called vfkit
 - tarball for signing is called crc-macos-installer.tar

it expects admin-helper, tray and vfkit universal binaries are
avaiable to download on their respective github releases

the resulting universal pkg is almost double the size of the old pkg
  • Loading branch information
anjannath authored and praveenkumar committed Jun 23, 2022
1 parent 924d26f commit c7c7b36
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/macos-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
with:
go-version: ${{ matrix.go }}
- name: Build macOS installer
run: make NO_CODESIGN=1 out/macos-amd64/crc-macos-amd64.pkg
run: make NO_CODESIGN=1 out/macos-universal/crc-macos-installer.pkg
- name: Install crc pkg
run: sudo installer -pkg out/macos-amd64/crc-macos-amd64.pkg -target /
run: sudo installer -pkg out/macos-universal/crc-macos-installer.pkg -target /
- name: Set podman preset as part of config
run: crc config set preset podman
- name: Run crc setup command
Expand Down
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ DOCS_BUILD_TARGET ?= /docs/source/getting_started/master.adoc

GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
TRAY_ARCH = $(subst amd64,x64,$(GOARCH))

HOST_BUILD_DIR=$(BUILD_DIR)/$(GOOS)-$(GOARCH)
GOPATH ?= $(shell go env GOPATH)
Expand Down Expand Up @@ -299,20 +298,23 @@ update-go-version:
goversioncheck:
./verify-go-version.sh

TRAY_RELEASE ?= packaging/tmp/crc-tray-macos-$(GOARCH).tar.gz
TRAY_RELEASE ?= packaging/tmp/crc-tray-macos.tar.gz

embed-download: $(HOST_BUILD_DIR)/crc-embedder
ifeq ($(CUSTOM_EMBED),false)
mkdir -p $(EMBED_DOWNLOAD_DIR)
$(HOST_BUILD_DIR)/crc-embedder download $(EMBED_DOWNLOAD_DIR)
endif

packaging/vfkit-$(GOARCH).entitlements:
packaging/vfkit.entitlements:
curl -sL https://raw.githubusercontent.com/code-ready/vfkit/main/vf.entitlements -o $@

packagedir: clean embed-download macos-release-binary packaging/vfkit-$(GOARCH).entitlements
macos-universal-binary: macos-release-binary
mkdir -p out/macos-universal
lipo -create out/macos-amd64/crc out/macos-arm64/crc -output out/macos-universal/crc

packagedir: clean embed-download macos-universal-binary packaging/vfkit.entitlements
echo -n $(CRC_VERSION) > packaging/VERSION
echo -n $(GOARCH) > packaging/ARCH
sed -e 's/__VERSION__/'$(CRC_VERSION)'/g' -e 's@__INSTALL_PATH__@$(MACOS_INSTALL_PATH)@g' packaging/darwin/Distribution.in >packaging/darwin/Distribution
sed -e 's/__VERSION__/'$(CRC_VERSION)'/g' -e 's@__INSTALL_PATH__@$(MACOS_INSTALL_PATH)@g' packaging/darwin/welcome.html.in >packaging/darwin/Resources/welcome.html
sed -e 's/__VERSION__/'$(CRC_VERSION)'/g' -e 's@__INSTALL_PATH__@$(MACOS_INSTALL_PATH)@g' packaging/darwin/postinstall.in >packaging/darwin/scripts/postinstall
Expand All @@ -322,20 +324,20 @@ packagedir: clean embed-download macos-release-binary packaging/vfkit-$(GOARCH).
mkdir -p packaging/root/Applications
tar -C packaging/root/Applications -xvzf $(TRAY_RELEASE)
rm $(TRAY_RELEASE)
mv packaging/root/Applications/crc-tray-darwin-$(TRAY_ARCH)/crc-tray.app packaging/root/Applications/Red\ Hat\ OpenShift\ Local.app
rm -fr packaging/root/Applications/crc-tray-darwin-$(TRAY_ARCH)
mv packaging/root/Applications/crc-tray-darwin-universal/crc-tray.app packaging/root/Applications/Red\ Hat\ OpenShift\ Local.app
rm -fr packaging/root/Applications/crc-tray-darwin-universal

mv packaging/tmp/* packaging/root/"$(MACOS_INSTALL_PATH)"

cp $(BUILD_DIR)/macos-$(GOARCH)/crc packaging/root/"$(MACOS_INSTALL_PATH)"
cp $(BUILD_DIR)/macos-universal/crc packaging/root/"$(MACOS_INSTALL_PATH)"
cp LICENSE packaging/darwin/Resources/LICENSE.txt
pkgbuild --analyze --root packaging/root packaging/components.plist
plutil -replace BundleIsRelocatable -bool NO packaging/components.plist

$(BUILD_DIR)/macos-$(GOARCH)/crc-macos-$(GOARCH).pkg: packagedir
$(BUILD_DIR)/macos-universal/crc-macos-installer.pkg: packagedir
./packaging/package.sh $(@D)

$(BUILD_DIR)/macos-$(GOARCH)/crc-macos-installer-$(GOARCH).tar: packagedir
$(BUILD_DIR)/macos-universal/crc-macos-installer.tar: packagedir
tar -cvf $@ ./packaging
cd $(@D) && sha256sum $(@F)>$(@F).sha256sum

Expand Down
2 changes: 1 addition & 1 deletion packaging/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ root/
/ARCH
/windows/msi/
packaging/windows/product.wxs
vfkit-*.entitlements
vfkit.entitlements
1 change: 1 addition & 0 deletions packaging/darwin/Distribution.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<options customize="never" allow-external-scripts="no"/>
<domains enable_localSystem="true" />
<options rootVolumeOnly="true"/>
<options hostArchitectures="x86_64,arm64" />
<installation-check script="installCheck();"/>
<script>
function installCheck() {
Expand Down
7 changes: 3 additions & 4 deletions packaging/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ function signAppBundle() {
binDir="${BASEDIR}/root/Applications/Red Hat OpenShift Local.app/Contents/Resources"

version=$(cat "${BASEDIR}/VERSION")
arch=$(cat "${BASEDIR}/ARCH")

sign "${binDir}/crc"
sign "${binDir}/crc-admin-helper-darwin"
sign "${binDir}/vfkit-${arch}"
sign "${binDir}/vfkit"

signAppBundle "${BASEDIR}/root/Applications/Red Hat OpenShift Local.app"

Expand All @@ -61,7 +60,7 @@ productbuild --distribution "${BASEDIR}/darwin/Distribution" \
rm "${OUTPUT}/crc.pkg"

if [ ! "${NO_CODESIGN}" -eq "1" ]; then
productsign --sign "${PRODUCTSIGN_IDENTITY}" "${OUTPUT}/crc-unsigned.pkg" "${OUTPUT}/crc-macos-${arch}.pkg"
productsign --sign "${PRODUCTSIGN_IDENTITY}" "${OUTPUT}/crc-unsigned.pkg" "${OUTPUT}/crc-macos-installer.pkg"
else
mv "${OUTPUT}/crc-unsigned.pkg" "${OUTPUT}/crc-macos-${arch}.pkg"
mv "${OUTPUT}/crc-unsigned.pkg" "${OUTPUT}/crc-macos-installer.pkg"
fi
4 changes: 2 additions & 2 deletions pkg/crc/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
CrcLandingPageURL = "https://console.redhat.com/openshift/create/local" // #nosec G101
DefaultPodmanURLBase = "https://storage.googleapis.com/libpod-master-releases"
DefaultAdminHelperCliBase = "https://github.com/code-ready/admin-helper/releases/download/0.0.10"
CRCMacTrayDownloadURL = "https://github.com/code-ready/tray-electron/releases/download/%s/crc-tray-macos-%s.tar.gz"
CRCMacTrayDownloadURL = "https://github.com/code-ready/tray-electron/releases/download/%s/crc-tray-macos.tar.gz"
CRCWindowsTrayDownloadURL = "https://github.com/code-ready/tray-electron/releases/download/%s/crc-tray-windows.zip"
DefaultContext = "admin"
DaemonHTTPEndpoint = "http://unix/api"
Expand Down Expand Up @@ -158,7 +158,7 @@ func GetKubeAdminPasswordPath() string {

// TODO: follow the same pattern as oc and podman above
func GetCRCMacTrayDownloadURL() string {
return fmt.Sprintf(CRCMacTrayDownloadURL, version.GetTrayVersion(), runtime.GOARCH)
return fmt.Sprintf(CRCMacTrayDownloadURL, version.GetTrayVersion())
}

func GetCRCWindowsTrayDownloadURL() string {
Expand Down
3 changes: 1 addition & 2 deletions pkg/crc/machine/vfkit/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ package vfkit

import (
"fmt"
"runtime"
)

const (
VfkitVersion = "0.0.1"
VfkitCommand = "vfkit"
)

var (
VfkitCommand = fmt.Sprintf("vfkit-%s", runtime.GOARCH)
VfkitDownloadURL = fmt.Sprintf("https://github.com/code-ready/vfkit/releases/download/v%s/%s", VfkitVersion, VfkitCommand)
)

0 comments on commit c7c7b36

Please sign in to comment.