mirror of
https://github.com/sickcodes/Docker-OSX.git
synced 2024-12-22 05:51:32 -06:00
Add Linux, libguestfs for building bootdisks within the Docker container. Add CPU_STRING to optionally override the whole CPU string. Unify variable names in ./custom.
This commit is contained in:
parent
4ffed54724
commit
9e5538c195
16
Dockerfile
16
Dockerfile
@ -174,6 +174,18 @@ RUN python fetch-macOS.py --version "${VERSION}" \
|
|||||||
|
|
||||||
WORKDIR /home/arch/OSX-KVM
|
WORKDIR /home/arch/OSX-KVM
|
||||||
|
|
||||||
|
ARG LINUX=true
|
||||||
|
|
||||||
|
# required to use libguestfs inside a docker container, to create bootdisks for docker-osx on-the-fly
|
||||||
|
RUN if [[ "${LINUX}" == true ]]; then \
|
||||||
|
sudo pacman -Syu linux libguestfs --noconfirm \
|
||||||
|
&& patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst \
|
||||||
|
&& curl -LO "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/${patched_glibc}" \
|
||||||
|
&& bsdtar -C / -xvf "${patched_glibc}" || echo "Everything is fine." \
|
||||||
|
; fi
|
||||||
|
|
||||||
|
RUN git clone https://github.com/sickcodes/Docker-OSX.git
|
||||||
|
|
||||||
RUN touch Launch.sh \
|
RUN touch Launch.sh \
|
||||||
&& chmod +x ./Launch.sh \
|
&& chmod +x ./Launch.sh \
|
||||||
&& tee -a Launch.sh <<< '#!/bin/sh' \
|
&& tee -a Launch.sh <<< '#!/bin/sh' \
|
||||||
@ -183,7 +195,7 @@ RUN touch Launch.sh \
|
|||||||
&& tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-8}000 \' \
|
&& tee -a Launch.sh <<< 'exec qemu-system-x86_64 -m ${RAM:-8}000 \' \
|
||||||
&& tee -a Launch.sh <<< '-cpu Penryn,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+pcid,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check \' \
|
&& tee -a Launch.sh <<< '-cpu Penryn,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+pcid,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check \' \
|
||||||
&& tee -a Launch.sh <<< '-machine q35,accel=kvm:tcg \' \
|
&& tee -a Launch.sh <<< '-machine q35,accel=kvm:tcg \' \
|
||||||
&& tee -a Launch.sh <<< '-smp ${SMP:-4},cores=${CORES:-4} \' \
|
&& tee -a Launch.sh <<< '-smp ${CPU_STRING:-${SMP:-4},cores=${CORES:-4}} \' \
|
||||||
&& tee -a Launch.sh <<< '-usb -device usb-kbd -device usb-tablet \' \
|
&& tee -a Launch.sh <<< '-usb -device usb-kbd -device usb-tablet \' \
|
||||||
&& tee -a Launch.sh <<< '-device isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal\(c\)AppleComputerInc \' \
|
&& tee -a Launch.sh <<< '-device isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal\(c\)AppleComputerInc \' \
|
||||||
&& tee -a Launch.sh <<< '-drive if=pflash,format=raw,readonly,file=/home/arch/OSX-KVM/OVMF_CODE.fd \' \
|
&& tee -a Launch.sh <<< '-drive if=pflash,format=raw,readonly,file=/home/arch/OSX-KVM/OVMF_CODE.fd \' \
|
||||||
@ -191,7 +203,7 @@ RUN touch Launch.sh \
|
|||||||
&& tee -a Launch.sh <<< '-smbios type=2 \' \
|
&& tee -a Launch.sh <<< '-smbios type=2 \' \
|
||||||
&& tee -a Launch.sh <<< '-audiodev ${AUDIO_DRIVER:-alsa},id=hda -device ich9-intel-hda -device hda-duplex,audiodev=hda \' \
|
&& tee -a Launch.sh <<< '-audiodev ${AUDIO_DRIVER:-alsa},id=hda -device ich9-intel-hda -device hda-duplex,audiodev=hda \' \
|
||||||
&& tee -a Launch.sh <<< '-device ich9-ahci,id=sata \' \
|
&& tee -a Launch.sh <<< '-device ich9-ahci,id=sata \' \
|
||||||
&& tee -a Launch.sh <<< '-drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file=/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2 \' \
|
&& tee -a Launch.sh <<< '-drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file=${BOOTDISK:-/home/arch/OSX-KVM/OpenCore-Catalina/OpenCore.qcow2} \' \
|
||||||
&& tee -a Launch.sh <<< '-device ide-hd,bus=sata.2,drive=OpenCoreBoot \' \
|
&& tee -a Launch.sh <<< '-device ide-hd,bus=sata.2,drive=OpenCoreBoot \' \
|
||||||
&& tee -a Launch.sh <<< '-device ide-hd,bus=sata.3,drive=InstallMedia \' \
|
&& tee -a Launch.sh <<< '-device ide-hd,bus=sata.3,drive=InstallMedia \' \
|
||||||
&& tee -a Launch.sh <<< '-drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=qcow2 \' \
|
&& tee -a Launch.sh <<< '-drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=qcow2 \' \
|
||||||
|
@ -702,19 +702,19 @@
|
|||||||
<key>AdviseWindows</key>
|
<key>AdviseWindows</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>MLB</key>
|
<key>MLB</key>
|
||||||
<string>{{BOARD_SERIAL_OLD}}</string>
|
<string>{{BOARD_SERIAL}}</string>
|
||||||
<key>ROM</key>
|
<key>ROM</key>
|
||||||
<data>
|
<data>
|
||||||
{{ROM_OLD}}
|
{{ROM}}
|
||||||
</data>
|
</data>
|
||||||
<key>SpoofVendor</key>
|
<key>SpoofVendor</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>SystemProductName</key>
|
<key>SystemProductName</key>
|
||||||
<string>{{DEVICE_MODEL}}</string>
|
<string>{{DEVICE_MODEL}}</string>
|
||||||
<key>SystemSerialNumber</key>
|
<key>SystemSerialNumber</key>
|
||||||
<string>{{SERIAL_OLD}}</string>
|
<string>{{SERIAL}}</string>
|
||||||
<key>SystemUUID</key>
|
<key>SystemUUID</key>
|
||||||
<string>{{SYSTEM_UUID_OLD}}</string>
|
<string>{{UUID}}</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>UpdateDataHub</key>
|
<key>UpdateDataHub</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
@ -25,12 +25,12 @@ General options:
|
|||||||
--help, -h, help Display this help and exit
|
--help, -h, help Display this help and exit
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
./genboot.sh \\
|
./generate-specific-bootdisk.sh \
|
||||||
--model iMacPro1,1 \\
|
--model iMacPro1,1 \
|
||||||
--serial C02TW0WAHX87 \\
|
--serial C02TW0WAHX87 \
|
||||||
--board-serial C027251024NJG36UE \\
|
--board-serial C027251024NJG36UE \
|
||||||
--uuid 5CCB366D-9118-4C61-A00A-E5BAF3BED451 \\
|
--uuid 5CCB366D-9118-4C61-A00A-E5BAF3BED451 \
|
||||||
--mac-address A8:5C:2C:9A:46:2F \\
|
--mac-address A8:5C:2C:9A:46:2F \
|
||||||
--output-bootdisk OpenCore-nopicker.qcow2
|
--output-bootdisk OpenCore-nopicker.qcow2
|
||||||
|
|
||||||
Author: Sick.Codes https://sick.codes/
|
Author: Sick.Codes https://sick.codes/
|
||||||
@ -58,21 +58,21 @@ while (( "$#" )); do
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
--serial=* )
|
--serial=* )
|
||||||
export SERIAL_NUMBER="${1#*=}"
|
export SERIAL="${1#*=}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--serial* )
|
--serial* )
|
||||||
export SERIAL_NUMBER="${2}"
|
export SERIAL="${2}"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--board-serial=* )
|
--board-serial=* )
|
||||||
export BOARD_SERIAL_NUMBER="${1#*=}"
|
export BOARD_SERIAL="${1#*=}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--board-serial* )
|
--board-serial* )
|
||||||
export BOARD_SERIAL_NUMBER="${2}"
|
export BOARD_SERIAL="${2}"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
@ -142,25 +142,25 @@ generate_bootdisk () {
|
|||||||
[[ -e ./opencore-image-ng.sh ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/custom-identity/custom/opencore-image-ng.sh && chmod +x opencore-image-ng.sh
|
[[ -e ./opencore-image-ng.sh ]] || wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/custom-identity/custom/opencore-image-ng.sh && chmod +x opencore-image-ng.sh
|
||||||
# plist required for bootdisks, so create anyway.
|
# plist required for bootdisks, so create anyway.
|
||||||
if [[ "${DEVICE_MODEL}" ]] \
|
if [[ "${DEVICE_MODEL}" ]] \
|
||||||
&& [[ "${SERIAL_NUMBER}" ]] \
|
&& [[ "${SERIAL}" ]] \
|
||||||
&& [[ "${BOARD_SERIAL_NUMBER}" ]] \
|
&& [[ "${BOARD_SERIALR}" ]] \
|
||||||
&& [[ "${UUID}" ]] \
|
&& [[ "${UUID}" ]] \
|
||||||
&& [[ "${MAC_ADDRESS}" ]]; then
|
&& [[ "${MAC_ADDRESS}" ]]; then
|
||||||
ROM_VALUE="${MacAddress//\:/}"
|
ROM="${MAC_ADDRESS//\:/}"
|
||||||
ROM_VALUE="${ROM_VALUE,,}"
|
ROM="${ROM,,}"
|
||||||
sed -e s/{{DEVICE_MODEL}}/"${DEVICE_MODEL}"/g \
|
sed -e s/{{DEVICE_MODEL}}/"${DEVICE_MODEL}"/g \
|
||||||
-e s/{{SERIAL_OLD}}/"${SERIAL_NUMBER}"/g \
|
-e s/{{SERIAL}}/"${SERIAL}"/g \
|
||||||
-e s/{{BOARD_SERIAL_OLD}}/"${BOARD_SERIAL_NUMBER}"/g \
|
-e s/{{BOARD_SERIAL}}/"${BOARD_SERIAL}"/g \
|
||||||
-e s/{{SYSTEM_UUID_OLD}}/"${UUID}"/g \
|
-e s/{{UUID}}/"${UUID}"/g \
|
||||||
-e s/{{ROM_OLD}}/"${ROM_VALUE}"/g \
|
-e s/{{ROM}}/"${ROM}"/g \
|
||||||
"${PLIST_MASTER}" > ./tmp.config.plist || exit 1
|
"${PLIST_MASTER}" > ./tmp.config.plist || exit 1
|
||||||
else
|
else
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Error: one of the following values is missing:
|
Error: one of the following values is missing:
|
||||||
|
|
||||||
--model "${DEVICE_MODEL:-MISSING}"
|
--model "${DEVICE_MODEL:-MISSING}"
|
||||||
--serial "${SERIAL_NUMBER:-MISSING}"
|
--serial "${SERIAL:-MISSING}"
|
||||||
--board-serial "${BOARD_SERIAL_NUMBER:-MISSING}"
|
--board-serial "${BOARD_SERIAL:-MISSING}"
|
||||||
--uuid "${UUID:-MISSING}"
|
--uuid "${UUID:-MISSING}"
|
||||||
--mac-address "${MAC_ADDRESS:-MISSING}"
|
--mac-address "${MAC_ADDRESS:-MISSING}"
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ EOF
|
|||||||
|
|
||||||
./opencore-image-ng.sh \
|
./opencore-image-ng.sh \
|
||||||
--cfg "${INPUT_PLIST:-./tmp.config.plist}" \
|
--cfg "${INPUT_PLIST:-./tmp.config.plist}" \
|
||||||
--img "${OUTPUT_QCOW:-./${SERIAL_NUMBER}.OpenCore-nopicker.qcow2}" || exit 1
|
--img "${OUTPUT_QCOW:-./${SERIAL}.OpenCore-nopicker.qcow2}" || exit 1
|
||||||
rm ./tmp.config.plist
|
rm ./tmp.config.plist
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -201,65 +201,65 @@ generate_serial_sets () {
|
|||||||
./macserial \
|
./macserial \
|
||||||
--num "${SERIAL_SET_COUNT:=1}" \
|
--num "${SERIAL_SET_COUNT:=1}" \
|
||||||
--model "${DEVICE_MODEL}" \
|
--model "${DEVICE_MODEL}" \
|
||||||
| while IFS='\ \|\ ' read -r Serial BoardSerial; do
|
| while IFS='\ \|\ ' read -r SERIAL BOARD_SERIAL; do
|
||||||
# make a uuid...
|
# make a uuid...
|
||||||
SmUUID="$(uuidgen)"
|
UUID="$(uuidgen)"
|
||||||
SmUUID="${SmUUID^^}"
|
UUID="${UUID^^}"
|
||||||
|
|
||||||
# get a random vendor specific MAC address.
|
# get a random vendor specific MAC address.
|
||||||
RANDOM_MAC_PREFIX="$(grep -e "${VENDOR_REGEX}" < "${MAC_ADDRESSES_FILE:=vendor_macs.tsv}" | sort --random-sort | head -n1)"
|
RANDOM_MAC_PREFIX="$(grep -e "${VENDOR_REGEX}" < "${MAC_ADDRESSES_FILE:=vendor_macs.tsv}" | sort --random-sort | head -n1)"
|
||||||
RANDOM_MAC_PREFIX="$(cut -d$'\t' -f1 <<< "${RANDOM_MAC_PREFIX}")"
|
RANDOM_MAC_PREFIX="$(cut -d$'\t' -f1 <<< "${RANDOM_MAC_PREFIX}")"
|
||||||
MacAddress="$(printf "${RANDOM_MAC_PREFIX}:%02X:%02X:%02X" $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])"
|
MAC_ADDRESS="$(printf "${RANDOM_MAC_PREFIX}:%02X:%02X:%02X" $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])"
|
||||||
|
|
||||||
# append to csv file
|
# append to csv file
|
||||||
if [[ "${CSV_SERIAL_SETS_FILE}" ]]; then
|
if [[ "${CSV_SERIAL_SETS_FILE}" ]]; then
|
||||||
echo "\"${DEVICE_MODEL}\",\"${Serial}\",\"${BoardSerial}\",\"${SmUUID}\",\"${MacAddress}\"" >> "${CSV_SERIAL_SETS_FILE}"
|
echo "\"${DEVICE_MODEL}\",\"${SERIAL}\",\"${BOARD_SERIAL}\",\"${UUID}\",\"${MAC_ADDRESS}\"" >> "${CSV_SERIAL_SETS_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# append to tsv file
|
# append to tsv file
|
||||||
if [[ "${TSV_SERIAL_SETS_FILE}" ]]; then
|
if [[ "${TSV_SERIAL_SETS_FILE}" ]]; then
|
||||||
printf "${DEVICE_MODEL}\t${Serial}\t${BoardSerial}\t${SmUUID}\t${MacAddress}\n" >> "${TSV_SERIAL_SETS_FILE}"
|
printf "${DEVICE_MODEL}\t${SERIAL}\t${BOARD_SERIAL}\t${UUID}\t${MAC_ADDRESS}\n" >> "${TSV_SERIAL_SETS_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
OUTPUT_ENV_FILE="${OUTPUT_ENV:-"${OUTPUT_DIRECTORY}/envs/${Serial}.env.sh"}"
|
OUTPUT_ENV_FILE="${OUTPUT_ENV:-"${OUTPUT_DIRECTORY}/envs/${SERIAL}.env.sh"}"
|
||||||
touch "${OUTPUT_ENV_FILE}"
|
touch "${OUTPUT_ENV_FILE}"
|
||||||
cat <<EOF > "${OUTPUT_ENV_FILE}"
|
cat <<EOF > "${OUTPUT_ENV_FILE}"
|
||||||
export Type=${DEVICE_MODEL}
|
export DEVICE_MODEL="${DEVICE_MODEL}"
|
||||||
export Serial=${Serial}
|
export SERIAL="${SERIAL}"
|
||||||
export BoardSerial=${BoardSerial}
|
export BOARD_SERIAL="${BOARD_SERIAL}"
|
||||||
export SmUUID=${SmUUID}
|
export UUID="${UUID}"
|
||||||
export MacAddress=${MacAddress}
|
export MAC_ADDRESS="${MAC_ADDRESS}"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# plist required for bootdisks, so create anyway.
|
# plist required for bootdisks, so create anyway.
|
||||||
if [[ "${CREATE_PLISTS}" ]] || [[ "${CREATE_QCOWS}" ]]; then
|
if [[ "${CREATE_PLISTS}" ]] || [[ "${CREATE_QCOWS}" ]]; then
|
||||||
mkdir -p "${OUTPUT_DIRECTORY}/plists"
|
mkdir -p "${OUTPUT_DIRECTORY}/plists"
|
||||||
source "${OUTPUT_ENV_FILE}"
|
source "${OUTPUT_ENV_FILE}"
|
||||||
ROM_VALUE="${MacAddress//\:/}"
|
ROM_VALUE="${MAC_ADDRESS//\:/}"
|
||||||
ROM_VALUE="${ROM_VALUE,,}"
|
ROM_VALUE="${ROM_VALUE,,}"
|
||||||
sed -e s/{{DEVICE_MODEL}}/"${Type}"/g \
|
sed -e s/{{DEVICE_MODEL}}/"${DEVICE_MODEL}"/g \
|
||||||
-e s/{{SERIAL_OLD}}/"${Serial}"/g \
|
-e s/{{SERIAL}}/"${SERIAL}"/g \
|
||||||
-e s/{{BOARD_SERIAL_OLD}}/"${BoardSerial}"/g \
|
-e s/{{BOARD_SERIAL}}/"${BOARD_SERIAL}"/g \
|
||||||
-e s/{{SYSTEM_UUID_OLD}}/"${SmUUID}"/g \
|
-e s/{{UUID}}/"${UUID}"/g \
|
||||||
-e s/{{ROM_OLD}}/"${ROM_VALUE}"/g \
|
-e s/{{ROM}}/"${ROM}"/g \
|
||||||
"${PLIST_MASTER}" > "${OUTPUT_DIRECTORY}/plists/${Serial}.config.plist" || exit 1
|
"${PLIST_MASTER}" > "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${CREATE_QCOWS}" ]]; then
|
if [[ "${CREATE_QCOWS}" ]]; then
|
||||||
mkdir -p "${OUTPUT_DIRECTORY}/qcows"
|
mkdir -p "${OUTPUT_DIRECTORY}/qcows"
|
||||||
./opencore-image-ng.sh \
|
./opencore-image-ng.sh \
|
||||||
--cfg "${OUTPUT_DIRECTORY}/plists/${Serial}.config.plist" \
|
--cfg "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" \
|
||||||
--img "${OUTPUT_QCOW:-${OUTPUT_DIRECTORY}/qcows/${Serial}.OpenCore-nopicker.qcow2}" || exit 1
|
--img "${OUTPUT_QCOW:-${OUTPUT_DIRECTORY}/qcows/${SERIAL}.OpenCore-nopicker.qcow2}" || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ -e "${CSV_SERIAL_SETS_FILE}" ]] && \
|
[[ -e "${CSV_SERIAL_SETS_FILE}" ]] && \
|
||||||
cat <(echo "Type,Serial,BoardSerial,SmUUID,MacAddress") "${CSV_SERIAL_SETS_FILE}"
|
cat <(echo "DEVICE_MODEL,SERIAL,BOARD_SERIAL,UUID,MAC_ADDRESS") "${CSV_SERIAL_SETS_FILE}"
|
||||||
|
|
||||||
|
|
||||||
[[ -e "${TSV_SERIAL_SETS_FILE}" ]] && \
|
[[ -e "${TSV_SERIAL_SETS_FILE}" ]] && \
|
||||||
cat <(printf "Type\tSerial\tBoardSerial\tSmUUID\tMacAddress\n") "${TSV_SERIAL_SETS_FILE}"
|
cat <(printf "DEVICE_MODEL\tSERIAL\BOARD_SERIAL\tUUID\tMAC_ADDRESS\n") "${TSV_SERIAL_SETS_FILE}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,21 +89,22 @@ function fish_fini() {
|
|||||||
fish umount-all
|
fish umount-all
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# disabled by sick.codes to allow unattended image overwrites
|
||||||
######################################################################
|
######################################################################
|
||||||
# sanity checks
|
# sanity checks
|
||||||
|
|
||||||
if test ! -f "$cfg"; then
|
# if test ! -f "$cfg"; then
|
||||||
echo "ERROR: cfg not found: $cfg"
|
# echo "ERROR: cfg not found: $cfg"
|
||||||
exit 1
|
# exit 1
|
||||||
fi
|
# fi
|
||||||
if test -f "$img"; then
|
# if test -f "$img"; then
|
||||||
if test "$allow_override" = "yes"; then
|
# if test "$allow_override" = "yes"; then
|
||||||
rm -f "$img"
|
# rm -f "$img"
|
||||||
else
|
# else
|
||||||
echo "ERROR: image exists: $img"
|
# echo "ERROR: image exists: $img"
|
||||||
exit 1
|
# exit 1
|
||||||
fi
|
# fi
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# go!
|
# go!
|
||||||
|
Loading…
Reference in New Issue
Block a user