opkg and opkg-utils can now be used to build .ipk files and generate images
from them.

No longer default HOST_IPKG_UTILS and HOST_IPKG to yes.
HOST_PACKAGE_MANAGEMENT_IPKG will select HOST_IPKG.
HOST_IPKG will select HOST_IPKG_UTILS.

Added package management selection to hosttools.

Changed scripts to use the package management utilities for the selected
package management system.

Signed-off-by: George McCollister <george.mccollis...@gmail.com>
---
 rules/host-ipkg-utils.in                        |    2 -
 rules/host-ipkg.in                              |    3 +-
 rules/host-package-management.in                |   22 +++++++++++
 rules/post/image_ipkg.make                      |    9 +++--
 rules/post/ptxd_make_image_common.make          |    1 +
 rules/post/ptxd_make_xpkg_common.make           |    4 ++-
 rules/post/virtual.make                         |    5 +++
 scripts/ipkg-push                               |    5 ++-
 scripts/lib/ptxd_make_image_prepare_work_dir.sh |   18 ++++++---
 scripts/lib/ptxd_make_ipkg_finish.sh            |    3 +-
 scripts/lib/ptxd_make_opkg_common.sh            |   22 +++++++++++
 scripts/lib/ptxd_make_opkg_finish.sh            |   45 +++++++++++++++++++++++
 12 files changed, 122 insertions(+), 17 deletions(-)
 create mode 100644 rules/host-package-management.in
 create mode 100644 scripts/lib/ptxd_make_opkg_common.sh
 create mode 100644 scripts/lib/ptxd_make_opkg_finish.sh

diff --git a/rules/host-ipkg-utils.in b/rules/host-ipkg-utils.in
index ff5018a..da10ff0 100644
--- a/rules/host-ipkg-utils.in
+++ b/rules/host-ipkg-utils.in
@@ -2,8 +2,6 @@
 
 config HOST_IPKG_UTILS
        tristate
-       # no prompt, policy is that we always need it
-       default y
        help
          ipkg-utils let you build packages in the ipkg format.
 
diff --git a/rules/host-ipkg.in b/rules/host-ipkg.in
index 00c8b2a..fa8b1d6 100644
--- a/rules/host-ipkg.in
+++ b/rules/host-ipkg.in
@@ -2,8 +2,7 @@
 
 config HOST_IPKG
        tristate
-       default y
-       # no prompt, policy is that we always need it
+       select HOST_IPKG_UTILS
        help
          ipkg is used on the development host to install packets into
          some directory. Example:
diff --git a/rules/host-package-management.in b/rules/host-package-management.in
new file mode 100644
index 0000000..f3d0f41
--- /dev/null
+++ b/rules/host-package-management.in
@@ -0,0 +1,22 @@
+## SECTION=hosttools
+
+choice
+       prompt "package management  "
+       default HOST_PACKAGE_MANAGEMENT_IPKG
+
+       config HOST_PACKAGE_MANAGEMENT_IPKG
+               bool
+               select HOST_IPKG
+               prompt "ipkg   "
+
+       config HOST_PACKAGE_MANAGEMENT_OPKG
+               bool
+               select HOST_OPKG
+               prompt "opkg   "
+endchoice
+
+config HOST_PACKAGE_MANAGEMENT
+       string
+       default "ipkg" if HOST_PACKAGE_MANAGEMENT_IPKG
+       default "opkg" if HOST_PACKAGE_MANAGEMENT_OPKG
+
diff --git a/rules/post/image_ipkg.make b/rules/post/image_ipkg.make
index 0385383..a375868 100644
--- a/rules/post/image_ipkg.make
+++ b/rules/post/image_ipkg.make
@@ -18,13 +18,14 @@ $(STATEDIR)/ipkg-push: 
$(STATEDIR)/host-ipkg-utils.install.post $(STATEDIR)/worl
 ifdef PTXCONF_IMAGE_IPKG_FORCED_PUSH
        rm  -rf 
$(PTXCONF_SETUP_IPKG_REPOSITORY)/$(PTXCONF_PROJECT)/dists/$(PTXCONF_PROJECT)$(PTXCONF_PROJECT_VERSION)
 endif
-       @echo "pushing ipkg pakets to ipkg-repository..."
+       @echo "pushing ipkg packets to ipkg-repository..."
        @$(HOST_ENV) $(PTXDIST_TOPDIR)/scripts/ipkg-push \
                --ipkgdir  $(call remove_quotes,$(PKGDIR)) \
                --repodir  $(call 
remove_quotes,$(PTXCONF_SETUP_IPKG_REPOSITORY)) \
                --revision $(call remove_quotes,$(PTXDIST_VERSION_FULL)) \
                --project  $(call remove_quotes,$(PTXCONF_PROJECT)) \
-               --dist     $(call 
remove_quotes,$(PTXCONF_PROJECT)$(PTXCONF_PROJECT_VERSION))
+               --dist     $(call 
remove_quotes,$(PTXCONF_PROJECT)$(PTXCONF_PROJECT_VERSION)) \
+               --type     $(PTXCONF_HOST_PACKAGE_MANAGEMENT)
        @echo "ipkg-repository updated"
        @touch $@
 
@@ -37,8 +38,8 @@ PHONY += $(PKGDIR)/Packages
 $(PKGDIR)/Packages: $(STATEDIR)/host-ipkg-utils.install.post
        @echo "Creating ipkg index '$@'..."
        @rm -f $(PKGDIR)/Packages*
-       @$(HOST_ENV) \
-               ipkg-make-index -l "$(PKGDIR)/Packages.filelist" -p "$(@)" 
"$(PKGDIR)" 
+       @$(HOST_ENV) $(PTXCONF_HOST_PACKAGE_MANAGEMENT)-make-index \
+               -l "$(PKGDIR)/Packages.filelist" -p "$(@)" "$(PKGDIR)"
        @echo "done."
 
 # vim: syntax=make
diff --git a/rules/post/ptxd_make_image_common.make 
b/rules/post/ptxd_make_image_common.make
index fd639a3..5969fd4 100644
--- a/rules/post/ptxd_make_image_common.make
+++ b/rules/post/ptxd_make_image_common.make
@@ -17,6 +17,7 @@ DOPERMISSIONS := '{   \
 image/env = \
        $(call ptx/env) \
        image_pkgs_selected_target="$(call ptx/escape,$(PTX_PACKAGES_INSTALL))" 
\
+       image_xpkg_type=$(PTXCONF_HOST_PACKAGE_MANAGEMENT) \
        \
        image_work_dir="$(call ptx/escape,$(image/work_dir))" \
        image_permissions="$(call ptx/escape,$(image/permissions))"
diff --git a/rules/post/ptxd_make_xpkg_common.make 
b/rules/post/ptxd_make_xpkg_common.make
index c7bff35..8d27c35 100644
--- a/rules/post/ptxd_make_xpkg_common.make
+++ b/rules/post/ptxd_make_xpkg_common.make
@@ -1,6 +1,7 @@
 # -*-makefile-*-
 #
 # Copyright (C) 2009, 2010 by Marc Kleine-Budde <m...@pengutronix.de>
+#               2011 by George McCollister <george.mccollis...@gmail.com>
 #
 # See CREDITS for details about who has contributed to this project.
 #
@@ -17,7 +18,8 @@ xpkg/env/impl = \
        CROSS_STRIP="$(call ptx/escape,$(CROSS_STRIP))"                         
\
        pkg_xpkg="$(call ptx/escape,$(1))"                                      
\
        pkg_ipkg_extra_args=$(PTXCONF_IMAGE_IPKG_EXTRA_ARGS)                    
\
-       pkg_xpkg_type="ipkg"
+       pkg_opkg_extra_args=$(PTXCONF_IMAGE_OPKG_EXTRA_ARGS)                    
\
+       pkg_xpkg_type=$(PTXCONF_HOST_PACKAGE_MANAGEMENT)
 
 #
 # $1: xpkg label
diff --git a/rules/post/virtual.make b/rules/post/virtual.make
index a484e52..4ba83fc 100644
--- a/rules/post/virtual.make
+++ b/rules/post/virtual.make
@@ -1,6 +1,7 @@
 # -*-makefile-*-
 #
 # Copyright (C) 2003-2010 by Marc Kleine-Budde <m...@pengutronix.de>
+#               2011 by George McCollister <george.mccollis...@gmail.com>
 # See CREDITS for details about who has contributed to this project.
 #
 # For further information about the PTXdist project and license conditions
@@ -19,6 +20,10 @@ ifdef PTXCONF_HOST_IPKG_UTILS
 $(STATEDIR)/virtual-cross-tools.install: 
$(STATEDIR)/host-ipkg-utils.install.post
 endif
 
+ifdef PTXCONF_HOST_OPKG_UTILS
+$(STATEDIR)/virtual-cross-tools.install: 
$(STATEDIR)/host-opkg-utils.install.post
+endif
+
 ifdef PTXCONF_CROSS_PKG_CONFIG_WRAPPER
 $(STATEDIR)/virtual-cross-tools.install: 
$(STATEDIR)/cross-pkg-config-wrapper.install.post
 endif
diff --git a/scripts/ipkg-push b/scripts/ipkg-push
index 4c8d224..3f8c823 100755
--- a/scripts/ipkg-push
+++ b/scripts/ipkg-push
@@ -31,6 +31,7 @@ usage() {
        echo "  --revision <revision>      dist revision name to be updated"
        echo "  --project  <projectname>   project name"
        echo "  --dist     <distname>      use this to make a dist release 
(optional)"
+       echo "  --type     <package type>  specify package type (default: ipkg)"
        echo
        exit 0
 }
@@ -40,6 +41,7 @@ REPODIR=
 DISTREVISION=
 PROJECT=
 DIST=
+TYPE=ipkg
 
 
 #
@@ -53,6 +55,7 @@ while [ $# -gt 0 ]; do
                --revision) DISTREVISION=`ptxd_abspath $2`; shift 2 ;;
                --project)  PROJECT=$2;                     shift 2 ;;
                --dist)     DIST=$2;                        shift 2 ;;
+               --type)     TYPE=$2;                        shift 2 ;;
                *)  usage "unknown option $1" ;;
        esac
 done
@@ -190,7 +193,7 @@ done
 
 echo "creating index.....: "
 
-(cd $REPODIR/$PROJECT/dists/$DIST && ipkg-make-index . > Packages)
+(cd $REPODIR/$PROJECT/dists/$DIST && ${TYPE}-make-index . > Packages)
 
 exit
 
diff --git a/scripts/lib/ptxd_make_image_prepare_work_dir.sh 
b/scripts/lib/ptxd_make_image_prepare_work_dir.sh
index 1715abe..3dd6229 100644
--- a/scripts/lib/ptxd_make_image_prepare_work_dir.sh
+++ b/scripts/lib/ptxd_make_image_prepare_work_dir.sh
@@ -1,6 +1,7 @@
 #!/bin/bash
 #
 # Copyright (C) 2010 by Marc Kleine-Budde <m...@pengutronix.de>
+#               2011 by George McCollister <george.mccollis...@gmail.com>
 #
 # See CREDITS for details about who has contributed to this project.
 #
@@ -22,11 +23,16 @@
 # out:
 # - $image_permissions         file containing all permissions
 #
-ptxd_make_image_extract_ipkg_files() {
+ptxd_make_image_extract_xpkg_files() {
     # FIXME: consolidate "ptxd_install_setup_src"
     local src="/etc/ipkg.conf"
-    local ipkg_conf="${PTXDIST_TEMPDIR}/${FUNCNAME}_ipkg.conf"
+    local xpkg_conf="${PTXDIST_TEMPDIR}/${FUNCNAME}_xpkg.conf"
     local -a list ptxd_reply
+    if ptxd_get_ptxconf "PTXCONF_HOST_PACKAGE_MANAGEMENT_OPKG" > /dev/null; 
then
+       src="/etc/opkg/opkg.conf"
+    else
+       src="/etc/ipkg.conf"
+    fi
     list=( \
        "${PTXDIST_WORKSPACE}/projectroot${PTXDIST_PLATFORMSUFFIX}${src}" \
        "${PTXDIST_WORKSPACE}/projectroot${src}${PTXDIST_PLATFORMSUFFIX}" \
@@ -50,10 +56,10 @@ ${list[*]}
 
     ARCH="${PTXDIST_IPKG_ARCH_STRING}" \
     SRC="" \
-       ptxd_replace_magic "${ptxd_reply}" > "${ipkg_conf}" &&
+       ptxd_replace_magic "${ptxd_reply}" > "${xpkg_conf}" &&
 
     DESTDIR="${image_work_dir}" \
-       fakeroot -- ipkg-cl -f "${ipkg_conf}" -o "${image_work_dir}" \
+       fakeroot -- ${image_xpkg_type}-cl -f "${xpkg_conf}" -o 
"${image_work_dir}" \
        install "${ptxd_reply_ipkg_files[@]}" &&
     if ! cat "${ptxd_reply_perm_files[@]}" > "${image_permissions}"; then
        echo "${PTXDIST_LOG_PROMPT}error: failed read permission files" >&2
@@ -62,12 +68,12 @@ ${list[*]}
 
     return
 }
-export -f ptxd_make_image_extract_ipkg_files
+export -f ptxd_make_image_extract_xpkg_files
 
 
 ptxd_make_image_prepare_work_dir() {
     ptxd_make_image_init &&
     ptxd_get_ipkg_files &&
-    ptxd_make_image_extract_ipkg_files
+    ptxd_make_image_extract_xpkg_files
 }
 export -f ptxd_make_image_prepare_work_dir
diff --git a/scripts/lib/ptxd_make_ipkg_finish.sh 
b/scripts/lib/ptxd_make_ipkg_finish.sh
index 8f91916..fe91954 100644
--- a/scripts/lib/ptxd_make_ipkg_finish.sh
+++ b/scripts/lib/ptxd_make_ipkg_finish.sh
@@ -2,6 +2,7 @@
 #
 # Copyright (C) 2005, 2006, 2007 Robert Schwebel <r.schwe...@pengutronix.de>
 #               2008, 2009, 2010 by Marc Kleine-Budde <m...@pengutronix.de>
+#               2011 by George McCollister <george.mccollis...@gmail.com>
 #
 # See CREDITS for details about who has contributed to this project.
 #
@@ -30,7 +31,7 @@ ptxd_make_ipkg_finish() {
     dep="${pkg_xpkg_deps[*]}"
     dep="${dep// /, }"
 
-    sed -i -e "s:@DEPENDS@:${dep}:g" "${pkg_ipkg_control}" || return
+    sed -i -e "s:@DEPENDS@:${dep}:g" "${pkg_xpkg_control}" || return
 
     local -a fake_args
     if [ -f "${pkg_fake_env}" ]; then
diff --git a/scripts/lib/ptxd_make_opkg_common.sh 
b/scripts/lib/ptxd_make_opkg_common.sh
new file mode 100644
index 0000000..dca8580
--- /dev/null
+++ b/scripts/lib/ptxd_make_opkg_common.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# Copyright (C) 2009 by Marc Kleine-Budde <m...@pengutronix.de>
+#               2011 by George McCollister <george.mccollis...@gmail.com>
+#
+# 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.
+#
+
+
+#
+# initialize variables needed to package opkgs
+#
+ptxd_make_opkg_init() {
+    pkg_opkg_tmp="${pkg_xpkg_tmp}/opkg"
+    pkg_xpkg_control_dir="${pkg_opkg_tmp}/CONTROL"
+    pkg_xpkg_control="${pkg_xpkg_control_dir}/control"
+    pkg_xpkg_conffiles="${pkg_xpkg_control_dir}/conffiles"
+}
+export -f ptxd_make_opkg_init
diff --git a/scripts/lib/ptxd_make_opkg_finish.sh 
b/scripts/lib/ptxd_make_opkg_finish.sh
new file mode 100644
index 0000000..97e1034
--- /dev/null
+++ b/scripts/lib/ptxd_make_opkg_finish.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# Copyright (C) 2005, 2006, 2007 Robert Schwebel <r.schwe...@pengutronix.de>
+#               2008, 2009, 2010 by Marc Kleine-Budde <m...@pengutronix.de>
+#               2011 by George McCollister <george.mccollis...@gmail.com>
+#
+# 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.
+#
+
+#
+# the actual opkg package creation, will run in fakeroot
+#
+ptxd_make_opkg_finish_impl() {
+    chown -R 0:0 "${pkg_xpkg_tmp}" &&
+    ptxd_make_xpkg_pkg "${pkg_opkg_tmp}" "${pkg_xpkg_cmds}" 
"${pkg_xpkg_perms}" &&
+    opkg-build ${pkg_opkg_extra_args} "${pkg_opkg_tmp}" "${ptx_pkg_dir}"
+}
+export -f ptxd_make_opkg_finish_impl
+
+
+#
+# create an opkg package
+#
+ptxd_make_opkg_finish() {
+    local dep
+
+    # replace space with ", "
+    dep="${pkg_xpkg_deps[*]}"
+    dep="${dep// /, }"
+
+    sed -i -e "s:@DEPENDS@:${dep}:g" "${pkg_xpkg_control}" || return
+
+    local -a fake_args
+    if [ -f "${pkg_fake_env}" ]; then
+       fake_args=( "-i" "${pkg_fake_env}" )
+    fi
+    fake_args[${#fake_args[@]}]="-u"
+
+    export ${!pkg_*} ${!ptx_*}
+    fakeroot "${fake_args[@]}" -- ptxd_make_opkg_finish_impl
+}
+export -f ptxd_make_opkg_finish
-- 
1.7.1


-- 
ptxdist mailing list
ptxdist@pengutronix.de

Reply via email to