From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: From: Michael Olbrich Date: Sun, 20 Nov 2011 13:44:23 +0100 Message-Id: <1321793063-6210-1-git-send-email-m.olbrich@pengutronix.de> In-Reply-To: <3944866A166FC34A948C72DD5EDDCA2A1DAE27E9@HQ0SBS01.airtag.local> References: <3944866A166FC34A948C72DD5EDDCA2A1DAE27E9@HQ0SBS01.airtag.local> Subject: [ptxdist] [PATCH] add install_script_replace to replace in pre/post scripts Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de Cc: Michael Olbrich Signed-off-by: Michael Olbrich --- I had some time to play with the idea. What do you think of this? Michael rules/post/install.make | 18 ++++++++++++++++++ scripts/lib/ptxd_make_xpkg_finish.sh | 25 ++++++++++++------------- scripts/lib/ptxd_make_xpkg_pkg.sh | 32 ++++++++++++++++++++++++++++++++ scripts/lib/ptxd_make_xpkg_prepare.sh | 7 ------- 4 files changed, 62 insertions(+), 20 deletions(-) diff --git a/rules/post/install.make b/rules/post/install.make index 35b0034..4ad7f87 100644 --- a/rules/post/install.make +++ b/rules/post/install.make @@ -278,6 +278,24 @@ install_replace_figlet = \ echo "ptxd_install_replace_figlet '$$FILE' '$$PLACEHOLDER' '$$VALUE'" >> "$(STATEDIR)/$$XPKG.cmds" # +# install_script_replace +# +# Replace placeholder with value in a script +# +# $1: xpkg label +# $2: script (preinst, postinst, ...) +# $3: placeholder +# $4: value +# +install_script_replace = \ + XPKG=$(subst _,-,$(strip $(1))); \ + FILE=$(strip $(2)); \ + PLACEHOLDER=$(strip $(3)); \ + VALUE=$(strip $(4)); \ + $(call install_check, install_script_replace); \ + echo "ptxd_install_script_replace '$$FILE' '$$PLACEHOLDER' '$$VALUE'" >> "$(STATEDIR)/$$XPKG.cmds" + +# # install_copy_toolchain_lib # # $1: xpkg label diff --git a/scripts/lib/ptxd_make_xpkg_finish.sh b/scripts/lib/ptxd_make_xpkg_finish.sh index d424eac..64bed28 100644 --- a/scripts/lib/ptxd_make_xpkg_finish.sh +++ b/scripts/lib/ptxd_make_xpkg_finish.sh @@ -72,6 +72,18 @@ EOF rm -f "${ptx_pkg_dir}/${pkg_xpkg}"_*"${PTXDIST_IPKG_ARCH_STRING}.ipk" # + # add pre-/postinst runs to the command list + # make sure we replace in preinst first + # + ( + cat "${pkg_xpkg_cmds}" | grep ptxd_install_script_replace + echo "ptxd_install_run preinst" + cat "${pkg_xpkg_cmds}" | grep -v ptxd_install_script_replace + echo "ptxd_install_run postinst" + ) > "${pkg_xpkg_cmds}.tmp" + mv "${pkg_xpkg_cmds}.tmp" "${pkg_xpkg_cmds}" + + # # create pkg # echo "xpkg_finish: creating ${pkg_xpkg_type} package ... " && @@ -83,18 +95,5 @@ EOF } echo "done." - - - # - # post install - # - # FIXME: install ipkg rather than executing script - if ptxd_in_path PTXDIST_PATH_RULES "${pkg_xpkg}.postinst"; then - echo "xpkg_finish: running postinst" - DESTDIR="${ptx_nfsroot}" /bin/sh "${ptxd_reply}" - DESTDIR="${ptx_nfsroot_dbg}" /bin/sh "${ptxd_reply}" - fi - - return } export -f ptxd_make_xpkg_finish diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh index 89d6319..ecc077a 100644 --- a/scripts/lib/ptxd_make_xpkg_pkg.sh +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh @@ -369,6 +369,24 @@ install replace: } export -f ptxd_install_replace +ptxd_install_script_replace() { + local dst="$1" + local placeholder="$2" + local value="$3" + + echo "\ +install script replace: + script=${dst} + '${placeholder}' -> '${value}' +" + + ptxd_exist "${pkg_xpkg_control_dir}/${dst}" && + sed -i -e "s,${placeholder},${value},g" "${pkg_xpkg_control_dir}/${dst}" || + + ptxd_install_error "install_script_replace failed!" +} +export -f ptxd_install_script_replace + ptxd_install_replace_figlet() { local dst="$1" local placeholder="$2" @@ -627,6 +645,20 @@ ptxd_install_lib() { } export -f ptxd_install_lib +ptxd_install_run() { + local script="${pkg_xpkg_control_dir}/${1}" + + if [ -e "${script}" ]; then + echo "\ +executing '${pkg_label}.${1}' +" + DESTDIR="${ptx_nfsroot}" /bin/sh "${script}" && + DESTDIR="${ptx_nfsroot_dbg}" /bin/sh "${script}" + fi || + ptxd_install_error "running '${1}' script failed!" +} +export -f ptxd_install_run + ptxd_make_xpkg_pkg() { local pkg_xpkg_tmp="$1" local pkg_xpkg_cmds="$2" diff --git a/scripts/lib/ptxd_make_xpkg_prepare.sh b/scripts/lib/ptxd_make_xpkg_prepare.sh index eeb9356..e88a347 100644 --- a/scripts/lib/ptxd_make_xpkg_prepare.sh +++ b/scripts/lib/ptxd_make_xpkg_prepare.sh @@ -93,13 +93,6 @@ install_init: @DEPENDS@ -> ${dep}" "${pkg_xpkg_control_dir}/${script}" || return echo "packaging: '$(ptxd_print_path "${ptxd_reply}")'" - - # FIXME: install ipkg rather than executing script - if [ "${script}" = "preinst" ]; then - echo "install_init: executing '${ptxd_reply}'" - DESTDIR="${ptx_nfsroot}" /bin/sh "${ptxd_reply}" - DESTDIR="${ptx_nfsroot_dbg}" /bin/sh "${ptxd_reply}" - fi else echo "not available" fi -- 1.7.7.1 -- ptxdist mailing list ptxdist@pengutronix.de