mirror of
https://github.com/containers/podman.git
synced 2025-05-17 23:26:08 +08:00
Add support for building macOS pkg installer
it installs podman and supporting binaries along with qemu to have a functioning podman install using a pkg podman and podman-mac-helper is compiled from source gvproxy binary is downloaded from its github releases and qemu from github release of containers/podman-machine-qemu [NO NEW TESTS NEEDED] Signed-off-by: Anjan Nath <kaludios@gmail.com>
This commit is contained in:
6
contrib/pkginstaller/.gitignore
vendored
Normal file
6
contrib/pkginstaller/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
out
|
||||||
|
Distribution
|
||||||
|
welcome.html
|
||||||
|
tmp-download
|
||||||
|
.vscode
|
||||||
|
root
|
17
contrib/pkginstaller/Distribution.in
Normal file
17
contrib/pkginstaller/Distribution.in
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<installer-script minSpecVersion="1.000000">
|
||||||
|
<title>Podman __VERSION__</title>
|
||||||
|
<background mime-type="image/png" file="banner.png" scaling="proportional"/>
|
||||||
|
<welcome file="welcome.html" mime-type="text/html" />
|
||||||
|
<conclusion file="conclusion.html" mime-type="text/html" />
|
||||||
|
<license file="LICENSE.txt"/>
|
||||||
|
<options customize="never" hostArchitectures="x86_64,arm64" />
|
||||||
|
<domains enable_localSystem="true" />
|
||||||
|
<choices-outline>
|
||||||
|
<line choice="podman"/>
|
||||||
|
</choices-outline>
|
||||||
|
<choice id="podman" title="podman">
|
||||||
|
<pkg-ref id="podman.pkg"/>
|
||||||
|
</choice>
|
||||||
|
<pkg-ref id="podman.pkg">podman.pkg</pkg-ref>
|
||||||
|
</installer-script>
|
50
contrib/pkginstaller/Makefile
Normal file
50
contrib/pkginstaller/Makefile
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
SHELL := bash
|
||||||
|
|
||||||
|
ARCH ?= aarch64
|
||||||
|
PODMAN_VERSION ?= 4.1.0
|
||||||
|
GVPROXY_VERSION ?= 0.4.0
|
||||||
|
QEMU_VERSION ?= 7.0.0-2
|
||||||
|
GVPROXY_RELEASE_URL ?= https://github.com/containers/gvisor-tap-vsock/releases/download/v$(GVPROXY_VERSION)/gvproxy-darwin
|
||||||
|
QEMU_RELEASE_URL ?= https://github.com/containers/podman-machine-qemu/releases/download/v$(QEMU_VERSION)/podman-machine-qemu-$(ARCH)-$(QEMU_VERSION).tar.xz
|
||||||
|
PACKAGE_DIR ?= out/packaging
|
||||||
|
TMP_DOWNLOAD ?= tmp-download
|
||||||
|
PACKAGE_ROOT ?= root
|
||||||
|
|
||||||
|
default: pkginstaller
|
||||||
|
|
||||||
|
get_gvproxy:
|
||||||
|
mkdir -p $(TMP_DOWNLOAD)
|
||||||
|
cd $(TMP_DOWNLOAD) && curl -sLo gvproxy $(GVPROXY_RELEASE_URL)
|
||||||
|
|
||||||
|
get_qemu:
|
||||||
|
mkdir -p $(TMP_DOWNLOAD)
|
||||||
|
cd $(TMP_DOWNLOAD) && curl -sLO $(QEMU_RELEASE_URL)
|
||||||
|
|
||||||
|
packagedir: package_root Distribution welcome.html
|
||||||
|
mkdir -p $(PACKAGE_DIR)
|
||||||
|
cp -r Resources $(PACKAGE_DIR)/
|
||||||
|
cp welcome.html $(PACKAGE_DIR)/Resources/
|
||||||
|
cp Distribution $(PACKAGE_DIR)/
|
||||||
|
cp -r scripts $(PACKAGE_DIR)/
|
||||||
|
cp -r $(PACKAGE_ROOT) $(PACKAGE_DIR)/
|
||||||
|
cp package.sh $(PACKAGE_DIR)/
|
||||||
|
cd $(PACKAGE_DIR) && pkgbuild --analyze --root ./root component.plist
|
||||||
|
echo -n $(PODMAN_VERSION) > $(PACKAGE_DIR)/VERSION
|
||||||
|
echo -n $(ARCH) > $(PACKAGE_DIR)/ARCH
|
||||||
|
cp ../../LICENSE $(PACKAGE_DIR)/Resources/LICENSE.txt
|
||||||
|
|
||||||
|
package_root: get_gvproxy get_qemu
|
||||||
|
mkdir -p $(PACKAGE_ROOT)/podman/bin $(PACKAGE_ROOT)/podman/qemu
|
||||||
|
tar -C $(PACKAGE_ROOT)/podman/qemu -xf $(TMP_DOWNLOAD)/podman-machine-qemu-$(ARCH)-$(QEMU_VERSION).tar.xz
|
||||||
|
cp $(TMP_DOWNLOAD)/gvproxy $(PACKAGE_ROOT)/podman/bin/
|
||||||
|
chmod a+x $(PACKAGE_ROOT)/podman/bin/*
|
||||||
|
|
||||||
|
%: %.in
|
||||||
|
@sed -e 's/__VERSION__/'$(PODMAN_VERSION)'/g' $< >$@
|
||||||
|
|
||||||
|
pkginstaller: packagedir
|
||||||
|
cd $(PACKAGE_DIR) && ./package.sh ..
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
rm -rf $(TMP_DOWNLOAD) $(PACKAGE_ROOT) $(PACKAGE_DIR) Distribution welcome.html
|
22
contrib/pkginstaller/README.md
Normal file
22
contrib/pkginstaller/README.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
## How to build
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ make ARCH=<amd64 | aarch64> NO_CODESIGN=1 pkginstaller
|
||||||
|
|
||||||
|
# or to create signed pkg
|
||||||
|
$ make ARCH=<amd64 | aarch64> CODESIGN_IDENTITY=<ID> PRODUCTSIGN_IDENTITY=<ID> pkginstaller
|
||||||
|
```
|
||||||
|
|
||||||
|
The generated pkg will be written to `out/podman-macos-installer-*.pkg`.
|
||||||
|
Currently the pkg installs `podman`, `qemu`, `gvproxy` and `podman-mac-helper` to `/Applications/podman`
|
||||||
|
|
||||||
|
The `qemu` build it uses is from [containers/podman-machine-qemu](https://github.com/containers/podman-machine-qemu)
|
||||||
|
|
||||||
|
## Uninstalling
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ sudo rm -rf /opt/podman
|
||||||
|
```
|
||||||
|
|
||||||
|
### Screenshot
|
||||||
|
<img width="626" alt="screenshot-macOS-pkg-podman" src="https://user-images.githubusercontent.com/8885742/157380992-2e3b1573-34a0-4aa0-bdc1-a85f4792a1d2.png">
|
BIN
contrib/pkginstaller/Resources/banner.png
Normal file
BIN
contrib/pkginstaller/Resources/banner.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
13
contrib/pkginstaller/Resources/conclusion.html
Normal file
13
contrib/pkginstaller/Resources/conclusion.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div align="left" style="font-family: Helvetica; padding-left: 10px;">
|
||||||
|
<br/>
|
||||||
|
<p style="color: #020202; font-size: 12px;">Thanks for installing Podman!</p>
|
||||||
|
<p style="color: #020202; font-size: 12px;">You can now start using the 'podman' command. First run 'podman machine init'</b>.</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
60
contrib/pkginstaller/package.sh
Executable file
60
contrib/pkginstaller/package.sh
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
BASEDIR=$(dirname "$0")
|
||||||
|
OUTPUT=$1
|
||||||
|
CODESIGN_IDENTITY=${CODESIGN_IDENTITY:-mock}
|
||||||
|
PRODUCTSIGN_IDENTITY=${PRODUCTSIGN_IDENTITY:-mock}
|
||||||
|
NO_CODESIGN=${NO_CODESIGN:-0}
|
||||||
|
HELPER_BINARIES_DIR="/opt/podman/qemu/bin"
|
||||||
|
|
||||||
|
binDir="${BASEDIR}/root/podman/bin"
|
||||||
|
|
||||||
|
function build_podman() {
|
||||||
|
pushd "$1"
|
||||||
|
make podman-remote HELPER_BINARIES_DIR="${HELPER_BINARIES_DIR}"
|
||||||
|
make podman-mac-helper
|
||||||
|
cp bin/darwin/podman "contrib/pkginstaller/out/packaging/${binDir}/podman"
|
||||||
|
cp bin/darwin/podman-mac-helper "contrib/pkginstaller/out/packaging/${binDir}/podman-mac-helper"
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
function sign() {
|
||||||
|
if [ "${NO_CODESIGN}" -eq "1" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
local opts=""
|
||||||
|
entitlements="${BASEDIR}/$(basename "$1").entitlements"
|
||||||
|
if [ -f "${entitlements}" ]; then
|
||||||
|
opts="--entitlements ${entitlements}"
|
||||||
|
fi
|
||||||
|
codesign --deep --sign "${CODESIGN_IDENTITY}" --options runtime --force --timestamp "${opts}" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
version=$(cat "${BASEDIR}/VERSION")
|
||||||
|
arch=$(cat "${BASEDIR}/ARCH")
|
||||||
|
|
||||||
|
build_podman "../../../../"
|
||||||
|
sign "${binDir}/podman"
|
||||||
|
sign "${binDir}/gvproxy"
|
||||||
|
sign "${binDir}/podman-mac-helper"
|
||||||
|
|
||||||
|
pkgbuild --identifier com.redhat.podman --version "${version}" \
|
||||||
|
--scripts "${BASEDIR}/scripts" \
|
||||||
|
--root "${BASEDIR}/root" \
|
||||||
|
--install-location /opt \
|
||||||
|
--component-plist "${BASEDIR}/component.plist" \
|
||||||
|
"${OUTPUT}/podman.pkg"
|
||||||
|
|
||||||
|
productbuild --distribution "${BASEDIR}/Distribution" \
|
||||||
|
--resources "${BASEDIR}/Resources" \
|
||||||
|
--package-path "${OUTPUT}" \
|
||||||
|
"${OUTPUT}/podman-unsigned.pkg"
|
||||||
|
rm "${OUTPUT}/podman.pkg"
|
||||||
|
|
||||||
|
if [ ! "${NO_CODESIGN}" -eq "1" ]; then
|
||||||
|
productsign --timestamp --sign "${PRODUCTSIGN_IDENTITY}" "${OUTPUT}/podman-unsigned.pkg" "${OUTPUT}/podman-installer-macos-${arch}.pkg"
|
||||||
|
else
|
||||||
|
mv "${OUTPUT}/podman-unsigned.pkg" "${OUTPUT}/podman-installer-macos-${arch}.pkg"
|
||||||
|
fi
|
27
contrib/pkginstaller/scripts/postinstall
Executable file
27
contrib/pkginstaller/scripts/postinstall
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
BZSH_PODMAN_PATH_EXP='PATH="/opt/podman/bin:$PATH"'
|
||||||
|
FISH_PODMAN_PATH_EXP='set PATH "/opt/podman/bin $PATH"'
|
||||||
|
BASHRC_PATH="$HOME/.bash_profile"
|
||||||
|
ZSHENV_PATH="$HOME/.zshenv"
|
||||||
|
ZSHRC_PATH="$HOME/.zshrc"
|
||||||
|
FSHCFG_PATH="$HOME/.config/fish/config.fish"
|
||||||
|
|
||||||
|
# append /Applications/podman/bin to $PATH
|
||||||
|
if [ -f "$BASHRC_PATH" ]; then
|
||||||
|
grep -Fxq "$BZSH_PODMAN_PATH_EXP" "$BASHRC_PATH" || echo "$BZSH_PODMAN_PATH_EXP" >> "$BASHRC_PATH"
|
||||||
|
fi
|
||||||
|
if [ -f "$ZSHENV_PATH" ]; then
|
||||||
|
grep -Fxq "$BZSH_PODMAN_PATH_EXP" "$ZSHENV_PATH" || echo "$BZSH_PODMAN_PATH_EXP" >> "$ZSHENV_PATH"
|
||||||
|
fi
|
||||||
|
if [ -f "$ZSHRC_PATH" ]; then
|
||||||
|
grep -Fxq "$BZSH_PODMAN_PATH_EXP" "$ZSHRC_PATH" || echo "$BZSH_PODMAN_PATH_EXP" >> "$ZSHRC_PATH"
|
||||||
|
fi
|
||||||
|
if [ -f "$FSHCFG_PATH" ]; then
|
||||||
|
grep -Fxq "$FISH_PODMAN_PATH_EXP" "$FSHCFG_PATH" || echo "$FISH_PODMAN_PATH_EXP" >> "$FSHCFG_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ln -s /opt/podman/bin/podman-mac-helper /opt/podman/qemu/bin/podman-mac-helper
|
||||||
|
ln -s /opt/podman/bin/gvproxy /opt/podman/qemu/bin/gvproxy
|
5
contrib/pkginstaller/scripts/preinstall
Executable file
5
contrib/pkginstaller/scripts/preinstall
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
rm -rf /opt/podman
|
16
contrib/pkginstaller/welcome.html.in
Normal file
16
contrib/pkginstaller/welcome.html.in
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div align="left" style="font-family: Helvetica; padding-left: 10px;">
|
||||||
|
<br/>
|
||||||
|
<p style="color: #020202; font-size: 12px;">This will install <span style="color: #46b9d6; font-size: 12px;">Podman __VERSION__</span>
|
||||||
|
on your computer. You will be guided through the steps necessary to install this software.</p>
|
||||||
|
<br/>
|
||||||
|
<p style="color: #abb0b0; font-size: 12px;">Click <span style="color: #626666">“Continue"</span> to continue the
|
||||||
|
setup</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user