VirtualBox

Changeset 688 in kBuild


Ignore:
Timestamp:
Dec 8, 2006 5:44:22 AM (18 years ago)
Author:
bird
Message:

more or less completed the fetch feature.

Location:
trunk/kBuild
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/footer.kmk

    r682 r688  
    103103_UNPACKS  :=
    104104_PATCHES  :=
     105_UNFETCHES:=
    105106_BLDPROGS :=
    106107_LIBS     :=
     
    603604
    604605
    605 #
    606 # Fetching Tools, Sources and Similar.
    607 #
     606## @page pg_fetches     Fetching Tools, Sources and Similar.
     607#
     608# The targets listed in the the FETCHES target list have the following attributes:
     609#       SOURCES
     610#       INST
     611#   FETCHTOOL
     612#   FETCHFLAGS
     613#   FETCHDIR
     614#   UNPACKTOOL
     615#   UNPACKFLAGS
     616#
     617# As usual the target name is an alias for 'creating' the target. Other
     618# aliases are:
     619#       pass_fetches
     620#       fetch
     621#       unfetch
     622#       download
     623#       unpack
     624#
     625# @remark
     626#
     627#   This is a little bit complex because we must guarantee that if a source file
     628#   changes only sligtly we must refetch it and to a proper unpacking of it. It
     629#   is also a desire that fetched archives and unpacked files can be deleted to
     630#   save space.
     631#
     632#   Thus, we must be able to cleanup what we've unpacked should any of the
     633#   sources be removed. We do this by maintaining a file listing the files
     634#   and directories that was unpacked. This operation is named 'unfetch'.
     635#
     636#   We make use of the SIZE and MD5 attributes for each of the sources to
     637#   construct a primary goal. Should any sources change only sligtly this
     638#   name will change and we'll have to remake it. Upon remaking we will
     639#   perform an 'unfetch' to remove old unpacked files.
     640#
     641#   By not depending directly on the archives (nor on any unpacked files)
     642#       but on a goal made up from the archive name, size and md5, we allow
     643#   the user to delete the archives. Naturally, this means we'll have to
     644#   check and fetch missing archives before attempting to unpack them.
     645#
     646# TODOs:
     647#       1. Port md5sum or some equivalent tool and include it in kBuild.
     648#   2. Download corruption / continuation.
     649#   3. It's quite possible that there is one too many indirect dependency now...
     650#
     651
     652## @todo move this!
    608653MD5SUM := md5sum
    609654
     
    613658.PRECIOUS: $(out)
    614659$(out) $($(target)_$(srcname)_FETCH_OUTPUT_): | $($(target)_$(srcname)_FETCH_DEPORD_)
    615         @$(ECHO) Downloading $(source)...
    616         $$(RM) -f $(out) $(out).md5 ## @todo fancy stuff like download continuation
     660        @$$(ECHO) Downloading $(source)...
     661        ## @todo do fancy stuff like download continuation.
     662        $$(RM) -f $(out) $(out).md5
    617663        $($(target)_$(srcname)_FETCH_CMDS_)
    618664        @$(if $(md5),$$(APPEND) $(out).md5 "$(md5) *$(out)")
     
    623669# Intermediate goal for making sure the md5 and size matches. it will (re) fetch the archive if necessary.
    624670$(out).checked_$(md5)_$(size): $($(target)_$(srcname)_FETCH_DEPEND_) | $($(target)_$(srcname)_FETCH_DEPORD_)
    625         @$(ECHO) Checking $(out) ($(source))...
     671        @$$(ECHO) Checking $(out) ($(source))...
    626672        $$(RM) -f $$@ $(out).md5
    627673        @# creates the .md5 we pass to md5sum.
    628         @$(if $(md5),$(APPEND) $(out).md5 "$(md5) *$(out)")     
    629         @# if the file exists, perform md5sum, otherwise just fetch it.
    630         $(if $(wildcard $(out)),\
    631                 $(MD5SUM) -c $(out).md5 || ( $(RM_EXT) -f $(out) && $(MAKE) -f $(MAKEFILE) $(out) ),\
    632                 $(MAKE) -f $(MAKEFILE) $(out) )
    633         @$(APPEND) $$@
    634 
    635 _TARGET_$(target)_FETCHED += $(out).checked_$(md5)_$(size)
     674        @$(if $(md5),$$(APPEND) $(out).md5 "$(md5) *$(out)")
     675        @# (re)fetch the file if it doesn't exist or if it doesn't matches the md5.
     676        ## @todo do fancy stuff like download continuation.
     677        ( test -f $(out) && $(if $(md5),$$(MD5SUM) -c $(out).md5, true) ) \
     678                || (   $$(RM_EXT) -f $(out) \
     679                    && $$(MAKE)      $(out) -f $(MAKEFILE) )
     680        @$$(APPEND) $$@
     681
     682_TARGET_$(target)_FETCHED += $(out) $(out).checked_$(md5)_$(size)
     683
     684# Just a little precaution.
     685.NOTPARALLEL: $(out) $(out).checked_$(md5)_$(size)
    636686
    637687endef
     
    639689## generates the unpack rule
    640690define def_fetch_src_unpack_rule
    641 #$ (warning def_fetch_src_unpack_rule: source=$(source))
    642 
    643691# This is the unpack rule. it has an order-only dependency on the download check.
    644692$(out) $($(target)_$(srcname)_UNPACK_OUTPUT_): $($(target)_$(srcname)_UNPACK_DEPEND_) \
    645693                | $($(target)_$(srcname)_UNPACK_DEPORD_) $(archive).checked_$(md5)_$(size)
    646         @$(ECHO) Unpacking $(source) into $(inst)...
     694        @$$(ECHO) Unpacking $(source) into $(inst)...
    647695        $$(RM) -f $(out)
     696        @# if the source archive doesn't exist fetch it (can have been deleted to save space).
     697        test -f $(archive) \
     698                || (   $$(RM_EXT) -f $(archive).checked_$(md5)_$(size) \
     699                    && $$(MAKE)      $(archive).checked_$(md5)_$(size) -f $(MAKEFILE) )
    648700        $($(target)_$(srcname)_UNPACK_CMDS_)
    649         @$(APPEND) $(out) $(out)
    650         @$(APPEND) $(out) $(out).check_$(md5)_$(size)
     701        @$$(APPEND) $(out) $(notdir $(archive).checked_$(md5)_$(size))
     702        @$$(APPEND) $(out) $(notdir $(out))
    651703
    652704$(eval _TARGET_$(target)_UNPACKED += $(out))
    653705_TARGET_$(target)_DIGEST := $(_TARGET_$(target)_DIGEST)-$(srcname)_$(md5)_$(size)
     706
     707.NOTPARALLEL: $(out)
    654708
    655709endef
     
    827881# @param        out
    828882# @param        inst
    829 # @param        _TARGET_$(target)_FETCHED...
     883# @param        _TARGET_$(target)_UNPACKED
     884# @param        _TARGET_$(target)_DIGEST
    830885# @param        bld_trg
    831886# @param        bld_trg_arch
     
    833888
    834889$(out): $(_TARGET_$(target)_UNPACKED) | $(call DIRDEP,$(inst))
    835         @$(ECHO) Successfully fetched $(target)
    836         $(RM) -f $$@ [email protected]
    837         @$(APPEND) [email protected] ""
    838         $(if $(_TARGET_$(target)_UNPACKED),$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> [email protected])
    839         $(MV) -f [email protected] $$@
     890        @$$(ECHO) Successfully fetched $(target)
     891        $$(RM) -f $$@ [email protected]
     892        @$$(APPEND) [email protected] "$(notdir $(out).$(_TARGET_$(target)_DIGEST))"
     893        $(if $(_TARGET_$(target)_UNPACKED),$$(CAT_EXT) $(_TARGET_$(target)_UNPACKED) >> [email protected])
     894        $$(MV) -f [email protected] $$@
    840895
    841896$(out)_unfetched:
    842         @$(ECHO) Unfetching $(target)...
    843         $(RM) -f $$(shell $$(CAT_EXT) $(out) 2> /dev/null)
    844         # figure out how to make this quiet...
    845         -$(RMDIR) -p $(dir $(out)) $$(sort $$(dir $$(shell $$(CAT_EXT) $(out) 2> /dev/null)))
    846         $(RM) -f $(out)
    847         -$(RMDIR) -p $(dir $(out))
     897        @$$(ECHO) Unfetching $(target)...
     898        $$(RM) -f $$(addprefix $(inst),$$(shell $$(CAT_EXT) $(out) 2> /dev/null | $$(SED) -e '/\/$$$$/d'))
     899        $$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $(out)) \
     900                $$(addprefix $(inst),$$(sort $$(dir $$(shell $$(CAT_EXT) $(out) 2> /dev/null))))
     901        $$(RM) -f $(out)
     902        $$(RMDIR) -p --ignore-fail-on-non-empty --ignore-fail-on-not-exist $$(dir $(out))
     903
     904$(out).$(_TARGET_$(target)_DIGEST): | $(call DIRDEP,$(inst))
     905        @$$(RM) -f $(out).$(_TARGET_$(target)_DIGEST)
     906        @$$(ECHO) $$(if $$(wildcard $(out)),Re-fetching,Fetching) $(target)...
     907        $$(if $$(wildcard $(out)),$$(MAKE) -f $(MAKEFILE) $(out)_unfetched)
     908        $$(MAKE) -f $(MAKEFILE) $(out)
     909        $$(APPEND) $$@ ""
     910       
     911$(target):: $(out).$(_TARGET_$(target)_DIGEST)
     912
     913.NOTPARALLEL: $(out) $(out)_unfetched $(out).$(_TARGET_$(target)_DIGEST)
    848914
    849915endef
     
    878944$(eval $(def_fetch_rules))
    879945
    880 _FETCHES += $(out)
     946_FETCHES += $(out).$(_TARGET_$(target)_DIGEST)
    881947_DOWNLOADS += $(_TARGET_$(target)_FETCHED)
    882948_UNPACKS += $(_TARGET_$(target)_UNPACKED)
     
    894960# some aliases.
    895961download: $(_DOWNLOADS)
    896 unpack: $(_UNPACK)
    897 fetches: $(_FETCHES)
    898 unfetches: $(_UNFETCHES)
     962unpack: $(_UNPACKS)
     963fetch: $(_FETCHES)
     964unfetch: $(_UNFETCHES)
    899965
    900966
     
    904970##
    905971##
    906 #define def_fetch_src
     972#define def_patch_src
    907973#
    908974#endef
     
    913979#
    914980#$(foreach source,$($(target)_SOURCES) $($(target)_SOURCES.$(BUILD_TYPE)) $($(target)_SOURCES.$(BUILD_TARGET)) $($(target)_SOURCES.$(BUILD_TARGET_ARCH)) $($(target)_SOURCES.$(BUILD_TARGET).$(BUILD_TARGET_ARCH)),\
    915 #       $(eval $(value def_patch_one)))
     981#       $(eval $(value def_patch_src)))
    916982#
    917983#_PATCHES +=
  • trunk/kBuild/tools/TAR.kmk

    r667 r688  
    5252define TOOL_TAR_UNPACK_CMDS
    5353        $(TOOL_TAR_UNPACK) -x $(flags) -C $(subst G:,,$(inst)) -f $(archive)
    54         $(TOOL_TAR_UNPACK) -t $(flags) -f $(archive)| $(SED) -e 's|^|$(inst)|g' > $(out)
     54        $(TOOL_TAR_UNPACK) -t $(flags) -f $(archive) > $(out)
    5555endef
    5656else
    5757define TOOL_TAR_UNPACK_CMDS
    5858        $(TOOL_TAR_UNPACK) -x $(flags) -C $(inst) -f $(archive)
    59         $(TOOL_TAR_UNPACK) -t $(flags) -f $(archive)| $(SED) -e 's|^|$(inst)|g' > $(out)
     59        $(TOOL_TAR_UNPACK) -t $(flags) -f $(archive) > $(out)
    6060endef
    6161endif
  • trunk/kBuild/tools/TARGZ.kmk

    r667 r688  
    5151define TOOL_TARGZ_UNPACK_CMDS
    5252        $(TOOL_TARGZ_UNPACK) -x $(flags) -C $(inst) -f $(archive)
    53         $(TOOL_TARGZ_UNPACK) -t $(flags) -f $(archive) | $(SED) -e 's|^|$(inst)|g' > $(out)
     53        $(TOOL_TARGZ_UNPACK) -t $(flags) -f $(archive) > $(out)
    5454endef
    5555
  • trunk/kBuild/tools/ZIP.kmk

    r681 r688  
    5454                -e '/ [0-2][0-9]:[0-6][0-9]/!d' \
    5555                -e 's/^.* [0-2][0-9]:[0-6][0-9]   //' \
    56                 -e 's|^|$(inst)|' \
    5756                > $(out)
    5857endef
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette