Changeset 43017


Ignore:
Timestamp:
2014-10-22T10:57:16+02:00 (3 years ago)
Author:
nbd
Message:

build: clean up and optimize ipkg control generator code

Signed-off-by: Felix Fietkau <nbd@…>

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/package-ipkg.mk

    r43015 r43017  
    1616define BuildIPKGVariable 
    1717ifdef Package/$(1)/$(2) 
    18   $(call shexport,Package/$(1)/$(2)) 
    19   $(1)_COMMANDS += var2file "$(call shvar,Package/$(1)/$(2))" $(2)$(3); 
     18  $$(IPKG_$(1)) : VAR_$(2)$(3)=$$(Package/$(1)/$(2)) 
     19  $(1)_COMMANDS += echo "$$$$$(2)$(3)" > $(2)$(3); 
    2020endif 
    2121endef 
     
    7575endif 
    7676 
     77_addsep=$(word 1,$(1))$(foreach w,$(wordlist 2,$(words $(1)),$(1)),$(strip $(2) $(w))) 
     78_cleansep=$(subst $(space)$(2)$(space),$(2)$(space),$(1)) 
     79mergelist=$(call _cleansep,$(call _addsep,$(1),$(comma)),$(comma)) 
     80addfield=$(if $(strip $(2)),$(1): $(2)) 
     81_define=define 
     82_endef=endef 
     83 
    7784ifeq ($(DUMP),) 
    7885  define BuildTarget/ipkg 
     
    133140                echo '$(ABI_VERSION)' > $$@ 
    134141 
     142    Package/$(1)/DEPENDS := $$(call mergelist,$$(filter-out @%,$$(IDEPEND_$(1)))) 
     143    ifneq ($$(EXTRA_DEPENDS),) 
     144      Package/$(1)/DEPENDS := $$(EXTRA_DEPENDS)$$(if $$(Package/$(1)/DEPENDS),$$(comma) $$(Package/$(1)/DEPENDS)) 
     145    endif 
     146 
     147$(_define) Package/$(1)/CONTROL 
     148Package: $(1) 
     149Version: $(VERSION) 
     150$$(call addfield,Depends,$$(Package/$(1)/DEPENDS) 
     151)$$(call addfield,Conflicts,$$(call mergelist,$(CONFLICTS)) 
     152)$$(call addfield,Provides,$(PROVIDES) 
     153)$$(call addfield,Source,$(SOURCE) 
     154)$$(call addfield,License,$$(PKG_LICENSE) 
     155)$$(call addfield,LicenseFiles,$$(PKG_LICENSE_FILES) 
     156)$$(call addfield,Section,$(SECTION) 
     157)$$(call addfield,Require-User,$(USERID) 
     158)$(if $(filter hold,$(PKG_FLAGS)),Status: unknown hold not-installed 
     159)$(if $(filter essential,$(PKG_FLAGS)),Essential: yes 
     160)$(if $(MAINTAINER),Maintainer: $(MAINTAINER) 
     161)Architecture: $(PKGARCH) 
     162Installed-Size: 0 
     163$(_endef) 
     164 
    135165    $(PKG_INFO_DIR)/$(1).provides: $$(IPKG_$(1)) 
     166    $$(IPKG_$(1)) : export CONTROL=$$(Package/$(1)/CONTROL) 
     167    $$(IPKG_$(1)) : export DESCRIPTION=$$(Package/$(1)/description) 
    136168    $$(IPKG_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-ipkg.mk 
    137169        @rm -rf $$(PDIR_$(1))/$(1)_* $$(IDIR_$(1)) 
     
    151183 
    152184        $(RSTRIP) $$(IDIR_$(1)) 
    153         ( \ 
    154                 echo "Package: $(1)"; \ 
    155                 echo "Version: $(VERSION)"; \ 
    156                 DEPENDS='$(EXTRA_DEPENDS)'; \ 
    157                 for depend in $$(filter-out @%,$$(IDEPEND_$(1))); do \ 
    158                         DEPENDS=$$$${DEPENDS:+$$$$DEPENDS, }$$$${depend##+}; \ 
    159                 done; \ 
    160                 [ -z "$$$$DEPENDS" ] || echo "Depends: $$$$DEPENDS"; \ 
    161                 CONFLICTS=''; \ 
    162                 for conflict in $(CONFLICTS); do \ 
    163                         CONFLICTS=$$$${CONFLICTS:+$$$$CONFLICTS, }$$$$conflict; \ 
    164                 done; \ 
    165                 [ -z "$$$$CONFLICTS" ] || echo "Conflicts: $$$$CONFLICTS"; \ 
    166                 $(if $(PROVIDES), echo "Provides: $(PROVIDES)"; ) \ 
    167                 echo "Source: $(SOURCE)"; \ 
    168                 $(if $(PKG_LICENSE), echo "License: $(PKG_LICENSE)"; ) \ 
    169                 $(if $(PKG_LICENSE_FILES), echo "LicenseFiles: $(PKG_LICENSE_FILES)"; ) \ 
    170                 echo "Section: $(SECTION)"; \ 
    171                 $(if $(USERID),echo "Require-User: $(USERID)"; ) \ 
    172                 $(if $(filter hold,$(PKG_FLAGS)),echo "Status: unknown hold not-installed"; ) \ 
    173                 $(if $(filter essential,$(PKG_FLAGS)), echo "Essential: yes"; ) \ 
    174                 $(if $(MAINTAINER),echo "Maintainer: $(MAINTAINER)"; ) \ 
    175                 echo "Architecture: $(PKGARCH)"; \ 
    176                 echo "Installed-Size: 0"; \ 
    177                 echo -n "Description: "; $(SH_FUNC) getvar $(call shvar,Package/$(1)/description) | sed -e 's,^[[:space:]]*, ,g'; \ 
    178         ) > $$(IDIR_$(1))/CONTROL/control 
    179         chmod 644 $$(IDIR_$(1))/CONTROL/control 
    180         ( \ 
    181                 echo "#!/bin/sh"; \ 
    182                 echo "[ \"\$$$${IPKG_NO_SCRIPT}\" = \"1\" ] && exit 0"; \ 
    183                 echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \ 
    184                 echo "default_postinst \$$$$0 \$$$$@"; \ 
    185         ) > $$(IDIR_$(1))/CONTROL/postinst 
    186         ( \ 
    187                 echo "#!/bin/sh"; \ 
    188                 echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \ 
    189                 echo "default_prerm \$$$$0 \$$$$@"; \ 
    190         ) > $$(IDIR_$(1))/CONTROL/prerm 
    191         chmod 0755 $$(IDIR_$(1))/CONTROL/prerm 
    192         $(SH_FUNC) (cd $$(IDIR_$(1))/CONTROL; \ 
     185        (cd $$(IDIR_$(1))/CONTROL; \ 
     186                ( \ 
     187                        echo "$$$$CONTROL"; \ 
     188                        echo -n "Description: "; echo "$$$$DESCRIPTION" | sed -e 's,^[[:space:]]*, ,g'; \ 
     189                ) > control; \ 
     190                chmod 644 control; \ 
     191                ( \ 
     192                        echo "#!/bin/sh"; \ 
     193                        echo "[ \"\$$$${IPKG_NO_SCRIPT}\" = \"1\" ] && exit 0"; \ 
     194                        echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \ 
     195                        echo "default_postinst \$$$$0 \$$$$@"; \ 
     196                ) > postinst; \ 
     197                ( \ 
     198                        echo "#!/bin/sh"; \ 
     199                        echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \ 
     200                        echo "default_prerm \$$$$0 \$$$$@"; \ 
     201                ) > prerm; \ 
     202                chmod 0755 prerm; \ 
    193203                $($(1)_COMMANDS) \ 
    194204        ) 
  • trunk/include/package.mk

    r42282 r43017  
    252252  ) 
    253253 
    254   $(call shexport,Package/$(1)/description) 
    255   $(call shexport,Package/$(1)/config) 
    256  
    257254  $(if $(DUMP), \ 
    258255    $(Dumpinfo/Package), \ 
  • trunk/rules.mk

    r42987 r43017  
    2222empty:= 
    2323space:= $(empty) $(empty) 
     24comma:=, 
    2425merge=$(subst $(space),,$(1)) 
    2526confvar=$(call merge,$(foreach v,$(1),$(if $($(v)),y,n))) 
Note: See TracChangeset for help on using the changeset viewer.