* [ptxdist] install_replace on a {pre,post}{rm,inst} script
@ 2011-11-10 10:45 Benoît BURNICHON
2011-11-10 12:34 ` Benoît BURNICHON
2011-11-20 12:44 ` [ptxdist] [PATCH] add install_script_replace to replace in pre/post scripts Michael Olbrich
0 siblings, 2 replies; 3+ messages in thread
From: Benoît BURNICHON @ 2011-11-10 10:45 UTC (permalink / raw)
To: ptxdist
Hi all,
I would like to perform an action like is done on lighttpd package.
@$(call install_replace, lighttpd, /etc/lighttpd/lighttpd.conf, \
@CGI@, $(call ptx/ifdef, PTXCONF_PHP5_SAPI_CGI,,#))
Problem is, that I want to perform the same thing in the install scripts:
@$(call install_script_replace, mypackage, postinst, \
@INSTALLDIR@,$(MYPACKAGE_LOCATION))
This way, I can choose the destination directory from the ptxdist menu.
BTW, the script postinst are run by ptxdist at targetinstall stage. The scripts should not fail on this call.
When using ipkg or opkg, scripts are called with different parameters:
- Ptxdist calls without arguments and with DESTDIR environment variable set to destination (nfs root or root-debug dir)
- Ipkg calls postinstall scripts with 'configure' argument and PKG_ROOT environment variable set to the destination.
- Ipkg can be called with -o (--offline) argument to set the offline directory to install to. (But be careful, there is no environment variables indicating that the install is an offline one)
Regards,
Ben
________________________________
Ce courriel et toutes les pièces jointes sont confidentiels et peuvent être couverts par un privilège ou une protection légale. Il est établi à l’attention exclusive de ses destinataires. Toute utilisation de ce courriel non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse préalable.
This email and any attachment are confidential and may be legally privileged or otherwise protected from disclosure. It is intended only for the stated addressee(s) and access to it by any other person(s) is unauthorized. Any use, dissemination or disclosure not in accordance with its purpose, either in whole or in part, is prohibited without our prior formal approval.
--
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ptxdist] install_replace on a {pre,post}{rm,inst} script
2011-11-10 10:45 [ptxdist] install_replace on a {pre,post}{rm,inst} script Benoît BURNICHON
@ 2011-11-10 12:34 ` Benoît BURNICHON
2011-11-20 12:44 ` [ptxdist] [PATCH] add install_script_replace to replace in pre/post scripts Michael Olbrich
1 sibling, 0 replies; 3+ messages in thread
From: Benoît BURNICHON @ 2011-11-10 12:34 UTC (permalink / raw)
To: ptxdist
> Hi all,
>
> I would like to perform an action like is done on lighttpd package.
> @$(call install_replace, lighttpd, /etc/lighttpd/lighttpd.conf, \
> @CGI@, $(call ptx/ifdef, PTXCONF_PHP5_SAPI_CGI,,#))
>
> Problem is, that I want to perform the same thing in the install scripts:
> @$(call install_script_replace, mypackage, postinst, \
> @INSTALLDIR@,$(MYPACKAGE_LOCATION))
I found out how to modify ptxdist to get the script substituted.
But, doing this will not be reflected in the scripts run by ptxdist as these are run from their original location.
Diff below would work for preinst script but not for postinst
------8<------------------8<------------------8<------------
diff --git a/scripts/lib/ptxd_make_xpkg_prepare.sh b/scripts/lib/ptxd_make_xpkg_prepare.sh
index eeb9356..3a3efc3 100644
--- a/scripts/lib/ptxd_make_xpkg_prepare.sh
+++ b/scripts/lib/ptxd_make_xpkg_prepare.sh
@@ -88,8 +88,9 @@ install_init: @DEPENDS@ -> ${dep}"
echo -n "install_init: ${script} "
if ptxd_in_path PTXDIST_PATH_RULES "${pkg_xpkg}.${script}"; then
- install -m 0755 \
- -D "${ptxd_reply}" \
+ ptxd_replace_magic "${ptxd_reply}" > \
+ "${pkg_xpkg_control_dir}/${script}" || return
+ chmod 0755 \
"${pkg_xpkg_control_dir}/${script}" || return
echo "packaging: '$(ptxd_print_path "${ptxd_reply}")'"
@@ -97,8 +98,8 @@ install_init: @DEPENDS@ -> ${dep}"
# 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}"
+ DESTDIR="${ptx_nfsroot}" /bin/sh "${pkg_xpkg_control_dir}/${script}"
+ DESTDIR="${ptx_nfsroot_dbg}" /bin/sh "${pkg_xpkg_control_dir}/${script}"
fi
else
echo "not available"
------8<------------------8<------------------8<------------
I wonder why ptxdist does not use the host_compiled ipkg to perform the install step.
{Host_ipkg_path}/ipkg-cl -o ${PTXDIST_ROOT} install ${PTXDIST_PLATFORM}/package/mypackage_trunk_armel.ipk
I tried it and it works
>
> This way, I can choose the destination directory from the ptxdist menu.
>
> BTW, the script postinst are run by ptxdist at targetinstall stage. The scripts
> should not fail on this call.
>
> When using ipkg or opkg, scripts are called with different parameters:
> - Ptxdist calls without arguments and with DESTDIR environment variable
> set to destination (nfs root or root-debug dir)
> - Ipkg calls postinstall scripts with 'configure' argument and PKG_ROOT
> environment variable set to the destination.
> - Ipkg can be called with -o (--offline) argument to set the offline
> directory to install to. (But be careful, there is no environment variables
> indicating that the install is an offline one)
I was wrong, the IPKG_OFFLINE_ROOT is set if in offline mode
>
> Regards,
>
> Ben
________________________________
Ce courriel et toutes les pièces jointes sont confidentiels et peuvent être couverts par un privilège ou une protection légale. Il est établi à l’attention exclusive de ses destinataires. Toute utilisation de ce courriel non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse préalable.
This email and any attachment are confidential and may be legally privileged or otherwise protected from disclosure. It is intended only for the stated addressee(s) and access to it by any other person(s) is unauthorized. Any use, dissemination or disclosure not in accordance with its purpose, either in whole or in part, is prohibited without our prior formal approval.
--
ptxdist mailing list
ptxdist@pengutronix.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ptxdist] [PATCH] add install_script_replace to replace in pre/post scripts
2011-11-10 10:45 [ptxdist] install_replace on a {pre,post}{rm,inst} script Benoît BURNICHON
2011-11-10 12:34 ` Benoît BURNICHON
@ 2011-11-20 12:44 ` Michael Olbrich
1 sibling, 0 replies; 3+ messages in thread
From: Michael Olbrich @ 2011-11-20 12:44 UTC (permalink / raw)
To: ptxdist; +Cc: Michael Olbrich
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-20 12:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-10 10:45 [ptxdist] install_replace on a {pre,post}{rm,inst} script Benoît BURNICHON
2011-11-10 12:34 ` Benoît BURNICHON
2011-11-20 12:44 ` [ptxdist] [PATCH] add install_script_replace to replace in pre/post scripts Michael Olbrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox