diff options
-rw-r--r-- | rules/post/ptxd_make_install.make | 21 | ||||
-rw-r--r-- | scripts/lib/ptxd_make_toolchain_install.sh | 42 |
2 files changed, 63 insertions, 0 deletions
diff --git a/rules/post/ptxd_make_install.make b/rules/post/ptxd_make_install.make new file mode 100644 index 0000000..c05655a --- /dev/null +++ b/rules/post/ptxd_make_install.make @@ -0,0 +1,21 @@ +# -*-makefile-*- +# +# Copyright (C) 2019 by Michael Olbrich <m.olbrich@pengutronix.de> +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +.PHONY: install + +toolchain/install = \ + $(call ptx/env) \ + ptx_install_destdir=$(DESTDIR) \ + ptxd_make_toolchain_install + +install: world + @$(call targetinfo) + @$(call toolchain/install) + @$(call finish) + +# vim: syntax=make diff --git a/scripts/lib/ptxd_make_toolchain_install.sh b/scripts/lib/ptxd_make_toolchain_install.sh new file mode 100644 index 0000000..4ef49e9 --- /dev/null +++ b/scripts/lib/ptxd_make_toolchain_install.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Copyright (C) 2019 by Michael Olbrich <m.olbrich@pengutronix.de> +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +ptxd_make_toolchain_install() { + local tmpfile install_helper + local prefix="$(ptxd_get_ptxconf PTXCONF_PREFIX_CROSS)" + local install_prefix="${ptx_install_destdir}${prefix}" + local install_source="${PTXDIST_SYSROOT_CROSS}${prefix}" + + echo "Installing to ${install_prefix} ..." + + if [ -d "${install_prefix}" ]; then + if [ -z "$(find "${install_prefix}" -maxdepth 0 -empty)" -a -z "${PTXDIST_FORCE}" ]; then + ptxd_bailout "${install_prefix} is not empty!" \ + "Use --force to remove the existing content first." + fi + fi + + mkdir -p "${install_prefix}" 2>/dev/null && + tmpfile="$(mktemp "${install_prefix}/touch.XXXXXXXX" 2>/dev/null)" && + rm "${tmpfile}" + if [ $? -ne 0 ]; then + echo + echo "'${install_prefix}' is not writable." + read -t 5 -p "Press enter to install with sudo!" + if [ ${?} -ne 0 ]; then + echo + return 1 + fi + install_helper=sudo + fi + ${install_helper} rm -rf "${install_prefix}" && + ${install_helper} mkdir -p $(dirname "${install_prefix}") && + ${install_helper} cp -a --no-preserve=ownership \ + "${install_source}" $(dirname "${install_prefix}") +} +export -f ptxd_make_toolchain_install |