Skip to content

Commit 500a00c

Browse files
Merge pull request #15194 from ashley-cui/backports
[CI:DOCS] [4.2] Backport MacOS pkginstaller
2 parents 49ae6cf + bf2a53a commit 500a00c

File tree

11 files changed

+266
-0
lines changed

11 files changed

+266
-0
lines changed

contrib/pkginstaller/.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
out
2+
Distribution
3+
welcome.html
4+
tmp-download
5+
.vscode
6+
root

contrib/pkginstaller/Distribution.in

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<installer-script minSpecVersion="1.000000">
3+
<title>Podman __VERSION__</title>
4+
<background mime-type="image/png" file="banner.png" scaling="proportional"/>
5+
<welcome file="welcome.html" mime-type="text/html" />
6+
<conclusion file="conclusion.html" mime-type="text/html" />
7+
<license file="LICENSE.txt"/>
8+
<options customize="never" hostArchitectures="x86_64,arm64" />
9+
<domains enable_localSystem="true" />
10+
<choices-outline>
11+
<line choice="podman"/>
12+
</choices-outline>
13+
<choice id="podman" title="podman">
14+
<pkg-ref id="podman.pkg"/>
15+
</choice>
16+
<pkg-ref id="podman.pkg">podman.pkg</pkg-ref>
17+
</installer-script>

contrib/pkginstaller/Makefile

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
SHELL := bash
2+
3+
ARCH ?= aarch64
4+
PODMAN_VERSION ?= 4.1.0
5+
GVPROXY_VERSION ?= 0.4.0
6+
QEMU_VERSION ?= 7.0.0-2
7+
GVPROXY_RELEASE_URL ?= https://github.com/containers/gvisor-tap-vsock/releases/download/v$(GVPROXY_VERSION)/gvproxy-darwin
8+
QEMU_RELEASE_URL ?= https://github.com/containers/podman-machine-qemu/releases/download/v$(QEMU_VERSION)/podman-machine-qemu-$(ARCH)-$(QEMU_VERSION).tar.xz
9+
PACKAGE_DIR ?= out/packaging
10+
TMP_DOWNLOAD ?= tmp-download
11+
PACKAGE_ROOT ?= root
12+
PKG_NAME := podman-installer-macos-$(ARCH).pkg
13+
14+
default: pkginstaller
15+
16+
$(TMP_DOWNLOAD)/gvproxy:
17+
mkdir -p $(TMP_DOWNLOAD)
18+
cd $(TMP_DOWNLOAD) && curl -sLo gvproxy $(GVPROXY_RELEASE_URL)
19+
20+
$(TMP_DOWNLOAD)/podman-machine-qemu-$(ARCH)-$(QEMU_VERSION).tar.xz:
21+
mkdir -p $(TMP_DOWNLOAD)
22+
cd $(TMP_DOWNLOAD) && curl -sLO $(QEMU_RELEASE_URL)
23+
24+
packagedir: package_root Distribution welcome.html
25+
mkdir -p $(PACKAGE_DIR)
26+
cp -r Resources $(PACKAGE_DIR)/
27+
cp welcome.html $(PACKAGE_DIR)/Resources/
28+
cp Distribution $(PACKAGE_DIR)/
29+
cp -r scripts $(PACKAGE_DIR)/
30+
cp -r $(PACKAGE_ROOT) $(PACKAGE_DIR)/
31+
cp package.sh $(PACKAGE_DIR)/
32+
cd $(PACKAGE_DIR) && pkgbuild --analyze --root ./root component.plist
33+
echo -n $(PODMAN_VERSION) > $(PACKAGE_DIR)/VERSION
34+
echo -n $(ARCH) > $(PACKAGE_DIR)/ARCH
35+
cp ../../LICENSE $(PACKAGE_DIR)/Resources/LICENSE.txt
36+
cp hvf.entitlements $(PACKAGE_DIR)/
37+
38+
package_root: clean-pkgroot $(TMP_DOWNLOAD)/podman-machine-qemu-$(ARCH)-$(QEMU_VERSION).tar.xz $(TMP_DOWNLOAD)/gvproxy
39+
mkdir -p $(PACKAGE_ROOT)/podman/bin $(PACKAGE_ROOT)/podman/qemu
40+
tar -C $(PACKAGE_ROOT)/podman/qemu -xf $(TMP_DOWNLOAD)/podman-machine-qemu-$(ARCH)-$(QEMU_VERSION).tar.xz
41+
cp $(TMP_DOWNLOAD)/gvproxy $(PACKAGE_ROOT)/podman/bin/
42+
chmod a+x $(PACKAGE_ROOT)/podman/bin/*
43+
44+
%: %.in
45+
@sed -e 's/__VERSION__/'$(PODMAN_VERSION)'/g' $< >$@
46+
47+
pkginstaller: packagedir
48+
cd $(PACKAGE_DIR) && ./package.sh ..
49+
50+
_notarize: pkginstaller
51+
xcrun notarytool submit --apple-id $(NOTARIZE_USERNAME) --password $(NOTARIZE_PASSWORD) --team-id=$(NOTARIZE_TEAM) -f json --wait out/$(PKG_NAME)
52+
53+
notarize: _notarize
54+
xcrun stapler staple out/$(PKG_NAME)
55+
56+
.PHONY: clean clean-pkgroot
57+
clean:
58+
rm -rf $(TMP_DOWNLOAD) $(PACKAGE_ROOT) $(PACKAGE_DIR) Distribution welcome.html
59+
60+
clean-pkgroot:
61+
rm -rf $(PACKAGE_ROOT) $(PACKAGE_DIR) Distribution welcome.html

contrib/pkginstaller/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## How to build
2+
3+
```sh
4+
$ make ARCH=<amd64 | aarch64> NO_CODESIGN=1 pkginstaller
5+
6+
# or to create signed pkg
7+
$ make ARCH=<amd64 | aarch64> CODESIGN_IDENTITY=<ID> PRODUCTSIGN_IDENTITY=<ID> pkginstaller
8+
9+
# or to prepare a signed and notarized pkg for release
10+
$ make ARCH=<amd64 | aarch64> CODESIGN_IDENTITY=<ID> PRODUCTSIGN_IDENTITY=<ID> NOTARIZE_USERNAME=<appleID> NOTARIZE_PASSWORD=<appleID-password> NOTARIZE_TEAM=<team-id> notarize
11+
```
12+
13+
The generated pkg will be written to `out/podman-macos-installer-*.pkg`.
14+
Currently the pkg installs `podman`, `qemu`, `gvproxy` and `podman-mac-helper` to `/opt/podman`
15+
16+
The `qemu` build it uses is from [containers/podman-machine-qemu](https://github.com/containers/podman-machine-qemu)
17+
18+
## Uninstalling
19+
20+
```sh
21+
$ sudo rm -rf /opt/podman
22+
```
23+
24+
### Screenshot
25+
<img width="626" alt="screenshot-macOS-pkg-podman" src="https://user-images.githubusercontent.com/8885742/157380992-2e3b1573-34a0-4aa0-bdc1-a85f4792a1d2.png">
49.2 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8"/>
5+
</head>
6+
<body>
7+
<div align="left" style="font-family: Helvetica; padding-left: 10px;">
8+
<br/>
9+
<p style="color: #020202; font-size: 12px;">Thanks for installing Podman!</p>
10+
<p style="color: #020202; font-size: 12px;">You can now start using the 'podman' command. First run 'podman machine init'</b>.</p>
11+
</div>
12+
</body>
13+
</html>

contrib/pkginstaller/hvf.entitlements

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.hypervisor</key>
6+
<true/>
7+
</dict>
8+
</plist>

contrib/pkginstaller/package.sh

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
BASEDIR=$(dirname "$0")
6+
OUTPUT=$1
7+
CODESIGN_IDENTITY=${CODESIGN_IDENTITY:-mock}
8+
PRODUCTSIGN_IDENTITY=${PRODUCTSIGN_IDENTITY:-mock}
9+
NO_CODESIGN=${NO_CODESIGN:-0}
10+
HELPER_BINARIES_DIR="/opt/podman/qemu/bin"
11+
12+
binDir="${BASEDIR}/root/podman/bin"
13+
qemuBinDir="${BASEDIR}/root/podman/qemu/bin"
14+
15+
version=$(cat "${BASEDIR}/VERSION")
16+
arch=$(cat "${BASEDIR}/ARCH")
17+
18+
function build_podman() {
19+
pushd "$1"
20+
make GOARCH="${arch}" podman-remote HELPER_BINARIES_DIR="${HELPER_BINARIES_DIR}"
21+
make GOARCH="${arch}" podman-mac-helper
22+
cp bin/darwin/podman "contrib/pkginstaller/out/packaging/${binDir}/podman"
23+
cp bin/darwin/podman-mac-helper "contrib/pkginstaller/out/packaging/${binDir}/podman-mac-helper"
24+
popd
25+
}
26+
27+
function sign() {
28+
if [ "${NO_CODESIGN}" -eq "1" ]; then
29+
return
30+
fi
31+
local opts=""
32+
entitlements="${BASEDIR}/$(basename "$1").entitlements"
33+
if [ -f "${entitlements}" ]; then
34+
opts="--entitlements ${entitlements}"
35+
fi
36+
codesign --deep --sign "${CODESIGN_IDENTITY}" --options runtime --timestamp --force ${opts} "$1"
37+
}
38+
39+
function signQemu() {
40+
if [ "${NO_CODESIGN}" -eq "1" ]; then
41+
return
42+
fi
43+
44+
local qemuArch="${arch}"
45+
if [ "${qemuArch}" = amd64 ]; then
46+
qemuArch=x86_64
47+
fi
48+
49+
# sign the files inside /opt/podman/qemu/lib
50+
libs=$(find "${BASEDIR}"/root/podman/qemu/lib -depth -name "*.dylib" -or -type f -perm +111)
51+
echo "${libs}" | xargs -t -I % codesign --deep --sign "${CODESIGN_IDENTITY}" --options runtime --timestamp --force % || true
52+
53+
# sign the files inside /opt/podman/qemu/bin except qemu-system-*
54+
bins=$(find "${BASEDIR}"/root/podman/qemu/bin -depth -type f -perm +111 ! -name "qemu-system-${qemuArch}")
55+
echo "${bins}" | xargs -t -I % codesign --deep --sign "${CODESIGN_IDENTITY}" --options runtime --timestamp --force % || true
56+
57+
# sign the qemu-system-* binary
58+
# need to remove any extended attributes, otherwise codesign complains:
59+
# qemu-system-aarch64: resource fork, Finder information, or similar detritus not allowed
60+
xattr -cr "${qemuBinDir}/qemu-system-${qemuArch}"
61+
codesign --deep --sign "${CODESIGN_IDENTITY}" --options runtime --timestamp --force \
62+
--entitlements "${BASEDIR}/hvf.entitlements" "${qemuBinDir}/qemu-system-${qemuArch}"
63+
}
64+
65+
build_podman "../../../../"
66+
sign "${binDir}/podman"
67+
sign "${binDir}/gvproxy"
68+
sign "${binDir}/podman-mac-helper"
69+
signQemu
70+
71+
pkgbuild --identifier com.redhat.podman --version "${version}" \
72+
--scripts "${BASEDIR}/scripts" \
73+
--root "${BASEDIR}/root" \
74+
--install-location /opt \
75+
--component-plist "${BASEDIR}/component.plist" \
76+
"${OUTPUT}/podman.pkg"
77+
78+
productbuild --distribution "${BASEDIR}/Distribution" \
79+
--resources "${BASEDIR}/Resources" \
80+
--package-path "${OUTPUT}" \
81+
"${OUTPUT}/podman-unsigned.pkg"
82+
rm "${OUTPUT}/podman.pkg"
83+
84+
if [ ! "${NO_CODESIGN}" -eq "1" ]; then
85+
productsign --timestamp --sign "${PRODUCTSIGN_IDENTITY}" "${OUTPUT}/podman-unsigned.pkg" "${OUTPUT}/podman-installer-macos-${arch}.pkg"
86+
else
87+
mv "${OUTPUT}/podman-unsigned.pkg" "${OUTPUT}/podman-installer-macos-${arch}.pkg"
88+
fi
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
BZSH_PODMAN_PATH_EXP='PATH="/opt/podman/bin:$PATH"'
6+
FISH_PODMAN_PATH_EXP='set PATH "/opt/podman/bin $PATH"'
7+
BASHRC_PATH="$HOME/.bash_profile"
8+
ZSHENV_PATH="$HOME/.zshenv"
9+
ZSHRC_PATH="$HOME/.zshrc"
10+
FSHCFG_PATH="$HOME/.config/fish/config.fish"
11+
12+
# append /Applications/podman/bin to $PATH
13+
if [ -f "$BASHRC_PATH" ]; then
14+
grep -Fxq "$BZSH_PODMAN_PATH_EXP" "$BASHRC_PATH" || echo "$BZSH_PODMAN_PATH_EXP" >> "$BASHRC_PATH"
15+
fi
16+
if [ -f "$ZSHENV_PATH" ]; then
17+
grep -Fxq "$BZSH_PODMAN_PATH_EXP" "$ZSHENV_PATH" || echo "$BZSH_PODMAN_PATH_EXP" >> "$ZSHENV_PATH"
18+
fi
19+
if [ -f "$ZSHRC_PATH" ]; then
20+
grep -Fxq "$BZSH_PODMAN_PATH_EXP" "$ZSHRC_PATH" || echo "$BZSH_PODMAN_PATH_EXP" >> "$ZSHRC_PATH"
21+
fi
22+
if [ -f "$FSHCFG_PATH" ]; then
23+
grep -Fxq "$FISH_PODMAN_PATH_EXP" "$FSHCFG_PATH" || echo "$FISH_PODMAN_PATH_EXP" >> "$FSHCFG_PATH"
24+
fi
25+
26+
ln -s /opt/podman/bin/podman-mac-helper /opt/podman/qemu/bin/podman-mac-helper
27+
ln -s /opt/podman/bin/gvproxy /opt/podman/qemu/bin/gvproxy
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
rm -rf /opt/podman

contrib/pkginstaller/welcome.html.in

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8"/>
5+
</head>
6+
<body>
7+
<div align="left" style="font-family: Helvetica; padding-left: 10px;">
8+
<br/>
9+
<p style="color: #020202; font-size: 12px;">This will install <span style="color: #46b9d6; font-size: 12px;">Podman __VERSION__</span>
10+
on your computer. You will be guided through the steps necessary to install this software.</p>
11+
<br/>
12+
<p style="color: #abb0b0; font-size: 12px;">Click <span style="color: #626666">“Continue"</span> to continue the
13+
setup</p>
14+
</div>
15+
</body>
16+
</html>

0 commit comments

Comments
 (0)