imagebuilder: add REVISION variable (closes #6795)
[openwrt.git] / target / imagebuilder / files / Makefile
index 6429437..49fd6db 100644 (file)
@@ -1,6 +1,6 @@
 # Makefile for OpenWrt
 #
-# Copyright (C) 2007 OpenWrt.org
+# Copyright (C) 2007-2010 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -24,6 +24,9 @@ include rules.mk
 include $(INCLUDE_DIR)/debug.mk
 include $(INCLUDE_DIR)/depends.mk
 
+include $(INCLUDE_DIR)/version.mk
+export REVISION
+
 define Helptext
 Available Commands:
        help:   This help text
@@ -79,20 +82,14 @@ info: FORCE
 $(TOPDIR)/tmp/ipkg.conf: FORCE
        @mkdir -p $(TOPDIR)/tmp
        @echo 'dest root /' > $@
-       @echo 'src packages file:$(TOPDIR)/packages' >> $@
+       @echo 'src packages file:$(PACKAGE_DIR)' >> $@
 
 BUILD_PACKAGES:=$(sort $(DEFAULT_PACKAGES) $(PACKAGES) $($(PROFILE)_PACKAGES) kernel)
-BUILD_PACKAGES:=$(patsubst base-files,base-files-$(BOARD)-$(KERNEL),$(BUILD_PACKAGES))
 # "-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))
 
 image:
-       if [ -z "$($(PROFILE)_NAME)" ]; then \
-               echo Profile $(PROFILE) not found.; \
-               echo 'Use "make info" to get a list of available target profiles'; \
-               false; \
-       fi
-       echo 'Building images for $(BOARD) - $($(PROFILE)_NAME)'
+       echo 'Building images for $(BOARD)$(if $($(PROFILE)_NAME), - $($(PROFILE)_NAME))'
        echo 'Packages: $(BUILD_PACKAGES)'
        echo
        rm -rf $(TARGET_DIR)
@@ -108,7 +105,9 @@ endif
 package_index: $(TOPDIR)/tmp/ipkg.conf FORCE
        @echo
        @echo Building package index...
-       (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages) >/dev/null 2>/dev/null
+       (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages && \
+               gzip -9c Packages > Packages.gz \
+       ) >/dev/null 2>/dev/null
        $(IPKG) update
 
 package_install: FORCE
@@ -125,10 +124,10 @@ package_postinst: FORCE
        @echo
        @echo Activating init scripts
        @( \
-               cd $(BUILD_DIR)/root; \
+               cd $(TARGET_DIR); \
                for script in ./etc/init.d/*; do \
                        grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
-                       IPKG_INSTROOT=$(BUILD_DIR)/root $(which bash) ./etc/rc.common $$script enable; \
+                       IPKG_INSTROOT=$(TARGET_DIR) $(which bash) ./etc/rc.common $$script enable; \
                done || true; \
        )