Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Vinay Malkani <vmalkani@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] automated opkg repository building. Fixes Version, Description, and pkg-generic.mk
Date: Mon,  3 Feb 2014 19:07:53 +0000	[thread overview]
Message-ID: <1391454473-6735-2-git-send-email-vmalkani@gmail.com> (raw)
In-Reply-To: <1391454473-6735-1-git-send-email-vmalkani@gmail.com>

---
 fs/Config.in                |  1 +
 fs/ipk/Config.in            | 13 +++++++
 fs/ipk/ipk.mk               | 22 +++++++++++
 package/pkg-generic.mk      |  2 +
 support/scripts/ipk-post.sh | 94 +++++++++++++++++++++++++++++++++++++++++++++
 support/scripts/ipk-pre.sh  | 31 +++++++++++++++
 6 files changed, 163 insertions(+)
 create mode 100644 fs/ipk/Config.in
 create mode 100644 fs/ipk/ipk.mk
 create mode 100755 support/scripts/ipk-post.sh
 create mode 100755 support/scripts/ipk-pre.sh

diff --git a/fs/Config.in b/fs/Config.in
index da4c5ff..7689cc2 100644
--- a/fs/Config.in
+++ b/fs/Config.in
@@ -11,5 +11,6 @@ source "fs/romfs/Config.in"
 source "fs/squashfs/Config.in"
 source "fs/tar/Config.in"
 source "fs/ubifs/Config.in"
+source "fs/ipk/Config.in"
 
 endmenu
diff --git a/fs/ipk/Config.in b/fs/ipk/Config.in
new file mode 100644
index 0000000..9087265
--- /dev/null
+++ b/fs/ipk/Config.in
@@ -0,0 +1,13 @@
+config BR2_TARGET_ROOTFS_IPK_REPO
+	bool "Ipk repository with packages"
+	default y
+	help
+	  Create a repository compatible with opkg/dpkg tools.
+
+	  Each selected packages is splitted in 4 parts:
+	     - main package with debug symbols stripped off
+	     - debug symbols
+	     - development files
+	     - documentation files
+	     - locales
+
diff --git a/fs/ipk/ipk.mk b/fs/ipk/ipk.mk
new file mode 100644
index 0000000..8b8d6f2
--- /dev/null
+++ b/fs/ipk/ipk.mk
@@ -0,0 +1,22 @@
+#############################################################
+#
+# Generate a repository for opkg
+#
+#############################################################
+
+define ROOTFS_IPK_REPO_CMD
+	mkdir -p $(BINARIES_DIR)/ipk_repository;                                                             \
+	( cd $(BINARIES_DIR)/ipk_repository && dpkg-scanpackages . ) > $(BINARIES_DIR)/ipk_repository/Packages; \
+	gzip < $(BINARIES_DIR)/ipk_repository/Packages      > $(BINARIES_DIR)/ipk_repository/Packages.gz;    \
+	echo "Archive: unstable"                           >> $(BINARIES_DIR)/ipk_repository/Release;        \
+	echo "Origin: Buildroot"                           >> $(BINARIES_DIR)/ipk_repository/Release;        \
+	echo "Label: Buildroot autogenerated repository"   >> $(BINARIES_DIR)/ipk_repository/Release;        \
+	echo "Architecture: $(ARCH)"                       >> $(BINARIES_DIR)/ipk_repository/Release;        \
+	echo "Your repository is ready.";                                                                    \
+	echo "If you use opkg, add this line to your /etc/opkg/buildroot.conf:";                             \
+	echo "   src/gz buildroot file://$(BINARIES_DIR)/ipk_repository";                                    \
+	echo "If you use apt, add this one to /etc/apt/sources.list.d/buildroot.list:";                      \
+	echo "   deb file://$(BINARIES_DIR)/ipk_repository .";
+endef
+
+$(eval $(call ROOTFS_TARGET,ipk_repo))
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 1b99c2a..c1c682f 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -216,6 +216,7 @@ $(BUILD_DIR)/%/.stamp_images_installed:
 $(BUILD_DIR)/%/.stamp_target_installed:
 	@$(call step_start,install-target)
 	@$(call MESSAGE,"Installing to target")
+	$(if $(BR2_TARGET_ROOTFS_IPK_REPO),support/scripts/ipk-pre.sh $(TARGET_DIR) $(BUILD_DIR) $($(PKG)_DIR_PREFIX) $($(PKG)_RAWNAME) $($(PKG)_VERSION)) $(ARCH) 
 	$(if $(BR2_INIT_SYSTEMD),\
 		$($(PKG)_INSTALL_INIT_SYSTEMD))
 	$(if $(BR2_INIT_SYSV)$(BR2_INIT_BUSYBOX),\
@@ -225,6 +226,7 @@ $(BUILD_DIR)/%/.stamp_target_installed:
 	$(Q)if test -n "$($(PKG)_CONFIG_SCRIPTS)" ; then \
 		$(RM) -f $(addprefix $(TARGET_DIR)/usr/bin/,$($(PKG)_CONFIG_SCRIPTS)) ; \
 	fi
+	$(if $(BR2_TARGET_ROOTFS_IPK_REPO),support/scripts/ipk-post.sh $(TARGET_DIR) $(BUILD_DIR) $($(PKG)_DIR_PREFIX) $($(PKG)_RAWNAME) $($(PKG)_VERSION)) $(ARCH) 
 	$(Q)touch $@
 	@$(call step_end,install-target)
 
diff --git a/support/scripts/ipk-post.sh b/support/scripts/ipk-post.sh
new file mode 100755
index 0000000..6b4eab3
--- /dev/null
+++ b/support/scripts/ipk-post.sh
@@ -0,0 +1,94 @@
+#!/bin/bash 
+#
+# Licence: GPL
+# Created: 2013-01-15 15:26:45+01:00
+# Main authors:
+#     - J?r?me Pouiller <[hidden email]>
+#     - Vinay Malkani	<[hidden email]>
+#
+# Second part of package building.
+#
+# Kill previously launched daemon. Using daemon result, create ipk files of
+# package.
+#
+
+TARGET_DIR=$1
+BUILD_DIR=$2
+PACKAGES_DIR=$3
+PKG_RAWNAME=$4
+PKG_VERSION=$5
+ARCH=$6
+PKG_DIR=$PACKAGES_DIR/$PKG_RAWNAME
+PKG_BUILD_DIR=$BUILD_DIR/$PKG_RAWNAME-$PKG_VERSION
+IPK_DIR=$BUILD_DIR/ipk_build
+PKG=$PKG_RAWNAME
+
+kill $(cat $PKG_BUILD_DIR/.ipk_inotify_pid)
+
+# Create DEBIAN/control files
+for P in $PKG $PKG-i18n $PKG-doc $PKG-dbg $PKG-dev; do
+    rm -fr $IPK_DIR/$P
+    mkdir -p $IPK_DIR/$P/DEBIAN
+    (
+        PKG_VERSION=`echo $PKG_VERSION | sed 's/^[a-Z]//g'`
+	echo "Package: $P"
+	echo "Version: $PKG_VERSION"
+	echo "Architecture: $ARCH"
+	echo "Maintainer: Buildroot Automated  <[no email]>"
+	[ $P == $PKG-i18n ] && echo "Depends: $PKG"
+	[ $P == $PKG-dev  ] && echo "Depends: $PKG"
+	[ $P == $PKG-dbg  ] && echo "Depends: $PKG"
+	[ $P == $PKG-doc  ] && echo "Recommends: $PKG"
+	echo "Description: $P"
+	sed '1,/help/d; /^$/Q' $PKG_DIR/Config.in
+        echo
+    ) > $IPK_DIR/$P/DEBIAN/control
+done
+
+# Place application files in package trees
+cut -f 2 $PKG_BUILD_DIR/.ipk_list_installed_files | sort | uniq | while read FILE_FULL; do
+  FILE=${FILE_FULL##$TARGET_DIR/}
+  DIR=${FILE%/*}
+  [[ -e $FILE_FULL ]] || continue
+  [[ -d $FILE_FULL ]] && continue
+  case /$FILE in
+    /usr/include/*|*.a|*.la|/usr/lib/pkgconfig/*|/usr/share/aclocal/*)
+      mkdir -p $IPK_DIR/$PKG-dev/$DIR
+      cp -pd $FILE_FULL $IPK_DIR/$PKG-dev/$FILE
+      ;;
+    /bin/*|/sbin/*|/lib/*.so*|/usr/bin/*|/usr/sbin/*|/usr/lib/*.so*)
+      mkdir -p $IPK_DIR/$PKG/$DIR
+      if [[ -L $FILE_FULL ]]; then
+          cp -pd $FILE_FULL $IPK_DIR/$PKG/$FILE
+      else
+          mkdir -p $IPK_DIR/$PKG-dbg/$DIR
+          strip $FILE_FULL -o $IPK_DIR/$PKG-dbg/$FILE.dbg --only-keep-debug
+          if [[ /$FILE == *thread*.so* ]]; then
+            strip $FILE_FULL -o $IPK_DIR/$PKG/$FILE --strip-debug
+          else
+            strip $FILE_FULL -o $IPK_DIR/$PKG/$FILE
+          fi
+      fi
+      ;;
+    /usr/*doc/*|/usr/*man/*|/usr/*info/*|/usr/*gtk-doc/*)
+      mkdir -p $IPK_DIR/$PKG-doc/$DIR
+      cp -pd $FILE_FULL $IPK_DIR/$PKG-doc/$FILE
+      ;;
+    /usr/share/locale/*)
+      mkdir -p $IPK_DIR/$PKG-i18n/$DIR
+      cp -pd $FILE_FULL $IPK_DIR/$PKG-i18n/$FILE
+      ;;
+    *)
+      mkdir -p $IPK_DIR/$PKG/$DIR
+      cp -pd $FILE_FULL $IPK_DIR/$PKG/$FILE
+      ;;
+  esac
+done
+
+# Create .deb (same than .ipk) file
+mkdir -p $BUILD_DIR/../images/ipk_repository
+for P in $PKG $PKG-i18n $PKG-doc $PKG-dbg $PKG-dev; do
+   if [[ $(ls $IPK_DIR/$P | wc -l) -gt 1 ]]; then
+       dpkg-deb -b $IPK_DIR/$P $BUILD_DIR/../images/ipk_repository
+   fi
+done
diff --git a/support/scripts/ipk-pre.sh b/support/scripts/ipk-pre.sh
new file mode 100755
index 0000000..31f54bc
--- /dev/null
+++ b/support/scripts/ipk-pre.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# Licence: GPL
+# Created: 2013-01-15 15:25:52+01:00
+# Main authors:
+#     - J?r?me Pouiller <[hidden email]>
+#     - Vinay Malkani <[hidden email]>
+#
+# First part of package building.
+#
+# It launches a daemon to spy write acces to target. Results are written to
+# .ipk_list_installed_files in build subdirectory of package.
+#
+
+TARGET_DIR=$1
+BUILD_DIR=$2
+PACKAGES_DIR=$3
+PKG_RAWNAME=$4
+PKG_VERSION=$5
+PKG_DIR=$PACKAGES_DIR/$PKG_RAWNAME
+PKG_BUILD_DIR=$BUILD_DIR/$PKG_RAWNAME-$PKG_VERSION
+IPK_DIR=$BUILD_DIR/ipk_build
+PKG=$PKG_RAWNAME
+
+inotifywait -mr $TARGET_DIR -e create -e modify -e moved_to --format '%e	%w%f' >  $PKG_BUILD_DIR/.ipk_list_installed_files &
+echo $! > $PKG_BUILD_DIR/.ipk_inotify_pid
+# FIXME Be sure inotifywait is started
+#sleep 3
+
+
+
-- 
1.8.3.2

  reply	other threads:[~2014-02-03 19:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Add support for automated building of Opkg repository>
2014-02-03 19:07 ` [Buildroot] automated building of Opkg repository Vinay Malkani
2014-02-03 19:07   ` Vinay Malkani [this message]
2014-02-03 19:11   ` vmalkani
2014-02-03 21:42   ` Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1391454473-6735-2-git-send-email-vmalkani@gmail.com \
    --to=vmalkani@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox