mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] ptxdist: add xpkg_install to install external ipkgs
@ 2018-02-04 21:31 Michael Grzeschik
  2018-02-05 14:51 ` Denis OSTERLAND
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Grzeschik @ 2018-02-04 21:31 UTC (permalink / raw)
  To: ptxdist

This patch enables the feature to call install_xpkg in the targetinstall stage
of any rule. This way it is possible to install external ipkgs into the targets
rootfilesystem.

The next example describes an simple usecase with two packages in local_src.

PACKAGES-$(EXAMPLERULE_IPKGS) += examplerule-ipkgs
EXAMPLERULE_IPKGS_VERSION	:= 1.0
EXAMPLERULE_IPKGS	:= examplerule-ipkgs-$(EXAMPLERULE_IPKGS_VERSION)
EXAMPLERULE_IPKGS_URL	:= file://$(PTXDIST_WORKSPACE)/local_src/$(EXAMPLERULE_IPKGS)

EXAMPLERULE_IPKGS_FILES := \
	example1-package_1.1.3_armhf.ipk \
	example2-package_0.3.3_armhf.ipk

define rmsuffix
$(shell echo $(1) | sed 's-^\([0-9a-zA-Z\-].*\)_\([a-zA-Z.0-9].*\)_.*-\1-g')
endef

$(STATEDIR)/examplerule.targetinstall:
	@$(call targetinfo)
	@$(foreach ipkg, $(EXAMPLERULE_IPKGS_FILES), \
		$(call install_xpkg, $(call rmsuffix, $(ipkg)), \
			$(EXAMPLERULE_IPKGS_URL)/$(ipkg));)
	@$(call touch)

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 rules/post/ptxd_make_xpkg_install.make |  33 ++++++++++
 scripts/lib/ptxd_make_xpkg_install.sh  | 111 +++++++++++++++++++++++++++++++++
 2 files changed, 144 insertions(+)
 create mode 100644 rules/post/ptxd_make_xpkg_install.make
 create mode 100644 scripts/lib/ptxd_make_xpkg_install.sh

diff --git a/rules/post/ptxd_make_xpkg_install.make b/rules/post/ptxd_make_xpkg_install.make
new file mode 100644
index 000000000..397961aab
--- /dev/null
+++ b/rules/post/ptxd_make_xpkg_install.make
@@ -0,0 +1,33 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2018 by Michael Grzeschik <mgr@pengutronix.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# install_finish
+#
+# finishes packet creation
+#
+# $1: packet label
+#
+install_xpkg = \
+	$(call xpkg/install, $(1), $(2))
+
+#
+# xpkg/install
+#
+# installs packet
+#
+# $1: xpkg label
+#
+xpkg/install = \
+	$(call xpkg/env, $(1))	\
+	pkg_xpkg_source='$(strip $(2))' \
+	ptxd_make_xpkg_install
+
+# vim: syntax=make
diff --git a/scripts/lib/ptxd_make_xpkg_install.sh b/scripts/lib/ptxd_make_xpkg_install.sh
new file mode 100644
index 000000000..f0367c5e1
--- /dev/null
+++ b/scripts/lib/ptxd_make_xpkg_install.sh
@@ -0,0 +1,111 @@
+#
+# ptxd_make_image_extract_ipkg_package - extract ipkg for later image generation
+#
+# in:
+# - $1				ipkg to be extracted
+# - $2				directory where ipkg are extracted
+# - $PTXDIST_IPKG_ARCH_STRING	ARCH variable for ipkg files
+#
+ptxd_make_image_extract_xpkg_package() {
+    # FIXME: consolidate "ptxd_install_setup_src"
+    local src="/etc/opkg/opkg.conf"
+    local xpkg_conf="$(mktemp ${PTXDIST_TEMPDIR}/XXXXXXXXXX_xpkg.conf)"
+    local ipkg="$1"
+    local work_dir="$2"
+    local -a list ptxd_reply
+    echo "option force_reinstall 1" > "${xpkg_conf}"
+    echo "option nodeps 1" >> "${xpkg_conf}"
+    echo "option volatile_cache 1" >> "${xpkg_conf}"
+    echo "option force_postinstall 1" >> "${xpkg_conf}"
+    list=( \
+	"${PTXDIST_WORKSPACE}/projectroot${PTXDIST_PLATFORMSUFFIX}${src}" \
+	"${PTXDIST_WORKSPACE}/projectroot${src}${PTXDIST_PLATFORMSUFFIX}" \
+	"${PTXDIST_WORKSPACE}/projectroot${src}" \
+	"${PTXDIST_TOPDIR}/projectroot${src}" \
+	)
+
+    if ! ptxd_get_path "${list[@]}"; then
+	local IFS="
+"
+	ptxd_bailout "
+unable to find '${src}'
+
+These location have been searched:
+${list[*]}
+"
+    fi
+
+#    rm -rf "${work_dir}" &&
+#    install -m 755 -d "${work_dir}" &&
+
+    ARCH="${PTXDIST_IPKG_ARCH_STRING}" \
+    SRC="" \
+    CHECKSIG="" \
+    CAPATH="" \
+    CAFILE="" \
+	ptxd_replace_magic "${ptxd_reply}" >> "${xpkg_conf}" &&
+
+    DESTDIR="${work_dir}" \
+	opkg -f "${xpkg_conf}" -o "${work_dir}" \
+	install "${ipkg}" &&
+
+   ptxd_install_fixup_timestamps "${work_dir}"
+}
+export -f ptxd_make_image_extract_xpkg_package
+
+ptxd_make_xpkg_install_impl() {
+    source="$1"
+    pkg_xpkg_tmp=""
+
+    ptxd_install_setup &&
+    for dir in "${dirs[@]}"; do
+	if [ -n "${dir}" ]; then
+	    echo installing to ${dir}; \
+	    ptxd_make_image_extract_xpkg_package \
+		"${source}" "${dir}" || break
+	fi
+    done
+}
+export -f ptxd_make_xpkg_install_impl
+
+#
+# function to install a generic package
+#
+ptxd_make_xpkg_install() {
+    ptxd_make_xpkg_init || return
+    local source="${pkg_xpkg_source//file:\/\//}"
+
+    #
+    # track "pkg name" to "xpkg filename" mapping
+    #
+    if [ -e "${pkg_xpkg_map}" ]; then
+	sed -i -e "/^${pkg_xpkg}$/d" "${pkg_xpkg_map}"
+    fi &&
+    echo "${pkg_xpkg}" >> "${pkg_xpkg_map}" || return
+
+    #
+    # license / currently not per package
+    #
+    echo -n "xpkg_install:	collecting license (${pkg_xpkg_license}) ... "
+    echo "${pkg_xpkg_license}" > "${pkg_xpkg_license_file}"
+    echo "done."
+
+    #
+    # remove old pkgs
+    # note: no version here, so we remove packages with old versions too
+    #
+    rm -f "${ptx_pkg_dir}/${pkg_xpkg}"_*"${PTXDIST_IPKG_ARCH_STRING}.ipk"
+
+    #
+    # copy to satisfy image creation
+    #
+    cp "${source}" "${ptx_pkg_dir}/"
+
+    #
+    # only created to satisfy image creation
+    #
+    touch ${pkg_xpkg_perms}
+
+    fakeroot ptxd_make_xpkg_install_impl ${source}
+}
+export -f ptxd_make_xpkg_install
-- 
2.15.1


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ptxdist] [PATCH] ptxdist: add xpkg_install to install external ipkgs
  2018-02-04 21:31 [ptxdist] [PATCH] ptxdist: add xpkg_install to install external ipkgs Michael Grzeschik
@ 2018-02-05 14:51 ` Denis OSTERLAND
  0 siblings, 0 replies; 2+ messages in thread
From: Denis OSTERLAND @ 2018-02-05 14:51 UTC (permalink / raw)
  To: ptxdist

Am Sonntag, den 04.02.2018, 22:31 +0100 schrieb Michael Grzeschik:
> This patch enables the feature to call install_xpkg in the targetinstall stage
> of any rule. This way it is possible to install external ipkgs into the targets
> rootfilesystem.
> 
> The next example describes an simple usecase with two packages in local_src.
> 
> PACKAGES-$(EXAMPLERULE_IPKGS) += examplerule-ipkgs
> EXAMPLERULE_IPKGS_VERSION	:= 1.0
> EXAMPLERULE_IPKGS	:= examplerule-ipkgs-$(EXAMPLERULE_IPKGS_VERSION)
> EXAMPLERULE_IPKGS_URL	:= file://$(PTXDIST_WORKSPACE)/local_src/$(EXAMPLERULE_IPKGS)
> 
> EXAMPLERULE_IPKGS_FILES := \
> 	example1-package_1.1.3_armhf.ipk \
> 	example2-package_0.3.3_armhf.ipk
> 
> define rmsuffix
> $(shell echo $(1) | sed 's-^\([0-9a-zA-Z\-].*\)_\([a-zA-Z.0-9].*\)_.*-\1-g')
> endef
> 
> $(STATEDIR)/examplerule.targetinstall:
> 	@$(call targetinfo)
> 	@$(foreach ipkg, $(EXAMPLERULE_IPKGS_FILES), \
> 		$(call install_xpkg, $(call rmsuffix, $(ipkg)), \
> 			$(EXAMPLERULE_IPKGS_URL)/$(ipkg));)
> 	@$(call touch)
> 
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
>  rules/post/ptxd_make_xpkg_install.make |  33 ++++++++++
>  scripts/lib/ptxd_make_xpkg_install.sh  | 111 +++++++++++++++++++++++++++++++++
>  2 files changed, 144 insertions(+)
>  create mode 100644 rules/post/ptxd_make_xpkg_install.make
>  create mode 100644 scripts/lib/ptxd_make_xpkg_install.sh
> 
> diff --git a/rules/post/ptxd_make_xpkg_install.make b/rules/post/ptxd_make_xpkg_install.make
> new file mode 100644
> index 000000000..397961aab
> --- /dev/null
> +++ b/rules/post/ptxd_make_xpkg_install.make
> @@ -0,0 +1,33 @@
> +# -*-makefile-*-
> +#
> +# Copyright (C) 2018 by Michael Grzeschik <mgr@pengutronix.de>
> +#
> +# See CREDITS for details about who has contributed to this project.
> +#
> +# For further information about the PTXdist project and license conditions
> +# see the README file.
> +#
> +
> +#
> +# install_finish
> +#
> +# finishes packet creation
> +#
> +# $1: packet label
Missing $2 documentation
> +#
> +install_xpkg = \
> +	$(call xpkg/install, $(1), $(2))
> +
> +#
> +# xpkg/install
> +#
> +# installs packet
> +#
> +# $1: xpkg label
Missing $2 documentation
> +#
> +xpkg/install = \
> +	$(call xpkg/env, $(1))	\
> +	pkg_xpkg_source='$(strip $(2))' \
> +	ptxd_make_xpkg_install
> +
> +# vim: syntax=make
> diff --git a/scripts/lib/ptxd_make_xpkg_install.sh b/scripts/lib/ptxd_make_xpkg_install.sh
> new file mode 100644
> index 000000000..f0367c5e1
> --- /dev/null
> +++ b/scripts/lib/ptxd_make_xpkg_install.sh
> @@ -0,0 +1,111 @@
> +#
> +# ptxd_make_image_extract_ipkg_package - extract ipkg for later image generation
> +#
> +# in:
> +# - $1				ipkg to be extracted
> +# - $2				directory where ipkg are extracted
> +# - $PTXDIST_IPKG_ARCH_STRING	ARCH variable for ipkg files
> +#
> +ptxd_make_image_extract_xpkg_package() {
> +    # FIXME: consolidate "ptxd_install_setup_src"
> +    local src="/etc/opkg/opkg.conf"
> +    local xpkg_conf="$(mktemp ${PTXDIST_TEMPDIR}/XXXXXXXXXX_xpkg.conf)"
> +    local ipkg="$1"
> +    local work_dir="$2"
> +    local -a list ptxd_reply
> +    echo "option force_reinstall 1" > "${xpkg_conf}"
> +    echo "option nodeps 1" >> "${xpkg_conf}"
> +    echo "option volatile_cache 1" >> "${xpkg_conf}"
> +    echo "option force_postinstall 1" >> "${xpkg_conf}"
> +    list=( \
> +	"${PTXDIST_WORKSPACE}/projectroot${PTXDIST_PLATFORMSUFFIX}${src}" \
> +	"${PTXDIST_WORKSPACE}/projectroot${src}${PTXDIST_PLATFORMSUFFIX}" \
> +	"${PTXDIST_WORKSPACE}/projectroot${src}" \
> +	"${PTXDIST_TOPDIR}/projectroot${src}" \
> +	)
> +
> +    if ! ptxd_get_path "${list[@]}"; then
> +	local IFS="
> +"
> +	ptxd_bailout "
> +unable to find '${src}'
> +
> +These location have been searched:
> +${list[*]}
> +"
> +    fi
> +
> +#    rm -rf "${work_dir}" &&
> +#    install -m 755 -d "${work_dir}" &&
> +
> +    ARCH="${PTXDIST_IPKG_ARCH_STRING}" \
> +    SRC="" \
> +    CHECKSIG="" \
> +    CAPATH="" \
> +    CAFILE="" \
> +	ptxd_replace_magic "${ptxd_reply}" >> "${xpkg_conf}" &&
> +
> +    DESTDIR="${work_dir}" \
> +	opkg -f "${xpkg_conf}" -o "${work_dir}" \
> +	install "${ipkg}" &&
Is it possible to do this with ipkg as well?
> +
> +   ptxd_install_fixup_timestamps "${work_dir}"
> +}
> +export -f ptxd_make_image_extract_xpkg_package
> +
> +ptxd_make_xpkg_install_impl() {
> +    source="$1"
> +    pkg_xpkg_tmp=""
> +
> +    ptxd_install_setup &&
> +    for dir in "${dirs[@]}"; do
> +	if [ -n "${dir}" ]; then
> +	    echo installing to ${dir}; \
> +	    ptxd_make_image_extract_xpkg_package \
> +		"${source}" "${dir}" || break
> +	fi
> +    done
> +}
> +export -f ptxd_make_xpkg_install_impl
> +
> +#
> +# function to install a generic package
> +#
> +ptxd_make_xpkg_install() {
> +    ptxd_make_xpkg_init || return
> +    local source="${pkg_xpkg_source//file:\/\//}"
> +
> +    #
> +    # track "pkg name" to "xpkg filename" mapping
> +    #
> +    if [ -e "${pkg_xpkg_map}" ]; then
> +	sed -i -e "/^${pkg_xpkg}$/d" "${pkg_xpkg_map}"
> +    fi &&
> +    echo "${pkg_xpkg}" >> "${pkg_xpkg_map}" || return
> +
> +    #
> +    # license / currently not per package
> +    #
> +    echo -n "xpkg_install:	collecting license (${pkg_xpkg_license}) ... "
> +    echo "${pkg_xpkg_license}" > "${pkg_xpkg_license_file}"
> +    echo "done."
> +
> +    #
> +    # remove old pkgs
> +    # note: no version here, so we remove packages with old versions too
> +    #
> +    rm -f "${ptx_pkg_dir}/${pkg_xpkg}"_*"${PTXDIST_IPKG_ARCH_STRING}.ipk"
> +
> +    #
> +    # copy to satisfy image creation
> +    #
> +    cp "${source}" "${ptx_pkg_dir}/"
> +
> +    #
> +    # only created to satisfy image creation
> +    #
> +    touch ${pkg_xpkg_perms}
> +
> +    fakeroot ptxd_make_xpkg_install_impl ${source}
> +}
> +export -f ptxd_make_xpkg_install
Diehl AKO Stiftung & Co. KG, Pfannerstraße 75-83, 88239 Wangen im Allgäu
Bereichsvorstand: Dr.-Ing. Michael Siedentop (Sprecher), Josef Fellner (Mitglied)
Sitz der Gesellschaft: Wangen i.A. – Registergericht: Amtsgericht Ulm HRA 620609 – Persönlich haftende Gesellschafterin: Diehl Verwaltungs-Stiftung – Sitz: Nürnberg – Registergericht: Amtsgericht Nürnberg HRA 11756 –
Vorstand: Dr.-Ing. E.h. Thomas Diehl (†) (Vorsitzender), Herr Dipl.-Wirtsch.-Ing. Wolfgang Weggen (stellvertretender Vorsitzender), Dipl.-Kfm. Claus Günther, Dipl.-Kfm. Frank Gutzeit, Dr.-Ing. Heinrich Schunk, Dr.-Ing. Michael Siedentop , Dipl.-Kfm. Dr.-Ing. Martin Sommer, Dipl.-Ing. (FH) Rainer von Borstel, Vorsitzender des Aufsichtsrates: Dr. Klaus Maier
___________________________________________________________________________________________________
Der Inhalt der vorstehenden E-Mail ist nicht rechtlich bindend. Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte Informationen.
Informieren Sie uns bitte, wenn Sie diese E-Mail faelschlicherweise erhalten haben. Bitte loeschen Sie in diesem Fall die Nachricht. Jede unerlaubte Form der Reproduktion, Bekanntgabe, Aenderung, Verteilung und/oder Publikation dieser E-Mail ist strengstens untersagt.
The contents of the above mentioned e-mail is not legally binding. This e-mail contains confidential and/or legally protected information. Please inform us if you have received this e-mail by mistake and delete it in such a case. Each unauthorized reproduction, disclosure, alteration, distribution and/or publication of this e-mail is strictly prohibited.
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-05 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-04 21:31 [ptxdist] [PATCH] ptxdist: add xpkg_install to install external ipkgs Michael Grzeschik
2018-02-05 14:51 ` Denis OSTERLAND

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox