diff --git a/scripts/package-deb.sh b/scripts/package-deb.sh index e28811ea..64a44505 100755 --- a/scripts/package-deb.sh +++ b/scripts/package-deb.sh @@ -20,7 +20,15 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # ################################################################################################## -set -euxo pipefail +set -euo pipefail + +NONINTERACTIVE=0 +while [[ $# -gt 0 ]]; do + case "$1" in + --noninteractive) NONINTERACTIVE=1; shift ;; + *) echo "Unknown argument: $1" >&2; exit 1 ;; + esac +done # SLASH root cd "$(dirname "$0")/.." @@ -31,6 +39,47 @@ export ARTIFACTS_DIR="${ARTIFACTS_DIR:-"$(pwd)"/deb}" export DPKG_ARCH="$(dpkg --print-architecture)" export DPKG_PARSED_VERSION="$(dpkg-parsechangelog -SVersion)" +# Warn before overwriting an existing build +if [[ -d "${ARTIFACTS_DIR}" ]] && [[ -t 0 ]] && [[ "${NONINTERACTIVE}" -eq 0 ]]; then + echo "WARNING: A previous .deb build already exists." >&2 + echo "Proceeding will remove the following directories and restart the build from scratch:" >&2 + echo " ${ARTIFACTS_DIR} (built .deb packages)" >&2 + echo " pbuild/ (CMake build tree)" >&2 + echo " debian/ (generated packaging metadata)" >&2 + echo " linker/src/install.prj" >&2 + echo " linker/resources/abstract_shell" >&2 + echo "This includes the static shell, which can take several hours to rebuild." >&2 + read -r -p "Overwrite existing build and start from scratch? [y/N] " _answer &2; exit 1 ;; + esac +fi + +# Check build prerequisites +_prereq_ok=1 + +if ! command -v v++ > /dev/null 2>&1; then + echo "ERROR: v++ not found in PATH. Source Vitis 2025.1 before building:" >&2 + echo " source /settings64.sh" >&2 + echo "See docs/tutorials/admin/platform-setup.rst for details." >&2 + _prereq_ok=0 +fi + +if ! compgen -G 'linker/resources/base/iprepo/smbus*/' > /dev/null 2>&1; then + echo "ERROR: SMBus IP (xilinx.com:ip:smbus:1.1) not found in linker/resources/base/iprepo/." >&2 + echo "Download it from https://www.xilinx.com/member/v80.html and place the IP" >&2 + echo "directory into linker/resources/base/iprepo/ before building." >&2 + echo "See docs/tutorials/admin/platform-setup.rst for details." >&2 + _prereq_ok=0 +fi + +if [[ "${_prereq_ok}" -eq 0 ]]; then + exit 1 +fi + +set -x + # Clean build rm -rf deb mkdir -p deb diff --git a/scripts/package-rpm.sh b/scripts/package-rpm.sh index 38239312..bc47ce3f 100755 --- a/scripts/package-rpm.sh +++ b/scripts/package-rpm.sh @@ -20,7 +20,15 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # ################################################################################################## -set -euxo pipefail +set -euo pipefail + +NONINTERACTIVE=0 +while [[ $# -gt 0 ]]; do + case "$1" in + --noninteractive) NONINTERACTIVE=1; shift ;; + *) echo "Unknown argument: $1" >&2; exit 1 ;; + esac +done # SLASH root cd "$(dirname "$0")/.." @@ -29,7 +37,48 @@ VERSION="$(tr -d '[:space:]' < packaging/version)" TOPDIR="$(pwd)/rpmbuild" ARTIFACTS_DIR="${ARTIFACTS_DIR:-$(pwd)/rpm}" -rm -rf "${TOPDIR}" "${ARTIFACTS_DIR}" +# Warn before overwriting an existing build +if [[ -d "${ARTIFACTS_DIR}" ]] && [[ -t 0 ]] && [[ "${NONINTERACTIVE}" -eq 0 ]]; then + echo "WARNING: A previous .rpm build already exists." >&2 + echo "Proceeding will remove the following directories and restart the build from scratch:" >&2 + [[ -d "${TOPDIR}" ]] && echo " ${TOPDIR} (rpmbuild tree)" >&2 + [[ -d "${ARTIFACTS_DIR}" ]] && echo " ${ARTIFACTS_DIR} (built .rpm packages)" >&2 + [[ -d pbuild ]] && echo " pbuild/ (CMake build tree)" >&2 + echo " linker/src/install.prj" >&2 + echo " linker/resources/abstract_shell" >&2 + echo "This includes the static shell, which can take several hours to rebuild." >&2 + read -r -p "Overwrite existing build and start from scratch? [y/N] " _answer &2; exit 1 ;; + esac +fi + +# Check build prerequisites +_prereq_ok=1 + +if ! command -v v++ > /dev/null 2>&1; then + echo "ERROR: v++ not found in PATH. Source Vitis 2025.1 before building:" >&2 + echo " source /settings64.sh" >&2 + echo "See docs/tutorials/admin/platform-setup.rst for details." >&2 + _prereq_ok=0 +fi + +if ! compgen -G 'linker/resources/base/iprepo/smbus*/' > /dev/null 2>&1; then + echo "ERROR: SMBus IP (xilinx.com:ip:smbus:1.1) not found in linker/resources/base/iprepo/." >&2 + echo "Download it from https://www.xilinx.com/member/v80.html and place the IP" >&2 + echo "directory into linker/resources/base/iprepo/ before building." >&2 + echo "See docs/tutorials/admin/platform-setup.rst for details." >&2 + _prereq_ok=0 +fi + +if [[ "${_prereq_ok}" -eq 0 ]]; then + exit 1 +fi + +set -x + +rm -rf "${TOPDIR}" "${ARTIFACTS_DIR}" pbuild mkdir -p "${TOPDIR}"/{BUILD,RPMS,SOURCES,SPECS,SRPMS} mkdir -p "${ARTIFACTS_DIR}"