* sourceipk.bbclass patch submission
@ 2010-07-01 20:30 Chase Maupin
2010-07-01 20:30 ` [PATCH 1/1] sourceipk: add class to create source ipks Chase Maupin
0 siblings, 1 reply; 3+ messages in thread
From: Chase Maupin @ 2010-07-01 20:30 UTC (permalink / raw)
To: openembedded-devel
All,
This e-mail is to describe the purpose of the patch that will
follow which adds a sourceipk.bbclass file to the classes
directory. The purpose of the sourceipk class is to allow
recipe authors and openembedded users to create a simple
ipk package that contains the patched sources and recipe
used to create the binary ipks. This source ipk does NOT
build the binary ipks itself, that is still done using
bitbake and openembedded.
The purpose is to allow the sources to be placed in a
feed along with the binaries and installed on either the
target system for native building or the host system for
reference on manual cross compilation if desired.
This can also be used by installers that will install/create
custom images and their corresponding sources based on user
selection.
Please consider the patch that follows for inclusion. I would
also like to take this time to thank Koen and Denys for their
input and feedback on this code.
Sincerely,
Chase Maupin
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/1] sourceipk: add class to create source ipks
2010-07-01 20:30 sourceipk.bbclass patch submission Chase Maupin
@ 2010-07-01 20:30 ` Chase Maupin
2010-07-06 15:04 ` Koen Kooi
0 siblings, 1 reply; 3+ messages in thread
From: Chase Maupin @ 2010-07-01 20:30 UTC (permalink / raw)
To: openembedded-devel; +Cc: Chase Maupin
* Created the sourceipk.bbclass class that can be used to
package the patched sources and recipe for an application
into an ipk for installation.
* Allows specification of the installation directory for the
sources using the SRCIPK_INSTALL_DIR variable.
* Can be enabled per package and controlled through the
CREATE_SRCIPK variable.
* Creates a README file in the sources directory that
explains the contents of the package.
* User can specify the package architecture for the source ipk
using the SRCIPK_PACKAGE_ARCH variable. The default value is
"all".
* Using the -L flag to the cp command to copy files pointed to by
symlinks and not the symlinks themselves.
Signed-off-by: Chase Maupin <chase.maupin@ti.com>
---
classes/sourceipk.bbclass | 127 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 127 insertions(+), 0 deletions(-)
create mode 100644 classes/sourceipk.bbclass
diff --git a/classes/sourceipk.bbclass b/classes/sourceipk.bbclass
new file mode 100644
index 0000000..e3f2c41
--- /dev/null
+++ b/classes/sourceipk.bbclass
@@ -0,0 +1,127 @@
+# sourceipk.bbclass enables the creation of an ipk file that contains the
+# sources used during the build. The sources contained in the ipk are the
+# patched sources before configuration has been done.
+#
+# This class is used to provide an easy method to ship the corresponding
+# sources for a package to end users so that they can install them on their
+# host or target systems.
+#
+# This package uses the following variables to control its operations:
+# - CREATE_SRCIPK = When set to 1 this variable indicates that
+# a source ipk should be generated for the package.
+# - SRCIPK_INSTALL_DIR = This variable indicates the directory to install
+# the sources into.
+# - SRCIPK_PACKAGE_ARCH = This variable allows specific recipies to
+# specify an architecture for the sourcetree
+# package is "all" is not appropriate
+#
+# The default installation directory for the sources is:
+# /usr/src/${PN}-src
+#
+# By setting the SRCIPK_INSTALL_DIR this default can be changed to any
+# location desired. When combined with the opkg -o option this allows for the
+# system building to specify a relative package install location to the
+# install root given to opkg. Each source ipk can have a different directory.
+#
+# Creation of the source ipk can be controlled per package by setting
+# CREATE_SRCIPK = "1" in the package recipe or by setting
+# CREATE_SRCIPK_pn-<package name> = "1" in your local.conf
+#
+#TODO:
+# Need to figure out how to use ipkg-build in this class.
+# I tried adding it as a dependency for the do_create_srcipk
+# task using:
+# do_create_srcipk[depends] += "ipkg-utils-native:do_populate_sysroot"
+# But then there is a circular dependency between sourcipk.bbclass and
+# ipkg-utils-native. Until I can figure out how to resolve this
+# circular dependency I am extracting the needed pieces from ipkg-build
+# into this class and building the source ipk myself.
+
+
+# Default is to not create the source ipk
+CREATE_SRCIPK ?= "0"
+
+# Default installation prefix
+SRCIPK_INSTALL_DIR ?= "/usr/src/${PN}-src"
+
+# Default PACKAGE_ARCH for sources is "all"
+SRCIPK_PACKAGE_ARCH ?= "all"
+
+# Create a README file that describes the contents of the source ipk
+sourceipk_create_readme() {
+ readme="$1/README.${PN}-src"
+ touch $readme
+ echo 'This package contains the patched sources for ${PN} that' >> $readme
+ echo 'were used to generate the ${PN} binary ipk package(s).' >> $readme
+ echo 'This package does not build or generate the binaries' >> $readme
+ echo 'directly. To build the binaries you must either' >> $readme
+ echo 'configure and build the sources yourself or use:' >> $readme
+ echo ' bitbake ${PN}' >> $readme
+ echo '' >> $readme
+ echo 'NOTE: The patches applied to the sources can be found in' >> $readme
+ echo " the \"patches\" directory" >> $readme
+}
+
+# Create the source ipk file. The ipk is manually created here instead
+# of using the normal ipk system because some recipes will over write
+# the PACKAGES variable. Thus if this class added a -src package
+# to the list of packages to be created that package would be lost.
+# See the linux kernel recipe for an example of this issue.
+sourceipk_do_create_srcipk() {
+ if [ ${CREATE_SRCIPK} != "0" ]
+ then
+ tmp_dir="${WORKDIR}/sourceipk-tmp"
+ srcipk_dir="${WORKDIR}/sourceipk-data"
+ mkdir -p $tmp_dir/CONTROL
+ mkdir -p $srcipk_dir
+ control_file="$tmp_dir/CONTROL/control"
+
+ # Write the control file
+ echo "Package: ${PN}-src" > $control_file
+ echo "Version: ${PV}-${PR}" >> $control_file
+ echo "Description: Patched sources for ${PN}" >> $control_file
+ echo "Section: ${SECTION}" >> $control_file
+ echo "Priority: Optional" >> $control_file
+ echo "Maintainer: ${MAINTAINER}" >> $control_file
+ echo "Architecture: ${SRCIPK_PACKAGE_ARCH}" >> $control_file
+ srcuri="${SRC_URI}"
+ if [ "$srcuri" == "" ]
+ then
+ srcuri="OpenEmbedded"
+ fi
+ echo "Source: $srcuri" >> $control_file
+
+ #Write the control tarball
+ tar -C $tmp_dir/CONTROL --owner=0 --group=0 -czf $srcipk_dir/control.tar.gz .
+
+ # Get rid of temporary control file
+ rm -rf $tmp_dir/CONTROL
+
+ # Copy sources for packaging
+ mkdir -p $tmp_dir/${SRCIPK_INSTALL_DIR}
+ cp -rLf ${S}/* $tmp_dir/${SRCIPK_INSTALL_DIR}/
+ sourceipk_create_readme $tmp_dir/${SRCIPK_INSTALL_DIR}/
+ cp ${FILE} $tmp_dir/${SRCIPK_INSTALL_DIR}/
+
+ #Write the data tarball
+ tar -C $tmp_dir --owner=0 --group=0 -czf $srcipk_dir/data.tar.gz .
+
+ # Create the debian-binary file
+ echo "2.0" > $srcipk_dir/debian-binary
+
+ #Write the ipk file
+ mkdir -p ${DEPLOY_DIR_IPK}/${SRCIPK_PACKAGE_ARCH}
+ pkg_file=${DEPLOY_DIR_IPK}/${SRCIPK_PACKAGE_ARCH}/${PN}-src_${PV}-${PR}_${SRCIPK_PACKAGE_ARCH}.ipk
+ rm -f $pkg_file
+ tar -C $srcipk_dir -czf $pkg_file .
+
+ # Remove the temporary directory
+ rm -rf $tmp_dir
+ fi
+}
+
+EXPORT_FUNCTIONS do_create_srcipk
+
+do_create_srcipk[deptask] = "do_patch"
+
+addtask create_srcipk after do_patch before do_configure
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 1/1] sourceipk: add class to create source ipks
2010-07-01 20:30 ` [PATCH 1/1] sourceipk: add class to create source ipks Chase Maupin
@ 2010-07-06 15:04 ` Koen Kooi
0 siblings, 0 replies; 3+ messages in thread
From: Koen Kooi @ 2010-07-06 15:04 UTC (permalink / raw)
To: openembedded-devel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Looks good to me. I'll apply it if there are no objections.
On 01-07-10 22:30, Chase Maupin wrote:
> * Created the sourceipk.bbclass class that can be used to
> package the patched sources and recipe for an application
> into an ipk for installation.
> * Allows specification of the installation directory for the
> sources using the SRCIPK_INSTALL_DIR variable.
> * Can be enabled per package and controlled through the
> CREATE_SRCIPK variable.
> * Creates a README file in the sources directory that
> explains the contents of the package.
> * User can specify the package architecture for the source ipk
> using the SRCIPK_PACKAGE_ARCH variable. The default value is
> "all".
> * Using the -L flag to the cp command to copy files pointed to by
> symlinks and not the symlinks themselves.
>
> Signed-off-by: Chase Maupin <chase.maupin@ti.com>
> ---
> classes/sourceipk.bbclass | 127 +++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 127 insertions(+), 0 deletions(-)
> create mode 100644 classes/sourceipk.bbclass
>
> diff --git a/classes/sourceipk.bbclass b/classes/sourceipk.bbclass
> new file mode 100644
> index 0000000..e3f2c41
> --- /dev/null
> +++ b/classes/sourceipk.bbclass
> @@ -0,0 +1,127 @@
> +# sourceipk.bbclass enables the creation of an ipk file that contains the
> +# sources used during the build. The sources contained in the ipk are the
> +# patched sources before configuration has been done.
> +#
> +# This class is used to provide an easy method to ship the corresponding
> +# sources for a package to end users so that they can install them on their
> +# host or target systems.
> +#
> +# This package uses the following variables to control its operations:
> +# - CREATE_SRCIPK = When set to 1 this variable indicates that
> +# a source ipk should be generated for the package.
> +# - SRCIPK_INSTALL_DIR = This variable indicates the directory to install
> +# the sources into.
> +# - SRCIPK_PACKAGE_ARCH = This variable allows specific recipies to
> +# specify an architecture for the sourcetree
> +# package is "all" is not appropriate
> +#
> +# The default installation directory for the sources is:
> +# /usr/src/${PN}-src
> +#
> +# By setting the SRCIPK_INSTALL_DIR this default can be changed to any
> +# location desired. When combined with the opkg -o option this allows for the
> +# system building to specify a relative package install location to the
> +# install root given to opkg. Each source ipk can have a different directory.
> +#
> +# Creation of the source ipk can be controlled per package by setting
> +# CREATE_SRCIPK = "1" in the package recipe or by setting
> +# CREATE_SRCIPK_pn-<package name> = "1" in your local.conf
> +#
> +#TODO:
> +# Need to figure out how to use ipkg-build in this class.
> +# I tried adding it as a dependency for the do_create_srcipk
> +# task using:
> +# do_create_srcipk[depends] += "ipkg-utils-native:do_populate_sysroot"
> +# But then there is a circular dependency between sourcipk.bbclass and
> +# ipkg-utils-native. Until I can figure out how to resolve this
> +# circular dependency I am extracting the needed pieces from ipkg-build
> +# into this class and building the source ipk myself.
> +
> +
> +# Default is to not create the source ipk
> +CREATE_SRCIPK ?= "0"
> +
> +# Default installation prefix
> +SRCIPK_INSTALL_DIR ?= "/usr/src/${PN}-src"
> +
> +# Default PACKAGE_ARCH for sources is "all"
> +SRCIPK_PACKAGE_ARCH ?= "all"
> +
> +# Create a README file that describes the contents of the source ipk
> +sourceipk_create_readme() {
> + readme="$1/README.${PN}-src"
> + touch $readme
> + echo 'This package contains the patched sources for ${PN} that' >> $readme
> + echo 'were used to generate the ${PN} binary ipk package(s).' >> $readme
> + echo 'This package does not build or generate the binaries' >> $readme
> + echo 'directly. To build the binaries you must either' >> $readme
> + echo 'configure and build the sources yourself or use:' >> $readme
> + echo ' bitbake ${PN}' >> $readme
> + echo '' >> $readme
> + echo 'NOTE: The patches applied to the sources can be found in' >> $readme
> + echo " the \"patches\" directory" >> $readme
> +}
> +
> +# Create the source ipk file. The ipk is manually created here instead
> +# of using the normal ipk system because some recipes will over write
> +# the PACKAGES variable. Thus if this class added a -src package
> +# to the list of packages to be created that package would be lost.
> +# See the linux kernel recipe for an example of this issue.
> +sourceipk_do_create_srcipk() {
> + if [ ${CREATE_SRCIPK} != "0" ]
> + then
> + tmp_dir="${WORKDIR}/sourceipk-tmp"
> + srcipk_dir="${WORKDIR}/sourceipk-data"
> + mkdir -p $tmp_dir/CONTROL
> + mkdir -p $srcipk_dir
> + control_file="$tmp_dir/CONTROL/control"
> +
> + # Write the control file
> + echo "Package: ${PN}-src" > $control_file
> + echo "Version: ${PV}-${PR}" >> $control_file
> + echo "Description: Patched sources for ${PN}" >> $control_file
> + echo "Section: ${SECTION}" >> $control_file
> + echo "Priority: Optional" >> $control_file
> + echo "Maintainer: ${MAINTAINER}" >> $control_file
> + echo "Architecture: ${SRCIPK_PACKAGE_ARCH}" >> $control_file
> + srcuri="${SRC_URI}"
> + if [ "$srcuri" == "" ]
> + then
> + srcuri="OpenEmbedded"
> + fi
> + echo "Source: $srcuri" >> $control_file
> +
> + #Write the control tarball
> + tar -C $tmp_dir/CONTROL --owner=0 --group=0 -czf $srcipk_dir/control.tar.gz .
> +
> + # Get rid of temporary control file
> + rm -rf $tmp_dir/CONTROL
> +
> + # Copy sources for packaging
> + mkdir -p $tmp_dir/${SRCIPK_INSTALL_DIR}
> + cp -rLf ${S}/* $tmp_dir/${SRCIPK_INSTALL_DIR}/
> + sourceipk_create_readme $tmp_dir/${SRCIPK_INSTALL_DIR}/
> + cp ${FILE} $tmp_dir/${SRCIPK_INSTALL_DIR}/
> +
> + #Write the data tarball
> + tar -C $tmp_dir --owner=0 --group=0 -czf $srcipk_dir/data.tar.gz .
> +
> + # Create the debian-binary file
> + echo "2.0" > $srcipk_dir/debian-binary
> +
> + #Write the ipk file
> + mkdir -p ${DEPLOY_DIR_IPK}/${SRCIPK_PACKAGE_ARCH}
> + pkg_file=${DEPLOY_DIR_IPK}/${SRCIPK_PACKAGE_ARCH}/${PN}-src_${PV}-${PR}_${SRCIPK_PACKAGE_ARCH}.ipk
> + rm -f $pkg_file
> + tar -C $srcipk_dir -czf $pkg_file .
> +
> + # Remove the temporary directory
> + rm -rf $tmp_dir
> + fi
> +}
> +
> +EXPORT_FUNCTIONS do_create_srcipk
> +
> +do_create_srcipk[deptask] = "do_patch"
> +
> +addtask create_srcipk after do_patch before do_configure
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iD8DBQFMM0X5MkyGM64RGpERAlLOAJ9zir2YCyl6hlF8+gAJReg+uWwZkwCdHOFp
m88nsflzdmgtkbIEWkLdtOM=
=VUiZ
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-07-06 15:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-01 20:30 sourceipk.bbclass patch submission Chase Maupin
2010-07-01 20:30 ` [PATCH 1/1] sourceipk: add class to create source ipks Chase Maupin
2010-07-06 15:04 ` Koen Kooi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox