- add a helper script to generate opkg.conf, attempt to detect package architecture...
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 8 Sep 2010 00:36:35 +0000 (00:36 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 8 Sep 2010 00:36:35 +0000 (00:36 +0000)
SVN-Revision: 22978

target/imagebuilder/Makefile
target/imagebuilder/files/Makefile
target/imagebuilder/files/opkg-generate-config.sh [new file with mode: 0755]
target/imagebuilder/files/repositories.conf [new file with mode: 0644]

index 42fb7bb69b1fe70429ca8f97b17bdc9d65b40891..9e9afb2b273cfec3859bee6fac218c8ea874de23 100644 (file)
@@ -22,15 +22,18 @@ all: compile
 
 $(BIN_DIR)/$(IB_NAME).tar.bz2: clean
        rm -rf $(PKG_BUILD_DIR)
-       mkdir -p $(IB_KDIR) $(PKG_BUILD_DIR)/staging_dir/host $(PKG_BUILD_DIR)/target
+       mkdir -p $(IB_KDIR) $(PKG_BUILD_DIR)/staging_dir/host \
+               $(PKG_BUILD_DIR)/target $(PKG_BUILD_DIR)/scripts
        -cp $(TOPDIR)/.config $(PKG_BUILD_DIR)/.config
        $(CP) \
                $(INCLUDE_DIR) $(SCRIPT_DIR) \
                $(TOPDIR)/rules.mk \
                ./files/Makefile \
+               ./files/repositories.conf \
                $(TMP_DIR)/.targetinfo \
                $(TMP_DIR)/.packageinfo \
                $(PKG_BUILD_DIR)/
+       $(CP) ./files/opkg-generate-config.sh $(PKG_BUILD_DIR)/scripts/
        $(CP) $(PACKAGE_DIR) $(PKG_BUILD_DIR)/packages
        $(CP) $(STAGING_DIR_HOST)/bin $(PKG_BUILD_DIR)/staging_dir/host/
        $(CP) $(TOPDIR)/target/linux $(PKG_BUILD_DIR)/target/
index 8e6c6d746262fb617720aa23034e23963267f620..0590dfa72c643a09715323ba8ae2ff221ee0c8b7 100644 (file)
@@ -86,19 +86,12 @@ _call_info: FORCE
 $(TOPDIR)/tmp/opkg.conf: FORCE
        @mkdir -p $(TOPDIR)/tmp
        @mkdir -p $(TARGET_DIR)/tmp
-       @echo 'dest root /' > $@
-       @echo 'src packages file:$(PACKAGE_DIR)' >> $@
-       @echo 'arch all 100' >> $@
-ifneq ($(CONFIG_TARGET_adm5120),y)
-       @echo 'arch $(BOARD) 200' >> $@
-else
-       @echo 'arch $(BOARD)_$(ARCH) 200' >> $@
-endif
-       @echo 'option offline_root $(TARGET_DIR)' >> $@
+       @$(TOPDIR)/scripts/opkg-generate-config.sh $(TARGET_DIR)
 
 BUILD_PACKAGES:=$(sort $(DEFAULT_PACKAGES) $(USER_PACKAGES) $($(USER_PROFILE)_PACKAGES) kernel)
 # "-pkgname" in the package list means remove "pkgname" from the package list
 BUILD_PACKAGES:=$(filter-out $(filter -%,$(BUILD_PACKAGES)) $(patsubst -%,%,$(filter -%,$(BUILD_PACKAGES))),$(BUILD_PACKAGES))
+PACKAGES:=
 
 _call_image:
        echo 'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))'
diff --git a/target/imagebuilder/files/opkg-generate-config.sh b/target/imagebuilder/files/opkg-generate-config.sh
new file mode 100755 (executable)
index 0000000..a385d9f
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+TOPDIR="$(pwd)"
+TARGETDIR="${1}"
+
+[ -f "$TOPDIR/scripts/${0##*/}" ] || {
+       echo "Please execute within the toplevel directory" >&2
+       exit 1
+}
+
+# Try to find package architecture from packages directory
+PKGARCH=
+for pkg in $TOPDIR/packages/*.ipk; do
+       if [ -f "$pkg" ]; then
+               PKGARCH="${pkg##*_}"
+               PKGARCH="${PKGARCH%.ipk}"
+               [ "$PKGARCH" = all ] || break
+       fi
+done
+
+# Try to find package architecture from the target directory
+[ -n "$PKGARCH" ] || {
+       PKGARCH="${TARGETDIR##*/root-}"
+       [ "$PKGARCH" != "$TARGETDIR" ] || {
+               echo "Cannot determine package architecture" >&2
+               exit 1
+       }
+}
+
+rm -f $TOPDIR/tmp/opkg.conf
+
+[ -f $TOPDIR/repositories.conf ] && \
+       $TOPDIR/staging_dir/host/bin/sed \
+               -n -e "s/\$A/$PKGARCH/g" -e "/^[[:space:]*]src/p" \
+               $TOPDIR/repositories.conf > $TOPDIR/tmp/opkg.conf
+
+cat <<EOT >> $TOPDIR/tmp/opkg.conf
+dest root /
+arch all 100
+arch $PKGARCH 200
+option offline_root $TARGETDIR
+src imagebuilder file:$TOPDIR/packages
+EOT
+
+exit 0
diff --git a/target/imagebuilder/files/repositories.conf b/target/imagebuilder/files/repositories.conf
new file mode 100644 (file)
index 0000000..a8bb183
--- /dev/null
@@ -0,0 +1,5 @@
+## Place your custom repositories here, they must match the architecture and version.
+## The special placeholder "$A" can be used to specify the current package architecture.
+
+# src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/$A/packages
+# src custom file:///usr/src/openwrt/bin/$A/packages