Merge pull request #866 from arjendekorte/patch-4
[project/luci.git] / luci.mk
diff --git a/luci.mk b/luci.mk
index 0aba5c5..2235cc5 100644 (file)
--- a/luci.mk
+++ b/luci.mk
@@ -30,7 +30,7 @@ LUCI_LANG.pt-br=Português do Brasil (Brazialian Portuguese)
 LUCI_LANG.pt=Português (Portuguese)
 LUCI_LANG.ro=Română (Romanian)
 LUCI_LANG.ru=Русский (Russian)
-LUCI_LANG.sk=Slovenčina (Slovene)
+LUCI_LANG.sk=Slovenčina (Slovak)
 LUCI_LANG.sv=Svenska (Swedish)
 LUCI_LANG.tr=Türkçe (Turkish)
 LUCI_LANG.uk=украї́нська (Ukrainian)
@@ -66,6 +66,19 @@ PKG_VERSION?=$(if $(DUMP),x,$(strip $(shell \
        echo "$$revision" \
 )))
 
+PKG_GITBRANCH?=$(if $(DUMP),x,$(strip $(shell \
+       variant="LuCI"; \
+       if git log -1 >/dev/null 2>/dev/null; then \
+               branch="$$(git symbolic-ref --short -q HEAD 2>/dev/null)"; \
+               if [ "$$branch" != "master" ]; then \
+                       variant="LuCI $$branch branch"; \
+               else \
+                       variant="LuCI Master"; \
+               fi; \
+       fi; \
+       echo "$$variant" \
+)))
+
 PKG_RELEASE?=1
 PKG_INSTALL:=$(if $(realpath src/Makefile),1)
 PKG_BUILD_DEPENDS += lua/host luci-base/host $(LUCI_BUILD_DEPENDS)
@@ -121,7 +134,7 @@ endef
 
 ifneq ($(wildcard ${CURDIR}/src/Makefile),)
  MAKE_PATH := src/
- MAKE_VARS += FPIC="$(FPIC)" LUCI_VERSION="$(PKG_VERSION)"
+ MAKE_VARS += FPIC="$(FPIC)" LUCI_VERSION="$(PKG_VERSION)" LUCI_GITBRANCH="$(PKG_GITBRANCH)"
 
  define Build/Compile
        $(call Build/Compile/Default,clean compile)
@@ -137,17 +150,26 @@ LUCI_LIBRARYDIR = $(LUA_LIBRARYDIR)/luci
 
 define SrcDiet
        $(FIND) $(1) -type f -name '*.lua' | while read src; do \
-               if $(STAGING_DIR_HOST)/bin/lua $(STAGING_DIR_HOST)/bin/LuaSrcDiet \
-                       --noopt-binequiv -o "$$$$src.o" "$$$$src"; \
+               if LuaSrcDiet --noopt-binequiv -o "$$$$src.o" "$$$$src"; \
                then mv "$$$$src.o" "$$$$src"; fi; \
        done
 endef
 
+define SubstituteVersion
+       $(FIND) $(1) -type f -name '*.htm' | while read src; do \
+               $(SED) 's/<%# *\([^ ]*\)PKG_VERSION *%>/\1$(PKG_VERSION)/g' \
+                   -e 's/"\(<%= *\(media\|resource\) *%>[^"]*\.\(js\|css\)\)"/"\1?v=$(PKG_VERSION)"/g' \
+                       "$$$$src"; \
+       done
+endef
+
 define Package/$(PKG_NAME)/install
        if [ -d $(PKG_BUILD_DIR)/luasrc ]; then \
          $(INSTALL_DIR) $(1)$(LUCI_LIBRARYDIR); \
          cp -pR $(PKG_BUILD_DIR)/luasrc/* $(1)$(LUCI_LIBRARYDIR)/; \
+         $(FIND) $(1)$(LUCI_LIBRARYDIR)/ -type f -name '*.luadoc' | $(XARGS) rm; \
          $(if $(CONFIG_LUCI_SRCDIET),$(call SrcDiet,$(1)$(LUCI_LIBRARYDIR)/),true); \
+         $(call SubstituteVersion,$(1)$(LUCI_LIBRARYDIR)/); \
        else true; fi
        if [ -d $(PKG_BUILD_DIR)/htdocs ]; then \
          $(INSTALL_DIR) $(1)$(HTDOCS); \
@@ -181,7 +203,7 @@ define LuciTranslation
     CATEGORY:=LuCI
     TITLE:=$(PKG_NAME) - $(1) translation
     HIDDEN:=1
-    DEFAULT:=LUCI_LANG_$(1)||ALL
+    DEFAULT:=LUCI_LANG_$(1)||(ALL&&m)
     DEPENDS:=$(PKG_NAME)
     PKGARCH:=all
   endef