Ship the Linux Preset Caches Before Packing the AppImage (#17485)

This commit is contained in:
HanifKoh authored and GitHub committed 2026-11-16 13:49:03 +08:00
1 parent cbf282e6b3
commit 191760b5cb
5 files changed
+69 -61

No files matched your search

+4 -20
View File
@@ -770,7 +770,8 @@ jobs:
run: |
# Build + tar the unit tests (-t) on both Linux legs so each arch
# (x86_64 + aarch64) gets tested by its own unit_tests_linux_* job.
./build_linux.sh -istrlL
# -P ships the system preset caches into the package before the AppImage is packed from it.
./build_linux.sh -istrlLP
./scripts/check_appimage_libs.sh ./build/package ./build/package/bin/orca-slicer
appimage=./build/OrcaSlicer_Linux_AppImage${{ env.ubuntu-ver-str }}${{ env.arch_suffix }}_${{ env.ver }}.AppImage
mv -n ./build/OrcaSlicer_Linux_V${{ env.ver_pure }}.AppImage "$appimage"
@@ -790,23 +791,6 @@ jobs:
retention-days: 5
if-no-files-found: error
- name: Build system preset cache (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
# Both were packed from resources/ before the caches existed, so the
# AppImage is unpacked first and the caches shipped into it and into
# the package tree; the source tree keeps its JSONs for later steps.
appimage=$(find build -maxdepth 1 -name "OrcaSlicer_Linux_AppImage*.AppImage" | head -1)
chmod +x "$appimage"
"$appimage" --appimage-extract
./scripts/build_preset_cache.sh -b build build/package/resources/profiles squashfs-root/resources/profiles
# The runtime extracts every directory as 0700, and appimagetool (continuous
# build 333 onwards) refuses to pack a tree other users cannot read.
chmod -R a+rX squashfs-root
appimagetool=$(find build -name "appimagetool.AppImage" | head -1)
ARCH=$(uname -m) "$appimagetool" --appimage-extract-and-run squashfs-root "$appimage"
rm -rf squashfs-root
# Ship the freshly-built validator so slice_check_linux (build_all.yml)
# can slice-sweep the shipped profiles with this PR's engine. Taken from
# the aarch64 leg so the sweep also exercises the arm build; x86_64 on
@@ -855,8 +839,8 @@ jobs:
path: './build/src/Release/OrcaSlicer_profile_validator'
# generate_system_cache is what scripts/build_preset_cache.sh bakes the
# <vendor>.opc caches with; it was already built by the "Build system
# preset cache (Linux)" step above. The .opc format is 64-bit
# <vendor>.opc caches with; build_linux.sh -P already built it to ship the
# caches in the package. The .opc format is 64-bit
# little-endian native, i.e. identical across every platform Orca ships,
# so only the Linux binary is published.
- name: Upload generate_system_cache Ubuntu
+13 -5
View File
@@ -8,7 +8,7 @@ SCRIPT_PATH=$(dirname "$(readlink -f "${0}")")
pushd "${SCRIPT_PATH}" > /dev/null
function usage() {
echo "Usage: ./${SCRIPT_NAME} [-1][-b][-c][-d][-D][-e][-F][-g][-h][-i][-j N][-J N][-p][-r][-s][-t][-u][-l][-L] [-- CMAKE_ARGS...]"
echo "Usage: ./${SCRIPT_NAME} [-1][-b][-c][-d][-D][-e][-F][-g][-h][-i][-j N][-J N][-p][-P][-r][-s][-t][-u][-l][-L] [-- CMAKE_ARGS...]"
echo " -1: limit builds to one core (where possible)"
echo " -j N: limit builds to N cores (where possible)"
echo " -J N: build up to N dependencies at a time, each still using -j jobs (default: 1)"
@@ -23,6 +23,7 @@ function usage() {
echo " -h: prints this help text"
echo " -i: build the Orca Slicer AppImage (optional)"
echo " -p: disable precompiled headers (on by default): more ccache hits after header changes, slower misses"
echo " -P: ship the system preset caches in the package and AppImage, deleting the preset JSONs they replace (CI packaging)"
echo " -r: skip RAM and disk checks (low RAM compiling)"
echo " -s: build the Orca Slicer (optional)"
echo " -t: build tests (optional), requires -s flag"
@@ -47,7 +48,7 @@ unset name
BUILD_DIR=build
BUILD_CONFIG=Release
FORWARDED_ARGS=()
while getopts ":1j:J:bcCdDeFghiprstulL" opt ; do
while getopts ":1j:J:bcCdDeFghipPrstulL" opt ; do
case ${opt} in
1 )
export CMAKE_BUILD_PARALLEL_LEVEL=1
@@ -104,6 +105,10 @@ while getopts ":1j:J:bcCdDeFghiprstulL" opt ; do
SLIC3R_PRECOMPILED_HEADERS="OFF"
FORWARDED_ARGS+=("-p")
;;
P )
SHIP_PRESET_CACHES="1"
FORWARDED_ARGS+=("-P")
;;
r )
SKIP_RAM_CHECK="1"
FORWARDED_ARGS+=("-r")
@@ -648,11 +653,14 @@ if [[ -n "${BUILD_IMAGE}" || -n "${BUILD_ORCA}" ]] ; then
pushd $BUILD_DIR > /dev/null
build_linux_image="./src/build_linux_image.sh"
if [[ -e ${build_linux_image} ]] ; then
extra_script_args=""
extra_script_args=()
if [[ -n "${BUILD_IMAGE}" ]] ; then
extra_script_args="-i"
extra_script_args+=("-i")
fi
print_and_run ${build_linux_image} ${extra_script_args} -R "${BUILD_CONFIG}"
if [[ -n "${SHIP_PRESET_CACHES}" ]] ; then
extra_script_args+=("-c")
fi
print_and_run ${build_linux_image} "${extra_script_args[@]}" -R "${BUILD_CONFIG}"
echo "done"
fi
+2 -1
View File
@@ -358,7 +358,8 @@ step, not something a build should do to a working tree by surprise: the Windows
refuses that target unless given `--prune-source`, and CI passes it.
Generation runs after the build, in the same job, so the caches ship with a build that
can read them.
can read them. On Linux it runs while the package tree is staged (`build_linux.sh -P`), so
the AppImage is packed from a tree that already holds them.
The flatpak differs only in where the script is called from. Nothing outside
flatpak-builder ever builds it, so there is no packaged tree for the workflow to point
+38 -33
View File
@@ -89,17 +89,43 @@ find_tool() {
printf '%s' "$best"
}
# The preset files a vendor profile lists, relative to its vendor directory, one
# per line. Nothing when the profile is missing.
listed_presets() {
[ -f "$1" ] || return 0
python3 - "$1" <<'EOF'
import json, sys
with open(sys.argv[1], encoding="utf-8") as f:
profile = json.load(f)
for key in ("machine_model_list", "process_list", "filament_list", "machine_list"):
for entry in profile.get(key, []):
print(entry["sub_path"])
# Prune one profiles directory for every vendor that has a cache in the first:
# drop the vendor profile, the preset files it lists, and the directories that
# leaves empty. One process for all vendors; starting one per vendor dominated
# the run.
prune_cached_presets() {
python3 - "$1" "$2" <<'EOF'
import json, os, sys
caches_dir, target = sys.argv[1:3]
shipped = pruned = 0
for name in sorted(os.listdir(caches_dir)):
if not name.endswith(".opc"):
continue
vendor = name[:-len(".opc")]
shipped += 1
# Read the list from the target's own profile, before it goes: the source
# profile may already be gone when an earlier target pruned it.
profile_path = os.path.join(target, vendor + ".json")
listed = []
if os.path.isfile(profile_path):
with open(profile_path, encoding="utf-8") as f:
profile = json.load(f)
for key in ("machine_model_list", "process_list", "filament_list", "machine_list"):
listed += [entry["sub_path"] for entry in profile.get(key, [])]
os.remove(profile_path)
pruned += 1
vendor_dir = os.path.join(target, vendor)
if not os.path.isdir(vendor_dir):
continue
for sub_path in listed:
path = vendor_dir + "/" + sub_path # not os.path.join: an absolute sub_path stays inside
if sub_path and os.path.isfile(path):
os.remove(path)
pruned += 1
for root, _, _ in os.walk(vendor_dir, topdown=False):
if not os.listdir(root):
os.rmdir(root)
print(f"{target}: {shipped} caches, dropped {pruned} preset JSONs")
EOF
}
@@ -158,26 +184,5 @@ for target in "$@"; do
cp "$profiles_dir"/*.opc "$resolved"/
fi
pruned=0
shipped=0
for cache in "$profiles_dir"/*.opc; do
vendor=$(basename "$cache" .opc)
shipped=$(( shipped + 1 ))
# Read the list from the target's own profile, before it goes: the
# source profile may already be gone when an earlier target pruned it.
listed=$(listed_presets "$resolved/$vendor.json")
if [ -f "$resolved/$vendor.json" ]; then
rm -f "$resolved/$vendor.json"
pruned=$(( pruned + 1 ))
fi
[ -d "$resolved/$vendor" ] || continue
while IFS= read -r sub_path; do
if [ -n "$sub_path" ] && [ -f "$resolved/$vendor/$sub_path" ]; then
rm -f "$resolved/$vendor/$sub_path"
pruned=$(( pruned + 1 ))
fi
done <<< "$listed"
find "$resolved/$vendor" -type d -empty -delete
done
echo "$resolved: $shipped caches, dropped $pruned preset JSONs"
prune_cached_presets "$profiles_dir" "$resolved"
done
@@ -22,13 +22,17 @@ fi
# shellcheck source=/dev/null
source "${POLICY_FILE}"
while getopts ":ihR:" opt; do
while getopts ":ichR:" opt; do
case ${opt} in
i )
export BUILD_IMAGE="1"
;;
h ) echo "Usage: ./build_linux_image.sh [-i][-R config]"
c )
SHIP_PRESET_CACHES="1"
;;
h ) echo "Usage: ./build_linux_image.sh [-i][-c][-R config]"
echo " -i: Generate Appimage (optional)"
echo " -c: Ship the system preset caches, deleting the preset JSONs they replace"
echo " -R: Specify from which config to obtain the binary: Release, RelWithDebInfo, or Debug"
exit 1
;;
@@ -185,6 +189,12 @@ echo -n "[9/9] Generating Linux app..."
fi
cp -Rf ../resources "$APPDIR/resources"
# Before the AppImage is packed from this tree, so it ships the caches without a repack.
if [ -n "$SHIP_PRESET_CACHES" ]; then
# Caches copied in with resources may be stale; the script ships a fresh set.
rm -f "$APPDIR/resources/profiles"/*.opc
"${REPO_ROOT}/scripts/build_preset_cache.sh" -b . -c "$CONFIG" "$APPDIR/resources/profiles"
fi
ORIGINAL_BINARY_LOCATION=""
if [ -f "src/${CONFIG}/@SLIC3R_APP_CMD@" ]; then