mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
buildsystem: be more cautious when overwriting package cache files
This commit is contained in:
parent
84c634a8ce
commit
76067bdf80
@ -478,33 +478,46 @@ debug_strip() {
|
|||||||
|
|
||||||
init_package_cache() {
|
init_package_cache() {
|
||||||
local _ANCHOR="@?+?@" DIR
|
local _ANCHOR="@?+?@" DIR
|
||||||
|
local temp_global temp_local
|
||||||
|
|
||||||
# If the package caches are unset, then populate them
|
# If the package caches are unset, then populate them
|
||||||
if [ -z "${_CACHE_PACKAGE_LOCAL}" -o -z "${_CACHE_PACKAGE_GLOBAL}" ]; then
|
if [ -z "${_CACHE_PACKAGE_LOCAL}" -o -z "${_CACHE_PACKAGE_GLOBAL}" ]; then
|
||||||
_CACHE_PACKAGE_LOCAL="${BUILD}/.cache_package_local"
|
temp_global="$(mktemp)"
|
||||||
_CACHE_PACKAGE_GLOBAL="${BUILD}/.cache_package_global"
|
temp_local="$(mktemp)"
|
||||||
mkdir -p "${BUILD}"
|
|
||||||
: > "${_CACHE_PACKAGE_LOCAL}"
|
|
||||||
: > "${_CACHE_PACKAGE_GLOBAL}"
|
|
||||||
|
|
||||||
# cache project/device folder for a package
|
# cache project/device folder for a package
|
||||||
if [ -n $DEVICE ]; then
|
if [ -n $DEVICE ]; then
|
||||||
for DIR in $(find $ROOT/projects/$PROJECT/devices/$DEVICE/packages -type d 2>/dev/null); do
|
for DIR in $(find $ROOT/projects/$PROJECT/devices/$DEVICE/packages -type d 2>/dev/null); do
|
||||||
[ -r "$DIR/package.mk" ] && echo "${DIR}${_ANCHOR}" >> "${_CACHE_PACKAGE_LOCAL}"
|
[ -r "$DIR/package.mk" ] && echo "${DIR}${_ANCHOR}" >> "${temp_local}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# cache project folder for a package
|
# cache project folder for a package
|
||||||
for DIR in $(find $ROOT/projects/$PROJECT/packages -type d 2>/dev/null); do
|
for DIR in $(find $ROOT/projects/$PROJECT/packages -type d 2>/dev/null); do
|
||||||
[ -r "$DIR/package.mk" ] && echo "${DIR}${_ANCHOR}" >> "${_CACHE_PACKAGE_LOCAL}"
|
[ -r "$DIR/package.mk" ] && echo "${DIR}${_ANCHOR}" >> "${temp_local}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# cache packages folder
|
# cache packages folder
|
||||||
for DIR in $(find $ROOT/$PACKAGES -type d 2>/dev/null); do
|
for DIR in $(find $ROOT/$PACKAGES -type d 2>/dev/null); do
|
||||||
[ -r "$DIR/package.mk" ] && echo "${DIR}${_ANCHOR}" >> "${_CACHE_PACKAGE_GLOBAL}"
|
[ -r "$DIR/package.mk" ] && echo "${DIR}${_ANCHOR}" >> "${temp_global}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
_CACHE_PACKAGE_LOCAL="${BUILD}/.cache_package_local"
|
||||||
|
_CACHE_PACKAGE_GLOBAL="${BUILD}/.cache_package_global"
|
||||||
export _CACHE_PACKAGE_LOCAL _CACHE_PACKAGE_GLOBAL
|
export _CACHE_PACKAGE_LOCAL _CACHE_PACKAGE_GLOBAL
|
||||||
|
|
||||||
|
# overwrite existing cache files only when they are invalid, or not yet created
|
||||||
|
mkdir -p "$(dirname "${_CACHE_PACKAGE_GLOBAL}")"
|
||||||
|
if [ -f "${_CACHE_PACKAGE_LOCAL}" ] && cmp -s "${temp_local}" "${_CACHE_PACKAGE_LOCAL}"; then
|
||||||
|
rm "${temp_local}"
|
||||||
|
else
|
||||||
|
mv "${temp_local}" "${_CACHE_PACKAGE_LOCAL}"
|
||||||
|
fi
|
||||||
|
if [ -f "${_CACHE_PACKAGE_GLOBAL}" ] && cmp -s "${temp_global}" "${_CACHE_PACKAGE_GLOBAL}"; then
|
||||||
|
rm "${temp_global}"
|
||||||
|
else
|
||||||
|
mv "${temp_global}" "${_CACHE_PACKAGE_GLOBAL}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user