@@ -22,7 +22,8 @@ function check_available_memory_and_disk() {
2222 FREE_DISK_KB=$( df -k . | tail -1 | awk ' {print $4}' )
2323 MIN_DISK_KB=$(( 10 * 1024 * 1024 ))
2424
25- if [ ${FREE_MEM_GB} -le ${MIN_MEM_GB} ]; then
25+ # if [ ${FREE_MEM_GB} -le ${MIN_MEM_GB} ]; then
26+ if [ ${FREE_MEM_GB} -lt ${MIN_MEM_GB} ]; then
2627 echo -e " \nERROR: Orca Slicer Builder requires at least ${MIN_MEM_GB} G of 'available' mem (systen has only ${FREE_MEM_GB} G available)"
2728 echo && free -h && echo
2829 exit 2
@@ -43,15 +44,18 @@ function usage() {
4344 echo " -d: build deps (optional)"
4445 echo " -h: this help output"
4546 echo " -i: Generate appimage (optional)"
47+ echo " -e: Generate deb package (optional)"
4648 echo " -r: skip ram and disk checks (low ram compiling)"
4749 echo " -s: build orca-slicer (optional)"
4850 echo " -u: update and build dependencies (optional and need sudo)"
51+ echo " -jN: set number of threads for ninja build (e.g., -j4)"
4952 echo " For a first use, you want to 'sudo ./BuildLinux.sh -u'"
5053 echo " and then './BuildLinux.sh -dsi'"
5154}
5255
5356unset name
54- while getopts " :1bcdghirsu" opt; do
57+ unset NUM_THREADS
58+ while getopts " :1bcdghirsuej:" opt; do
5559 case ${opt} in
5660 1 )
5761 export CMAKE_BUILD_PARALLEL_LEVEL=1
@@ -71,6 +75,9 @@ while getopts ":1bcdghirsu" opt; do
7175 i )
7276 BUILD_IMAGE=" 1"
7377 ;;
78+ e )
79+ BUILD_DEB=" 1"
80+ ;;
7481 r )
7582 SKIP_RAM_CHECK=" 1"
7683 ;;
@@ -80,6 +87,9 @@ while getopts ":1bcdghirsu" opt; do
8087 u )
8188 UPDATE_LIB=" 1"
8289 ;;
90+ j )
91+ NUM_THREADS=${OPTARG}
92+ ;;
8393 esac
8494done
8595
90100fi
91101
92102DISTRIBUTION=$( awk -F= ' /^ID=/ {print $2}' /etc/os-release)
93- # treat ubuntu as debian
103+ # 规范化发行版ID(去引号并转小写)
104+ DISTRIBUTION=$( echo ${DISTRIBUTION} | tr -d ' "' | tr ' [:upper:]' ' [:lower:]' )
105+ # 将 ubuntu 视为 debian
94106if [ " ${DISTRIBUTION} " == " ubuntu" ]
95107then
96108 DISTRIBUTION=" debian"
@@ -103,6 +115,11 @@ then
103115 DISTRIBUTION=" debian2"
104116 fi
105117fi
118+ # 兼容麒麟系统(Kylin/openKylin),使用专用脚本
119+ if [ " ${DISTRIBUTION} " == " kylin" ] || [ " ${DISTRIBUTION} " == " openkylin" ]
120+ then
121+ DISTRIBUTION=" kylin"
122+ fi
106123if [ ! -f ./linux.d/${DISTRIBUTION} ]
107124then
108125 echo " Your distribution does not appear to be currently supported by these build scripts"
@@ -186,9 +203,13 @@ then
186203 ${BUILD_ARGS}
187204 echo " done"
188205 echo " Building CrealityPrint ..."
189- cmake --build build --target CrealityPrint
206+ if [[ -n " ${num_threads} " ]]; then
207+ cmake --build build --target CrealityPrint -j${NUM_THREADS}
208+ else
209+ cmake --build build --target CrealityPrint
210+ fi
190211 echo " Building CrealityPrint_profile_validator .."
191- cmake --build build --target CrealityPrint_profile_validator
212+ # cmake --build build --target CrealityPrint_profile_validator
192213 ./run_gettext.sh
193214 echo " done"
194215fi
@@ -205,6 +226,11 @@ echo "[9/9] Generating Linux app..."
205226 else
206227 ${ROOT} /build/src/BuildLinuxImage.sh
207228 fi
229+ if [[ -n " ${BUILD_DEB} " ]] && [[ -e ${ROOT} /build/src/BuildLinuxDeb.sh ]]
230+ then
231+ chmod 755 ${ROOT} /build/src/BuildLinuxDeb.sh
232+ ${ROOT} /build/src/BuildLinuxDeb.sh
233+ fi
208234 popd
209235echo " done"
210236fi
0 commit comments