mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-19 09:39:15 +00:00
CI: Add wrapper function for macOS disk image operations
As not only detaching but apparently all operations of hdiutil can be blocked by slow disk I/O on CI runners, this wraps all invocations of it in a helper function that attempts up to 5 retries with a backoff timer.
This commit is contained in:
parent
b5c5f71cee
commit
7ece5cd057
59
.github/scripts/utils.zsh/create_diskimage
vendored
59
.github/scripts/utils.zsh/create_diskimage
vendored
|
@ -19,16 +19,46 @@ log_group "Create macOS disk image"
|
||||||
local _hdiutil_flags
|
local _hdiutil_flags
|
||||||
if (( _loglevel < 1 )) _hdiutil_flags='-quiet'
|
if (( _loglevel < 1 )) _hdiutil_flags='-quiet'
|
||||||
|
|
||||||
trap "hdiutil detach ${_hdiutil_flags} /Volumes/${output_name}; rm temp.dmg; log_group; return 2" ERR
|
trap "safe_hdiutil detach ${_hdiutil_flags} /Volumes/${output_name}; rm temp.dmg; log_group; return 2" ERR
|
||||||
|
|
||||||
hdiutil create ${_hdiutil_flags} \
|
safe_hdiutil() {
|
||||||
|
local _status=0
|
||||||
|
local -r -a _backoff=(2 5 10 15 30)
|
||||||
|
|
||||||
|
for i ({1..5}) {
|
||||||
|
if [[ ${1} == detach ]] {
|
||||||
|
if ! [[ -d ${@[-1]} ]] {
|
||||||
|
log_warning "Volume at mountpoint ${@[-1]} is not mounted anymore. Continuing."
|
||||||
|
_status=0
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hdiutil ${@} && _status=0 || _status=1
|
||||||
|
|
||||||
|
if (( _status )) {
|
||||||
|
log_warning "Unable to run 'hdiutil ${@}' (attempt #${i}). Retrying."
|
||||||
|
sleep ${_backoff[${i}]}
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (( _status )) {
|
||||||
|
log_error "Unable to run 'hdiutil ${@}'. Aborting"
|
||||||
|
log_group
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
safe_hdiutil create ${_hdiutil_flags} \
|
||||||
-volname "${volume_name}" \
|
-volname "${volume_name}" \
|
||||||
-srcfolder ${source} \
|
-srcfolder ${source} \
|
||||||
-ov \
|
-ov \
|
||||||
-fs APFS \
|
-fs APFS \
|
||||||
-format UDRW \
|
-format UDRW \
|
||||||
temp.dmg
|
temp.dmg
|
||||||
hdiutil attach ${_hdiutil_flags} \
|
safe_hdiutil attach ${_hdiutil_flags} \
|
||||||
-noverify \
|
-noverify \
|
||||||
-readwrite \
|
-readwrite \
|
||||||
-mountpoint /Volumes/${output_name} \
|
-mountpoint /Volumes/${output_name} \
|
||||||
|
@ -48,28 +78,9 @@ SetFile -a C /Volumes/${output_name}
|
||||||
rm -rf -- /Volumes/${output_name}/.fseventsd(N)
|
rm -rf -- /Volumes/${output_name}/.fseventsd(N)
|
||||||
log_info "Converting disk image..."
|
log_info "Converting disk image..."
|
||||||
|
|
||||||
if (( ${+CI} )) {
|
safe_hdiutil detach ${_hdiutil_flags} /Volumes/${output_name}
|
||||||
local _status=0
|
|
||||||
for i ({1..5}) {
|
|
||||||
hdiutil detach ${_hdiutil_flags} /Volumes/${output_name} && _status=0 || _status=1
|
|
||||||
|
|
||||||
if (( _status )) {
|
safe_hdiutil convert ${_hdiutil_flags} \
|
||||||
log_warning "Unable to eject disk image (attempt #${i}). Retrying."
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (( _status )) {
|
|
||||||
log_error "Unable to eject disk image after 5 attempts. Aborting"
|
|
||||||
log_group
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
hdiutil detach ${_hdiutil_flags} /Volumes/${output_name}
|
|
||||||
}
|
|
||||||
|
|
||||||
hdiutil convert ${_hdiutil_flags} \
|
|
||||||
-format ULMO \
|
-format ULMO \
|
||||||
-ov \
|
-ov \
|
||||||
-o ${output_name}.dmg temp.dmg
|
-o ${output_name}.dmg temp.dmg
|
||||||
|
|
Loading…
Reference in a new issue