mirror of
https://github.com/sickcodes/Docker-OSX.git
synced 2024-11-29 14:05:51 +08: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
|
||||
|
||||
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 \
|
||||
&& chmod +x ./Launch.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 <<< '-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 <<< '-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 <<< '-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 \' \
|
||||
@ -191,7 +203,7 @@ RUN touch Launch.sh \
|
||||
&& 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 <<< '-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.3,drive=InstallMedia \' \
|
||||
&& 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>
|
||||
<false/>
|
||||
<key>MLB</key>
|
||||
<string>{{BOARD_SERIAL_OLD}}</string>
|
||||
<string>{{BOARD_SERIAL}}</string>
|
||||
<key>ROM</key>
|
||||
<data>
|
||||
{{ROM_OLD}}
|
||||
{{ROM}}
|
||||
</data>
|
||||
<key>SpoofVendor</key>
|
||||
<true/>
|
||||
<key>SystemProductName</key>
|
||||
<string>{{DEVICE_MODEL}}</string>
|
||||
<key>SystemSerialNumber</key>
|
||||
<string>{{SERIAL_OLD}}</string>
|
||||
<string>{{SERIAL}}</string>
|
||||
<key>SystemUUID</key>
|
||||
<string>{{SYSTEM_UUID_OLD}}</string>
|
||||
<string>{{UUID}}</string>
|
||||
</dict>
|
||||
<key>UpdateDataHub</key>
|
||||
<true/>
|
||||
|
@ -25,12 +25,12 @@ General options:
|
||||
--help, -h, help Display this help and exit
|
||||
|
||||
Example:
|
||||
./genboot.sh \\
|
||||
--model iMacPro1,1 \\
|
||||
--serial C02TW0WAHX87 \\
|
||||
--board-serial C027251024NJG36UE \\
|
||||
--uuid 5CCB366D-9118-4C61-A00A-E5BAF3BED451 \\
|
||||
--mac-address A8:5C:2C:9A:46:2F \\
|
||||
./generate-specific-bootdisk.sh \
|
||||
--model iMacPro1,1 \
|
||||
--serial C02TW0WAHX87 \
|
||||
--board-serial C027251024NJG36UE \
|
||||
--uuid 5CCB366D-9118-4C61-A00A-E5BAF3BED451 \
|
||||
--mac-address A8:5C:2C:9A:46:2F \
|
||||
--output-bootdisk OpenCore-nopicker.qcow2
|
||||
|
||||
Author: Sick.Codes https://sick.codes/
|
||||
@ -58,21 +58,21 @@ while (( "$#" )); do
|
||||
;;
|
||||
|
||||
--serial=* )
|
||||
export SERIAL_NUMBER="${1#*=}"
|
||||
export SERIAL="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--serial* )
|
||||
export SERIAL_NUMBER="${2}"
|
||||
export SERIAL="${2}"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
|
||||
--board-serial=* )
|
||||
export BOARD_SERIAL_NUMBER="${1#*=}"
|
||||
export BOARD_SERIAL="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--board-serial* )
|
||||
export BOARD_SERIAL_NUMBER="${2}"
|
||||
export BOARD_SERIAL="${2}"
|
||||
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
|
||||
# plist required for bootdisks, so create anyway.
|
||||
if [[ "${DEVICE_MODEL}" ]] \
|
||||
&& [[ "${SERIAL_NUMBER}" ]] \
|
||||
&& [[ "${BOARD_SERIAL_NUMBER}" ]] \
|
||||
&& [[ "${SERIAL}" ]] \
|
||||
&& [[ "${BOARD_SERIALR}" ]] \
|
||||
&& [[ "${UUID}" ]] \
|
||||
&& [[ "${MAC_ADDRESS}" ]]; then
|
||||
ROM_VALUE="${MacAddress//\:/}"
|
||||
ROM_VALUE="${ROM_VALUE,,}"
|
||||
ROM="${MAC_ADDRESS//\:/}"
|
||||
ROM="${ROM,,}"
|
||||
sed -e s/{{DEVICE_MODEL}}/"${DEVICE_MODEL}"/g \
|
||||
-e s/{{SERIAL_OLD}}/"${SERIAL_NUMBER}"/g \
|
||||
-e s/{{BOARD_SERIAL_OLD}}/"${BOARD_SERIAL_NUMBER}"/g \
|
||||
-e s/{{SYSTEM_UUID_OLD}}/"${UUID}"/g \
|
||||
-e s/{{ROM_OLD}}/"${ROM_VALUE}"/g \
|
||||
-e s/{{SERIAL}}/"${SERIAL}"/g \
|
||||
-e s/{{BOARD_SERIAL}}/"${BOARD_SERIAL}"/g \
|
||||
-e s/{{UUID}}/"${UUID}"/g \
|
||||
-e s/{{ROM}}/"${ROM}"/g \
|
||||
"${PLIST_MASTER}" > ./tmp.config.plist || exit 1
|
||||
else
|
||||
cat <<EOF
|
||||
Error: one of the following values is missing:
|
||||
|
||||
--model "${DEVICE_MODEL:-MISSING}"
|
||||
--serial "${SERIAL_NUMBER:-MISSING}"
|
||||
--board-serial "${BOARD_SERIAL_NUMBER:-MISSING}"
|
||||
--serial "${SERIAL:-MISSING}"
|
||||
--board-serial "${BOARD_SERIAL:-MISSING}"
|
||||
--uuid "${UUID:-MISSING}"
|
||||
--mac-address "${MAC_ADDRESS:-MISSING}"
|
||||
|
||||
@ -170,7 +170,7 @@ EOF
|
||||
|
||||
./opencore-image-ng.sh \
|
||||
--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
|
||||
|
||||
}
|
||||
|
@ -201,65 +201,65 @@ generate_serial_sets () {
|
||||
./macserial \
|
||||
--num "${SERIAL_SET_COUNT:=1}" \
|
||||
--model "${DEVICE_MODEL}" \
|
||||
| while IFS='\ \|\ ' read -r Serial BoardSerial; do
|
||||
| while IFS='\ \|\ ' read -r SERIAL BOARD_SERIAL; do
|
||||
# make a uuid...
|
||||
SmUUID="$(uuidgen)"
|
||||
SmUUID="${SmUUID^^}"
|
||||
UUID="$(uuidgen)"
|
||||
UUID="${UUID^^}"
|
||||
|
||||
# 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="$(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
|
||||
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
|
||||
|
||||
# append to tsv file
|
||||
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
|
||||
|
||||
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}"
|
||||
cat <<EOF > "${OUTPUT_ENV_FILE}"
|
||||
export Type=${DEVICE_MODEL}
|
||||
export Serial=${Serial}
|
||||
export BoardSerial=${BoardSerial}
|
||||
export SmUUID=${SmUUID}
|
||||
export MacAddress=${MacAddress}
|
||||
export DEVICE_MODEL="${DEVICE_MODEL}"
|
||||
export SERIAL="${SERIAL}"
|
||||
export BOARD_SERIAL="${BOARD_SERIAL}"
|
||||
export UUID="${UUID}"
|
||||
export MAC_ADDRESS="${MAC_ADDRESS}"
|
||||
EOF
|
||||
|
||||
# plist required for bootdisks, so create anyway.
|
||||
if [[ "${CREATE_PLISTS}" ]] || [[ "${CREATE_QCOWS}" ]]; then
|
||||
mkdir -p "${OUTPUT_DIRECTORY}/plists"
|
||||
source "${OUTPUT_ENV_FILE}"
|
||||
ROM_VALUE="${MacAddress//\:/}"
|
||||
ROM_VALUE="${MAC_ADDRESS//\:/}"
|
||||
ROM_VALUE="${ROM_VALUE,,}"
|
||||
sed -e s/{{DEVICE_MODEL}}/"${Type}"/g \
|
||||
-e s/{{SERIAL_OLD}}/"${Serial}"/g \
|
||||
-e s/{{BOARD_SERIAL_OLD}}/"${BoardSerial}"/g \
|
||||
-e s/{{SYSTEM_UUID_OLD}}/"${SmUUID}"/g \
|
||||
-e s/{{ROM_OLD}}/"${ROM_VALUE}"/g \
|
||||
"${PLIST_MASTER}" > "${OUTPUT_DIRECTORY}/plists/${Serial}.config.plist" || exit 1
|
||||
sed -e s/{{DEVICE_MODEL}}/"${DEVICE_MODEL}"/g \
|
||||
-e s/{{SERIAL}}/"${SERIAL}"/g \
|
||||
-e s/{{BOARD_SERIAL}}/"${BOARD_SERIAL}"/g \
|
||||
-e s/{{UUID}}/"${UUID}"/g \
|
||||
-e s/{{ROM}}/"${ROM}"/g \
|
||||
"${PLIST_MASTER}" > "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" || exit 1
|
||||
fi
|
||||
|
||||
if [[ "${CREATE_QCOWS}" ]]; then
|
||||
mkdir -p "${OUTPUT_DIRECTORY}/qcows"
|
||||
./opencore-image-ng.sh \
|
||||
--cfg "${OUTPUT_DIRECTORY}/plists/${Serial}.config.plist" \
|
||||
--img "${OUTPUT_QCOW:-${OUTPUT_DIRECTORY}/qcows/${Serial}.OpenCore-nopicker.qcow2}" || exit 1
|
||||
--cfg "${OUTPUT_DIRECTORY}/plists/${SERIAL}.config.plist" \
|
||||
--img "${OUTPUT_QCOW:-${OUTPUT_DIRECTORY}/qcows/${SERIAL}.OpenCore-nopicker.qcow2}" || exit 1
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
[[ -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}" ]] && \
|
||||
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
|
||||
}
|
||||
|
||||
# disabled by sick.codes to allow unattended image overwrites
|
||||
######################################################################
|
||||
# sanity checks
|
||||
|
||||
if test ! -f "$cfg"; then
|
||||
echo "ERROR: cfg not found: $cfg"
|
||||
exit 1
|
||||
fi
|
||||
if test -f "$img"; then
|
||||
if test "$allow_override" = "yes"; then
|
||||
rm -f "$img"
|
||||
else
|
||||
echo "ERROR: image exists: $img"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# if test ! -f "$cfg"; then
|
||||
# echo "ERROR: cfg not found: $cfg"
|
||||
# exit 1
|
||||
# fi
|
||||
# if test -f "$img"; then
|
||||
# if test "$allow_override" = "yes"; then
|
||||
# rm -f "$img"
|
||||
# else
|
||||
# echo "ERROR: image exists: $img"
|
||||
# exit 1
|
||||
# fi
|
||||
# fi
|
||||
|
||||
######################################################################
|
||||
# go!
|
||||
|
Loading…
Reference in New Issue
Block a user